#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;
};
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ puts(char *);
int strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  struct tm *tm_ptr;
  time_t the_time;
  char buf[256];
  int result;
  (void)time(&the_time);
  tm_ptr = localtime(&the_time);
  result = strftime(buf, sizeof(buf), "%A %d %B, %I:%S %p", tm_ptr);
  if (result != 0) {
    printf("strftime gives: %s\n", buf);
    puts("PASS");
    return 0;
  } else {
    puts("FAIL");
    return 1;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x14(%rbp),%rdi
call   1060 <time@plt>
lea    -0x14(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x10(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x100,%esi
lea    0xe71(%rip),%rdx
call   1070 <strftime@plt>
mov    %eax,-0x124(%rbp)
cmpl   $0x0,-0x124(%rbp)
je     11d2 <main+0x82>
lea    -0x120(%rbp),%rsi
lea    0xe5e(%rip),%rdi
call   1050 <printf@plt>
lea    0xe66(%rip),%rdi
call   1040 <puts@plt>
movl   $0x0,-0x4(%rbp)
jmp    11e5 <main+0x95>
lea    0xe53(%rip),%rdi
call   1040 <puts@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x110,%rsp
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1060 <time@plt>
mov    %rbx,%rdi
call   1030 <localtime@plt>
lea    0xe8c(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0x100,%esi
mov    %rax,%rcx
call   1070 <strftime@plt>
test   %eax,%eax
je     11a6 <main+0x56>
lea    0xe82(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1050 <printf@plt>
xor    %ebx,%ebx
lea    0xe83(%rip),%rdi
jmp    11b2 <main+0x62>
mov    $0x1,%ebx
lea    0xe7a(%rip),%rdi
call   1040 <puts@plt>
mov    %ebx,%eax
add    $0x110,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [19 x i8] c"%A %d %B, %I:%S %p\00"
@.str.1 = [20 x i8] c"strftime gives: %s\0A\00"
@.str.2 = [5 x i8] c"PASS\00"
@.str.3 = [5 x i8] c"FAIL\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.tm*
%3 = alloca i32
%4 = alloca [256 x i8]
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 @time(i32* %3)
%7 = call %struct.tm* @localtime(i32* %3)
store %struct.tm* %7, %struct.tm** %2
%8 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%9 = load %struct.tm*, %struct.tm** %2
%10 = call i32 @strftime(i8* %8, i32 256, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %9)
store i32 %10, i32* %5
%11 = load i32, i32* %5
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %0
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %4, i64 0, i64 0
%15 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = call i32 @puts(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %19
17: ; preds = %0
%18 = call i32 @puts(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %1
br label %19
19: ; preds = %17, %13
%20 = load i32, i32* %1
ret i32 %20
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [19 x i8] c"%A %d %B, %I:%S %p\00"
@.str.1 = [20 x i8] c"strftime gives: %s\0A\00"
@.str.2 = [5 x i8] c"PASS\00"
@.str.3 = [5 x i8] c"FAIL\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [256 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%5 = call i32 @time(i32* %1)
%6 = call %struct.tm* @localtime(i32* %1)
%7 = call i32 @strftime(i8* %4, i32 256, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %struct.tm* %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %0
%10 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %4)
br label %11
11: ; preds = %0, %9
%12 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), %9 ], [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %0 ]
%13 = phi i32 [ 0, %9 ], [ 1, %0 ]
%14 = call i32 @puts(i8* dereferenceable(1) %12)
ret i32 %13
}