#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 */
struct tm {
  int tm_hour;
  int tm_min;
};

/* Variables and functions */
int /*<<< orphan*/ localtime_r(long *, struct tm *);
int /*<<< orphan*/ printf(char *, int, ...);
long time(int /*<<< orphan*/);
int main() {
  long int seconds_since_epoch;
  struct tm current_time, *time_ptr;
  int hour, minute, second, day, month, year;
  seconds_since_epoch = time(0);
  printf("time() - seconds since epoch: %ld\n", seconds_since_epoch);
  time_ptr = &current_time;
  localtime_r(&seconds_since_epoch, time_ptr);
  hour = current_time.tm_hour;
  minute = time_ptr->tm_min;
  second = *((int *)time_ptr);
  printf("Current time is: %02d:%02d:%02d\n", hour, minute, second);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
xor    %edi,%edi
call   1050 <time@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %eax,%esi
lea    0xeb0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    -0x8(%rbp),%rdi
call   1030 <localtime_r@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
mov    -0x24(%rbp),%ecx
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
xor    %edi,%edi
call   1050 <time@plt>
mov    %rax,0x10(%rsp)
lea    0xeb9(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1030 <localtime_r@plt>
mov    0x8(%rsp),%ecx
mov    0xc(%rsp),%edx
lea    0xeb5(%rip),%rdi
mov    %ecx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32 }
@.str = [35 x i8] c"time() - seconds since epoch: %ld\0A\00"
@.str.1 = [33 x i8] c"Current time is: %02d:%02d:%02d\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca %struct.tm
%3 = alloca %struct.tm*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = call i64 @time(i32 0)
store i64 %10, i64* %1
%11 = load i64, i64* %1
%12 = trunc i64 %11 to i32
%13 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %12)
store %struct.tm* %2, %struct.tm** %3
%14 = load %struct.tm*, %struct.tm** %3
%15 = call i32 @localtime_r(i64* %1, %struct.tm* %14)
%16 = getelementptr inbounds %struct.tm, %struct.tm* %2, i32 0, i32 0
%17 = load i32, i32* %16
store i32 %17, i32* %4
%18 = load %struct.tm*, %struct.tm** %3
%19 = getelementptr inbounds %struct.tm, %struct.tm* %18, i32 0, i32 1
%20 = load i32, i32* %19
store i32 %20, i32* %5
%21 = load %struct.tm*, %struct.tm** %3
%22 = bitcast %struct.tm* %21 to i32*
%23 = load i32, i32* %22
store i32 %23, i32* %6
%24 = load i32, i32* %4
%25 = load i32, i32* %5
%26 = load i32, i32* %6
%27 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %24, i32 %25, i32 %26)
ret i32 0
}

LLVM IR (-O2):
%struct.tm = type { i32, i32 }
@.str = [35 x i8] c"time() - seconds since epoch: %ld\0A\00"
@.str.1 = [33 x i8] c"Current time is: %02d:%02d:%02d\0A\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca %struct.tm
%3 = bitcast i64* %1 to i8*
%4 = bitcast %struct.tm* %2 to i8*
%5 = tail call i64 @time(i32 0)
store i64 %5, i64* %1
%6 = trunc i64 %5 to i32
%7 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = call i32 @localtime_r(i64* %1, %struct.tm* %2)
%9 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 0
%10 = load i32, i32* %9
%11 = getelementptr inbounds %struct.tm, %struct.tm* %2, i64 0, i32 1
%12 = load i32, i32* %11
%13 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %10, i32 %12, i32 %10)
ret i32 0
}