#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 */
struct timeval {
  int dummy;
};

/* Variables and functions */
int atoi(char *);
int /*<<< orphan*/ f1(int);
int /*<<< orphan*/ f2(int);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, int, double, double);
double timediff(struct timeval *, struct timeval *);
int main(int argc, char *argv[]) {
  struct timeval t1, t2, t3;
  int n;
  if (argc < 2)
    n = 1000000;
  else
    n = atoi(argv[1]);
  gettimeofday(&t1, NULL);
  f1(n);
  gettimeofday(&t2, NULL);
  f2(n);
  gettimeofday(&t3, NULL);
  printf("n=%d: f1 %f, f2 %f\n", n, timediff(&t2, &t1), timediff(&t3, &t2));
}


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   $0x2,-0x8(%rbp)
jge    118c <main+0x2c>
movl   $0xf4240,-0x2c(%rbp)
jmp    119c <main+0x3c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x2c(%rbp)
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    -0x2c(%rbp),%edi
call   1060 <f1@plt>
lea    -0x20(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    -0x2c(%rbp),%edi
call   1030 <f2@plt>
lea    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
lea    -0x20(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1080 <timediff@plt>
movsd  %xmm0,-0x38(%rbp)
lea    -0x28(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1080 <timediff@plt>
mov    -0x3c(%rbp),%esi
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
lea    0xdf6(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    $0xf4240,%ebx
cmp    $0x2,%edi
jl     1180 <main+0x20>
mov    0x8(%rsi),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebx
lea    0x20(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
mov    %ebx,%edi
call   1060 <f1@plt>
lea    0x18(%rsp),%r15
mov    %r15,%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
mov    %ebx,%edi
call   1030 <f2@plt>
lea    0x10(%rsp),%r12
mov    %r12,%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1080 <timediff@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r12,%rdi
mov    %r15,%rsi
call   1080 <timediff@plt>
movaps %xmm0,%xmm1
lea    0xe1f(%rip),%rdi
mov    %ebx,%esi
movsd  0x8(%rsp),%xmm0
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.timeval = type { i32 }
@.str = [20 x i8] c"n=%d: f1 %f, f2 %f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.timeval
%7 = alloca %struct.timeval
%8 = alloca %struct.timeval
%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 slt i32 %10, 2
br i1 %11, label %12, label %13
12: ; preds = %2
store i32 1000000, i32* %9
br 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)
store i32 %17, i32* %9
br label %18
18: ; preds = %13, %12
%19 = call i32 @gettimeofday(%struct.timeval* %6, i32* null)
%20 = load i32, i32* %9
%21 = call i32 @f1(i32 %20)
%22 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
%23 = load i32, i32* %9
%24 = call i32 @f2(i32 %23)
%25 = call i32 @gettimeofday(%struct.timeval* %8, i32* null)
%26 = load i32, i32* %9
%27 = call double @timediff(%struct.timeval* %7, %struct.timeval* %6)
%28 = call double @timediff(%struct.timeval* %8, %struct.timeval* %7)
%29 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %26, double %27, double %28)
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
@.str = [20 x i8] c"n=%d: f1 %f, f2 %f\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.timeval
%4 = alloca %struct.timeval
%5 = alloca %struct.timeval
%6 = bitcast %struct.timeval* %3 to i8*
%7 = bitcast %struct.timeval* %4 to i8*
%8 = bitcast %struct.timeval* %5 to i8*
%9 = icmp slt i32 %0, 2
br i1 %9, label %14, label %10
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = tail call i32 @atoi(i8* %12)
br label %14
14: ; preds = %2, %10
%15 = phi i32 [ %13, %10 ], [ 1000000, %2 ]
%16 = call i32 @gettimeofday(%struct.timeval* %3, i32* null)
%17 = tail call i32 @f1(i32 %15)
%18 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%19 = tail call i32 @f2(i32 %15)
%20 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
%21 = call double @timediff(%struct.timeval* %4, %struct.timeval* %3)
%22 = call double @timediff(%struct.timeval* %5, %struct.timeval* %4)
%23 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %15, double %21, double %22)
ret i32 0
}