#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 */
char **afl_init_argv(int *);
int /*<<< orphan*/ printf(char *, int, ...);
int main(int argc, char *argv[]) {
  do {
    argv = afl_init_argv(&argc);
    argv[0] = ("a.out");
    if (!argc)
      argc = 1;
  } while (0);
  int i;
  printf("argc = %d\n", argc);
  for (i = 0; i < argc; i++)
    printf("argv[%d] = '%s'\n", i, argv[i]);
  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)
lea    -0x8(%rbp),%rdi
call   1040 <afl_init_argv@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
lea    0xeb2(%rip),%rcx
mov    %rcx,(%rax)
cmpl   $0x0,-0x8(%rbp)
jne    1162 <main+0x42>
movl   $0x1,-0x8(%rbp)
jmp    1167 <main+0x47>
mov    -0x8(%rbp),%esi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11b6 <main+0x96>
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117f <main+0x5f>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edi,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1040 <afl_init_argv@plt>
mov    %rax,%r15
lea    0xebf(%rip),%rax
mov    %rax,(%r15)
mov    0xc(%rsp),%esi
test   %esi,%esi
jne    1159 <main+0x39>
movl   $0x1,0xc(%rsp)
mov    $0x1,%esi
lea    0xea6(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
cmpl   $0x0,0xc(%rsp)
jle    119e <main+0x7e>
lea    0xe9c(%rip),%r14
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
mov    (%r15,%rbx,8),%rdx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbx
movslq 0xc(%rsp),%rax
cmp    %rax,%rbx
jl     1180 <main+0x60>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [6 x i8] c"a.out\00"
@.str.1 = [11 x i8] c"argc = %d\0A\00"
@.str.2 = [17 x i8] c"argv[%d] = '%s'\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
br label %7
7: ; preds = %2
%8 = call i8** @afl_init_argv(i32* %4)
store i8** %8, i8*** %5
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 0
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %10
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 0
br i1 %12, label %14, label %13
13: ; preds = %7
store i32 1, i32* %4
br label %14
14: ; preds = %13, %7
br label %15
15: ; preds = %14
%16 = load i32, i32* %4
%17 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %16)
store i32 0, i32* %6
br label %18
18: ; preds = %30, %15
%19 = load i32, i32* %6
%20 = load i32, i32* %4
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %33
22: ; preds = %18
%23 = load i32, i32* %6
%24 = load i8**, i8*** %5
%25 = load i32, i32* %6
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8*, i8** %24, i64 %26
%28 = load i8*, i8** %27
%29 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %23, i8* %28)
br label %30
30: ; preds = %22
%31 = load i32, i32* %6
%32 = add nsw i32 %31, 1
store i32 %32, i32* %6
br label %18
33: ; preds = %18
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"a.out\00"
@.str.1 = [11 x i8] c"argc = %d\0A\00"
@.str.2 = [17 x i8] c"argv[%d] = '%s'\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
store i32 %0, i32* %3
%4 = call i8** @afl_init_argv(i32* %3)
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8** %4
%5 = load i32, i32* %3
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %8
7: ; preds = %2
store i32 1, i32* %3
br label %8
8: ; preds = %2, %7
%9 = phi i32 [ %5, %2 ], [ 1, %7 ]
%10 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = load i32, i32* %3
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %8, %13
%14 = phi i64 [ %19, %13 ], [ 0, %8 ]
%15 = getelementptr inbounds i8*, i8** %4, i64 %14
%16 = load i8*, i8** %15
%17 = trunc i64 %14 to i32
%18 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %17, i8* %16)
%19 = add nuw nsw i64 %14, 1
%20 = load i32, i32* %3
%21 = sext i32 %20 to i64
%22 = icmp slt i64 %19, %21
br i1 %22, label %13, label %23
23: ; preds = %13, %8
ret i32 0
}