#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 dummy;
};

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
char *asctime(struct tm *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
struct tm *gmtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  struct tm *ptm;
  time_t t;
  char *str_time;
  if ((t = time(NULL)) < 0) {
    fprintf(stderr, "Err.(%s) getting time\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
  if ((ptm = gmtime(&t)) == NULL) {
    fprintf(stderr, "Err.(%s) conversion gmtime()\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
  if ((str_time = asctime(ptm)) == NULL) {
    fprintf(stderr, "Err.(%s) str conversion: asctime()\n", strerror(errno));
    exit(EXIT_FAILURE);
  }
  printf("%s", str_time);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    11ce <main+0x5e>
mov    0x2e45(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    0x2e31(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x24(%rbp),%edi
mov    %rax,%rdx
lea    0xe45(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e09(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
lea    -0x14(%rbp),%rdi
call   1070 <gmtime@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    121f <main+0xaf>
mov    0x2df4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x28(%rbp),%edi
mov    %rax,%rdx
lea    0xe0b(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2db8(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rdi
call   1030 <asctime@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1270 <main+0x100>
mov    0x2da3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    0x2d8f(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
mov    -0x2c(%rbp),%edi
mov    %rax,%rdx
lea    0xdd8(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2d67(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    -0x20(%rbp),%rsi
lea    0xdde(%rip),%rdi
call   1040 <printf@plt>
mov    0x2d41(%rip),%rax
mov    (%rax),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,0xc(%rsp)
test   %eax,%eax
js     11be <main+0x4e>
lea    0xc(%rsp),%rdi
call   1070 <gmtime@plt>
test   %rax,%rax
je     11de <main+0x6e>
mov    %rax,%rdi
call   1030 <asctime@plt>
test   %rax,%rax
je     11fe <main+0x8e>
lea    0xeb2(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    0x2e12(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
ret
mov    0x2e1b(%rip),%rax
mov    (%rax),%ebx
mov    0x2e0a(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xe24(%rip),%rsi
jmp    121c <main+0xac>
mov    0x2dfb(%rip),%rax
mov    (%rax),%ebx
mov    0x2dea(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xe1b(%rip),%rsi
jmp    121c <main+0xac>
mov    0x2ddb(%rip),%rax
mov    (%rax),%ebx
mov    0x2dca(%rip),%rax
mov    (%rax),%edi
call   1090 <strerror@plt>
lea    0xe19(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1050 <fprintf@plt>
mov    0x2da3(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.tm = type { i32 }
@stderr = global i32 0
@.str = [23 x i8] c"Err.(%s) getting time\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.1 = [30 x i8] c"Err.(%s) conversion gmtime()\0A\00"
@.str.2 = [36 x i8] c"Err.(%s) str conversion: asctime()\0A\00"
@.str.3 = [3 x i8] c"%s\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.tm*
%3 = alloca i32
%4 = alloca i8*
store i32 0, i32* %1
%5 = call i32 @time(i32* null)
store i32 %5, i32* %3
%6 = icmp slt i32 %5, 0
br i1 %6, label %7, label %14
7: ; preds = %0
%8 = load i32, i32* @stderr
%9 = load i32, i32* @errno
%10 = call i8* @strerror(i32 %9)
%11 = call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %10)
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %0
%15 = call %struct.tm* @gmtime(i32* %3)
store %struct.tm* %15, %struct.tm** %2
%16 = icmp eq %struct.tm* %15, null
br i1 %16, label %17, label %24
17: ; preds = %14
%18 = load i32, i32* @stderr
%19 = load i32, i32* @errno
%20 = call i8* @strerror(i32 %19)
%21 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = load i32, i32* @EXIT_FAILURE
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %14
%25 = load %struct.tm*, %struct.tm** %2
%26 = call i8* @asctime(%struct.tm* %25)
store i8* %26, i8** %4
%27 = icmp eq i8* %26, null
br i1 %27, label %28, label %35
28: ; preds = %24
%29 = load i32, i32* @stderr
%30 = load i32, i32* @errno
%31 = call i8* @strerror(i32 %30)
%32 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i8* %31)
%33 = load i32, i32* @EXIT_FAILURE
%34 = call i32 @exit(i32 %33)
unreachable
35: ; preds = %24
%36 = load i8*, i8** %4
%37 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %36)
%38 = load i32, i32* @EXIT_SUCCESS
ret i32 %38
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@stderr = global i32 0
@.str = [23 x i8] c"Err.(%s) getting time\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.1 = [30 x i8] c"Err.(%s) conversion gmtime()\0A\00"
@.str.2 = [36 x i8] c"Err.(%s) str conversion: asctime()\0A\00"
@.str.3 = [3 x i8] c"%s\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @time(i32* null)
store i32 %3, i32* %1
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %12
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = load i32, i32* @errno
%8 = tail call i8* @strerror(i32 %7)
%9 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %0
%13 = call %struct.tm* @gmtime(i32* %1)
%14 = icmp eq %struct.tm* %13, null
br i1 %14, label %15, label %22
15: ; preds = %12
%16 = load i32, i32* @stderr
%17 = load i32, i32* @errno
%18 = call i8* @strerror(i32 %17)
%19 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = load i32, i32* @EXIT_FAILURE
%21 = call i32 @exit(i32 %20)
unreachable
22: ; preds = %12
%23 = call i8* @asctime(%struct.tm* %13)
%24 = icmp eq i8* %23, null
br i1 %24, label %25, label %32
25: ; preds = %22
%26 = load i32, i32* @stderr
%27 = load i32, i32* @errno
%28 = call i8* @strerror(i32 %27)
%29 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i8* %28)
%30 = load i32, i32* @EXIT_FAILURE
%31 = call i32 @exit(i32 %30)
unreachable
32: ; preds = %22
%33 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %23)
%34 = load i32, i32* @EXIT_SUCCESS
ret i32 %34
}