#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 {
  float tv_sec;
  float tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char *argv[]) {
  printf("default sched...");
  struct timeval times[100000];
  float total;
  float delta;
  float maximum;
  int count;
  struct timeval timeread;
  for (count = 0; count < 100000; count++) {
    gettimeofday(&timeread, NULL);
    times[count] = timeread;
  }
  total = maximum = delta = 0;
  for (count = 0; count < 100000 - 1; count++) {
    printf("\n %d", count);
    delta = times[count + 1].tv_sec - times[count].tv_sec;
    delta += (times[count + 1].tv_usec - times[count].tv_usec) / (float)1000000;
    total += delta;
    if (delta > maximum) {
      maximum = delta;
    }
  }
  printf("The average time for the gettimeofday() call: %.6f\n", total / count);
  printf("The maximum time for the gettimeofday() call: %.6f\n", maximum);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc3530,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0xc3520(%rbp)
cmpl   $0x186a0,-0xc3520(%rbp)
jge    119b <main+0x7b>
lea    -0xc3528(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
movslq -0xc3520(%rbp),%rax
mov    -0xc3528(%rbp),%rcx
mov    %rcx,-0xc3510(%rbp,%rax,8)
ff
mov    -0xc3520(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc3520(%rbp)
jmp    1151 <main+0x31>
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc3518(%rbp)
ff
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc351c(%rbp)
ff
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc3514(%rbp)
ff
movl   $0x0,-0xc3520(%rbp)
cmpl   $0x1869f,-0xc3520(%rbp)
jge    12ac <main+0x18c>
mov    -0xc3520(%rbp),%esi
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc3520(%rbp),%eax
add    $0x1,%eax
cltq
movss  -0xc3510(%rbp,%rax,8),%xmm0
f3 ff
movslq -0xc3520(%rbp),%rax
subss  -0xc3510(%rbp,%rax,8),%xmm0
f3 ff
movss  %xmm0,-0xc3518(%rbp)
ff
mov    -0xc3520(%rbp),%eax
add    $0x1,%eax
cltq
movss  -0xc350c(%rbp,%rax,8),%xmm0
f3 ff
movslq -0xc3520(%rbp),%rax
subss  -0xc350c(%rbp,%rax,8),%xmm0
f3 ff
movss  0xdbe(%rip),%xmm1
divss  %xmm1,%xmm0
addss  -0xc3518(%rbp),%xmm0
ff
movss  %xmm0,-0xc3518(%rbp)
ff
movss  -0xc3518(%rbp),%xmm0
ff
addss  -0xc3514(%rbp),%xmm0
ff
movss  %xmm0,-0xc3514(%rbp)
ff
movss  -0xc3518(%rbp),%xmm0
ff
ucomiss -0xc351c(%rbp),%xmm0
jbe    1293 <main+0x173>
movss  -0xc3518(%rbp),%xmm0
ff
movss  %xmm0,-0xc351c(%rbp)
ff
jmp    1298 <main+0x178>
mov    -0xc3520(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc3520(%rbp)
jmp    11c6 <main+0xa6>
movss  -0xc3514(%rbp),%xmm0
ff
cvtsi2ssl -0xc3520(%rbp),%xmm1
ff
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd4f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0xc351c(%rbp),%xmm0
ff
cvtss2sd %xmm0,%xmm0
lea    0xd69(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0xc3530,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0xc3538,%rsp
lea    0xed7(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x28(%rsp),%r14
nop
mov    %r14,%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
mov    0x28(%rsp),%rax
mov    %rax,0x30(%rsp,%rbx,8)
add    $0x1,%rbx
cmp    $0x186a0,%rbx
jne    1140 <main+0x20>
xorps  %xmm0,%xmm0
lea    0xeae(%rip),%r14
xor    %ebx,%ebx
xorps  %xmm1,%xmm1
movaps %xmm1,0x10(%rsp)
movss  %xmm0,0xc(%rsp)
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
movsd  0x30(%rsp,%rbx,8),%xmm0
movsd  0x38(%rsp,%rbx,8),%xmm1
lea    0x1(%rbx),%rax
subps  %xmm0,%xmm1
movaps %xmm1,%xmm0
shufps $0x55,%xmm1,%xmm0
divss  0xe57(%rip),%xmm0
addss  %xmm1,%xmm0
movaps 0x10(%rsp),%xmm1
addss  %xmm0,%xmm1
maxss  0xc(%rsp),%xmm0
mov    %rax,%rbx
cmp    $0x1869f,%rax
jne    1170 <main+0x50>
divss  0xe35(%rip),%xmm1
movaps %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xe3c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movaps 0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe59(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0xc3538,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timeval = type { float, float }
@.str = [17 x i8] c"default sched...\00"
@.str.1 = [5 x i8] c"\0A %d\00"
@.str.2 = [52 x i8] c"The average time for the gettimeofday() call: %.6f\0A\00"
@.str.3 = [52 x i8] c"The maximum time for the gettimeofday() call: %.6f\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [100000 x %struct.timeval]
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca i32
%11 = alloca %struct.timeval
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %10
br label %13
13: ; preds = %23, %2
%14 = load i32, i32* %10
%15 = icmp slt i32 %14, 100000
br i1 %15, label %16, label %26
16: ; preds = %13
%17 = call i32 @gettimeofday(%struct.timeval* %11, i32* null)
%18 = load i32, i32* %10
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [100000 x %struct.timeval], [100000 x %struct.timeval]* %6, i64 0, i64 %19
%21 = bitcast %struct.timeval* %20 to i8*
%22 = bitcast %struct.timeval* %11 to i8*
br label %23
23: ; preds = %16
%24 = load i32, i32* %10
%25 = add nsw i32 %24, 1
store i32 %25, i32* %10
br label %13
26: ; preds = %13
store float 0.000000e+00, float* %8
store float 0.000000e+00, float* %9
store float 0.000000e+00, float* %7
store i32 0, i32* %10
br label %27
27: ; preds = %69, %26
%28 = load i32, i32* %10
%29 = icmp slt i32 %28, 99999
br i1 %29, label %30, label %72
30: ; preds = %27
%31 = load i32, i32* %10
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %10
%34 = add nsw i32 %33, 1
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [100000 x %struct.timeval], [100000 x %struct.timeval]* %6, i64 0, i64 %35
%37 = getelementptr inbounds %struct.timeval, %struct.timeval* %36, i32 0, i32 0
%38 = load float, float* %37
%39 = load i32, i32* %10
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [100000 x %struct.timeval], [100000 x %struct.timeval]* %6, i64 0, i64 %40
%42 = getelementptr inbounds %struct.timeval, %struct.timeval* %41, i32 0, i32 0
%43 = load float, float* %42
%44 = fsub float %38, %43
store float %44, float* %8
%45 = load i32, i32* %10
%46 = add nsw i32 %45, 1
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [100000 x %struct.timeval], [100000 x %struct.timeval]* %6, i64 0, i64 %47
%49 = getelementptr inbounds %struct.timeval, %struct.timeval* %48, i32 0, i32 1
%50 = load float, float* %49
%51 = load i32, i32* %10
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [100000 x %struct.timeval], [100000 x %struct.timeval]* %6, i64 0, i64 %52
%54 = getelementptr inbounds %struct.timeval, %struct.timeval* %53, i32 0, i32 1
%55 = load float, float* %54
%56 = fsub float %50, %55
%57 = fdiv float %56, 1.000000e+06
%58 = load float, float* %8
%59 = fadd float %58, %57
store float %59, float* %8
%60 = load float, float* %8
%61 = load float, float* %7
%62 = fadd float %61, %60
store float %62, float* %7
%63 = load float, float* %8
%64 = load float, float* %9
%65 = fcmp ogt float %63, %64
br i1 %65, label %66, label %68
66: ; preds = %30
%67 = load float, float* %8
store float %67, float* %9
br label %68
68: ; preds = %66, %30
br label %69
69: ; preds = %68
%70 = load i32, i32* %10
%71 = add nsw i32 %70, 1
store i32 %71, i32* %10
br label %27
72: ; preds = %27
%73 = load float, float* %7
%74 = load i32, i32* %10
%75 = sitofp i32 %74 to float
%76 = fdiv float %73, %75
%77 = fpext float %76 to double
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), double %77)
%79 = load float, float* %9
%80 = fpext float %79 to double
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0), double %80)
%82 = load i32, i32* %3
ret i32 %82
}

LLVM IR (-O2):
%struct.timeval = type { float, float }
@.str = [17 x i8] c"default sched...\00"
@.str.1 = [5 x i8] c"\0A %d\00"
@.str.2 = [52 x i8] c"The average time for the gettimeofday() call: %.6f\0A\00"
@.str.3 = [52 x i8] c"The maximum time for the gettimeofday() call: %.6f\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [100000 x %struct.timeval]
%4 = alloca i64
%5 = bitcast i64* %4 to %struct.timeval*
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%7 = bitcast [100000 x %struct.timeval]* %3 to i8*
%8 = bitcast i64* %4 to i8*
br label %9
9: ; preds = %2, %9
%10 = phi i64 [ 0, %2 ], [ %15, %9 ]
%11 = call i32 @gettimeofday(%struct.timeval* %5, i32* null)
%12 = getelementptr inbounds [100000 x %struct.timeval], [100000 x %struct.timeval]* %3, i64 0, i64 %10
%13 = bitcast %struct.timeval* %12 to i64*
%14 = load i64, i64* %4
store i64 %14, i64* %13
%15 = add nuw nsw i64 %10, 1
%16 = icmp eq i64 %15, 100000
br i1 %16, label %17, label %9
17: ; preds = %9, %17
%18 = phi i64 [ %23, %17 ], [ 0, %9 ]
%19 = phi float [ %37, %17 ], [ 0.000000e+00, %9 ]
%20 = phi float [ %35, %17 ], [ 0.000000e+00, %9 ]
%21 = trunc i64 %18 to i32
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %21)
%23 = add nuw nsw i64 %18, 1
%24 = getelementptr inbounds [100000 x %struct.timeval], [100000 x %struct.timeval]* %3, i64 0, i64 %23, i32 0
%25 = getelementptr inbounds [100000 x %struct.timeval], [100000 x %struct.timeval]* %3, i64 0, i64 %18, i32 0
%26 = bitcast float* %24 to <2 x float>*
%27 = load <2 x float>, <2 x float>* %26
%28 = bitcast float* %25 to <2 x float>*
%29 = load <2 x float>, <2 x float>* %28
%30 = fsub <2 x float> %27, %29
%31 = extractelement <2 x float> %30, i64 1
%32 = fdiv float %31, 1.000000e+06
%33 = extractelement <2 x float> %30, i64 0
%34 = fadd float %33, %32
%35 = fadd float %20, %34
%36 = fcmp ogt float %34, %19
%37 = select i1 %36, float %34, float %19
%38 = icmp eq i64 %23, 99999
br i1 %38, label %39, label %17
39: ; preds = %17
%40 = fdiv float %35, 9.999900e+04
%41 = fpext float %40 to double
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), double %41)
%43 = fpext float %37 to double
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0), double %43)
ret i32 0
}