#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;

/* Variables and functions */
int LONG_MAX;
int LONG_MIN;
int /*<<< orphan*/ daylight;
int /*<<< orphan*/ printTime(int /*<<< orphan*/);
int /*<<< orphan*/ printTimeReentrant(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ timezone;
char **tzname;
int main(void) {
  time_t t = time(NULL);
  printf("static variables before calling ctime(): tzname=%s timezone=%ld "
         "daylight=%d\n",
         tzname[1], timezone, daylight);
  printTime(t);
  printf("static variables after calling ctime(): tzname=%s timezone=%ld "
         "daylight=%d\n",
         tzname[1], timezone, daylight);
  printTime((time_t)0);
  printTime((time_t)-1);
  printf("sizeof(time_t): %zd\n", sizeof(time_t));
  printf("sizeof(long): %zd\n", sizeof(long));
  printTime((time_t)(LONG_MAX / 350));
  printTime((time_t)(LONG_MIN / 350));
  printTimeReentrant((time_t)(LONG_MAX / 350));
  printTimeReentrant((time_t)(LONG_MIN / 350));
  printTime((time_t)(LONG_MAX));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,-0x8(%rbp)
mov    0x2e66(%rip),%rax
mov    (%rax),%rax
mov    0x8(%rax),%rsi
mov    0x2e60(%rip),%rax
mov    (%rax),%edx
mov    0x2e3f(%rip),%rax
mov    (%rax),%ecx
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
call   1060 <printTime@plt>
mov    0x2e30(%rip),%rax
mov    (%rax),%rax
mov    0x8(%rax),%rsi
mov    0x2e2a(%rip),%rax
mov    (%rax),%edx
mov    0x2e09(%rip),%rax
mov    (%rax),%ecx
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1060 <printTime@plt>
mov    $0xffffffff,%edi
call   1060 <printTime@plt>
lea    0xec2(%rip),%rdi
mov    $0x4,%esi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec4(%rip),%rdi
mov    $0x8,%esi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2ddb(%rip),%rax
mov    (%rax),%eax
mov    $0x15e,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1060 <printTime@plt>
mov    0x2dd3(%rip),%rax
mov    (%rax),%eax
mov    $0x15e,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1060 <printTime@plt>
mov    0x2dab(%rip),%rax
mov    (%rax),%eax
mov    $0x15e,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1030 <printTimeReentrant@plt>
mov    0x2da3(%rip),%rax
mov    (%rax),%eax
mov    $0x15e,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1030 <printTimeReentrant@plt>
mov    0x2d7b(%rip),%rax
mov    (%rax),%edi
call   1060 <printTime@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,%ebx
mov    0x2e70(%rip),%r14
mov    (%r14),%rax
mov    0x8(%rax),%rsi
mov    0x2e6a(%rip),%r15
mov    (%r15),%edx
mov    0x2e48(%rip),%r12
mov    (%r12),%ecx
lea    0xe85(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%edi
call   1060 <printTime@plt>
mov    (%r14),%rax
mov    0x8(%rax),%rsi
mov    (%r15),%edx
mov    (%r12),%ecx
lea    0xeaf(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   1060 <printTime@plt>
mov    $0xffffffff,%edi
call   1060 <printTime@plt>
lea    0xedc(%rip),%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xede(%rip),%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2df5(%rip),%r14
movslq (%r14),%rax
imul   $0x5d9f7391,%rax,%rdi
mov    %rdi,%rax
shr    $0x3f,%rax
sar    $0x27,%rdi
add    %eax,%edi
call   1060 <printTime@plt>
mov    0x2de2(%rip),%rbx
movslq (%rbx),%rax
imul   $0x5d9f7391,%rax,%rdi
mov    %rdi,%rax
shr    $0x3f,%rax
sar    $0x27,%rdi
add    %eax,%edi
call   1060 <printTime@plt>
movslq (%r14),%rax
imul   $0x5d9f7391,%rax,%rdi
mov    %rdi,%rax
shr    $0x3f,%rax
sar    $0x27,%rdi
add    %eax,%edi
call   1030 <printTimeReentrant@plt>
movslq (%rbx),%rax
imul   $0x5d9f7391,%rax,%rdi
mov    %rdi,%rax
shr    $0x3f,%rax
sar    $0x27,%rdi
add    %eax,%edi
call   1030 <printTimeReentrant@plt>
mov    (%r14),%edi
call   1060 <printTime@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [77 x i8] c"static variables before calling ctime(): tzname=%s timezone=%ld daylight=%d\0A\00"
@tzname = global i8** null
@timezone = global i32 0
@daylight = global i32 0
@.str.1 = [76 x i8] c"static variables after calling ctime(): tzname=%s timezone=%ld daylight=%d\0A\00"
@.str.2 = [21 x i8] c"sizeof(time_t): %zd\0A\00"
@.str.3 = [19 x i8] c"sizeof(long): %zd\0A\00"
@LONG_MAX = global i32 0
@LONG_MIN = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @time(i32* null)
store i32 %3, i32* %2
%4 = load i8**, i8*** @tzname
%5 = getelementptr inbounds i8*, i8** %4, i64 1
%6 = load i8*, i8** %5
%7 = load i32, i32* @timezone
%8 = load i32, i32* @daylight
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str, i64 0, i64 0), i8* %6, i32 %7, i32 %8)
%10 = load i32, i32* %2
%11 = call i32 @printTime(i32 %10)
%12 = load i8**, i8*** @tzname
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = load i32, i32* @timezone
%16 = load i32, i32* @daylight
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([76 x i8], [76 x i8]* @.str.1, i64 0, i64 0), i8* %14, i32 %15, i32 %16)
%18 = call i32 @printTime(i32 0)
%19 = call i32 @printTime(i32 -1)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i64 4)
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i64 8)
%22 = load i32, i32* @LONG_MAX
%23 = sdiv i32 %22, 350
%24 = call i32 @printTime(i32 %23)
%25 = load i32, i32* @LONG_MIN
%26 = sdiv i32 %25, 350
%27 = call i32 @printTime(i32 %26)
%28 = load i32, i32* @LONG_MAX
%29 = sdiv i32 %28, 350
%30 = call i32 @printTimeReentrant(i32 %29)
%31 = load i32, i32* @LONG_MIN
%32 = sdiv i32 %31, 350
%33 = call i32 @printTimeReentrant(i32 %32)
%34 = load i32, i32* @LONG_MAX
%35 = call i32 @printTime(i32 %34)
ret i32 0
}

