#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 atoi(char *);
int /*<<< orphan*/ printf(char *);
int run(int);
int main(int argc, char *argv[]) {
  int i;
  int result;
  int n = 10000;
  if (argc > 1)
    n = atoi(argv[1]);
  for (i = 0; i < 20000; i++)
    result = run(n);
  if (result != 50005000)
    printf("*** wrong result ***\n");
  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)
movl   $0x2710,-0x1c(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1167 <main+0x37>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x4e20,-0x14(%rbp)
jge    1194 <main+0x64>
mov    -0x1c(%rbp),%edi
call   1030 <run@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116e <main+0x3e>
cmpl   $0x2fb0408,-0x18(%rbp)
je     11ad <main+0x7d>
lea    0xe58(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    $0x2710,%ebx
cmp    $0x2,%edi
jl     1148 <main+0x18>
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebx
mov    $0x4e20,%ebp
nopl   (%rax)
mov    %ebx,%edi
call   1040 <run@plt>
add    $0xffffffff,%ebp
jne    1150 <main+0x20>
cmp    $0x2fb0408,%eax
je     116f <main+0x3f>
lea    0xe96(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"*** wrong result ***\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 10000, i32* %8
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 1
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @atoi(i8* %14)
store i32 %15, i32* %8
br label %16
16: ; preds = %11, %2
store i32 0, i32* %6
br label %17
17: ; preds = %23, %16
%18 = load i32, i32* %6
%19 = icmp slt i32 %18, 20000
br i1 %19, label %20, label %26
20: ; preds = %17
%21 = load i32, i32* %8
%22 = call i32 @run(i32 %21)
store i32 %22, i32* %7
br label %23
23: ; preds = %20
%24 = load i32, i32* %6
%25 = add nsw i32 %24, 1
store i32 %25, i32* %6
br label %17
26: ; preds = %17
%27 = load i32, i32* %7
%28 = icmp ne i32 %27, 50005000
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
br label %31
31: ; preds = %29, %26
ret i32 0
}

LLVM IR (-O2):
@str = [21 x i8] c"*** wrong result ***\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
br label %8
8: ; preds = %4, %2
%9 = phi i32 [ %7, %4 ], [ 10000, %2 ]
br label %10
10: ; preds = %8, %10
%11 = phi i32 [ 0, %8 ], [ %13, %10 ]
%12 = tail call i32 @run(i32 %9)
%13 = add nuw nsw i32 %11, 1
%14 = icmp eq i32 %13, 20000
br i1 %14, label %15, label %10
15: ; preds = %10
%16 = icmp eq i32 %12, 50005000
br i1 %16, label %19, label %17
17: ; preds = %15
%18 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
br label %19
19: ; preds = %17, %15
ret i32 0
}