#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, double);
int /*<<< orphan*/ sleep(int);
int yogrt_remaining();
main(int argc, char *argv[]) {
  int i;
  int rem;
  struct timeval tv1[1], tv2[2], tv3[1];
  double t1, t2, t3;
  while (1) {
    gettimeofday(tv1, NULL);
    rem = yogrt_remaining();
    gettimeofday(tv2, NULL);
    t1 = tv1->tv_sec + (tv1->tv_usec * (double)0.000001);
    t2 = tv2->tv_sec + (tv2->tv_usec * (double)0.000001);
    printf("rem = %-8d, yogrt_remaining overhead: %.03f msec\n", rem,
           (t2 - t1) * 1000);
    sleep(1);
  }
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%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>
movsd  -0x30(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
movsd  0xe79(%rip),%xmm2
mulsd  %xmm2,%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  %xmm0,-0x68(%rbp)
movsd  -0x50(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm0
movsd  0xe4a(%rip),%xmm2
mulsd  %xmm2,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x90(%rbp)
ff
movsd  %xmm0,-0x70(%rbp)
mov    -0x18(%rbp),%esi
movsd  -0x70(%rbp),%xmm0
subsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  0xe08(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
lea    0xe08(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
jmp    1159 <main+0x19>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %rsp,%r14
lea    0x10(%rsp),%r15
lea    0xebf(%rip),%rbx
nopl   0x0(%rax)
mov    %r14,%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
xor    %eax,%eax
call   1050 <yogrt_remaining@plt>
mov    %eax,%ebp
mov    %r15,%rdi
xor    %esi,%esi
call   1040 <gettimeofday@plt>
movupd 0x18(%rsp),%xmm0
movhpd 0x8(%rsp),%xmm0
movapd 0x10(%rsp),%xmm1
movhpd (%rsp),%xmm1
mulpd  0xe64(%rip),%xmm0
addpd  %xmm1,%xmm0
movapd %xmm0,%xmm1
unpckhpd %xmm0,%xmm1
subsd  %xmm1,%xmm0
mulsd  0xe5c(%rip),%xmm0
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1060 <sleep@plt>
jmp    1160 <main+0x20>

LLVM IR (-O0):
%struct.timeval = type { double, double }
@.str = [50 x i8] c"rem = %-8d, yogrt_remaining overhead: %.03f msec\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
br label %14
14: ; preds = %2, %14
%15 = getelementptr inbounds [1 x %struct.timeval], [1 x %struct.timeval]* %8, i64 0, i64 0
%16 = call i32 @gettimeofday(%struct.timeval* %15, i32* null)
%17 = call i32 (...) @yogrt_remaining()
store i32 %17, i32* %7
%18 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %9, i64 0, i64 0
%19 = call i32 @gettimeofday(%struct.timeval* %18, i32* null)
%20 = getelementptr inbounds [1 x %struct.timeval], [1 x %struct.timeval]* %8, i64 0, i64 0
%21 = getelementptr inbounds %struct.timeval, %struct.timeval* %20, i32 0, i32 0
%22 = load double, double* %21
%23 = getelementptr inbounds [1 x %struct.timeval], [1 x %struct.timeval]* %8, i64 0, i64 0
%24 = getelementptr inbounds %struct.timeval, %struct.timeval* %23, i32 0, i32 1
%25 = load double, double* %24
%26 = call double @llvm.fmuladd.f64(double %25, double 0x3EB0C6F7A0B5ED8D, double %22)
store double %26, double* %11
%27 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %9, i64 0, i64 0
%28 = getelementptr inbounds %struct.timeval, %struct.timeval* %27, i32 0, i32 0
%29 = load double, double* %28
%30 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %9, i64 0, i64 0
%31 = getelementptr inbounds %struct.timeval, %struct.timeval* %30, i32 0, i32 1
%32 = load double, double* %31
%33 = call double @llvm.fmuladd.f64(double %32, double 0x3EB0C6F7A0B5ED8D, double %29)
store double %33, double* %12
%34 = load i32, i32* %7
%35 = load double, double* %12
%36 = load double, double* %11
%37 = fsub double %35, %36
%38 = fmul double %37, 1.000000e+03
%39 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i32 %34, double %38)
%40 = call i32 @sleep(i32 1)
br label %14
}

LLVM IR (-O2):
%struct.timeval = type { double, double }
@.str = [50 x i8] c"rem = %-8d, yogrt_remaining overhead: %.03f msec\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [1 x %struct.timeval]
%4 = alloca [2 x %struct.timeval]
%5 = bitcast [1 x %struct.timeval]* %3 to i8*
%6 = bitcast [2 x %struct.timeval]* %4 to i8*
%7 = getelementptr inbounds [1 x %struct.timeval], [1 x %struct.timeval]* %3, i64 0, i64 0
%8 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %4, i64 0, i64 0
%9 = getelementptr inbounds [1 x %struct.timeval], [1 x %struct.timeval]* %3, i64 0, i64 0, i32 0
%10 = getelementptr inbounds [1 x %struct.timeval], [1 x %struct.timeval]* %3, i64 0, i64 0, i32 1
%11 = getelementptr inbounds [2 x %struct.timeval], [2 x %struct.timeval]* %4, i64 0, i64 0, i32 1
%12 = bitcast [2 x %struct.timeval]* %4 to <2 x double>*
%13 = bitcast double* %11 to <2 x double>*
br label %14
14: ; preds = %14, %2
%15 = call i32 @gettimeofday(%struct.timeval* %7, i32* null)
%16 = tail call i32 (...) @yogrt_remaining()
%17 = call i32 @gettimeofday(%struct.timeval* %8, i32* null)
%18 = load double, double* %9
%19 = load double, double* %10
%20 = load <2 x double>, <2 x double>* %12
%21 = load <2 x double>, <2 x double>* %13
%22 = insertelement <2 x double> %21, double %19, i64 1
%23 = insertelement <2 x double> %20, double %18, i64 1
%24 = call <2 x double> @llvm.fmuladd.v2f64(<2 x double> %22, <2 x double> <double 0x3EB0C6F7A0B5ED8D, double 0x3EB0C6F7A0B5ED8D>, <2 x double> %23)
%25 = shufflevector <2 x double> %24, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%26 = fsub <2 x double> %24, %25
%27 = extractelement <2 x double> %26, i64 0
%28 = fmul double %27, 1.000000e+03
%29 = tail call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i32 %16, double %28)
%30 = tail call i32 @sleep(i32 1)
br label %14
}