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

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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
call   1060 <time@plt>
cmp    $0x0,%rax
jge    11bc <main+0x5c>
mov    0x2e57(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    0x2e43(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x14(%rbp),%edi
mov    %rax,%rdx
lea    0xe57(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
lea    -0x8(%rbp),%rdi
call   1030 <ctime@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    120d <main+0xad>
mov    0x2e06(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    -0x18(%rbp),%edi
mov    %rax,%rdx
lea    0xe1f(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2dca(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rsi
lea    0xe23(%rip),%rdi
call   1040 <printf@plt>
mov    0x2da4(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rdi
call   1060 <time@plt>
test   %rax,%rax
js     11a1 <main+0x41>
lea    0xc(%rsp),%rdi
call   1030 <ctime@plt>
test   %rax,%rax
je     11c1 <main+0x61>
lea    0xeb1(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    0x2e2f(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
ret
mov    0x2e38(%rip),%rax
mov    (%rax),%ebx
mov    0x2e27(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xe41(%rip),%rsi
jmp    11df <main+0x7f>
mov    0x2e18(%rip),%rax
mov    (%rax),%ebx
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xe3a(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1050 <fprintf@plt>
mov    0x2de0(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [25 x i8] c"Err.(%s) getting time()\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
@.str.1 = [34 x i8] c"Err.(%s) str conversion: ctime()\0A\00"
@.str.2 = [3 x i8] c"%s\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i64 @time(i32* %1)
%4 = icmp slt i64 %3, 0
br i1 %4, label %5, label %12
5: ; preds = %0
%6 = load i32, i32* @stderr
%7 = load i32, i32* @errno
%8 = call i8* @strerror(i32 %7)
%9 = call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i8* %8)
%10 = load i32, i32* @EXIT_FAILURE
%11 = call i32 @exit(i32 %10)
unreachable
12: ; preds = %0
%13 = call i8* @ctime(i32* %1)
%14 = icmp eq i8* %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 ([34 x i8], [34 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 i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%24 = load i32, i32* @EXIT_SUCCESS
ret i32 %24
}