LLVM IR (-O2):
@.str = [77 x i8] c"static variables before calling ctime(): tzname=%s timezone=%ld daylight=%d\0A\00"
@tzname = global i8** null
@timezone = global i32 0
@daylight = global i32 0
@.str.1 = [76 x i8] c"static variables after calling ctime(): tzname=%s timezone=%ld daylight=%d\0A\00"
@.str.2 = [21 x i8] c"sizeof(time_t): %zd\0A\00"
@.str.3 = [19 x i8] c"sizeof(long): %zd\0A\00"
@LONG_MAX = global i32 0
@LONG_MIN = global i32 0
define i32 @main() {
%1 = tail call i32 @time(i32* null)
%2 = load i8**, i8*** @tzname
%3 = getelementptr inbounds i8*, i8** %2, i64 1
%4 = load i8*, i8** %3
%5 = load i32, i32* @timezone
%6 = load i32, i32* @daylight
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([77 x i8], [77 x i8]* @.str, i64 0, i64 0), i8* %4, i32 %5, i32 %6)
%8 = tail call i32 @printTime(i32 %1)
%9 = load i8**, i8*** @tzname
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = load i32, i32* @timezone
%13 = load i32, i32* @daylight
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([76 x i8], [76 x i8]* @.str.1, i64 0, i64 0), i8* %11, i32 %12, i32 %13)
%15 = tail call i32 @printTime(i32 0)
%16 = tail call i32 @printTime(i32 -1)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i64 4)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i64 8)
%19 = load i32, i32* @LONG_MAX
%20 = sdiv i32 %19, 350
%21 = tail call i32 @printTime(i32 %20)
%22 = load i32, i32* @LONG_MIN
%23 = sdiv i32 %22, 350
%24 = tail call i32 @printTime(i32 %23)
%25 = load i32, i32* @LONG_MAX
%26 = sdiv i32 %25, 350
%27 = tail call i32 @printTimeReentrant(i32 %26)
%28 = load i32, i32* @LONG_MIN
%29 = sdiv i32 %28, 350
%30 = tail call i32 @printTimeReentrant(i32 %29)
%31 = load i32, i32* @LONG_MAX
%32 = tail call i32 @printTime(i32 %31)
ret i32 0
}