#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 time_t;
struct tm {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int INT_MAX;
char *asctime(struct tm *);
double difftime(int, int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
struct tm *gmtime(int *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printInfo(char *, double *, int);
int /*<<< orphan*/ printf(char *, ...);
int time(int /*<<< orphan*/ *);
int main() {
  time_t time_t_wrap, currtime;
  struct tm *utc_time;
  double diff;
  time_t_wrap = INT_MAX;
  utc_time = gmtime(&time_t_wrap);
  if (utc_time == NULL) {
    perror("gmtime");
    exit(EXIT_FAILURE);
  }
  printf("UNIX Demon will hunt you until %s", asctime(utc_time));
  currtime = time(NULL);
  if (currtime == -1) {
    perror("time");
    exit(EXIT_FAILURE);
  }
  diff = difftime(time_t_wrap, currtime);
  printf("That is, ");
  printInfo("years", &diff, (365 * (24 * (60 * (60)))));
  printInfo("months", &diff, (30 * (24 * (60 * (60)))));
  printInfo("weeks", &diff, (7 * (24 * (60 * (60)))));
  printInfo("days", &diff, (24 * (60 * (60))));
  printInfo("hours", &diff, (60 * (60)));
  printInfo("minutes", &diff, (60));
  if (diff > 0) {
    printf("and %d seconds.", (int)diff);
  }
  printf("\n");
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e52(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
lea    -0x8(%rbp),%rdi
call   1080 <gmtime@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11cd <main+0x4d>
lea    0xe46(%rip),%rdi
call   1070 <perror@plt>
mov    0x2e12(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x18(%rbp),%rdi
call   1030 <asctime@plt>
mov    %rax,%rsi
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    1217 <main+0x97>
lea    0xdfe(%rip),%rdi
call   1070 <perror@plt>
mov    0x2dc8(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <difftime@plt>
movsd  %xmm0,-0x20(%rbp)
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdf7(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x1e13380,%edx
call   10a0 <printInfo@plt>
lea    0xde8(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x278d00,%edx
call   10a0 <printInfo@plt>
lea    0xdda(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x93a80,%edx
call   10a0 <printInfo@plt>
lea    0xdcb(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x15180,%edx
call   10a0 <printInfo@plt>
lea    0xdbb(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0xe10,%edx
call   10a0 <printInfo@plt>
lea    0xdac(%rip),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x3c,%edx
call   10a0 <printInfo@plt>
movsd  -0x20(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    12d8 <main+0x158>
cvttsd2si -0x20(%rbp),%esi
lea    0xd88(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd8a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2ce3(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    0x2e4c(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1090 <gmtime@plt>
test   %rax,%rax
jne    11ba <main+0x2a>
lea    0xe48(%rip),%rdi
jmp    11e6 <main+0x56>
mov    %rax,%rdi
call   1040 <asctime@plt>
lea    0xe3e(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   1070 <time@plt>
cmp    $0xffffffff,%eax
jne    11f9 <main+0x69>
lea    0xe1c(%rip),%rdi
call   1080 <perror@plt>
mov    0x2de6(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>
mov    0x4(%rsp),%edi
mov    %eax,%esi
call   1060 <difftime@plt>
movsd  %xmm0,0x8(%rsp)
lea    0xe18(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe14(%rip),%rdi
lea    0x8(%rsp),%rbx
mov    %rbx,%rsi
mov    $0x1e13380,%edx
call   10b0 <printInfo@plt>
lea    0xe01(%rip),%rdi
mov    %rbx,%rsi
mov    $0x278d00,%edx
call   10b0 <printInfo@plt>
lea    0xdf4(%rip),%rdi
mov    %rbx,%rsi
mov    $0x93a80,%edx
call   10b0 <printInfo@plt>
lea    0xde6(%rip),%rdi
mov    %rbx,%rsi
mov    $0x15180,%edx
call   10b0 <printInfo@plt>
lea    0xdd7(%rip),%rdi
mov    %rbx,%rsi
mov    $0xe10,%edx
call   10b0 <printInfo@plt>
lea    0xdc9(%rip),%rdi
mov    %rbx,%rsi
mov    $0x3c,%edx
call   10b0 <printInfo@plt>
movsd  0x8(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    12b7 <main+0x127>
cvttsd2si %xmm0,%esi
lea    0xda9(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2d08(%rip),%rax
mov    (%rax),%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
%struct.tm = type { i32 }
@INT_MAX = global i32 0
@.str = [7 x i8] c"gmtime\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [34 x i8] c"UNIX Demon will hunt you until %s\00"
@.str.2 = [5 x i8] c"time\00"
@.str.3 = [10 x i8] c"That is, \00"
@.str.4 = [6 x i8] c"years\00"
@.str.5 = [7 x i8] c"months\00"
@.str.6 = [6 x i8] c"weeks\00"
@.str.7 = [5 x i8] c"days\00"
@.str.8 = [6 x i8] c"hours\00"
@.str.9 = [8 x i8] c"minutes\00"
@.str.10 = [16 x i8] c"and %d seconds.\00"
@.str.11 = [2 x i8] c"\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca %struct.tm*
%5 = alloca double
store i32 0, i32* %1
%6 = load i32, i32* @INT_MAX
store i32 %6, i32* %2
%7 = call %struct.tm* @gmtime(i32* %2)
store %struct.tm* %7, %struct.tm** %4
%8 = load %struct.tm*, %struct.tm** %4
%9 = icmp eq %struct.tm* %8, null
br i1 %9, label %10, label %14
10: ; preds = %0
%11 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %0
%15 = load %struct.tm*, %struct.tm** %4
%16 = call i8* @asctime(%struct.tm* %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = call i32 @time(i32* null)
store i32 %18, i32* %3
%19 = load i32, i32* %3
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %25
21: ; preds = %14
%22 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%23 = load i32, i32* @EXIT_FAILURE
%24 = call i32 @exit(i32 %23)
unreachable
25: ; preds = %14
%26 = load i32, i32* %2
%27 = load i32, i32* %3
%28 = call double @difftime(i32 %26, i32 %27)
store double %28, double* %5
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%30 = call i32 @printInfo(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), double* %5, i32 31536000)
%31 = call i32 @printInfo(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), double* %5, i32 2592000)
%32 = call i32 @printInfo(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), double* %5, i32 604800)
%33 = call i32 @printInfo(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), double* %5, i32 86400)
%34 = call i32 @printInfo(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), double* %5, i32 3600)
%35 = call i32 @printInfo(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), double* %5, i32 60)
%36 = load double, double* %5
%37 = fcmp ogt double %36, 0.000000e+00
br i1 %37, label %38, label %42
38: ; preds = %25
%39 = load double, double* %5
%40 = fptosi double %39 to i32
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i32 %40)
br label %42
42: ; preds = %38, %25
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
%44 = load i32, i32* @EXIT_SUCCESS
%45 = call i32 @exit(i32 %44)
unreachable
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@INT_MAX = global i32 0
@.str = [7 x i8] c"gmtime\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [34 x i8] c"UNIX Demon will hunt you until %s\00"
@.str.2 = [5 x i8] c"time\00"
@.str.3 = [10 x i8] c"That is, \00"
@.str.4 = [6 x i8] c"years\00"
@.str.5 = [7 x i8] c"months\00"
@.str.6 = [6 x i8] c"weeks\00"
@.str.7 = [5 x i8] c"days\00"
@.str.8 = [6 x i8] c"hours\00"
@.str.9 = [8 x i8] c"minutes\00"
@.str.10 = [16 x i8] c"and %d seconds.\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = bitcast i32* %1 to i8*
%4 = bitcast double* %2 to i8*
%5 = load i32, i32* @INT_MAX
store i32 %5, i32* %1
%6 = call %struct.tm* @gmtime(i32* %1)
%7 = icmp eq %struct.tm* %6, null
br i1 %7, label %8, label %12
8: ; preds = %0
%9 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = call i32 @exit(i32 %10)
unreachable
12: ; preds = %0
%13 = call i8* @asctime(%struct.tm* %6)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = call i32 @time(i32* null)
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %21
17: ; preds = %12
%18 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%19 = load i32, i32* @EXIT_FAILURE
%20 = call i32 @exit(i32 %19)
unreachable
21: ; preds = %12
%22 = load i32, i32* %1
%23 = call double @difftime(i32 %22, i32 %15)
store double %23, double* %2
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%25 = call i32 @printInfo(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), double* %2, i32 31536000)
%26 = call i32 @printInfo(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), double* %2, i32 2592000)
%27 = call i32 @printInfo(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), double* %2, i32 604800)
%28 = call i32 @printInfo(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), double* %2, i32 86400)
%29 = call i32 @printInfo(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), double* %2, i32 3600)
%30 = call i32 @printInfo(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), double* %2, i32 60)
%31 = load double, double* %2
%32 = fcmp ogt double %31, 0.000000e+00
br i1 %32, label %33, label %36
33: ; preds = %21
%34 = fptosi double %31 to i32
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.10, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %33, %21
%37 = call i32 @putchar(i32 10)
%38 = load i32, i32* @EXIT_SUCCESS
%39 = call i32 @exit(i32 %38)
unreachable
}