#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 *);
double run(int);
int main(int argc, char *argv[]) {
  int i;
  double result;
  int n = 10000;
  if (argc > 1)
    n = atoi(argv[1]);
  for (i = 0; i < 5000; i++)
    result = run(n);
  if (result != 50005000.)
    printf("*** wrong result ***\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x2710,-0x24(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1167 <main+0x37>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x1388,-0x14(%rbp)
jge    1196 <main+0x66>
mov    -0x24(%rbp),%edi
call   1030 <run@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116e <main+0x3e>
movsd  -0x20(%rbp),%xmm0
movsd  0xe5d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11b8 <main+0x88>
jp     11b8 <main+0x88>
jmp    11c4 <main+0x94>
lea    0xe49(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%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    $0x1388,%ebp
nopl   (%rax)
mov    %ebx,%edi
call   1040 <run@plt>
add    $0xffffffff,%ebp
jne    1150 <main+0x20>
ucomisd 0xe9c(%rip),%xmm0
jne    1168 <main+0x38>
jnp    1174 <main+0x44>
lea    0xe99(%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 double
%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, 5000
br i1 %19, label %20, label %26
20: ; preds = %17
%21 = load i32, i32* %8
%22 = call double @run(i32 %21)
store double %22, double* %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 double, double* %7
%28 = fcmp une double %27, 5.000500e+07
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 double @run(i32 %9)
%13 = add nuw nsw i32 %11, 1
%14 = icmp eq i32 %13, 5000
br i1 %14, label %15, label %10
15: ; preds = %10
%16 = fcmp une double %12, 5.000500e+07
br i1 %16, label %17, label %19
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
}