#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 /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(unsigned char *);
unsigned char *load_code(char *, long *);
int /*<<< orphan*/ reverse_aska(unsigned char *, long);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  unsigned char *code;
  long code_bytes;
  if (argc < 2) {
    fprintf(stderr, "Usage: %s app.b32\n", argv[0]);
    exit(EXIT_SUCCESS);
  }
  code = load_code(argv[1], &code_bytes);
  if (!code) {
    fprintf(stderr, "Error (load_code)\n");
    exit(EXIT_FAILURE);
  }
  reverse_aska(code + 8, code_bytes - 8);
  free(code);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    119c <main+0x4c>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe79(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e3b(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x20(%rbp),%rsi
call   1060 <load_code@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11e1 <main+0x91>
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
lea    0xe47(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2dfe(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x18(%rbp),%rdi
add    $0x8,%rdi
mov    -0x20(%rbp),%rsi
sub    $0x8,%rsi
call   1040 <reverse_aska@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
cmp    $0x1,%edi
jle    1195 <main+0x45>
mov    0x8(%rsi),%rdi
lea    0x8(%rsp),%rsi
call   1060 <load_code@plt>
test   %rax,%rax
je     11bd <main+0x6d>
mov    %rax,%rbx
mov    %rax,%rdi
add    $0x8,%rdi
mov    0x8(%rsp),%rsi
add    $0xfffffffffffffff8,%rsi
call   1040 <reverse_aska@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
mov    (%rsi),%rdx
lea    0xe58(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    0x2e1c(%rip),%rax
mov    (%rax),%edi
lea    0xe46(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x2dfd(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [19 x i8] c"Usage: %s app.b32\0A\00"
@EXIT_SUCCESS = global i32 0
@.str.1 = [19 x i8] c"Error (load_code)\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i64
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 2
br i1 %9, label %10, label %18
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %14)
%16 = load i32, i32* @EXIT_SUCCESS
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i8* @load_code(i8* %21, i64* %7)
store i8* %22, i8** %6
%23 = load i8*, i8** %6
%24 = icmp ne i8* %23, null
br i1 %24, label %30, label %25
25: ; preds = %18
%26 = load i32, i32* @stderr
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%28 = load i32, i32* @EXIT_FAILURE
%29 = call i32 @exit(i32 %28)
unreachable
30: ; preds = %18
%31 = load i8*, i8** %6
%32 = getelementptr inbounds i8, i8* %31, i64 8
%33 = load i64, i64* %7
%34 = sub nsw i64 %33, 8
%35 = call i32 @reverse_aska(i8* %32, i64 %34)
%36 = load i8*, i8** %6
%37 = call i32 @free(i8* %36)
ret i32 0
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [19 x i8] c"Usage: %s app.b32\0A\00"
@EXIT_SUCCESS = global i32 0
@.str.1 = [19 x i8] c"Error (load_code)\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to i8*
%5 = icmp slt i32 %0, 2
br i1 %5, label %6, label %12
6: ; preds = %2
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %1
%9 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i32, i32* @EXIT_SUCCESS
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %2
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = call i8* @load_code(i8* %14, i64* %3)
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %22
17: ; preds = %12
%18 = load i32, i32* @stderr
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%20 = load i32, i32* @EXIT_FAILURE
%21 = call i32 @exit(i32 %20)
unreachable
22: ; preds = %12
%23 = getelementptr inbounds i8, i8* %15, i64 8
%24 = load i64, i64* %3
%25 = add nsw i64 %24, -8
%26 = call i32 @reverse_aska(i8* %23, i64 %25)
%27 = call i32 @free(i8* %15)
ret i32 0
}