#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 timezone {
  int dummy;
};
struct timeval {
  double tv_sec;
  double tv_usec;
};

/* Variables and functions */
int gettimeofday(struct timeval *, struct timezone *);
int /*<<< orphan*/ printf(char *, int);
double rtclock() {
  struct timezone Tzp;
  struct timeval Tp;
  int stat;
  stat = gettimeofday(&Tp, &Tzp);
  if (stat != 0)
    printf("Error return from gettimeofday: %d", stat);
  return (Tp.tv_sec + Tp.tv_usec * 1.0e-6);
}


x86 assembly (clang, -O0):
<rtclock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    -0x18(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <gettimeofday@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1151 <rtclock+0x31>
mov    -0x1c(%rbp),%esi
lea    0xebc(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x18(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
movsd  0xe9d(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rtclock>:
sub    $0x18,%rsp
lea    0x8(%rsp),%rdi
mov    %rsp,%rsi
call   1040 <gettimeofday@plt>
test   %eax,%eax
je     1143 <rtclock+0x23>
lea    0xecc(%rip),%rdi
mov    %eax,%esi
call   1030 <printf@plt>
movsd  0x10(%rsp),%xmm0
mulsd  0xeaf(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.timezone = type { i32 }
%struct.timeval = type { double, double }
@.str = [35 x i8] c"Error return from gettimeofday: %d\00"
define double @rtclock() {
%1 = alloca %struct.timezone
%2 = alloca %struct.timeval
%3 = alloca i32
%4 = call i32 @gettimeofday(%struct.timeval* %2, %struct.timezone* %1)
store i32 %4, i32* %3
%5 = load i32, i32* %3
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = load i32, i32* %3
%9 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %8)
br label %10
10: ; preds = %7, %0
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 0
%12 = load double, double* %11
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 1
%14 = load double, double* %13
%15 = call double @llvm.fmuladd.f64(double %14, double 0x3EB0C6F7A0B5ED8D, double %12)
ret double %15
}

LLVM IR (-O2):
%struct.timezone = type { i32 }
%struct.timeval = type { double, double }
@.str = [35 x i8] c"Error return from gettimeofday: %d\00"
define double @rtclock() {
%1 = alloca %struct.timezone
%2 = alloca %struct.timeval
%3 = bitcast %struct.timezone* %1 to i8*
%4 = bitcast %struct.timeval* %2 to i8*
%5 = call i32 @gettimeofday(%struct.timeval* %2, %struct.timezone* %1)
%6 = icmp eq i32 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %0
%8 = tail call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %9
9: ; preds = %7, %0
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%11 = load double, double* %10
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 1
%13 = load double, double* %12
%14 = tail call double @llvm.fmuladd.f64(double %13, double 0x3EB0C6F7A0B5ED8D, double %11)
ret double %14
}