#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_year;
  int tm_hour;
};

/* Variables and functions */
char *ctime(int /*<<< orphan*/ *);
struct tm *gmtime(int /*<<< orphan*/ *);
struct tm *localtime(int /*<<< orphan*/ *);
int mktime(struct tm *);
int /*<<< orphan*/ printf(char *, ...);
int time(int /*<<< orphan*/ *);
void time3_test() {
  int ct = time(NULL);
  struct tm *time_utc = gmtime((time_t *)&ct);
  struct tm *time_local = localtime((time_t *)&ct);
  int ct2 = mktime(time_utc);
  printf("current time %s\n", ctime((time_t *)&ct));
  printf("year %d %d h %d %d \n", time_utc->tm_year, time_local->tm_year,
         time_utc->tm_hour, time_local->tm_hour);
  printf("mktime %d %d\n", ct2, ct);
}


x86 assembly (clang, -O0):
<time3_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0x4(%rbp)
lea    -0x4(%rbp),%rdi
call   1080 <gmtime@plt>
mov    %rax,-0x10(%rbp)
lea    -0x4(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1070 <mktime@plt>
mov    %eax,-0x1c(%rbp)
lea    -0x4(%rbp),%rdi
call   1040 <ctime@plt>
mov    %rax,%rsi
lea    0xe53(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%r8d
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x1c(%rbp),%esi
mov    -0x4(%rbp),%edx
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<time3_test>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%r15
mov    %r15,%rdi
call   1080 <gmtime@plt>
mov    %rax,%rbp
mov    %r15,%rdi
call   1030 <localtime@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1070 <mktime@plt>
mov    %eax,%r14d
mov    %r15,%rdi
call   1040 <ctime@plt>
lea    0xe59(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x0(%rbp),%esi
mov    0x4(%rbp),%ecx
mov    (%rbx),%edx
mov    0x4(%rbx),%r8d
lea    0xe4d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%edx
lea    0xe50(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32 }
@.str = [17 x i8] c"current time %s\0A\00"
@.str.1 = [21 x i8] c"year %d %d h %d %d \0A\00"
@.str.2 = [14 x i8] c"mktime %d %d\0A\00"
define void @time3_test() {
%1 = alloca i32
%2 = alloca %struct.tm*
%3 = alloca %struct.tm*
%4 = alloca i32
%5 = call i32 @time(i32* null)
store i32 %5, i32* %1
%6 = call %struct.tm* @gmtime(i32* %1)
store %struct.tm* %6, %struct.tm** %2
%7 = call %struct.tm* @localtime(i32* %1)
store %struct.tm* %7, %struct.tm** %3
%8 = load %struct.tm*, %struct.tm** %2
%9 = call i32 @mktime(%struct.tm* %8)
store i32 %9, i32* %4
%10 = call i8* @ctime(i32* %1)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load %struct.tm*, %struct.tm** %2
%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 0
%17 = load i32, i32* %16
%18 = load %struct.tm*, %struct.tm** %2
%19 = getelementptr inbounds %struct.tm, %struct.tm* %18, i32 0, i32 1
%20 = load i32, i32* %19
%21 = load %struct.tm*, %struct.tm** %3
%22 = getelementptr inbounds %struct.tm, %struct.tm* %21, i32 0, i32 1
%23 = load i32, i32* %22
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %14, i32 %17, i32 %20, i32 %23)
%25 = load i32, i32* %4
%26 = load i32, i32* %1
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %25, i32 %26)
ret void
}

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