#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*/ fprintf(int /*<<< orphan*/, char *, int, double, int);
double gettime();
int /*<<< orphan*/ loop(int);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  double start, elapsed;
  int i, count;
  count = argc == 2 ? atoi(argv[1]) : 1600000;
  start = gettime();
  loop(count);
  elapsed = gettime() - start;
  fprintf(stderr, "%d iterations in %g secs (%g thousand/sec)\n", count,
          elapsed, count / elapsed / 1e3);
}


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)
cmpl   $0x2,-0x8(%rbp)
jne    1175 <main+0x35>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x2c(%rbp)
jmp    1182 <main+0x42>
mov    $0x186a00,%eax
mov    %eax,-0x2c(%rbp)
jmp    1182 <main+0x42>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    $0x0,%al
call   1060 <gettime@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x28(%rbp),%edi
call   1030 <loop@plt>
mov    $0x0,%al
call   1060 <gettime@plt>
subsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%edx
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0x28(%rbp),%xmm1
divsd  -0x20(%rbp),%xmm1
movsd  0xe30(%rip),%xmm2
divsd  %xmm2,%xmm1
cvttsd2si %xmm1,%ecx
lea    0xe29(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    $0x186a00,%ebx
cmp    $0x2,%edi
jne    115a <main+0x1a>
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1060 <gettime@plt>
movsd  %xmm0,0x8(%rsp)
mov    %ebx,%edi
call   1030 <loop@plt>
xor    %eax,%eax
call   1060 <gettime@plt>
subsd  0x8(%rsp),%xmm0
mov    0x2e5e(%rip),%rax
mov    (%rax),%edi
cvtsi2sd %ebx,%xmm1
divsd  %xmm0,%xmm1
divsd  0xe6c(%rip),%xmm1
cvttsd2si %xmm1,%ecx
lea    0xe69(%rip),%rsi
mov    %ebx,%edx
call   1040 <fprintf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [44 x i8] c"%d iterations in %g secs (%g thousand/sec)\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp eq i32 %10, 2
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @atoi(i8* %15)
br label %18
17: ; preds = %2
br label %18
18: ; preds = %17, %12
%19 = phi i32 [ %16, %12 ], [ 1600000, %17 ]
store i32 %19, i32* %9
%20 = call double (...) @gettime()
store double %20, double* %6
%21 = load i32, i32* %9
%22 = call i32 @loop(i32 %21)
%23 = call double (...) @gettime()
%24 = load double, double* %6
%25 = fsub double %23, %24
store double %25, double* %7
%26 = load i32, i32* @stderr
%27 = load i32, i32* %9
%28 = load double, double* %7
%29 = load i32, i32* %9
%30 = sitofp i32 %29 to double
%31 = load double, double* %7
%32 = fdiv double %30, %31
%33 = fdiv double %32, 1.000000e+03
%34 = fptosi double %33 to i32
%35 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 %27, double %28, i32 %34)
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [44 x i8] c"%d iterations in %g secs (%g thousand/sec)\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
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 = %2, %4
%9 = phi i32 [ %7, %4 ], [ 1600000, %2 ]
%10 = tail call double (...) @gettime()
%11 = tail call i32 @loop(i32 %9)
%12 = tail call double (...) @gettime()
%13 = fsub double %12, %10
%14 = load i32, i32* @stderr
%15 = sitofp i32 %9 to double
%16 = fdiv double %15, %13
%17 = fdiv double %16, 1.000000e+03
%18 = fptosi double %17 to i32
%19 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 %9, double %13, i32 %18)
ret i32 0
}