#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 */
scalar_t__ EOF;
int /*<<< orphan*/ asctime(struct tm *);
int /*<<< orphan*/ cctools_debug(long long, char *, int /*<<< orphan*/);
int /*<<< orphan*/ errno;
scalar_t__ fputs(int /*<<< orphan*/, int /*<<< orphan*/);
struct tm *localtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
void print_time() {
  time_t curtime;
  struct tm *loctime;
  curtime = time(NULL);
  loctime = localtime(&curtime);
  if (fputs(asctime(loctime), stdout) == EOF) {
    cctools_debug((1LL << 3), "fputs fails: %s\n", strerror(errno));
  }
}


x86 assembly (clang, -O0):
<print_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,-0x4(%rbp)
lea    -0x4(%rbp),%rdi
call   1030 <localtime@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <asctime@plt>
mov    %eax,%edi
mov    0x2e3d(%rip),%rax
mov    (%rax),%esi
call   1050 <fputs@plt>
mov    0x2e47(%rip),%rcx
cmp    (%rcx),%rax
jne    11cb <print_time+0x6b>
mov    0x2e27(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
mov    %eax,%edx
mov    $0x8,%edi
lea    0xe3a(%rip),%rsi
call   1060 <cctools_debug@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_time>:
push   %rax
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <localtime@plt>
mov    %rax,%rdi
call   1040 <asctime@plt>
mov    0x2e4b(%rip),%rcx
mov    (%rcx),%esi
mov    %eax,%edi
call   1050 <fputs@plt>
mov    0x2e53(%rip),%rcx
cmp    (%rcx),%rax
jne    11bb <print_time+0x5b>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
call   1080 <strerror@plt>
lea    0xe51(%rip),%rsi
mov    $0x8,%edi
mov    %eax,%edx
call   1060 <cctools_debug@plt>
pop    %rax
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@stdout = global i32 0
@EOF = global i64 0
@.str = [17 x i8] c"fputs fails: %s\0A\00"
@errno = global i32 0
define void @print_time() {
%1 = alloca i32
%2 = alloca %struct.tm*
%3 = call i32 @time(i32* null)
store i32 %3, i32* %1
%4 = call %struct.tm* @localtime(i32* %1)
store %struct.tm* %4, %struct.tm** %2
%5 = load %struct.tm*, %struct.tm** %2
%6 = call i32 @asctime(%struct.tm* %5)
%7 = load i32, i32* @stdout
%8 = call i64 @fputs(i32 %6, i32 %7)
%9 = load i64, i64* @EOF
%10 = icmp eq i64 %8, %9
br i1 %10, label %11, label %15
11: ; preds = %0
%12 = load i32, i32* @errno
%13 = call i32 @strerror(i32 %12)
%14 = call i32 @cctools_debug(i64 8, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %13)
br label %15
15: ; preds = %11, %0
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@stdout = global i32 0
@EOF = global i64 0
@.str = [17 x i8] c"fputs fails: %s\0A\00"
@errno = global i32 0
define void @print_time() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @time(i32* null)
store i32 %3, i32* %1
%4 = call %struct.tm* @localtime(i32* %1)
%5 = call i32 @asctime(%struct.tm* %4)
%6 = load i32, i32* @stdout
%7 = call i64 @fputs(i32 %5, i32 %6)
%8 = load i64, i64* @EOF
%9 = icmp eq i64 %7, %8
br i1 %9, label %10, label %14
10: ; preds = %0
%11 = load i32, i32* @errno
%12 = call i32 @strerror(i32 %11)
%13 = call i32 @cctools_debug(i64 8, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i32 %12)
br label %14
14: ; preds = %10, %0
ret void
}