#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_FAILURE;
int EXIT_SUCCESS;
char *ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  time_t datetime;
  struct tm *lt;
  char buffer[1000];
  datetime = time(NULL);
  if (!datetime) {
    do {
      perror("time");
      exit(EXIT_FAILURE);
    } while (0);
  }
  lt = localtime(&datetime);
  strftime(buffer, 1000, "%R %A %e %B", lt);
  printf("The time returned by ctime is %s\n", ctime(&datetime));
  printf("The time returned by localtime is %s\n", buffer);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    11be <main+0x4e>
jmp    11a4 <main+0x34>
lea    0xe55(%rip),%rdi
call   1080 <perror@plt>
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
lea    -0x14(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x20(%rbp)
lea    -0x410(%rbp),%rdi
mov    -0x20(%rbp),%rcx
mov    $0x3e8,%esi
lea    0xe23(%rip),%rdx
call   1070 <strftime@plt>
lea    -0x14(%rbp),%rdi
call   1040 <ctime@plt>
mov    %rax,%rsi
lea    0xe17(%rip),%rdi
call   1050 <printf@plt>
lea    -0x410(%rbp),%rsi
lea    0xe26(%rip),%rdi
call   1050 <printf@plt>
mov    0x2dbf(%rip),%rax
mov    (%rax),%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x3f8,%rsp
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,0xc(%rsp)
test   %eax,%eax
je     11ec <main+0x7c>
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <localtime@plt>
lea    0xe68(%rip),%rdx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x3e8,%esi
mov    %rax,%rcx
call   1070 <strftime@plt>
mov    %rbx,%rdi
call   1040 <ctime@plt>
lea    0xe50(%rip),%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
lea    0xe63(%rip),%rdi
mov    %r14,%rsi
call   1050 <printf@plt>
mov    0x2df9(%rip),%rax
mov    (%rax),%eax
add    $0x3f8,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe0d(%rip),%rdi
call   1080 <perror@plt>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [5 x i8] c"time\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [12 x i8] c"%R %A %e %B\00"
@.str.2 = [34 x i8] c"The time returned by ctime is %s\0A\00"
@.str.3 = [38 x i8] c"The time returned by localtime 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*
%8 = alloca [1000 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 @time(i32* null)
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = icmp ne i32 %10, 0
br i1 %11, label %18, label %12
12: ; preds = %2
br label %13
13: ; preds = %12
%14 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* @EXIT_FAILURE
%16 = call i32 @exit(i32 %15)
unreachable
17: ; No predecessors!
br label %18
18: ; preds = %17, %2
%19 = call %struct.tm* @localtime(i32* %6)
store %struct.tm* %19, %struct.tm** %7
%20 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%21 = load %struct.tm*, %struct.tm** %7
%22 = call i32 @strftime(i8* %20, i32 1000, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %21)
%23 = call i8* @ctime(i32* %6)
%24 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %23)
%25 = getelementptr inbounds [1000 x i8], [1000 x i8]* %8, i64 0, i64 0
%26 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i8* %25)
%27 = load i32, i32* @EXIT_SUCCESS
ret i32 %27
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [5 x i8] c"time\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [12 x i8] c"%R %A %e %B\00"
@.str.2 = [34 x i8] c"The time returned by ctime is %s\0A\00"
@.str.3 = [38 x i8] c"The time returned by localtime is %s\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca [1000 x i8]
%5 = bitcast i32* %3 to i8*
%6 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%7 = tail call i32 @time(i32* null)
store i32 %7, i32* %3
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%11 = load i32, i32* @EXIT_FAILURE
%12 = tail call i32 @exit(i32 %11)
unreachable
13: ; preds = %2
%14 = call %struct.tm* @localtime(i32* %3)
%15 = call i32 @strftime(i8* %6, i32 1000, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), %struct.tm* %14)
%16 = call i8* @ctime(i32* %3)
%17 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i8* %16)
%18 = call i32 @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i8* %6)
%19 = load i32, i32* @EXIT_SUCCESS
ret i32 %19
}