> For the complete documentation index, see [llms.txt](https://alham-rizvi.gitbook.io/alhamrizvi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://alham-rizvi.gitbook.io/alhamrizvi/picoctf-writeups/picoctf/reverse-engineering/asm2.md).

# asm2

I decompiled that assembly code to C,

We are given a function:

```c
int asm2(int a, int b) {
    int var1 = b;
    int var2 = a;

    while (var2 <= 0xd72d) {
        var1 += 1;
        var2 += 0xcb;
    }

    return var1;
}
```

#### Step 1: Convert values

```
a = 0xf  = 15  
b = 0x17 = 23  
0xd72d   = 55085  
0xcb     = 203
```

#### Step 2: Understand the loop

* `var2` starts at 15
* Each loop adds 203
* Loop runs while `var2 <= 55085`

So we solve:

```
15 + n × 203 ≤ 55085
```

```
55085 - 15 = 55070  
55070 / 203 = 271 (floor)
```

So total iterations:

```
271 + 1 = 272
```

#### Step 3: Update var1

* `var1` starts at 23
* It increases by 1 each loop

```
var1 = 23 + 272 = 295
```

#### Step 4: Convert to hex

```
295 = 0x127
```

#### Final Answer

```
0x127
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://alham-rizvi.gitbook.io/alhamrizvi/picoctf-writeups/picoctf/reverse-engineering/asm2.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
