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

/* Variables and functions */
double CalcLST(int, int, int, double, double);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
struct tm *gmtime(int /*<<< orphan*/ *);
double LSTNow(void) {
  int year, month, day;
  int hours, minutes, seconds, milliseconds;
  long int usecs;
  double glong;
  double ut, lst;
  time_t now;
  struct timeval t;
  struct tm *g;
  extern double SiteLongitude;
  gettimeofday(&t, NULL);
  now = t.tv_sec;
  usecs = t.tv_usec;
  g = gmtime(&now);
  year = g->tm_year;
  year = year + 1900;
  month = g->tm_mon;
  month = month + 1;
  day = g->tm_mday;
  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);
  glong = SiteLongitude;
  lst = CalcLST(year, month, day, ut, glong);
  return (lst);
}


x86 assembly (clang, -O0):
<LSTNow>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
lea    -0x58(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <gettimeofday@plt>
mov    -0x50(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0x28(%rbp)
lea    -0x44(%rbp),%rdi
call   1050 <gmtime@plt>
mov    %rax,-0x60(%rbp)
mov    -0x60(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x76c,%eax
mov    %eax,-0x4(%rbp)
mov    -0x60(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x60(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0x60(%rbp),%rax
mov    0xc(%rax),%eax
mov    %eax,-0x10(%rbp)
mov    -0x60(%rbp),%rax
mov    0x10(%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x60(%rbp),%rax
mov    0x14(%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x28(%rbp),%rax
mov    $0x3e8,%ecx
cqto
idiv   %rcx
mov    %eax,-0x1c(%rbp)
cvtsi2sdl -0x1c(%rbp),%xmm0
movsd  0xe43(%rip),%xmm1
divsd  %xmm1,%xmm0
cvtsi2sdl -0x18(%rbp),%xmm1
movsd  0xe2a(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvtsi2sdl -0x14(%rbp),%xmm1
movsd  0xe0d(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
cvtsi2sdl -0x10(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    0x2dd0(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
movsd  -0x38(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
call   1040 <CalcLST@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LSTNow>:
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   1050 <gmtime@plt>
mov    $0x76c,%edi
add    (%rax),%edi
mov    0x4(%rax),%esi
mov    0x8(%rax),%edx
add    $0x1,%esi
mov    %rbx,%rcx
shr    $0x3f,%rcx
shr    $0x7,%rbx
cvtsi2sdl 0x14(%rax),%xmm0
divsd  0xe73(%rip),%xmm0
add    %ecx,%ebx
movd   %ebx,%xmm1
movd   0x10(%rax),%xmm2
punpckldq %xmm1,%xmm2
cvtdq2pd %xmm2,%xmm1
divpd  0xe68(%rip),%xmm1
movapd %xmm1,%xmm2
unpckhpd %xmm1,%xmm2
addsd  %xmm0,%xmm2
xorps  %xmm0,%xmm0
cvtsi2sdl 0xc(%rax),%xmm0
addsd  %xmm1,%xmm2
addsd  %xmm2,%xmm0
mov    0x2e15(%rip),%rax
movsd  (%rax),%xmm1
call   1040 <CalcLST@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i32 }
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@SiteLongitude = external global double
define double @LSTNow() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca i32
%13 = alloca %struct.timeval
%14 = alloca %struct.tm*
%15 = call i32 @gettimeofday(%struct.timeval* %13, i32* null)
%16 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 1
%17 = load i32, i32* %16
store i32 %17, i32* %12
%18 = getelementptr inbounds %struct.timeval, %struct.timeval* %13, i32 0, i32 0
%19 = load i64, i64* %18
store i64 %19, i64* %8
%20 = call %struct.tm* @gmtime(i32* %12)
store %struct.tm* %20, %struct.tm** %14
%21 = load %struct.tm*, %struct.tm** %14
%22 = getelementptr inbounds %struct.tm, %struct.tm* %21, i32 0, i32 0
%23 = load i32, i32* %22
store i32 %23, i32* %1
%24 = load i32, i32* %1
%25 = add nsw i32 %24, 1900
store i32 %25, i32* %1
%26 = load %struct.tm*, %struct.tm** %14
%27 = getelementptr inbounds %struct.tm, %struct.tm* %26, i32 0, i32 1
%28 = load i32, i32* %27
store i32 %28, i32* %2
%29 = load i32, i32* %2
%30 = add nsw i32 %29, 1
store i32 %30, i32* %2
%31 = load %struct.tm*, %struct.tm** %14
%32 = getelementptr inbounds %struct.tm, %struct.tm* %31, i32 0, i32 2
%33 = load i32, i32* %32
store i32 %33, i32* %3
%34 = load %struct.tm*, %struct.tm** %14
%35 = getelementptr inbounds %struct.tm, %struct.tm* %34, i32 0, i32 3
%36 = load i32, i32* %35
store i32 %36, i32* %4
%37 = load %struct.tm*, %struct.tm** %14
%38 = getelementptr inbounds %struct.tm, %struct.tm* %37, i32 0, i32 4
%39 = load i32, i32* %38
store i32 %39, i32* %5
%40 = load %struct.tm*, %struct.tm** %14
%41 = getelementptr inbounds %struct.tm, %struct.tm* %40, i32 0, i32 5
%42 = load i32, i32* %41
store i32 %42, i32* %6
%43 = load i64, i64* %8
%44 = sdiv i64 %43, 1000
%45 = trunc i64 %44 to i32
store i32 %45, i32* %7
%46 = load i32, i32* %7
%47 = sitofp i32 %46 to double
%48 = fdiv double %47, 3.600000e+06
%49 = load i32, i32* %6
%50 = sitofp i32 %49 to double
%51 = fdiv double %50, 3.600000e+03
%52 = fadd double %48, %51
%53 = load i32, i32* %5
%54 = sitofp i32 %53 to double
%55 = fdiv double %54, 6.000000e+01
%56 = fadd double %52, %55
%57 = load i32, i32* %4
%58 = sitofp i32 %57 to double
%59 = fadd double %56, %58
store double %59, double* %10
%60 = load double, double* @SiteLongitude
store double %60, double* %9
%61 = load i32, i32* %1
%62 = load i32, i32* %2
%63 = load i32, i32* %3
%64 = load double, double* %10
%65 = load double, double* %9
%66 = call double @CalcLST(i32 %61, i32 %62, i32 %63, double %64, double %65)
store double %66, double* %11
%67 = load double, double* %11
ret double %67
}

LLVM IR (-O2):
%struct.timeval = type { i64, i32 }
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@SiteLongitude = external global double
define double @LSTNow() {
%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 = add nsw i32 %12, 1900
%14 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 1
%15 = load i32, i32* %14
%16 = add nsw i32 %15, 1
%17 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 2
%18 = load i32, i32* %17
%19 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 3
%20 = load i32, i32* %19
%21 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 4
%22 = load i32, i32* %21
%23 = getelementptr inbounds %struct.tm, %struct.tm* %10, i64 0, i32 5
%24 = load i32, i32* %23
%25 = sdiv i64 %9, 1000
%26 = trunc i64 %25 to i32
%27 = sitofp i32 %24 to double
%28 = fdiv double %27, 3.600000e+03
%29 = insertelement <2 x i32> poison, i32 %22, i64 0
%30 = insertelement <2 x i32> %29, i32 %26, i64 1
%31 = sitofp <2 x i32> %30 to <2 x double>
%32 = fdiv <2 x double> %31, <double 6.000000e+01, double 3.600000e+06>
%33 = extractelement <2 x double> %32, i64 1
%34 = fadd double %33, %28
%35 = extractelement <2 x double> %32, i64 0
%36 = fadd double %35, %34
%37 = sitofp i32 %20 to double
%38 = fadd double %36, %37
%39 = load double, double* @SiteLongitude
%40 = call double @CalcLST(i32 %13, i32 %16, i32 %18, double %38, double %39)
ret double %40
}