#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_hour;
  int tm_min;
  scalar_t__ tm_sec;
};

/* Variables and functions */
char *ctime(int /*<<< orphan*/ *);
int difftime(int /*<<< orphan*/, int /*<<< orphan*/);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ mktime(struct tm *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ set_file_perm();
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  time_t now = time(NULL);
  struct tm newyear;
  newyear = *localtime(&now);
  newyear.tm_hour = 14;
  newyear.tm_min = 45;
  newyear.tm_sec = 0;
  char *c_time_string = ctime(&now);
  printf("Time now: %s", c_time_string);
  int time_diff = difftime(mktime(&newyear), now);
  printf("Time diff: %d\n", time_diff);
  set_file_perm();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,-0x14(%rbp)
lea    -0x14(%rbp),%rdi
call   1030 <localtime@plt>
mov    (%rax),%rcx
mov    %rcx,-0x28(%rbp)
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
movl   $0xe,-0x28(%rbp)
movl   $0x2d,-0x24(%rbp)
movq   $0x0,-0x20(%rbp)
lea    -0x14(%rbp),%rdi
call   1040 <ctime@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x28(%rbp),%rdi
call   1090 <mktime@plt>
mov    %eax,%edi
mov    -0x14(%rbp),%esi
call   1070 <difftime@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%esi
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1050 <set_file_perm@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <localtime@plt>
movabs $0x2d0000000e,%rax
mov    %rax,0x10(%rsp)
movq   $0x0,0x18(%rsp)
mov    %rbx,%rdi
call   1040 <ctime@plt>
lea    0xe4c(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0x10(%rsp),%rdi
call   1090 <mktime@plt>
mov    0xc(%rsp),%esi
mov    %eax,%edi
call   1070 <difftime@plt>
lea    0xe33(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1050 <set_file_perm@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i64 }
@.str = [13 x i8] c"Time now: %s\00"
@.str.1 = [15 x i8] c"Time diff: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca %struct.tm
%7 = alloca i8*
%8 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%9 = call i32 @time(i32* null)
store i32 %9, i32* %5
%10 = call %struct.tm* @localtime(i32* %5)
%11 = bitcast %struct.tm* %6 to i8*
%12 = bitcast %struct.tm* %10 to i8*
%13 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 0
store i32 14, i32* %13
%14 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 1
store i32 45, i32* %14
%15 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 2
store i64 0, i64* %15
%16 = call i8* @ctime(i32* %5)
store i8* %16, i8** %7
%17 = load i8*, i8** %7
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %17)
%19 = call i32 @mktime(%struct.tm* %6)
%20 = load i32, i32* %5
%21 = call i32 @difftime(i32 %19, i32 %20)
store i32 %21, i32* %8
%22 = load i32, i32* %8
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = call i32 (...) @set_file_perm()
ret i32 0
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i64 }
@.str = [13 x i8] c"Time now: %s\00"
@.str.1 = [15 x i8] c"Time diff: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca %struct.tm
%5 = bitcast i32* %3 to i8*
%6 = tail call i32 @time(i32* null)
store i32 %6, i32* %3
%7 = bitcast %struct.tm* %4 to i8*
%8 = call %struct.tm* @localtime(i32* %3)
%9 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 0
store i32 14, i32* %9
%10 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 1
store i32 45, i32* %10
%11 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 2
store i64 0, i64* %11
%12 = call i8* @ctime(i32* %3)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = call i32 @mktime(%struct.tm* %4)
%15 = load i32, i32* %3
%16 = call i32 @difftime(i32 %14, i32 %15)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = call i32 (...) @set_file_perm()
ret i32 0
}