#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 time_t;
struct tm {
  int dummy;
};
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
scalar_t__ EOF;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fputs(char *, int /*<<< orphan*/);
struct tm *gmtime(int *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int time(int /*<<< orphan*/ *);
void timestamp() {
  time_t t = time(NULL);
  {
    if (!(t != -1)) {
      perror("time() error");
      exit(EXIT_FAILURE);
    }
  };
  struct tm *m = gmtime(&t);
  {
    if (!(m)) {
      perror("gmtime() error");
      exit(EXIT_FAILURE);
    }
  };
  char buf[64];
  {
    if (!(strftime(buf, sizeof(buf), "%FT%TZ", m))) {
      perror("strftime() error");
      exit(EXIT_FAILURE);
    }
  };
  {
    if (!(fputs(buf, stdout) != EOF)) {
      perror("puts() error");
      exit(EXIT_FAILURE);
    }
  };
}


x86 assembly (clang, -O0):
<timestamp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
xor    %eax,%eax
mov    %eax,%edi
call   1040 <time@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
jne    1198 <timestamp+0x38>
lea    0xe95(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
lea    -0x4(%rbp),%rdi
call   1070 <gmtime@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11ca <timestamp+0x6a>
lea    0xe49(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e15(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
lea    -0x50(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x40,%esi
lea    0xe31(%rip),%rdx
call   1050 <strftime@plt>
cmp    $0x0,%eax
jne    1206 <timestamp+0xa6>
lea    0xe23(%rip),%rdi
call   1060 <perror@plt>
mov    0x2dd9(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
lea    -0x50(%rbp),%rdi
mov    0x2dbf(%rip),%rax
mov    (%rax),%esi
call   1030 <fputs@plt>
mov    0x2dc9(%rip),%rcx
cmp    (%rcx),%rax
jne    1242 <timestamp+0xe2>
lea    0xdf8(%rip),%rdi
call   1060 <perror@plt>
mov    0x2d9d(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timestamp>:
sub    $0x58,%rsp
xor    %edi,%edi
call   1040 <time@plt>
mov    %eax,0xc(%rsp)
cmp    $0xffffffff,%eax
je     11c4 <timestamp+0x64>
lea    0xc(%rsp),%rdi
call   1070 <gmtime@plt>
test   %rax,%rax
je     11cd <timestamp+0x6d>
lea    0xe85(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x40,%esi
mov    %rax,%rcx
call   1050 <strftime@plt>
test   %eax,%eax
je     11d6 <timestamp+0x76>
mov    0x2e29(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rdi
call   1030 <fputs@plt>
mov    0x2e2e(%rip),%rcx
cmp    (%rcx),%rax
je     11df <timestamp+0x7f>
add    $0x58,%rsp
ret
lea    0xe4f(%rip),%rdi
jmp    11e6 <timestamp+0x86>
lea    0xe2c(%rip),%rdi
jmp    11e6 <timestamp+0x86>
lea    0xe39(%rip),%rdi
jmp    11e6 <timestamp+0x86>
lea    0xe41(%rip),%rdi
call   1060 <perror@plt>
mov    0x2de6(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [13 x i8] c"time() error\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [15 x i8] c"gmtime() error\00"
@.str.2 = [7 x i8] c"%FT%TZ\00"
@.str.3 = [17 x i8] c"strftime() error\00"
@stdout = global i32 0
@EOF = global i64 0
@.str.4 = [13 x i8] c"puts() error\00"
define void @timestamp() {
%1 = alloca i32
%2 = alloca %struct.tm*
%3 = alloca [64 x i8]
%4 = call i32 @time(i32* null)
store i32 %4, i32* %1
%5 = load i32, i32* %1
%6 = icmp ne i32 %5, -1
br i1 %6, label %11, label %7
7: ; preds = %0
%8 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* @EXIT_FAILURE
%10 = call i32 @exit(i32 %9)
unreachable
11: ; preds = %0
%12 = call %struct.tm* @gmtime(i32* %1)
store %struct.tm* %12, %struct.tm** %2
%13 = load %struct.tm*, %struct.tm** %2
%14 = icmp ne %struct.tm* %13, null
br i1 %14, label %19, label %15
15: ; preds = %11
%16 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%17 = load i32, i32* @EXIT_FAILURE
%18 = call i32 @exit(i32 %17)
unreachable
19: ; preds = %11
%20 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%21 = load %struct.tm*, %struct.tm** %2
%22 = call i32 @strftime(i8* %20, i32 64, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), %struct.tm* %21)
%23 = icmp ne i32 %22, 0
br i1 %23, label %28, label %24
24: ; preds = %19
%25 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%26 = load i32, i32* @EXIT_FAILURE
%27 = call i32 @exit(i32 %26)
unreachable
28: ; preds = %19
%29 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%30 = load i32, i32* @stdout
%31 = call i64 @fputs(i8* %29, i32 %30)
%32 = load i64, i64* @EOF
%33 = icmp ne i64 %31, %32
br i1 %33, label %38, label %34
34: ; preds = %28
%35 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%36 = load i32, i32* @EXIT_FAILURE
%37 = call i32 @exit(i32 %36)
unreachable
38: ; preds = %28
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [13 x i8] c"time() error\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [15 x i8] c"gmtime() error\00"
@.str.2 = [7 x i8] c"%FT%TZ\00"
@.str.3 = [17 x i8] c"strftime() error\00"
@stdout = global i32 0
@EOF = global i64 0
@.str.4 = [13 x i8] c"puts() error\00"
define void @timestamp() {
%1 = alloca i32
%2 = alloca [64 x i8]
%3 = bitcast i32* %1 to i8*
%4 = tail call i32 @time(i32* null)
store i32 %4, i32* %1
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %10
6: ; preds = %0
%7 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @EXIT_FAILURE
%9 = tail call i32 @exit(i32 %8)
unreachable
10: ; preds = %0
%11 = call %struct.tm* @gmtime(i32* %1)
%12 = icmp eq %struct.tm* %11, null
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; preds = %10
%18 = getelementptr inbounds [64 x i8], [64 x i8]* %2, i64 0, i64 0
%19 = call i32 @strftime(i8* %18, i32 64, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), %struct.tm* %11)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = call i32 @perror(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%23 = load i32, i32* @EXIT_FAILURE
%24 = call i32 @exit(i32 %23)
unreachable
25: ; preds = %17
%26 = load i32, i32* @stdout
%27 = call i64 @fputs(i8* %18, i32 %26)
%28 = load i64, i64* @EOF
%29 = icmp eq i64 %27, %28
br i1 %29, label %30, label %34
30: ; preds = %25
%31 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%32 = load i32, i32* @EXIT_FAILURE
%33 = call i32 @exit(i32 %32)
unreachable
34: ; preds = %25
ret void
}