#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 *);
double getusec();
int /*<<< orphan*/ printf(char *, double, double);
int main(int argc, char *argv[]) {
  int n = (argc > 1) ? atoi(argv[1]) : 100000;
  double t0 = getusec();
  double junk = 0.0;
  for (int i = 0; i < n; i++) {
    junk += getusec();
  }
  double t1 = getusec();
  printf("dt = %lf s junk = %4.1e\n", 1.e-6 * (t1 - t0), junk);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1165 <main+0x35>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x3c(%rbp)
jmp    1172 <main+0x42>
mov    $0x186a0,%eax
mov    %eax,-0x3c(%rbp)
jmp    1172 <main+0x42>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1030 <getusec@plt>
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11be <main+0x8e>
mov    $0x0,%al
call   1030 <getusec@plt>
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1193 <main+0x63>
mov    $0x0,%al
call   1030 <getusec@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm1
subsd  -0x20(%rbp),%xmm1
movsd  0xe24(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  -0x28(%rbp),%xmm1
lea    0xe1c(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
cmp    $0x1,%edi
jle    1161 <main+0x31>
mov    0x8(%rsi),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1030 <getusec@plt>
movsd  %xmm0,0x8(%rsp)
test   %ebx,%ebx
jg     1173 <main+0x43>
xorpd  %xmm0,%xmm0
movsd  %xmm0,(%rsp)
jmp    11a4 <main+0x74>
xor    %eax,%eax
call   1030 <getusec@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0x186a0,%ebx
xorpd  %xmm0,%xmm0
nopw   0x0(%rax,%rax,1)
movsd  %xmm0,(%rsp)
xor    %eax,%eax
call   1030 <getusec@plt>
movsd  (%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  (%rsp),%xmm0
add    $0xffffffff,%ebx
jne    1180 <main+0x50>
xor    %eax,%eax
call   1030 <getusec@plt>
subsd  0x8(%rsp),%xmm0
mulsd  0xe47(%rip),%xmm0
lea    0xe48(%rip),%rdi
movsd  (%rsp),%xmm1
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [25 x i8] c"dt = %lf s junk = %4.1e\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 double
%9 = alloca i32
%10 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 1
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @atoi(i8* %16)
br label %19
18: ; preds = %2
br label %19
19: ; preds = %18, %13
%20 = phi i32 [ %17, %13 ], [ 100000, %18 ]
store i32 %20, i32* %6
%21 = call double (...) @getusec()
store double %21, double* %7
store double 0.000000e+00, double* %8
store i32 0, i32* %9
br label %22
22: ; preds = %30, %19
%23 = load i32, i32* %9
%24 = load i32, i32* %6
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %33
26: ; preds = %22
%27 = call double (...) @getusec()
%28 = load double, double* %8
%29 = fadd double %28, %27
store double %29, double* %8
br label %30
30: ; preds = %26
%31 = load i32, i32* %9
%32 = add nsw i32 %31, 1
store i32 %32, i32* %9
br label %22
33: ; preds = %22
%34 = call double (...) @getusec()
store double %34, double* %10
%35 = load double, double* %10
%36 = load double, double* %7
%37 = fsub double %35, %36
%38 = fmul double 0x3EB0C6F7A0B5ED8D, %37
%39 = load double, double* %8
%40 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), double %38, double %39)
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"dt = %lf s junk = %4.1e\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call double (...) @getusec()
br label %12
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = tail call double (...) @getusec()
%11 = icmp sgt i32 %9, 0
br i1 %11, label %12, label %15
12: ; preds = %4, %6
%13 = phi double [ %5, %4 ], [ %10, %6 ]
%14 = phi i32 [ 100000, %4 ], [ %9, %6 ]
br label %22
15: ; preds = %22, %6
%16 = phi double [ %10, %6 ], [ %13, %22 ]
%17 = phi double [ 0.000000e+00, %6 ], [ %26, %22 ]
%18 = tail call double (...) @getusec()
%19 = fsub double %18, %16
%20 = fmul double %19, 0x3EB0C6F7A0B5ED8D
%21 = tail call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), double %20, double %17)
ret i32 0
22: ; preds = %12, %22
%23 = phi double [ %26, %22 ], [ 0.000000e+00, %12 ]
%24 = phi i32 [ %27, %22 ], [ 0, %12 ]
%25 = tail call double (...) @getusec()
%26 = fadd double %23, %25
%27 = add nuw nsw i32 %24, 1
%28 = icmp eq i32 %27, %14
br i1 %28, label %15, label %22
}