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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ mktime(struct tm *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  struct tm *ptm;
  time_t t, gm;
  if ((t = time(NULL)) < 0) {
    fprintf(stderr, "Err.(%s) getting time\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
  ptm = localtime(&t);
  gm = mktime(ptm);
  printf("localtime() - ");
  printf("%d/%d/%d - %d:%d:%d\n", ptm->tm_mon = ptm->tm_mon + 1, ptm->tm_mday,
         ptm->tm_year = ptm->tm_year + 1900, ptm->tm_hour, ptm->tm_min,
         ptm->tm_sec);
  printf("localtime() to mktime() - %ld \n", gm);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    11ce <main+0x5e>
mov    0x2e45(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x1c(%rbp),%edi
mov    %rax,%rdx
lea    0xe45(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
lea    -0x14(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <mktime@plt>
mov    %eax,-0x18(%rbp)
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
add    $0x1,%esi
mov    -0x10(%rbp),%rax
mov    %esi,(%rax)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%ecx
add    $0x76c,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%r8d
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%r9d
mov    -0x10(%rbp),%rax
mov    0x14(%rax),%eax
lea    0xde9(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d69(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,0x14(%rsp)
test   %eax,%eax
js     11fb <main+0x8b>
lea    0x14(%rsp),%rdi
call   1030 <localtime@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1070 <mktime@plt>
mov    %eax,%ebp
lea    0xe74(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%esi
mov    0x4(%rbx),%edx
add    $0x1,%esi
mov    %esi,(%rbx)
mov    $0x76c,%ecx
add    0x8(%rbx),%ecx
mov    %ecx,0x8(%rbx)
mov    0xc(%rbx),%r8d
mov    0x10(%rbx),%r9d
mov    0x14(%rbx),%eax
mov    %eax,(%rsp)
lea    0xe52(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe59(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2dd6(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret
mov    0x2dde(%rip),%rax
mov    (%rax),%ebx
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xde7(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1050 <fprintf@plt>
mov    0x2da6(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@stderr = global i32 0
@.str = [23 x i8] c"Err.(%s) getting time\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.1 = [15 x i8] c"localtime() - \00"
@.str.2 = [21 x i8] c"%d/%d/%d - %d:%d:%d\0A\00"
@.str.3 = [32 x i8] c"localtime() to mktime() - %ld \0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.tm*
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @time(i32* null)
store i32 %5, i32* %3
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %14
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = load i32, i32* @errno
%10 = call i8* @strerror(i32 %9)
%11 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %0
%15 = call %struct.tm* @localtime(i32* %3)
store %struct.tm* %15, %struct.tm** %2
%16 = load %struct.tm*, %struct.tm** %2
%17 = call i32 @mktime(%struct.tm* %16)
store i32 %17, i32* %4
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%19 = load %struct.tm*, %struct.tm** %2
%20 = getelementptr inbounds %struct.tm, %struct.tm* %19, i32 0, i32 0
%21 = load i32, i32* %20
%22 = add nsw i32 %21, 1
%23 = load %struct.tm*, %struct.tm** %2
%24 = getelementptr inbounds %struct.tm, %struct.tm* %23, i32 0, i32 0
store i32 %22, i32* %24
%25 = load %struct.tm*, %struct.tm** %2
%26 = getelementptr inbounds %struct.tm, %struct.tm* %25, i32 0, i32 1
%27 = load i32, i32* %26
%28 = load %struct.tm*, %struct.tm** %2
%29 = getelementptr inbounds %struct.tm, %struct.tm* %28, i32 0, i32 2
%30 = load i32, i32* %29
%31 = add nsw i32 %30, 1900
%32 = load %struct.tm*, %struct.tm** %2
%33 = getelementptr inbounds %struct.tm, %struct.tm* %32, i32 0, i32 2
store i32 %31, i32* %33
%34 = load %struct.tm*, %struct.tm** %2
%35 = getelementptr inbounds %struct.tm, %struct.tm* %34, i32 0, i32 3
%36 = load i32, i32* %35
%37 = load %struct.tm*, %struct.tm** %2
%38 = getelementptr inbounds %struct.tm, %struct.tm* %37, i32 0, i32 4
%39 = load i32, i32* %38
%40 = load %struct.tm*, %struct.tm** %2
%41 = getelementptr inbounds %struct.tm, %struct.tm* %40, i32 0, i32 5
%42 = load i32, i32* %41
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %22, i32 %27, i32 %31, i32 %36, i32 %39, i32 %42)
%44 = load i32, i32* %4
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %44)
%46 = load i32, i32* @EXIT_SUCCESS
ret i32 %46
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@stderr = global i32 0
@.str = [23 x i8] c"Err.(%s) getting time\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.1 = [15 x i8] c"localtime() - \00"
@.str.2 = [21 x i8] c"%d/%d/%d - %d:%d:%d\0A\00"
@.str.3 = [32 x i8] c"localtime() to mktime() - %ld \0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @time(i32* null)
store i32 %3, i32* %1
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %12
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = load i32, i32* @errno
%8 = tail call i8* @strerror(i32 %7)
%9 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %0
%13 = call %struct.tm* @localtime(i32* %1)
%14 = call i32 @mktime(%struct.tm* %13)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%16 = getelementptr inbounds %struct.tm, %struct.tm* %13, i64 0, i32 0
%17 = load i32, i32* %16
%18 = add nsw i32 %17, 1
store i32 %18, i32* %16
%19 = getelementptr inbounds %struct.tm, %struct.tm* %13, i64 0, i32 1
%20 = load i32, i32* %19
%21 = getelementptr inbounds %struct.tm, %struct.tm* %13, i64 0, i32 2
%22 = load i32, i32* %21
%23 = add nsw i32 %22, 1900
store i32 %23, i32* %21
%24 = getelementptr inbounds %struct.tm, %struct.tm* %13, i64 0, i32 3
%25 = load i32, i32* %24
%26 = getelementptr inbounds %struct.tm, %struct.tm* %13, i64 0, i32 4
%27 = load i32, i32* %26
%28 = getelementptr inbounds %struct.tm, %struct.tm* %13, i64 0, i32 5
%29 = load i32, i32* %28
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %18, i32 %20, i32 %23, i32 %25, i32 %27, i32 %29)
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%32 = load i32, i32* @EXIT_SUCCESS
ret i32 %32
}