#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 long time_t;
struct timezone {
  int tz_minuteswest;
  int tz_dsttime;
};
struct timeval {
  long tv_sec;
  int tv_usec;
};

/* Variables and functions */
char *ctime(long *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ gettimeofday(struct timeval *, struct timezone *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  struct timeval tv;
  struct timezone tz;
  time_t now;
  time_t beginning_of_time = 1L << (sizeof(time_t) * 8 - 1);
  time_t end_of_time = ~beginning_of_time;
  printf("time_t is %d bits long\n\n", sizeof(time_t) * 8);
  gettimeofday(&tv, &tz);
  now = tv.tv_sec;
  printf("Current time of day represented as a struct timeval:\n"
         "tv.tv_sec = 0x%08x, tv.tv_usec = 0x%08x\n"
         "tz.tz_minuteswest = 0x%08x, tz.tz_dsttime = 0x%08x\n\n",
         tv.tv_sec, tv.tv_usec, tz.tz_minuteswest, tz.tz_dsttime);
  printf("Demonstrating ctime()%s:\n",
         sizeof(time_t) * 8 <= 32
             ? ""
             : " (may hang after printing first line; press control-C)");
  printf("time is now %s", ctime(&now));
  printf("time begins %s", ctime(&beginning_of_time));
  printf("time ends %s", ctime(&end_of_time));
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movabs $0x8000000000000000,%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
xor    $0xffffffffffffffff,%rax
mov    %rax,-0x38(%rbp)
lea    0xe90(%rip),%rdi
mov    $0x40,%esi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <gettimeofday@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%edx
mov    -0x20(%rbp),%ecx
mov    -0x1c(%rbp),%r8d
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xef7(%rip),%rdi
lea    0xf0a(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x28(%rbp),%rdi
call   1030 <ctime@plt>
mov    %rax,%rsi
lea    0xf27(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x30(%rbp),%rdi
call   1030 <ctime@plt>
mov    %rax,%rsi
lea    0xf1c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x38(%rbp),%rdi
call   1030 <ctime@plt>
mov    %rax,%rsi
lea    0xf11(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<main>:
sub    $0x38,%rsp
movabs $0x7fffffffffffffff,%rax
ff ff 7f
lea    0x1(%rax),%rcx
mov    %rcx,0x18(%rsp)
mov    %rax,0x10(%rsp)
lea    0xe9d(%rip),%rdi
mov    $0x40,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x28(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1050 <gettimeofday@plt>
mov    0x28(%rsp),%rsi
mov    %rsi,0x20(%rsp)
mov    0x30(%rsp),%edx
mov    0x8(%rsp),%ecx
mov    0xc(%rsp),%r8d
lea    0xe7d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf01(%rip),%rdi
lea    0xf14(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x20(%rsp),%rdi
call   1030 <ctime@plt>
lea    0xf33(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x18(%rsp),%rdi
call   1030 <ctime@plt>
lea    0xf27(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x10(%rsp),%rdi
call   1030 <ctime@plt>
lea    0xf1b(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
%struct.timeval = type { i64, i32 }
%struct.timezone = type { i32, i32 }
@.str = [25 x i8] c"time_t is %d bits long\0A\0A\00"
@.str.1 = [146 x i8] c"Current time of day represented as a struct timeval:\0Atv.tv_sec = 0x%08x, tv.tv_usec = 0x%08x\0Atz.tz_minuteswest = 0x%08x, tz.tz_dsttime = 0x%08x\0A\0A\00"
@.str.2 = [26 x i8] c"Demonstrating ctime()%s:\0A\00"
@.str.3 = [55 x i8] c" (may hang after printing first line; press control-C)\00"
@.str.4 = [15 x i8] c"time is now %s\00"
@.str.5 = [15 x i8] c"time begins %s\00"
@.str.6 = [13 x i8] c"time ends %s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.timeval
%3 = alloca %struct.timezone
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i32 0, i32* %1
store i64 -9223372036854775808, i64* %5
%7 = load i64, i64* %5
%8 = xor i64 %7, -1
store i64 %8, i64* %6
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i64 64)
%10 = call i32 @gettimeofday(%struct.timeval* %2, %struct.timezone* %3)
%11 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 0
%12 = load i64, i64* %11
store i64 %12, i64* %4
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 0
%14 = load i64, i64* %13
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 1
%16 = load i32, i32* %15
%17 = getelementptr inbounds %struct.timezone, %struct.timezone* %3, i32 0, i32 0
%18 = load i32, i32* %17
%19 = getelementptr inbounds %struct.timezone, %struct.timezone* %3, i32 0, i32 1
%20 = load i32, i32* %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str.1, i64 0, i64 0), i64 %14, i32 %16, i32 %18, i32 %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.3, i64 0, i64 0))
%23 = call i8* @ctime(i64* %4)
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* %23)
%25 = call i8* @ctime(i64* %5)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* %25)
%27 = call i8* @ctime(i64* %6)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i8* %27)
%29 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.timeval = type { i64, i32 }
%struct.timezone = type { i32, i32 }
@.str = [25 x i8] c"time_t is %d bits long\0A\0A\00"
@.str.1 = [146 x i8] c"Current time of day represented as a struct timeval:\0Atv.tv_sec = 0x%08x, tv.tv_usec = 0x%08x\0Atz.tz_minuteswest = 0x%08x, tz.tz_dsttime = 0x%08x\0A\0A\00"
@.str.2 = [26 x i8] c"Demonstrating ctime()%s:\0A\00"
@.str.3 = [55 x i8] c" (may hang after printing first line; press control-C)\00"
@.str.4 = [15 x i8] c"time is now %s\00"
@.str.5 = [15 x i8] c"time begins %s\00"
@.str.6 = [13 x i8] c"time ends %s\00"
define i32 @main() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timezone
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = bitcast %struct.timeval* %1 to i8*
%7 = bitcast %struct.timezone* %2 to i8*
%8 = bitcast i64* %3 to i8*
%9 = bitcast i64* %4 to i8*
store i64 -9223372036854775808, i64* %4
%10 = bitcast i64* %5 to i8*
store i64 9223372036854775807, i64* %5
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i64 64)
%12 = call i32 @gettimeofday(%struct.timeval* %1, %struct.timezone* %2)
%13 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%14 = load i64, i64* %13
store i64 %14, i64* %3
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 1
%16 = load i32, i32* %15
%17 = getelementptr inbounds %struct.timezone, %struct.timezone* %2, i64 0, i32 0
%18 = load i32, i32* %17
%19 = getelementptr inbounds %struct.timezone, %struct.timezone* %2, i64 0, i32 1
%20 = load i32, i32* %19
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([146 x i8], [146 x i8]* @.str.1, i64 0, i64 0), i64 %14, i32 %16, i32 %18, i32 %20)
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.3, i64 0, i64 0))
%23 = call i8* @ctime(i64* %3)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i8* %23)
%25 = call i8* @ctime(i64* %4)
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* %25)
%27 = call i8* @ctime(i64* %5)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.6, i64 0, i64 0), i8* %27)
%29 = call i32 @exit(i32 0)
unreachable
}