#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*/ output;

/* Variables and functions */
int errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
struct tm *localtime(int *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stderr;
scalar_t__ strftime(char *, int, char *, struct tm *);
int time(int /*<<< orphan*/ *);
int main(void) {
  char output[200];
  struct tm *temp = NULL;
  time_t t;
  if ((t = time(NULL)) == -1) {
    perror("Time");
    return errno;
  }
  if ((temp = localtime(&t)) == NULL) {
    perror("Localtime");
    return errno;
  }
  if (strftime(output, sizeof(output), "%a %d %B %Y %V %n", temp) == 0) {
    fprintf(stderr, "Strftime returned 0\n");
    return -1;
  }
  printf("Time string is: %s", output);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xe0,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0xd8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0xdc(%rbp)
cmp    $0xffffffff,%eax
jne    11b2 <main+0x52>
lea    0xe64(%rip),%rdi
call   1080 <perror@plt>
mov    0x2e30(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1250 <main+0xf0>
lea    -0xdc(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0xd8(%rbp)
cmp    $0x0,%rax
jne    11ec <main+0x8c>
lea    0xe2f(%rip),%rdi
call   1080 <perror@plt>
mov    0x2df6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    1250 <main+0xf0>
lea    -0xd0(%rbp),%rdi
mov    -0xd8(%rbp),%rcx
mov    $0xc8,%esi
lea    0xe09(%rip),%rdx
call   1070 <strftime@plt>
cmp    $0x0,%rax
jne    1236 <main+0xd6>
mov    0x2dc4(%rip),%rax
mov    (%rax),%edi
lea    0xdfc(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1250 <main+0xf0>
lea    -0xd0(%rbp),%rsi
lea    0xdf2(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xe0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0xd8,%rsp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,0xc(%rsp)
cmp    $0xffffffff,%eax
je     11e1 <main+0x81>
lea    0xc(%rsp),%rdi
call   1030 <localtime@plt>
test   %rax,%rax
je     11ea <main+0x8a>
lea    0xe82(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0xc8,%esi
mov    %rax,%rcx
call   1070 <strftime@plt>
test   %rax,%rax
je     11bf <main+0x5f>
lea    0xe8b(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xd8,%rsp
ret
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
lea    0xe52(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0xd8,%rsp
ret
lea    0xe18(%rip),%rdi
jmp    11f1 <main+0x91>
lea    0xe14(%rip),%rdi
call   1080 <perror@plt>
mov    0x2ddb(%rip),%rax
mov    (%rax),%eax
add    $0xd8,%rsp
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [5 x i8] c"Time\00"
@errno = global i32 0
@.str.1 = [10 x i8] c"Localtime\00"
@.str.2 = [18 x i8] c"%a %d %B %Y %V %n\00"
@stderr = global i32 0
@.str.3 = [21 x i8] c"Strftime returned 0\0A\00"
@.str.4 = [19 x i8] c"Time string is: %s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [200 x i8]
%3 = alloca %struct.tm*
%4 = alloca i32
store i32 0, i32* %1
store %struct.tm* null, %struct.tm** %3
%5 = call i32 @time(i32* null)
store i32 %5, i32* %4
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* @errno
store i32 %9, i32* %1
br label %27
10: ; preds = %0
%11 = call %struct.tm* @localtime(i32* %4)
store %struct.tm* %11, %struct.tm** %3
%12 = icmp eq %struct.tm* %11, null
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%15 = load i32, i32* @errno
store i32 %15, i32* %1
br label %27
16: ; preds = %10
%17 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%18 = load %struct.tm*, %struct.tm** %3
%19 = call i64 @strftime(i8* %17, i32 200, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), %struct.tm* %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %16
%22 = load i32, i32* @stderr
%23 = call i32 @fprintf(i32 %22, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %1
br label %27
24: ; preds = %16
%25 = getelementptr inbounds [200 x i8], [200 x i8]* %2, i64 0, i64 0
%26 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %25)
store i32 0, i32* %1
br label %27
27: ; preds = %24, %21, %13, %7
%28 = load i32, i32* %1
ret i32 %28
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [5 x i8] c"Time\00"
@errno = global i32 0
@.str.1 = [10 x i8] c"Localtime\00"
@.str.2 = [18 x i8] c"%a %d %B %Y %V %n\00"
@stderr = global i32 0
@.str.3 = [21 x i8] c"Strftime returned 0\0A\00"
@.str.4 = [19 x i8] c"Time string is: %s\00"
define i32 @main() {
%1 = alloca [200 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [200 x i8], [200 x i8]* %1, i64 0, i64 0
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @time(i32* null)
store i32 %5, i32* %2
%6 = icmp eq i32 %5, -1
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* @errno
br label %24
10: ; preds = %0
%11 = call %struct.tm* @localtime(i32* %2)
%12 = icmp eq %struct.tm* %11, null
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = call i32 @perror(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%15 = load i32, i32* @errno
br label %24
16: ; preds = %10
%17 = call i64 @strftime(i8* %3, i32 200, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), %struct.tm* %11)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %24
22: ; preds = %16
%23 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %3)
br label %24
24: ; preds = %22, %19, %13, %7
%25 = phi i32 [ %9, %7 ], [ %15, %13 ], [ -1, %19 ], [ 0, %22 ]
ret i32 %25
}