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

/* Variables and functions */
int /*<<< orphan*/ LC_ALL;
char *asctime(struct tm *);
char *ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ *setlocale(int /*<<< orphan*/, char *);
scalar_t__ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  time_t t;
  struct tm *loc;
  char buf[200];
  if (setlocale(LC_ALL, "") == NULL) {
    printf("LC_ALL cannot be set\n");
    exit(1);
  }
  t = time(NULL);
  printf("ctime() of time() value is: %s", ctime(&t));
  loc = localtime(&t);
  if (loc == NULL) {
    printf("Error: localtime\n");
    exit(1);
  }
  printf("asctime() of local time is: %s", asctime(loc));
  if (strftime(buf, 200, "%A, %d %B %Y, %H:%M:%S %Z", loc) == 0) {
    printf("strftime returned 0\n");
    exit(1);
  }
  printf("strftime() of local time is: %s\n", buf);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
lea    0xeeb(%rip),%rsi
call   1080 <setlocale@plt>
cmp    $0x0,%rax
jne    11d0 <main+0x50>
lea    0xe41(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,-0x14(%rbp)
lea    -0x14(%rbp),%rdi
call   1040 <ctime@plt>
mov    %rax,%rsi
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0x14(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1226 <main+0xa6>
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    -0x20(%rbp),%rdi
call   1050 <asctime@plt>
mov    %rax,%rsi
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    -0xf0(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0xc8,%esi
lea    0xe0f(%rip),%rdx
call   1090 <strftime@plt>
cmp    $0x0,%rax
jne    127e <main+0xfe>
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
lea    -0xf0(%rbp),%rsi
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0xe0,%rsp
mov    0x2e41(%rip),%rax
mov    (%rax),%edi
lea    0xed0(%rip),%rsi
call   1090 <setlocale@plt>
test   %rax,%rax
jne    11be <main+0x2e>
lea    0xee5(%rip),%rdi
jmp    123e <main+0xae>
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <ctime@plt>
lea    0xe23(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1030 <localtime@plt>
test   %rax,%rax
jne    11fd <main+0x6d>
lea    0xe92(%rip),%rdi
jmp    123e <main+0xae>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <asctime@plt>
lea    0xe10(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xe1e(%rip),%rdx
lea    0x10(%rsp),%rdi
mov    $0xc8,%esi
mov    %rbx,%rcx
call   10a0 <strftime@plt>
test   %rax,%rax
jne    124d <main+0xbd>
lea    0xe3b(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
lea    0xe04(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1070 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
%struct.tm = type { i32 }
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [22 x i8] c"LC_ALL cannot be set\0A\00"
@.str.2 = [31 x i8] c"ctime() of time() value is: %s\00"
@.str.3 = [18 x i8] c"Error: localtime\0A\00"
@.str.4 = [31 x i8] c"asctime() of local time is: %s\00"
@.str.5 = [26 x i8] c"%A, %d %B %Y, %H:%M:%S %Z\00"
@.str.6 = [21 x i8] c"strftime returned 0\0A\00"
@.str.7 = [33 x i8] c"strftime() of local time is: %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.tm*
%8 = alloca [200 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* @LC_ALL
%10 = call i32* @setlocale(i32 %9, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %15
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %2
%16 = call i32 @time(i32* null)
store i32 %16, i32* %6
%17 = call i8* @ctime(i32* %6)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %17)
%19 = call %struct.tm* @localtime(i32* %6)
store %struct.tm* %19, %struct.tm** %7
%20 = load %struct.tm*, %struct.tm** %7
%21 = icmp eq %struct.tm* %20, null
br i1 %21, label %22, label %25
22: ; preds = %15
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %15
%26 = load %struct.tm*, %struct.tm** %7
%27 = call i8* @asctime(%struct.tm* %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %27)
%29 = getelementptr inbounds [200 x i8], [200 x i8]* %8, i64 0, i64 0
%30 = load %struct.tm*, %struct.tm** %7
%31 = call i64 @strftime(i8* %29, i32 200, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), %struct.tm* %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %25
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.6, i64 0, i64 0))
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %25
%37 = getelementptr inbounds [200 x i8], [200 x i8]* %8, i64 0, i64 0
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i8* %37)
%39 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.2 = [31 x i8] c"ctime() of time() value is: %s\00"
@.str.4 = [31 x i8] c"asctime() of local time is: %s\00"
@.str.5 = [26 x i8] c"%A, %d %B %Y, %H:%M:%S %Z\00"
@.str.7 = [33 x i8] c"strftime() of local time is: %s\0A\00"
@str = [20 x i8] c"strftime returned 0\00"
@str.8 = [17 x i8] c"Error: localtime\00"
@str.9 = [21 x i8] c"LC_ALL cannot be set\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca [200 x i8]
%5 = bitcast i32* %3 to i8*
%6 = getelementptr inbounds [200 x i8], [200 x i8]* %4, i64 0, i64 0
%7 = load i32, i32* @LC_ALL
%8 = tail call i32* @setlocale(i32 %7, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.9, i64 0, i64 0))
%12 = tail call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = tail call i32 @time(i32* null)
store i32 %14, i32* %3
%15 = call i8* @ctime(i32* %3)
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* %15)
%17 = call %struct.tm* @localtime(i32* %3)
%18 = icmp eq %struct.tm* %17, null
br i1 %18, label %19, label %22
19: ; preds = %13
%20 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.8, i64 0, i64 0))
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %13
%23 = call i8* @asctime(%struct.tm* %17)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i8* %23)
%25 = call i64 @strftime(i8* %6, i32 200, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), %struct.tm* %17)
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %22
%28 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %22
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i8* %6)
%32 = call i32 @exit(i32 0)
unreachable
}