#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int determine_logical_expression(char *, unsigned int *, unsigned int);
unsigned short getUShort(char *);
unsigned int handleIf(char *assembled, unsigned int currentPoint,
                      unsigned int length) {
  int conditionalResult =
      determine_logical_expression(assembled, &currentPoint, length);
  if (conditionalResult)
    return currentPoint + sizeof(unsigned short);
  unsigned short blockLen = getUShort(&assembled[currentPoint]);
  return currentPoint + sizeof(unsigned short) + blockLen;
}


x86 assembly (clang, -O0):
<handleIf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%edx
lea    -0x14(%rbp),%rsi
call   1040 <determine_logical_expression@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     115e <handleIf+0x3e>
mov    -0x14(%rbp),%eax
add    $0x2,%rax
mov    %eax,-0x4(%rbp)
jmp    1182 <handleIf+0x62>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%eax
add    %rax,%rdi
call   1030 <getUShort@plt>
mov    %ax,-0x1e(%rbp)
mov    -0x14(%rbp),%eax
add    $0x2,%rax
movzwl -0x1e(%rbp),%ecx
add    %rcx,%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<handleIf>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    %esi,0xc(%rsp)
lea    0xc(%rsp),%rsi
call   1040 <determine_logical_expression@plt>
mov    %eax,%ecx
mov    0xc(%rsp),%eax
test   %ecx,%ecx
je     1145 <handleIf+0x25>
add    $0x2,%eax
jmp    115c <handleIf+0x3c>
add    %rax,%rbx
mov    %rbx,%rdi
call   1030 <getUShort@plt>
mov    0xc(%rsp),%ecx
movzwl %ax,%eax
add    %ecx,%eax
add    $0x2,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @handleIf(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i16
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%10 = load i8*, i8** %5
%11 = load i32, i32* %7
%12 = call i32 @determine_logical_expression(i8* %10, i32* %6, i32 %11)
store i32 %12, i32* %8
%13 = load i32, i32* %8
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %3
%16 = load i32, i32* %6
%17 = zext i32 %16 to i64
%18 = add i64 %17, 2
%19 = trunc i64 %18 to i32
store i32 %19, i32* %4
br label %33
20: ; preds = %3
%21 = load i8*, i8** %5
%22 = load i32, i32* %6
%23 = zext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
%25 = call zeroext i16 @getUShort(i8* %24)
store i16 %25, i16* %9
%26 = load i32, i32* %6
%27 = zext i32 %26 to i64
%28 = add i64 %27, 2
%29 = load i16, i16* %9
%30 = zext i16 %29 to i64
%31 = add i64 %28, %30
%32 = trunc i64 %31 to i32
store i32 %32, i32* %4
br label %33
33: ; preds = %20, %15
%34 = load i32, i32* %4
ret i32 %34
}

LLVM IR (-O2):
define i32 @handleIf(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
store i32 %1, i32* %4
%5 = call i32 @determine_logical_expression(i8* %0, i32* %4, i32 %2)
%6 = icmp eq i32 %5, 0
%7 = load i32, i32* %4
br i1 %6, label %10, label %8
8: ; preds = %3
%9 = add i32 %7, 2
br label %18
10: ; preds = %3
%11 = zext i32 %7 to i64
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = call zeroext i16 @getUShort(i8* %12)
%14 = load i32, i32* %4
%15 = add i32 %14, 2
%16 = zext i16 %13 to i32
%17 = add i32 %15, %16
br label %18
18: ; preds = %10, %8
%19 = phi i32 [ %9, %8 ], [ %17, %10 ]
ret i32 %19
}