#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 */
typedef int /*<<< orphan*/ time_t;
struct tm {
  int tm_hour;
  int tm_min;
  int tm_sec;
};
struct timeval {
  long tv_usec;
  int /*<<< orphan*/ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
struct tm *gmtime(int /*<<< orphan*/ *);
double UTNow(void) {
  int hours, minutes, seconds, milliseconds;
  long int usecs;
  double ut;
  time_t now;
  struct timeval t;
  struct tm *g;
  gettimeofday(&t, NULL);
  now = t.tv_sec;
  usecs = t.tv_usec;
  g = gmtime(&now);
  hours = g->tm_hour;
  minutes = g->tm_min;
  seconds = g->tm_sec;
  milliseconds = usecs / 1000;
  ut = ((double)milliseconds) / 3600000. + ((double)seconds) / 3600. +
       ((double)minutes) / 60. + ((double)hours);
  return (ut);
}


x86 assembly (clang, -O0):
<UTNow>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    -0x38(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
mov    -0x30(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    -0x24(%rbp),%rdi
call   1040 <gmtime@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x40(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x8(%rbp)
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rax
mov    $0x3e8,%ecx
cqto
idiv   %rcx
mov    %eax,-0x10(%rbp)
cvtsi2sdl -0x10(%rbp),%xmm0
movsd  0xe85(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
movsd  0xe6c(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
movsd  0xe4f(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvtsi2sdl -0x4(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UTNow>:
push   %rbx
sub    $0x20,%rsp
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1030 <gettimeofday@plt>
mov    0x18(%rsp),%eax
mov    %eax,0xc(%rsp)
movabs $0x20c49ba5e353f7cf,%rax
9b c4 20
imulq  0x10(%rsp)
mov    %rdx,%rbx
lea    0xc(%rsp),%rdi
call   1040 <gmtime@plt>
mov    %rbx,%rcx
shr    $0x3f,%rcx
shr    $0x7,%rbx
cvtsi2sdl 0x8(%rax),%xmm0
add    %ecx,%ebx
divsd  0xe91(%rip),%xmm0
movd   %ebx,%xmm1
movd   0x4(%rax),%xmm2
punpckldq %xmm1,%xmm2
cvtdq2pd %xmm2,%xmm1
divpd  0xe88(%rip),%xmm1
movapd %xmm1,%xmm2
unpckhpd %xmm1,%xmm2
addsd  %xmm0,%xmm2
addsd  %xmm1,%xmm2
xorps  %xmm0,%xmm0
cvtsi2sdl (%rax),%xmm0
addsd  %xmm2,%xmm0
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i32 }
%struct.tm = type { i32, i32, i32 }
define double @UTNow() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i64
%6 = alloca double
%7 = alloca i32
%8 = alloca %struct.timeval
%9 = alloca %struct.tm*
%10 = call i32 @gettimeofday(%struct.timeval* %8, i32* null)
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 1
%12 = load i32, i32* %11
store i32 %12, i32* %7
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %8, i32 0, i32 0
%14 = load i64, i64* %13
store i64 %14, i64* %5
%15 = call %struct.tm* @gmtime(i32* %7)
store %struct.tm* %15, %struct.tm** %9
%16 = load %struct.tm*, %struct.tm** %9
%17 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 0
%18 = load i32, i32* %17
store i32 %18, i32* %1
%19 = load %struct.tm*, %struct.tm** %9
%20 = getelementptr inbounds %struct.tm, %struct.tm* %19, i32 0, i32 1
%21 = load i32, i32* %20
store i32 %21, i32* %2
%22 = load %struct.tm*, %struct.tm** %9
%23 = getelementptr inbounds %struct.tm, %struct.tm* %22, i32 0, i32 2
%24 = load i32, i32* %23
store i32 %24, i32* %3
%25 = load i64, i64* %5
%26 = sdiv i64 %25, 1000
%27 = trunc i64 %26 to i32
store i32 %27, i32* %4
%28 = load i32, i32* %4
%29 = sitofp i32 %28 to double
%30 = fdiv double %29, 3.600000e+06
%31 = load i32, i32* %3
%32 = sitofp i32 %31 to double
%33 = fdiv double %32, 3.600000e+03
%34 = fadd double %30, %33
%35 = load i32, i32* %2
%36 = sitofp i32 %35 to double
%37 = fdiv double %36, 6.000000e+01
%38 = fadd double %34, %37
%39 = load i32, i32* %1
%40 = sitofp i32 %39 to double
%41 = fadd double %38, %40
store double %41, double* %6
%42 = load double, double* %6
ret double %42
}

LLVM IR (-O2):
%struct.timeval = type { i64, i32 }
%struct.tm = type { i32, i32, i32 }
define double @UTNow() {
%1 = alloca i32
%2 = alloca %struct.timeval
%3 = bitcast i32* %1 to i8*
%4 = bitcast %struct.timeval* %2 to i8*
%5 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%6 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 1
%7 = load i32, i32* %6
store i32 %7, i32* %1
%8 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%9 = load i64, i64* %8
%10 = call %struct.tm* @gmtime(i32* %1)
%11 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 0
%12 = load i32, i32* %11
%13 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 1
%14 = load i32, i32* %13
%15 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 2
%16 = load i32, i32* %15
%17 = sdiv i64 %9, 1000
%18 = trunc i64 %17 to i32
%19 = sitofp i32 %16 to double
%20 = fdiv double %19, 3.600000e+03
%21 = insertelement <2 x i32> poison, i32 %14, i64 0
%22 = insertelement <2 x i32> %21, i32 %18, i64 1
%23 = sitofp <2 x i32> %22 to <2 x double>
%24 = fdiv <2 x double> %23, <double 6.000000e+01, double 3.600000e+06>
%25 = extractelement <2 x double> %24, i64 1
%26 = fadd double %25, %20
%27 = extractelement <2 x double> %24, i64 0
%28 = fadd double %27, %26
%29 = sitofp i32 %12 to double
%30 = fadd double %28, %29
ret double %30
}