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

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


x86 assembly (clang, -O0):
<TimeYMDHMSToYrsec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    %r9d,-0x18(%rbp)
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
mov    -0x4(%rbp),%eax
sub    $0x76c,%eax
mov    %eax,-0x38(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x1,-0x30(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x24(%rbp)
lea    0xe3f(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x40(%rbp)
lea    0xe2f(%rip),%rdi
lea    0xe2a(%rip),%rsi
mov    $0x1,%edx
call   1040 <setenv@plt>
mov    $0x0,%al
call   1060 <tzset@plt>
lea    -0x38(%rbp),%rdi
call   1070 <mktime@plt>
mov    %rax,-0x20(%rbp)
lea    -0x38(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
mov    -0x4(%rbp),%eax
sub    $0x76c,%eax
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x24(%rbp)
lea    -0x38(%rbp),%rdi
call   1070 <mktime@plt>
sub    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     1268 <TimeYMDHMSToYrsec+0x108>
mov    -0x40(%rbp),%rsi
lea    0xda7(%rip),%rdi
mov    $0x1,%edx
call   1040 <setenv@plt>
jmp    1274 <TimeYMDHMSToYrsec+0x114>
lea    0xd91(%rip),%rdi
call   1080 <unsetenv@plt>
mov    $0x0,%al
call   1060 <tzset@plt>
mov    -0x20(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TimeYMDHMSToYrsec>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9d,0xc(%rsp)
mov    %r8d,0x8(%rsp)
mov    %ecx,0x4(%rsp)
mov    %edx,(%rsp)
mov    %esi,%ebx
mov    %edi,%r15d
lea    0x10(%rsp),%r13
mov    %r13,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
add    $0xfffff894,%r15d
mov    %r15d,0x10(%rsp)
movaps 0xe55(%rip),%xmm0
movups %xmm0,0x14(%rsp)
movl   $0x0,0x24(%rsp)
lea    0xe51(%rip),%rbp
mov    %rbp,%rdi
call   1030 <getenv@plt>
mov    %rax,%r14
lea    0xe41(%rip),%rsi
mov    %rbp,%rdi
mov    $0x1,%edx
call   1040 <setenv@plt>
xor    %eax,%eax
call   1060 <tzset@plt>
mov    %r13,%rdi
call   1070 <mktime@plt>
mov    %rax,%r12
mov    %r13,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
mov    %r15d,0x10(%rsp)
add    $0xffffffff,%ebx
mov    %ebx,0x14(%rsp)
mov    (%rsp),%eax
mov    %eax,0x18(%rsp)
mov    0x4(%rsp),%eax
mov    %eax,0x1c(%rsp)
mov    0x8(%rsp),%eax
mov    %eax,0x20(%rsp)
mov    0xc(%rsp),%eax
mov    %eax,0x24(%rsp)
mov    %r13,%rdi
call   1070 <mktime@plt>
mov    %rax,%rbx
lea    0xdd4(%rip),%rdi
test   %r14,%r14
je     1250 <TimeYMDHMSToYrsec+0xf0>
mov    %r14,%rsi
mov    $0x1,%edx
call   1040 <setenv@plt>
jmp    1255 <TimeYMDHMSToYrsec+0xf5>
call   1080 <unsetenv@plt>
sub    %r12d,%ebx
xor    %eax,%eax
call   1060 <tzset@plt>
mov    %ebx,%eax
add    $0x28,%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, i32 }
@.str = [3 x i8] c"TZ\00"
@.str.1 = [1 x i8] zeroinitializer
define i32 @TimeYMDHMSToYrsec(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i64
%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 i32 %5, i32* %12
%16 = call i32 @memset(%struct.tm* %14, i32 0, i32 24)
%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 = getelementptr inbounds %struct.tm, %struct.tm* %14, i32 0, i32 1
store i32 0, i32* %20
%21 = getelementptr inbounds %struct.tm, %struct.tm* %14, i32 0, i32 2
store i32 1, i32* %21
%22 = getelementptr inbounds %struct.tm, %struct.tm* %14, i32 0, i32 3
store i32 0, i32* %22
%23 = getelementptr inbounds %struct.tm, %struct.tm* %14, i32 0, i32 4
store i32 0, i32* %23
%24 = getelementptr inbounds %struct.tm, %struct.tm* %14, i32 0, i32 5
store i32 0, i32* %24
%25 = call i8* @getenv(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %25, i8** %15
%26 = 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)
%27 = call i32 (...) @tzset()
%28 = call i64 @mktime(%struct.tm* %14)
store i64 %28, i64* %13
%29 = call i32 @memset(%struct.tm* %14, i32 0, i32 24)
%30 = load i32, i32* %7
%31 = sub nsw i32 %30, 1900
%32 = getelementptr inbounds %struct.tm, %struct.tm* %14, i32 0, i32 0
store i32 %31, i32* %32
%33 = load i32, i32* %8
%34 = sub nsw i32 %33, 1
%35 = getelementptr inbounds %struct.tm, %struct.tm* %14, i32 0, i32 1
store i32 %34, i32* %35
%36 = load i32, i32* %9
%37 = getelementptr inbounds %struct.tm, %struct.tm* %14, i32 0, i32 2
store i32 %36, i32* %37
%38 = load i32, i32* %10
%39 = getelementptr inbounds %struct.tm, %struct.tm* %14, i32 0, i32 3
store i32 %38, i32* %39
%40 = load i32, i32* %11
%41 = getelementptr inbounds %struct.tm, %struct.tm* %14, i32 0, i32 4
store i32 %40, i32* %41
%42 = load i32, i32* %12
%43 = getelementptr inbounds %struct.tm, %struct.tm* %14, i32 0, i32 5
store i32 %42, i32* %43
%44 = call i64 @mktime(%struct.tm* %14)
%45 = load i64, i64* %13
%46 = sub nsw i64 %44, %45
store i64 %46, i64* %13
%47 = load i8*, i8** %15
%48 = icmp ne i8* %47, null
br i1 %48, label %49, label %52
49: ; preds = %6
%50 = load i8*, i8** %15
%51 = call i32 @setenv(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %50, i32 1)
br label %54
52: ; preds = %6
%53 = call i32 @unsetenv(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %54
54: ; preds = %52, %49
%55 = call i32 (...) @tzset()
%56 = load i64, i64* %13
%57 = trunc i64 %56 to i32
ret i32 %57
}

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