#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*/ EXIT_SUCCESS;
int /*<<< orphan*/ LC_ALL;
char *asctime(struct tm *);
char *ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ err_exit(char *, int /*<<< orphan*/);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
struct tm *localtime(int /*<<< orphan*/ *);
char *my_strftime(int /*<<< orphan*/ *, struct tm *);
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ *setlocale(int /*<<< orphan*/, char *);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  time_t real_time;
  struct tm *tmp;
  if (setlocale(LC_ALL, "") == NULL) {
    err_exit("Error on setlocale %s\n", strerror(errno));
  }
  real_time = time(NULL);
  if ((tmp = localtime(&real_time)) == NULL) {
    err_exit("Error on localtime, %s\n", strerror(errno));
  }
  printf("ctime() is %s\nasctime() is %s\n", ctime(&real_time), asctime(tmp));
  printf("strftime() is %s\n", my_strftime(NULL, tmp));
  exit(EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
lea    0xe68(%rip),%rsi
call   10a0 <setlocale@plt>
cmp    $0x0,%rax
jne    11f1 <main+0x51>
mov    0x2e04(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    %eax,%esi
lea    0xe14(%rip),%rdi
call   1090 <err_exit@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,-0x14(%rbp)
lea    -0x14(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1230 <main+0x90>
mov    0x2dc5(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
mov    %eax,%esi
lea    0xdec(%rip),%rdi
call   1090 <err_exit@plt>
lea    -0x14(%rbp),%rdi
call   1040 <ctime@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <asctime@plt>
mov    -0x28(%rbp),%rsi
mov    %rax,%rdx
lea    0xddb(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0x20(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edi
call   1050 <my_strftime@plt>
mov    %rax,%rsi
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    0x2d58(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
lea    0xe7a(%rip),%rsi
call   10a0 <setlocale@plt>
test   %rax,%rax
jne    11da <main+0x3a>
mov    0x2e1b(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xe2d(%rip),%rdi
mov    %eax,%esi
call   1090 <err_exit@plt>
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <localtime@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1213 <main+0x73>
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
call   10c0 <strerror@plt>
lea    0xe0b(%rip),%rdi
mov    %eax,%esi
call   1090 <err_exit@plt>
lea    0x4(%rsp),%rdi
call   1040 <ctime@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1060 <asctime@plt>
lea    0xe00(%rip),%rdi
mov    %r14,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1070 <printf@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   1050 <my_strftime@plt>
lea    0xe01(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2d7a(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
%struct.tm = type { i32 }
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [23 x i8] c"Error on setlocale %s\0A\00"
@errno = global i32 0
@.str.2 = [24 x i8] c"Error on localtime, %s\0A\00"
@.str.3 = [31 x i8] c"ctime() is %s\0Aasctime() is %s\0A\00"
@.str.4 = [18 x i8] c"strftime() is %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca %struct.tm*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* @LC_ALL
%9 = call i32* @setlocale(i32 %8, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i32, i32* @errno
%13 = call i32 @strerror(i32 %12)
%14 = call i32 @err_exit(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %11, %2
%16 = call i32 @time(i32* null)
store i32 %16, i32* %6
%17 = call %struct.tm* @localtime(i32* %6)
store %struct.tm* %17, %struct.tm** %7
%18 = icmp eq %struct.tm* %17, null
br i1 %18, label %19, label %23
19: ; preds = %15
%20 = load i32, i32* @errno
%21 = call i32 @strerror(i32 %20)
%22 = call i32 @err_exit(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %21)
br label %23
23: ; preds = %19, %15
%24 = call i8* @ctime(i32* %6)
%25 = load %struct.tm*, %struct.tm** %7
%26 = call i8* @asctime(%struct.tm* %25)
%27 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %24, i8* %26)
%28 = load %struct.tm*, %struct.tm** %7
%29 = call i8* @my_strftime(i32* null, %struct.tm* %28)
%30 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* %29)
%31 = load i32, i32* @EXIT_SUCCESS
%32 = call i32 @exit(i32 %31)
unreachable
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@LC_ALL = global i32 0
@.str = [1 x i8] zeroinitializer
@.str.1 = [23 x i8] c"Error on setlocale %s\0A\00"
@errno = global i32 0
@.str.2 = [24 x i8] c"Error on localtime, %s\0A\00"
@.str.3 = [31 x i8] c"ctime() is %s\0Aasctime() is %s\0A\00"
@.str.4 = [18 x i8] c"strftime() is %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = load i32, i32* @LC_ALL
%6 = tail call i32* @setlocale(i32 %5, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i32, i32* @errno
%10 = tail call i32 @strerror(i32 %9)
%11 = tail call i32 @err_exit(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i32 %10)
br label %12
12: ; preds = %8, %2
%13 = tail call i32 @time(i32* null)
store i32 %13, i32* %3
%14 = call %struct.tm* @localtime(i32* %3)
%15 = icmp eq %struct.tm* %14, null
br i1 %15, label %16, label %20
16: ; preds = %12
%17 = load i32, i32* @errno
%18 = call i32 @strerror(i32 %17)
%19 = call i32 @err_exit(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %16, %12
%21 = call i8* @ctime(i32* %3)
%22 = call i8* @asctime(%struct.tm* %14)
%23 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0), i8* %21, i8* %22)
%24 = call i8* @my_strftime(i32* null, %struct.tm* %14)
%25 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i8* %24)
%26 = load i32, i32* @EXIT_SUCCESS
%27 = call i32 @exit(i32 %26)
unreachable
}