#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;
};
struct timeval {
  int tv_sec;
  int tv_usec;
};

/* Variables and functions */
char *asctime(struct tm *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
struct tm *localtime(int *);
int /*<<< orphan*/ printf(char *, ...);
int time(int /*<<< orphan*/ *);
int main() {
  time_t ctime;
  struct tm *tm;
  struct timeval gettime;
  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);
  gettimeofday(&gettime, NULL);
  printf("sec is %d,usec is %d\n", gettime.tv_sec, gettime.tv_usec);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <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,-0x20(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe71(%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    0xe45(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1060 <gettimeofday@plt>
mov    -0x18(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <asctime@plt>
mov    %rax,%r14
mov    0xc(%rsp),%esi
lea    0xe7b(%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    0xe64(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe7a(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1060 <gettimeofday@plt>
mov    0x10(%rsp),%esi
mov    0x14(%rsp),%edx
lea    0xe60(%rip),%rdi
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 }
%struct.timeval = type { 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"
@.str.3 = [22 x i8] c"sec is %d,usec is %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.tm*
%4 = alloca %struct.timeval
%5 = alloca i8*
store i32 0, i32* %1
%6 = call i32 @time(i32* null)
store i32 %6, i32* %2
%7 = call %struct.tm* @localtime(i32* %2)
store %struct.tm* %7, %struct.tm** %3
%8 = load %struct.tm*, %struct.tm** %3
%9 = call i8* @asctime(%struct.tm* %8)
store i8* %9, i8** %5
%10 = load i32, i32* %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = load %struct.tm*, %struct.tm** %3
%13 = getelementptr inbounds %struct.tm, %struct.tm* %12, i32 0, i32 0
%14 = load i32, i32* %13
%15 = load %struct.tm*, %struct.tm** %3
%16 = getelementptr inbounds %struct.tm, %struct.tm* %15, i32 0, i32 1
%17 = load i32, i32* %16
%18 = load %struct.tm*, %struct.tm** %3
%19 = getelementptr inbounds %struct.tm, %struct.tm* %18, i32 0, i32 2
%20 = load i32, i32* %19
%21 = load %struct.tm*, %struct.tm** %3
%22 = getelementptr inbounds %struct.tm, %struct.tm* %21, i32 0, i32 3
%23 = load i32, i32* %22
%24 = load %struct.tm*, %struct.tm** %3
%25 = getelementptr inbounds %struct.tm, %struct.tm* %24, i32 0, i32 4
%26 = load i32, i32* %25
%27 = load %struct.tm*, %struct.tm** %3
%28 = getelementptr inbounds %struct.tm, %struct.tm* %27, i32 0, i32 5
%29 = load i32, i32* %28
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32 %14, i32 %17, i32 %20, i32 %23, i32 %26, i32 %29)
%31 = load i8*, i8** %5
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %31)
%33 = call i32 @gettimeofday(%struct.timeval* %4, i32* null)
%34 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 0
%35 = load i32, i32* %34
%36 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i32 0, i32 1
%37 = load i32, i32* %36
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %35, i32 %37)
ret i32 0
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
%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"
@.str.3 = [22 x i8] c"sec is %d,usec is %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.timeval
%3 = bitcast i32* %1 to i8*
%4 = bitcast %struct.timeval* %2 to i8*
%5 = tail call i32 @time(i32* null)
store i32 %5, i32* %1
%6 = call %struct.tm* @localtime(i32* %1)
%7 = call i8* @asctime(%struct.tm* %6)
%8 = load i32, i32* %1
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 0
%11 = load i32, i32* %10
%12 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 1
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 2
%15 = load i32, i32* %14
%16 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 3
%17 = load i32, i32* %16
%18 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 4
%19 = load i32, i32* %18
%20 = getelementptr inbounds %struct.tm, %struct.tm* %6, i64 0, i32 5
%21 = load i32, i32* %20
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %13, i32 %15, i32 %17, i32 %19, i32 %21)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8* %7)
%24 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%25 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%26 = load i32, i32* %25
%27 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 1
%28 = load i32, i32* %27
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %26, i32 %28)
ret i32 0
}