#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 tm {
  int dummy;
};

/* Variables and functions */
long atol(char *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
struct tm *makeit(long);
int /*<<< orphan*/ printf(char *, float, ...);
float timeit(struct tm *, long);
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  if (argc < 3)
    usage();
  long trials = atol(argv[1]);
  long ndates = atol(argv[2]);
  if (ndates < 1 || trials < 1)
    usage();
  struct tm *dates = makeit(ndates);
  float total = 0.0;
  long i;
  for (i = 0; i < trials; i++) {
    float secs = timeit(dates, ndates);
    printf("%3d: %f s\n", (int)i, secs);
    total += secs;
  }
  printf("avg: %f s\n", total / trials);
  exit(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   $0x3,-0x8(%rbp)
jge    1187 <main+0x27>
mov    $0x0,%al
call   1050 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atol@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atol@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x1,-0x20(%rbp)
jl     11bf <main+0x5f>
cmpq   $0x1,-0x18(%rbp)
jge    11c6 <main+0x66>
mov    $0x0,%al
call   1050 <usage@plt>
mov    -0x20(%rbp),%rdi
call   1030 <makeit@plt>
mov    %rax,-0x28(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x2c(%rbp)
movq   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    1242 <main+0xe2>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1070 <timeit@plt>
movss  %xmm0,-0x3c(%rbp)
mov    -0x38(%rbp),%rax
cvtsi2ss %eax,%xmm0
movss  -0x3c(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
lea    0xde5(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movss  -0x3c(%rbp),%xmm0
addss  -0x2c(%rbp),%xmm0
movss  %xmm0,-0x2c(%rbp)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    11e3 <main+0x83>
movss  -0x2c(%rbp),%xmm0
cvtsi2ssq -0x18(%rbp),%xmm1
divss  %xmm1,%xmm0
lea    0xdb3(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
cmp    $0x2,%edi
jg     117c <main+0x1c>
xor    %eax,%eax
call   1050 <usage@plt>
mov    0x8(%rbx),%rdi
call   1060 <atol@plt>
mov    %rax,%r14
mov    0x10(%rbx),%rdi
call   1060 <atol@plt>
mov    %rax,%r15
test   %rax,%rax
jle    11a8 <main+0x48>
test   %r14,%r14
jle    11a8 <main+0x48>
mov    %r15,%rdi
call   1030 <makeit@plt>
jmp    11bf <main+0x5f>
xor    %eax,%eax
call   1050 <usage@plt>
mov    %r15,%rdi
call   1030 <makeit@plt>
xorps  %xmm0,%xmm0
test   %r14,%r14
jle    1214 <main+0xb4>
mov    %rax,%r13
xorps  %xmm0,%xmm0
xor    %ebx,%ebx
lea    0xe32(%rip),%r12
xchg   %ax,%ax
movss  %xmm0,0xc(%rsp)
mov    %r13,%rdi
mov    %r15,%rsi
call   1070 <timeit@plt>
movaps %xmm0,%xmm1
movss  %xmm0,0x8(%rsp)
xorps  %xmm0,%xmm0
cvtsi2ss %ebx,%xmm0
cvtss2sd %xmm1,%xmm1
mov    %r12,%rdi
mov    $0x2,%al
call   1040 <printf@plt>
movss  0xc(%rsp),%xmm0
addss  0x8(%rsp),%xmm0
add    $0x1,%rbx
cmp    %rbx,%r14
jne    11d0 <main+0x70>
xorps  %xmm1,%xmm1
cvtsi2ss %r14,%xmm1
divss  %xmm1,%xmm0
lea    0xde4(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [11 x i8] c"%3d: %f s\0A\00"
@.str.1 = [11 x i8] c"avg: %f s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca %struct.tm*
%9 = alloca float
%10 = alloca i64
%11 = alloca float
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 3
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = call i32 (...) @usage()
br label %16
16: ; preds = %14, %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i64 @atol(i8* %19)
store i64 %20, i64* %6
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 2
%23 = load i8*, i8** %22
%24 = call i64 @atol(i8* %23)
store i64 %24, i64* %7
%25 = load i64, i64* %7
%26 = icmp slt i64 %25, 1
br i1 %26, label %30, label %27
27: ; preds = %16
%28 = load i64, i64* %6
%29 = icmp slt i64 %28, 1
br i1 %29, label %30, label %32
30: ; preds = %27, %16
%31 = call i32 (...) @usage()
br label %32
32: ; preds = %30, %27
%33 = load i64, i64* %7
%34 = call %struct.tm* @makeit(i64 %33)
store %struct.tm* %34, %struct.tm** %8
store float 0.000000e+00, float* %9
store i64 0, i64* %10
br label %35
35: ; preds = %52, %32
%36 = load i64, i64* %10
%37 = load i64, i64* %6
%38 = icmp slt i64 %36, %37
br i1 %38, label %39, label %55
39: ; preds = %35
%40 = load %struct.tm*, %struct.tm** %8
%41 = load i64, i64* %7
%42 = call float @timeit(%struct.tm* %40, i64 %41)
store float %42, float* %11
%43 = load i64, i64* %10
%44 = trunc i64 %43 to i32
%45 = sitofp i32 %44 to float
%46 = load float, float* %11
%47 = fpext float %46 to double
%48 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), float %45, double %47)
%49 = load float, float* %11
%50 = load float, float* %9
%51 = fadd float %50, %49
store float %51, float* %9
br label %52
52: ; preds = %39
%53 = load i64, i64* %10
%54 = add nsw i64 %53, 1
store i64 %54, i64* %10
br label %35
55: ; preds = %35
%56 = load float, float* %9
%57 = load i64, i64* %6
%58 = sitofp i64 %57 to float
%59 = fdiv float %56, %58
%60 = call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), float %59)
%61 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [11 x i8] c"%3d: %f s\0A\00"
@.str.1 = [11 x i8] c"avg: %f s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (...) @usage()
br label %6
6: ; preds = %4, %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @atol(i8* %8)
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i64 @atol(i8* %11)
%13 = icmp slt i64 %12, 1
%14 = icmp slt i64 %9, 1
%15 = select i1 %13, i1 true, i1 %14
br i1 %15, label %18, label %16
16: ; preds = %6
%17 = tail call %struct.tm* @makeit(i64 %12)
br label %22
18: ; preds = %6
%19 = tail call i32 (...) @usage()
%20 = tail call %struct.tm* @makeit(i64 %12)
%21 = icmp sgt i64 %9, 0
br i1 %21, label %22, label %35
22: ; preds = %16, %18
%23 = phi %struct.tm* [ %17, %16 ], [ %20, %18 ]
br label %24
24: ; preds = %22, %24
%25 = phi float [ %32, %24 ], [ 0.000000e+00, %22 ]
%26 = phi i64 [ %33, %24 ], [ 0, %22 ]
%27 = tail call float @timeit(%struct.tm* %23, i64 %12)
%28 = trunc i64 %26 to i32
%29 = sitofp i32 %28 to float
%30 = fpext float %27 to double
%31 = tail call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), float %29, double %30)
%32 = fadd float %25, %27
%33 = add nuw nsw i64 %26, 1
%34 = icmp eq i64 %33, %9
br i1 %34, label %35, label %24
35: ; preds = %24, %18
%36 = phi float [ 0.000000e+00, %18 ], [ %32, %24 ]
%37 = sitofp i64 %9 to float
%38 = fdiv float %36, %37
%39 = tail call i32 (i8*, float, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), float %38)
%40 = tail call i32 @exit(i32 0)
unreachable
}