#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 double time_t;
struct tm {
  int tm_year;
  int tm_mon;
  int tm_mday;
  int tm_hour;
  int tm_min;
  double tm_sec;
};

/* Variables and functions */
double floor(double);
char *getenv(char *);
int /*<<< orphan*/ memset(struct tm *, int /*<<< orphan*/, int);
double mktime(struct tm *);
int /*<<< orphan*/ setenv(char *, char *, int);
int /*<<< orphan*/ tzset();
int /*<<< orphan*/ unsetenv(char *);
double TimeYMDHMSToEpoch(int yr, int mo, int dy, int hr, int mn, double sec) {
  time_t clock;
  struct tm tm;
  char *tz;
  memset(&tm, 0, sizeof(struct tm));
  tm.tm_year = yr - 1900;
  tm.tm_mon = mo - 1;
  tm.tm_mday = dy;
  tm.tm_hour = hr;
  tm.tm_min = mn;
  tm.tm_sec = floor(sec);
  tz = getenv("TZ");
  setenv("TZ", "", 1);
  tzset();
  clock = mktime(&tm);
  if (tz)
    setenv("TZ", tz, 1);
  else
    unsetenv("TZ");
  tzset();
  return clock + (sec - floor(sec));
}


x86 assembly (clang, -O0):
<TimeYMDHMSToEpoch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
movsd  %xmm0,-0x20(%rbp)
lea    -0x48(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1050 <memset@plt>
mov    -0x4(%rbp),%eax
sub    $0x76c,%eax
mov    %eax,-0x48(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x44(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x40(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1090 <floor@plt>
movsd  %xmm0,-0x30(%rbp)
lea    0xe27(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x50(%rbp)
lea    0xe17(%rip),%rdi
lea    0xe12(%rip),%rsi
mov    $0x1,%edx
call   1040 <setenv@plt>
mov    $0x0,%al
call   1060 <tzset@plt>
lea    -0x48(%rbp),%rdi
call   1070 <mktime@plt>
movsd  %xmm0,-0x28(%rbp)
cmpq   $0x0,-0x50(%rbp)
je     1234 <TimeYMDHMSToEpoch+0xc4>
mov    -0x50(%rbp),%rsi
lea    0xddb(%rip),%rdi
mov    $0x1,%edx
call   1040 <setenv@plt>
jmp    1240 <TimeYMDHMSToEpoch+0xd0>
lea    0xdc5(%rip),%rdi
call   1080 <unsetenv@plt>
mov    $0x0,%al
call   1060 <tzset@plt>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x20(%rbp),%xmm0
call   1090 <floor@plt>
movsd  -0x60(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x58(%rbp),%xmm0
subsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TimeYMDHMSToEpoch>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
movsd  %xmm0,(%rsp)
mov    %r8d,%r15d
mov    %ecx,%r12d
mov    %edx,%r13d
mov    %esi,%ebp
mov    %edi,%ebx
lea    0x18(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1050 <memset@plt>
add    $0xfffff894,%ebx
mov    %ebx,0x18(%rsp)
add    $0xffffffff,%ebp
mov    %ebp,0x1c(%rsp)
mov    %r13d,0x20(%rsp)
mov    %r12d,0x24(%rsp)
mov    %r15d,0x28(%rsp)
movsd  (%rsp),%xmm0
call   1090 <floor@plt>
movsd  %xmm0,0x10(%rsp)
movsd  %xmm0,0x30(%rsp)
lea    0xe1f(%rip),%rbp
mov    %rbp,%rdi
call   1030 <getenv@plt>
mov    %rax,%rbx
lea    0xe0f(%rip),%rsi
mov    %rbp,%rdi
mov    $0x1,%edx
call   1040 <setenv@plt>
xor    %eax,%eax
call   1060 <tzset@plt>
mov    %r14,%rdi
call   1070 <mktime@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xde4(%rip),%rdi
test   %rbx,%rbx
je     1230 <TimeYMDHMSToEpoch+0xc0>
mov    %rbx,%rsi
mov    $0x1,%edx
call   1040 <setenv@plt>
jmp    1235 <TimeYMDHMSToEpoch+0xc5>
call   1080 <unsetenv@plt>
xor    %eax,%eax
call   1060 <tzset@plt>
movsd  (%rsp),%xmm0
subsd  0x10(%rsp),%xmm0
addsd  0x8(%rsp),%xmm0
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, double }
@.str = [3 x i8] c"TZ\00"
@.str.1 = [1 x i8] zeroinitializer
define double @TimeYMDHMSToEpoch(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, double %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca double
%13 = alloca double
%14 = alloca %struct.tm
%15 = alloca i8*
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store double %5, double* %12
%16 = call i32 @memset(%struct.tm* %14, i32 0, i32 32)
%17 = load i32, i32* %7
%18 = sub nsw i32 %17, 1900
%19 = getelementptr inbounds %struct.tm, %struct.tm* %14, i32 0, i32 0
store i32 %18, i32* %19
%20 = load i32, i32* %8
%21 = sub nsw i32 %20, 1
%22 = getelementptr inbounds %struct.tm, %struct.tm* %14, i32 0, i32 1
store i32 %21, i32* %22
%23 = load i32, i32* %9
%24 = getelementptr inbounds %struct.tm, %struct.tm* %14, i32 0, i32 2
store i32 %23, i32* %24
%25 = load i32, i32* %10
%26 = getelementptr inbounds %struct.tm, %struct.tm* %14, i32 0, i32 3
store i32 %25, i32* %26
%27 = load i32, i32* %11
%28 = getelementptr inbounds %struct.tm, %struct.tm* %14, i32 0, i32 4
store i32 %27, i32* %28
%29 = load double, double* %12
%30 = call double @llvm.floor.f64(double %29)
%31 = getelementptr inbounds %struct.tm, %struct.tm* %14, i32 0, i32 5
store double %30, double* %31
%32 = call i8* @getenv(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %32, i8** %15
%33 = call i32 @setenv(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i32 1)
%34 = call i32 (...) @tzset()
%35 = call double @mktime(%struct.tm* %14)
store double %35, double* %13
%36 = load i8*, i8** %15
%37 = icmp ne i8* %36, null
br i1 %37, label %38, label %41
38: ; preds = %6
%39 = load i8*, i8** %15
%40 = call i32 @setenv(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %39, i32 1)
br label %43
41: ; preds = %6
%42 = call i32 @unsetenv(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %43
43: ; preds = %41, %38
%44 = call i32 (...) @tzset()
%45 = load double, double* %13
%46 = load double, double* %12
%47 = load double, double* %12
%48 = call double @llvm.floor.f64(double %47)
%49 = fsub double %46, %48
%50 = fadd double %45, %49
ret double %50
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, double }
@.str = [3 x i8] c"TZ\00"
@.str.1 = [1 x i8] zeroinitializer
define double @TimeYMDHMSToEpoch(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, double %5) {
%7 = alloca %struct.tm
%8 = bitcast %struct.tm* %7 to i8*
%9 = call i32 @memset(%struct.tm* %7, i32 0, i32 32)
%10 = add nsw i32 %0, -1900
%11 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 0
store i32 %10, i32* %11
%12 = add nsw i32 %1, -1
%13 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 1
store i32 %12, i32* %13
%14 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 2
store i32 %2, i32* %14
%15 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 3
store i32 %3, i32* %15
%16 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 4
store i32 %4, i32* %16
%17 = call double @llvm.floor.f64(double %5)
%18 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 5
store double %17, double* %18
%19 = call i8* @getenv(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @setenv(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i32 1)
%21 = call i32 (...) @tzset()
%22 = call double @mktime(%struct.tm* %7)
%23 = icmp eq i8* %19, null
br i1 %23, label %26, label %24
24: ; preds = %6
%25 = call i32 @setenv(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %19, i32 1)
br label %28
26: ; preds = %6
%27 = call i32 @unsetenv(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %28
28: ; preds = %26, %24
%29 = call i32 (...) @tzset()
%30 = fsub double %5, %17
%31 = fadd double %30, %22
ret double %31
}