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

/* Variables and functions */
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int yogrt_remaining();
main(int argc, char *argv[]) {
  int i;
  int rem;
  struct timeval tv1[1], tv2[2], tv3[1];
  double t1, t2, t3;
  gettimeofday(tv1, NULL);
  rem = yogrt_remaining();
  gettimeofday(tv2, NULL);
  for (i = 0; i < 10000; i++) {
    rem = yogrt_remaining();
  }
  gettimeofday(tv3, NULL);
  t1 = tv1->tv_sec + (tv1->tv_usec * (double)0.000001);
  t2 = tv2->tv_sec + (tv2->tv_usec * (double)0.000001);
  t3 = tv3->tv_sec + (tv3->tv_usec * (double)0.000001);
  printf("yogrt_remaining first call:\n\t%.03f msec\n", (t2 - t1) * 1000);
  printf("yogrt_remaining cached timing:\n");
  printf("\t%.0f calls/sec\n", 10000 / (t3 - t2));
  printf("\t%.3f usecs/call\n", (t3 - t2) / 10000 * 100000);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x30(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
mov    $0x0,%al
call   1050 <yogrt_remaining@plt>
mov    %eax,-0x18(%rbp)
lea    -0x50(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x2710,-0x14(%rbp)
jge    11a9 <main+0x69>
mov    $0x0,%al
call   1050 <yogrt_remaining@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1184 <main+0x44>
lea    -0x60(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <gettimeofday@plt>
movsd  -0x30(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
movsd  0xe50(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x50(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
movsd  0xe31(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x60(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm0
movsd  0xe12(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x70(%rbp),%xmm0
subsd  -0x68(%rbp),%xmm0
movsd  0xdeb(%rip),%xmm1
mulsd  %xmm1,%xmm0
lea    0xdf0(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x78(%rbp),%xmm1
subsd  -0x70(%rbp),%xmm1
movsd  0xdb1(%rip),%xmm0
divsd  %xmm1,%xmm0
lea    0xe07(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movsd  -0x78(%rbp),%xmm0
subsd  -0x70(%rbp),%xmm0
movsd  0xd8d(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xd79(%rip),%xmm1
mulsd  %xmm1,%xmm0
lea    0xde8(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x60,%rsp
lea    0x20(%rsp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
xor    %eax,%eax
call   1060 <yogrt_remaining@plt>
lea    0x40(%rsp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
mov    $0x2710,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1060 <yogrt_remaining@plt>
add    $0xffffffff,%ebx
jne    1180 <main+0x30>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
movapd 0x40(%rsp),%xmm0
movupd 0x48(%rsp),%xmm2
movhpd 0x28(%rsp),%xmm2
movhpd 0x20(%rsp),%xmm0
mulpd  0xe48(%rip),%xmm2
addpd  %xmm0,%xmm2
movapd %xmm2,0x30(%rsp)
movsd  0x18(%rsp),%xmm0
mulsd  0xe40(%rip),%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movapd %xmm2,%xmm1
unpckhpd %xmm2,%xmm1
movapd %xmm2,%xmm0
subsd  %xmm1,%xmm0
mulsd  0xe24(%rip),%xmm0
lea    0xe35(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe73(%rip),%rdi
call   1030 <puts@plt>
movsd  0x8(%rsp),%xmm1
subsd  0x30(%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0xdf8(%rip),%xmm0
divsd  %xmm1,%xmm0
lea    0xe26(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movsd  0x8(%rsp),%xmm0
divsd  0xdd8(%rip),%xmm0
mulsd  0xdd8(%rip),%xmm0
lea    0xe13(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
%struct.timeval = type { double, double }
@.str = [41 x i8] c"yogrt_remaining first call:\0A\09%.03f msec\0A\00"
@.str.1 = [32 x i8] c"yogrt_remaining cached timing:\0A\00"
@.str.2 = [17 x i8] c"\09%.0f calls/sec\0A\00"
@.str.3 = [18 x i8] c"\09%.3f usecs/call\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca [1 x %struct.timeval]
%9 = alloca [2 x %struct.timeval]
%10 = alloca [1 x %struct.timeval]
%11 = alloca double
%12 = alloca double
%13 = alloca double
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = getelementptr inbounds [1 x %struct.timeval], [1 x %struct.timeval]* %8, i64 0, i64 0
%15 = call i32 @gettimeofday(%struct.timeval* %14, i32* null)
%16 = call i32 (...) @yogrt_remaining()
store i32 %16, i32* %7
%17 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %9, i64 0, i64 0
%18 = call i32 @gettimeofday(%struct.timeval* %17, i32* null)
store i32 0, i32* %6
br label %19
19: ; preds = %24, %2
%20 = load i32, i32* %6
%21 = icmp slt i32 %20, 10000
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = call i32 (...) @yogrt_remaining()
store i32 %23, i32* %7
br label %24
24: ; preds = %22
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
br label %19
27: ; preds = %19
%28 = getelementptr inbounds [1 x %struct.timeval], [1 x %struct.timeval]* %10, i64 0, i64 0
%29 = call i32 @gettimeofday(%struct.timeval* %28, i32* null)
%30 = getelementptr inbounds [1 x %struct.timeval], [1 x %struct.timeval]* %8, i64 0, i64 0
%31 = getelementptr inbounds %struct.timeval, %struct.timeval* %30, i32 0, i32 0
%32 = load double, double* %31
%33 = getelementptr inbounds [1 x %struct.timeval], [1 x %struct.timeval]* %8, i64 0, i64 0
%34 = getelementptr inbounds %struct.timeval, %struct.timeval* %33, i32 0, i32 1
%35 = load double, double* %34
%36 = call double @llvm.fmuladd.f64(double %35, double 0x3EB0C6F7A0B5ED8D, double %32)
store double %36, double* %11
%37 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %9, i64 0, i64 0
%38 = getelementptr inbounds %struct.timeval, %struct.timeval* %37, i32 0, i32 0
%39 = load double, double* %38
%40 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %9, i64 0, i64 0
%41 = getelementptr inbounds %struct.timeval, %struct.timeval* %40, i32 0, i32 1
%42 = load double, double* %41
%43 = call double @llvm.fmuladd.f64(double %42, double 0x3EB0C6F7A0B5ED8D, double %39)
store double %43, double* %12
%44 = getelementptr inbounds [1 x %struct.timeval], [1 x %struct.timeval]* %10, i64 0, i64 0
%45 = getelementptr inbounds %struct.timeval, %struct.timeval* %44, i32 0, i32 0
%46 = load double, double* %45
%47 = getelementptr inbounds [1 x %struct.timeval], [1 x %struct.timeval]* %10, i64 0, i64 0
%48 = getelementptr inbounds %struct.timeval, %struct.timeval* %47, i32 0, i32 1
%49 = load double, double* %48
%50 = call double @llvm.fmuladd.f64(double %49, double 0x3EB0C6F7A0B5ED8D, double %46)
store double %50, double* %13
%51 = load double, double* %12
%52 = load double, double* %11
%53 = fsub double %51, %52
%54 = fmul double %53, 1.000000e+03
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), double %54)
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%57 = load double, double* %13
%58 = load double, double* %12
%59 = fsub double %57, %58
%60 = fdiv double 1.000000e+04, %59
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), double %60)
%62 = load double, double* %13
%63 = load double, double* %12
%64 = fsub double %62, %63
%65 = fdiv double %64, 1.000000e+04
%66 = fmul double %65, 1.000000e+05
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), double %66)
%68 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.timeval = type { double, double }
@.str = [41 x i8] c"yogrt_remaining first call:\0A\09%.03f msec\0A\00"
@.str.2 = [17 x i8] c"\09%.0f calls/sec\0A\00"
@.str.3 = [18 x i8] c"\09%.3f usecs/call\0A\00"
@str = [31 x i8] c"yogrt_remaining cached timing:\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1 x %struct.timeval]
%4 = alloca [2 x %struct.timeval]
%5 = alloca [1 x %struct.timeval]
%6 = bitcast [1 x %struct.timeval]* %3 to i8*
%7 = bitcast [2 x %struct.timeval]* %4 to i8*
%8 = bitcast [1 x %struct.timeval]* %5 to i8*
%9 = getelementptr inbounds [1 x %struct.timeval], [1 x %struct.timeval]* %3, i64 0, i64 0
%10 = call i32 @gettimeofday(%struct.timeval* %9, i32* null)
%11 = tail call i32 (...) @yogrt_remaining()
%12 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %4, i64 0, i64 0
%13 = call i32 @gettimeofday(%struct.timeval* %12, i32* null)
br label %14
14: ; preds = %2, %14
%15 = phi i32 [ 0, %2 ], [ %17, %14 ]
%16 = tail call i32 (...) @yogrt_remaining()
%17 = add nuw nsw i32 %15, 1
%18 = icmp eq i32 %17, 10000
br i1 %18, label %19, label %14
19: ; preds = %14
%20 = getelementptr inbounds [1 x %struct.timeval], [1 x %struct.timeval]* %5, i64 0, i64 0
%21 = call i32 @gettimeofday(%struct.timeval* %20, i32* null)
%22 = getelementptr inbounds [1 x %struct.timeval], [1 x %struct.timeval]* %3, i64 0, i64 0, i32 0
%23 = load double, double* %22
%24 = getelementptr inbounds [1 x %struct.timeval], [1 x %struct.timeval]* %3, i64 0, i64 0, i32 1
%25 = load double, double* %24
%26 = bitcast [2 x %struct.timeval]* %4 to <2 x double>*
%27 = load <2 x double>, <2 x double>* %26
%28 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %4, i64 0, i64 0, i32 1
%29 = bitcast double* %28 to <2 x double>*
%30 = load <2 x double>, <2 x double>* %29
%31 = insertelement <2 x double> %30, double %25, i64 1
%32 = insertelement <2 x double> %27, double %23, i64 1
%33 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %31, <2 x double> <double 0x3EB0C6F7A0B5ED8D, double 0x3EB0C6F7A0B5ED8D>, <2 x double> %32)
%34 = getelementptr inbounds [1 x %struct.timeval], [1 x %struct.timeval]* %5, i64 0, i64 0, i32 0
%35 = load double, double* %34
%36 = getelementptr inbounds [1 x %struct.timeval], [1 x %struct.timeval]* %5, i64 0, i64 0, i32 1
%37 = load double, double* %36
%38 = tail call double @llvm.fmuladd.f64(double %37, double 0x3EB0C6F7A0B5ED8D, double %35)
%39 = extractelement <2 x double> %33, i64 0
%40 = shufflevector <2 x double> %33, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%41 = fsub <2 x double> %33, %40
%42 = extractelement <2 x double> %41, i64 0
%43 = fmul double %42, 1.000000e+03
%44 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), double %43)
%45 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%46 = fsub double %38, %39
%47 = fdiv double 1.000000e+04, %46
%48 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), double %47)
%49 = fdiv double %46, 1.000000e+04
%50 = fmul double %49, 1.000000e+05
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), double %50)
%52 = tail call i32 @exit(i32 0)
unreachable
}