#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 {
  double tm_hour;
  double tm_min;
  double tm_sec;
  int /*<<< orphan*/ tm_mday;
  scalar_t__ tm_mon;
  scalar_t__ tm_year;
};

/* Variables and functions */
double gcal2j(scalar_t__, scalar_t__, int /*<<< orphan*/);
struct tm *gmtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
double utc_now(void) {
  double utc;
  time_t t;
  struct tm *ptm;
  t = time(NULL);
  ptm = gmtime(&t);
  utc = gcal2j(1900 + ptm->tm_year, ptm->tm_mon + 1, ptm->tm_mday) - 0.5;
  utc += (ptm->tm_hour + (ptm->tm_min + (ptm->tm_sec / 60.0)) / 60.0) / 24.0;
  return (utc);
}


x86 assembly (clang, -O0):
<utc_now>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,-0xc(%rbp)
lea    -0xc(%rbp),%rdi
call   1050 <gmtime@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    0x28(%rax),%rdi
add    $0x76c,%rdi
mov    -0x18(%rbp),%rax
mov    0x20(%rax),%rsi
add    $0x1,%rsi
mov    -0x18(%rbp),%rax
mov    0x18(%rax),%edx
call   1030 <gcal2j@plt>
movsd  0xe90(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x18(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x18(%rbp),%rax
movsd  0x10(%rax),%xmm2
movsd  0xe5d(%rip),%xmm3
divsd  %xmm3,%xmm2
addsd  %xmm2,%xmm1
movsd  0xe4d(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  0xe35(%rip),%xmm1
divsd  %xmm1,%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<utc_now>:
push   %rbx
sub    $0x10,%rsp
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1050 <gmtime@plt>
mov    %rax,%rbx
mov    $0x76c,%edi
add    0x28(%rax),%rdi
mov    0x20(%rax),%rsi
add    $0x1,%rsi
mov    0x18(%rax),%edx
call   1030 <gcal2j@plt>
addsd  0xe92(%rip),%xmm0
movsd  0x10(%rbx),%xmm1
movsd  0xe8d(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  0x8(%rbx),%xmm1
divsd  %xmm2,%xmm1
addsd  (%rbx),%xmm1
divsd  0xe7c(%rip),%xmm1
addsd  %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tm = type { double, double, double, i32, i64, i64 }
define double @utc_now() {
%1 = alloca double
%2 = alloca i32
%3 = alloca %struct.tm*
%4 = call i32 @time(i32* null)
store i32 %4, i32* %2
%5 = call %struct.tm* @gmtime(i32* %2)
store %struct.tm* %5, %struct.tm** %3
%6 = load %struct.tm*, %struct.tm** %3
%7 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 5
%8 = load i64, i64* %7
%9 = add nsw i64 1900, %8
%10 = load %struct.tm*, %struct.tm** %3
%11 = getelementptr inbounds %struct.tm, %struct.tm* %10, i32 0, i32 4
%12 = load i64, i64* %11
%13 = add nsw i64 %12, 1
%14 = load %struct.tm*, %struct.tm** %3
%15 = getelementptr inbounds %struct.tm, %struct.tm* %14, i32 0, i32 3
%16 = load i32, i32* %15
%17 = call double @gcal2j(i64 %9, i64 %13, i32 %16)
%18 = fsub double %17, 5.000000e-01
store double %18, double* %1
%19 = load %struct.tm*, %struct.tm** %3
%20 = getelementptr inbounds %struct.tm, %struct.tm* %19, i32 0, i32 0
%21 = load double, double* %20
%22 = load %struct.tm*, %struct.tm** %3
%23 = getelementptr inbounds %struct.tm, %struct.tm* %22, i32 0, i32 1
%24 = load double, double* %23
%25 = load %struct.tm*, %struct.tm** %3
%26 = getelementptr inbounds %struct.tm, %struct.tm* %25, i32 0, i32 2
%27 = load double, double* %26
%28 = fdiv double %27, 6.000000e+01
%29 = fadd double %24, %28
%30 = fdiv double %29, 6.000000e+01
%31 = fadd double %21, %30
%32 = fdiv double %31, 2.400000e+01
%33 = load double, double* %1
%34 = fadd double %33, %32
store double %34, double* %1
%35 = load double, double* %1
ret double %35
}

LLVM IR (-O2):
%struct.tm = type { double, double, double, i32, i64, i64 }
define double @utc_now() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @time(i32* null)
store i32 %3, i32* %1
%4 = call %struct.tm* @gmtime(i32* %1)
%5 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 5
%6 = load i64, i64* %5
%7 = add nsw i64 %6, 1900
%8 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 4
%9 = load i64, i64* %8
%10 = add nsw i64 %9, 1
%11 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 3
%12 = load i32, i32* %11
%13 = call double @gcal2j(i64 %7, i64 %10, i32 %12)
%14 = fadd double %13, -5.000000e-01
%15 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 0
%16 = load double, double* %15
%17 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 1
%18 = load double, double* %17
%19 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 2
%20 = load double, double* %19
%21 = fdiv double %20, 6.000000e+01
%22 = fadd double %18, %21
%23 = fdiv double %22, 6.000000e+01
%24 = fadd double %16, %23
%25 = fdiv double %24, 2.400000e+01
%26 = fadd double %14, %25
ret double %26
}