#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 *);
struct tm *gmtime(scalar_t__ *);
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 *);
void TimeYrsecToYMDHMS(int yrsec, int yr, int *mo, int *dy, int *hr, int *mn,
                       int *sc) {
  time_t clock;
  struct tm tmyr;
  struct tm *tm;
  char *tz;
  memset(&tmyr, 0, sizeof(struct tm));
  tmyr.tm_year = yr - 1900;
  tmyr.tm_mon = 0;
  tmyr.tm_mday = 1;
  tmyr.tm_hour = 0;
  tmyr.tm_min = 0;
  tmyr.tm_sec = 0;
  tz = getenv("TZ");
  setenv("TZ", "", 1);
  tzset();
  clock = mktime(&tmyr);
  if (tz)
    setenv("TZ", tz, 1);
  else
    unsetenv("TZ");
  tzset();
  clock = clock + yrsec;
  tm = gmtime(&clock);
  *mo = tm->tm_mon + 1;
  *dy = tm->tm_mday;
  *hr = tm->tm_hour;
  *mn = tm->tm_min;
  *sc = tm->tm_sec;
}


x86 assembly (clang, -O0):
<TimeYrsecToYMDHMS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
lea    -0x48(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
mov    -0x8(%rbp),%eax
sub    $0x76c,%eax
mov    %eax,-0x48(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x1,-0x40(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x34(%rbp)
lea    0xe29(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x58(%rbp)
lea    0xe19(%rip),%rdi
lea    0xe14(%rip),%rsi
mov    $0x1,%edx
call   1040 <setenv@plt>
mov    $0x0,%al
call   1060 <tzset@plt>
lea    -0x48(%rbp),%rdi
call   1070 <mktime@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x58(%rbp)
je     1231 <TimeYrsecToYMDHMS+0xc1>
mov    -0x58(%rbp),%rsi
lea    0xdde(%rip),%rdi
mov    $0x1,%edx
call   1040 <setenv@plt>
jmp    123d <TimeYrsecToYMDHMS+0xcd>
lea    0xdc8(%rip),%rdi
call   1090 <unsetenv@plt>
mov    $0x0,%al
call   1060 <tzset@plt>
mov    -0x30(%rbp),%rax
movslq -0x4(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x30(%rbp)
lea    -0x30(%rbp),%rdi
call   1080 <gmtime@plt>
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rax
mov    0x4(%rax),%ecx
add    $0x1,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x50(%rbp),%rax
mov    0x8(%rax),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x50(%rbp),%rax
mov    0xc(%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x50(%rbp),%rax
mov    0x10(%rax),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x50(%rbp),%rax
mov    0x14(%rax),%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TimeYrsecToYMDHMS>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9,0x10(%rsp)
mov    %r8,0x8(%rsp)
mov    %rcx,%r12
mov    %rdx,%r13
mov    %esi,%ebp
mov    %edi,%r15d
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1050 <memset@plt>
add    $0xfffff894,%ebp
mov    %ebp,0x20(%rsp)
movaps 0xe48(%rip),%xmm0
movups %xmm0,0x24(%rsp)
movl   $0x0,0x34(%rsp)
lea    0xe44(%rip),%rbp
mov    %rbp,%rdi
call   1030 <getenv@plt>
mov    %rax,%r14
lea    0xe34(%rip),%rsi
mov    %rbp,%rdi
mov    $0x1,%edx
call   1040 <setenv@plt>
xor    %eax,%eax
call   1060 <tzset@plt>
mov    %rbx,%rdi
call   1070 <mktime@plt>
mov    %rax,%rbx
lea    0xe0c(%rip),%rdi
test   %r14,%r14
je     1218 <TimeYrsecToYMDHMS+0xa8>
mov    %r14,%rsi
mov    $0x1,%edx
call   1040 <setenv@plt>
jmp    121d <TimeYrsecToYMDHMS+0xad>
call   1090 <unsetenv@plt>
xor    %eax,%eax
call   1060 <tzset@plt>
movslq %r15d,%rax
add    %rax,%rbx
mov    %rbx,0x18(%rsp)
lea    0x18(%rsp),%rdi
call   1080 <gmtime@plt>
mov    0x4(%rax),%ecx
add    $0x1,%ecx
mov    %ecx,0x0(%r13)
mov    0x8(%rax),%ecx
mov    %ecx,(%r12)
mov    0xc(%rax),%ecx
mov    0x8(%rsp),%rdx
mov    %ecx,(%rdx)
mov    0x10(%rax),%ecx
mov    0x10(%rsp),%rdx
mov    %ecx,(%rdx)
mov    0x14(%rax),%eax
mov    0x70(%rsp),%rcx
mov    %eax,(%rcx)
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, i32 }
@.str = [3 x i8] c"TZ\00"
@.str.1 = [1 x i8] zeroinitializer
define void @TimeYrsecToYMDHMS(i32 %0, i32 %1, i32* %2, i32* %3, i32* %4, i32* %5, i32* %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i64
%16 = alloca %struct.tm
%17 = alloca %struct.tm*
%18 = alloca i8*
store i32 %0, i32* %8
store i32 %1, i32* %9
store i32* %2, i32** %10
store i32* %3, i32** %11
store i32* %4, i32** %12
store i32* %5, i32** %13
store i32* %6, i32** %14
%19 = call i32 @memset(%struct.tm* %16, i32 0, i32 24)
%20 = load i32, i32* %9
%21 = sub nsw i32 %20, 1900
%22 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 0
store i32 %21, i32* %22
%23 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 1
store i32 0, i32* %23
%24 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 2
store i32 1, i32* %24
%25 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 3
store i32 0, i32* %25
%26 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 4
store i32 0, i32* %26
%27 = getelementptr inbounds %struct.tm, %struct.tm* %16, i32 0, i32 5
store i32 0, i32* %27
%28 = call i8* @getenv(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i8* %28, i8** %18
%29 = 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)
%30 = call i32 (...) @tzset()
%31 = call i64 @mktime(%struct.tm* %16)
store i64 %31, i64* %15
%32 = load i8*, i8** %18
%33 = icmp ne i8* %32, null
br i1 %33, label %34, label %37
34: ; preds = %7
%35 = load i8*, i8** %18
%36 = call i32 @setenv(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %35, i32 1)
br label %39
37: ; preds = %7
%38 = call i32 @unsetenv(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %39
39: ; preds = %37, %34
%40 = call i32 (...) @tzset()
%41 = load i64, i64* %15
%42 = load i32, i32* %8
%43 = sext i32 %42 to i64
%44 = add nsw i64 %41, %43
store i64 %44, i64* %15
%45 = call %struct.tm* @gmtime(i64* %15)
store %struct.tm* %45, %struct.tm** %17
%46 = load %struct.tm*, %struct.tm** %17
%47 = getelementptr inbounds %struct.tm, %struct.tm* %46, i32 0, i32 1
%48 = load i32, i32* %47
%49 = add nsw i32 %48, 1
%50 = load i32*, i32** %10
store i32 %49, i32* %50
%51 = load %struct.tm*, %struct.tm** %17
%52 = getelementptr inbounds %struct.tm, %struct.tm* %51, i32 0, i32 2
%53 = load i32, i32* %52
%54 = load i32*, i32** %11
store i32 %53, i32* %54
%55 = load %struct.tm*, %struct.tm** %17
%56 = getelementptr inbounds %struct.tm, %struct.tm* %55, i32 0, i32 3
%57 = load i32, i32* %56
%58 = load i32*, i32** %12
store i32 %57, i32* %58
%59 = load %struct.tm*, %struct.tm** %17
%60 = getelementptr inbounds %struct.tm, %struct.tm* %59, i32 0, i32 4
%61 = load i32, i32* %60
%62 = load i32*, i32** %13
store i32 %61, i32* %62
%63 = load %struct.tm*, %struct.tm** %17
%64 = getelementptr inbounds %struct.tm, %struct.tm* %63, i32 0, i32 5
%65 = load i32, i32* %64
%66 = load i32*, i32** %14
store i32 %65, i32* %66
ret void
}

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 void @TimeYrsecToYMDHMS(i32 %0, i32 %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3, i32* nocapture writeonly %4, i32* nocapture writeonly %5, i32* nocapture writeonly %6) {
%8 = alloca i64
%9 = alloca %struct.tm
%10 = bitcast i64* %8 to i8*
%11 = bitcast %struct.tm* %9 to i8*
%12 = call i32 @memset(%struct.tm* %9, i32 0, i32 24)
%13 = add nsw i32 %1, -1900
%14 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 0
store i32 %13, i32* %14
%15 = getelementptr inbounds %struct.tm, %struct.tm* %9, i64 0, i32 1
%16 = bitcast i32* %15 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* %9, 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* %9)
%22 = icmp eq i8* %18, null
br i1 %22, label %25, label %23
23: ; preds = %7
%24 = call i32 @setenv(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %18, i32 1)
br label %27
25: ; preds = %7
%26 = call i32 @unsetenv(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %27
27: ; preds = %25, %23
%28 = call i32 (...) @tzset()
%29 = sext i32 %0 to i64
%30 = add nsw i64 %21, %29
store i64 %30, i64* %8
%31 = call %struct.tm* @gmtime(i64* %8)
%32 = getelementptr inbounds %struct.tm, %struct.tm* %31, i64 0, i32 1
%33 = load i32, i32* %32
%34 = add nsw i32 %33, 1
store i32 %34, i32* %2
%35 = getelementptr inbounds %struct.tm, %struct.tm* %31, i64 0, i32 2
%36 = load i32, i32* %35
store i32 %36, i32* %3
%37 = getelementptr inbounds %struct.tm, %struct.tm* %31, i64 0, i32 3
%38 = load i32, i32* %37
store i32 %38, i32* %4
%39 = getelementptr inbounds %struct.tm, %struct.tm* %31, i64 0, i32 4
%40 = load i32, i32* %39
store i32 %40, i32* %5
%41 = getelementptr inbounds %struct.tm, %struct.tm* %31, i64 0, i32 5
%42 = load i32, i32* %41
store i32 %42, i32* %6
ret void
}