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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  char buff[256];
  time_t now = time(NULL);
  struct tm tm = *localtime(&now);
  tm.tm_year = 2039 - 1900;
  if (strftime(buff, sizeof buff, "%s", &tm) == 0) {
    fprintf(stderr, "strftime() returned 0\n");
    exit(EXIT_FAILURE);
  }
  printf("seconds since epoch: %s\n", buff);
  if (buff[0] == '-') {
    fprintf(stderr, "FAIL\n");
    exit(EXIT_FAILURE);
  }
  if (strftime(buff, sizeof buff, "%c", &tm) == 0) {
    fprintf(stderr, "strftime() returned 0\n");
    exit(EXIT_FAILURE);
  }
  printf("date string        : %s\n", buff);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0x114(%rbp)
lea    -0x114(%rbp),%rdi
call   1030 <localtime@plt>
mov    (%rax),%eax
mov    %eax,-0x118(%rbp)
movl   $0x8b,-0x118(%rbp)
lea    -0x110(%rbp),%rdi
mov    $0x100,%esi
lea    0xe4e(%rip),%rdx
lea    -0x118(%rbp),%rcx
call   1070 <strftime@plt>
cmp    $0x0,%rax
jne    11eb <main+0x8b>
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
lea    0xe2b(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2df4(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
lea    -0x110(%rbp),%rsi
lea    0xe21(%rip),%rdi
call   1040 <printf@plt>
movsbl -0x110(%rbp),%eax
cmp    $0x2d,%eax
jne    1231 <main+0xd1>
mov    0x2dcb(%rip),%rax
mov    (%rax),%edi
lea    0xe15(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2dae(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
lea    -0x110(%rbp),%rdi
mov    $0x100,%esi
lea    0xdf5(%rip),%rdx
lea    -0x118(%rbp),%rcx
call   1070 <strftime@plt>
cmp    $0x0,%rax
jne    127d <main+0x11d>
mov    0x2d7f(%rip),%rax
mov    (%rax),%edi
lea    0xd99(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
lea    -0x110(%rbp),%rsi
lea    0xdb1(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x120,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x118,%rsp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
movl   $0x8b,0x8(%rsp)
lea    0xe75(%rip),%rdx
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rcx
mov    $0x100,%esi
call   1070 <strftime@plt>
test   %rax,%rax
je     11f7 <main+0x97>
lea    0xe6f(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1040 <printf@plt>
cmpb   $0x2d,0x10(%rsp)
je     1209 <main+0xa9>
lea    0xe76(%rip),%rdx
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rcx
mov    $0x100,%esi
call   1070 <strftime@plt>
test   %rax,%rax
je     11f7 <main+0x97>
lea    0xe59(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x118,%rsp
ret
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
lea    0xdfc(%rip),%rsi
jmp    1219 <main+0xb9>
mov    0x2dd0(%rip),%rax
mov    (%rax),%edi
lea    0xe1a(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2db3(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [3 x i8] c"%s\00"
@stderr = global i32 0
@.str.1 = [23 x i8] c"strftime() returned 0\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [25 x i8] c"seconds since epoch: %s\0A\00"
@.str.3 = [6 x i8] c"FAIL\0A\00"
@.str.4 = [3 x i8] c"%c\00"
@.str.5 = [25 x i8] c"date string : %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [256 x i8]
%3 = alloca i32
%4 = alloca %struct.tm
store i32 0, i32* %1
%5 = call i32 @time(i32* null)
store i32 %5, i32* %3
%6 = call %struct.tm* @localtime(i32* %3)
%7 = bitcast %struct.tm* %4 to i8*
%8 = bitcast %struct.tm* %6 to i8*
%9 = getelementptr inbounds %struct.tm, %struct.tm* %4, i32 0, i32 0
store i32 139, i32* %9
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%11 = call i64 @strftime(i8* %10, i32 256, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %struct.tm* %4)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %0
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %0
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%20 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i8* %19)
%21 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 45
br i1 %24, label %25, label %30
25: ; preds = %18
%26 = load i32, i32* @stderr
%27 = call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%28 = load i32, i32* @EXIT_FAILURE
%29 = call i32 @exit(i32 %28)
unreachable
30: ; preds = %18
%31 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%32 = call i64 @strftime(i8* %31, i32 256, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), %struct.tm* %4)
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %39
34: ; preds = %30
%35 = load i32, i32* @stderr
%36 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%37 = load i32, i32* @EXIT_FAILURE
%38 = call i32 @exit(i32 %37)
unreachable
39: ; preds = %30
%40 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%41 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %40)
ret i32 0
}

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