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

/* Variables and functions */
char *asctime(struct tm *);
struct tm *localtime(int *);
int /*<<< orphan*/ printf(char *, ...);
int time(int /*<<< orphan*/ *);
int main() {
  time_t ctime;
  struct tm *tm;
  ctime = time(NULL);
  tm = localtime(&ctime);
  char *asct = asctime(tm);
  printf("ctime is %d\n", ctime);
  printf("localtime is %d,%d,%d %d : %d : %d\n", tm->tm_year, tm->tm_mon,
         tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
  printf("Now is %s\n", asct);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0x8(%rbp)
lea    -0x8(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <asctime@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%ecx
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    0xe55(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,0x14(%rsp)
lea    0x14(%rsp),%rdi
call   1030 <localtime@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <asctime@plt>
mov    %rax,%r14
mov    0x14(%rsp),%esi
lea    0xe8b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%esi
mov    0x4(%rbx),%edx
mov    0x8(%rbx),%ecx
mov    0xc(%rbx),%r8d
mov    0x10(%rbx),%r9d
mov    0x14(%rbx),%eax
mov    %eax,(%rsp)
lea    0xe74(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe8a(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [13 x i8] c"ctime is %d\0A\00"
@.str.1 = [36 x i8] c"localtime is %d,%d,%d %d : %d : %d\0A\00"
@.str.2 = [11 x i8] c"Now is %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.tm*
%4 = alloca i8*
store i32 0, i32* %1
%5 = call i32 @time(i32* null)
store i32 %5, i32* %2
%6 = call %struct.tm* @localtime(i32* %2)
store %struct.tm* %6, %struct.tm** %3
%7 = load %struct.tm*, %struct.tm** %3
%8 = call i8* @asctime(%struct.tm* %7)
store i8* %8, i8** %4
%9 = load i32, i32* %2
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = load %struct.tm*, %struct.tm** %3
%12 = getelementptr inbounds %struct.tm, %struct.tm* %11, i32 0, i32 0
%13 = load i32, i32* %12
%14 = load %struct.tm*, %struct.tm** %3
%15 = getelementptr inbounds %struct.tm, %struct.tm* %14, i32 0, i32 1
%16 = load i32, i32* %15
%17 = load %struct.tm*, %struct.tm** %3
%18 = getelementptr inbounds %struct.tm, %struct.tm* %17, i32 0, i32 2
%19 = load i32, i32* %18
%20 = load %struct.tm*, %struct.tm** %3
%21 = getelementptr inbounds %struct.tm, %struct.tm* %20, i32 0, i32 3
%22 = load i32, i32* %21
%23 = load %struct.tm*, %struct.tm** %3
%24 = getelementptr inbounds %struct.tm, %struct.tm* %23, i32 0, i32 4
%25 = load i32, i32* %24
%26 = load %struct.tm*, %struct.tm** %3
%27 = getelementptr inbounds %struct.tm, %struct.tm* %26, i32 0, i32 5
%28 = load i32, i32* %27
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32 %13, i32 %16, i32 %19, i32 %22, i32 %25, i32 %28)
%30 = load i8*, i8** %4
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %30)
ret i32 0
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [13 x i8] c"ctime is %d\0A\00"
@.str.1 = [36 x i8] c"localtime is %d,%d,%d %d : %d : %d\0A\00"
@.str.2 = [11 x i8] c"Now is %s\0A\00"
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 = call %struct.tm* @localtime(i32* %1)
%5 = call i8* @asctime(%struct.tm* %4)
%6 = load i32, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 0
%9 = load i32, i32* %8
%10 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 1
%11 = load i32, i32* %10
%12 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 2
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 3
%15 = load i32, i32* %14
%16 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 4
%17 = load i32, i32* %16
%18 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 5
%19 = load i32, i32* %18
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32 %9, i32 %11, i32 %13, i32 %15, i32 %17, i32 %19)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %5)
ret i32 0
}