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

/* Variables and functions */
int /*<<< orphan*/ localtime(int /*<<< orphan*/ *);
int strftime(char *, int, char *, int /*<<< orphan*/);
char *fmt_time(time_t when) {
  static char buffer[256];
  int len;
  len = strftime(buffer, sizeof buffer, "%c", localtime(&when));
  if (len == 0)
    buffer[0] = '\0';
  else
    buffer[(sizeof buffer) - 1] = '\0';
  return buffer;
}


x86 assembly (clang, -O0):
<fmt_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x4(%rbp),%rdi
call   1030 <localtime@plt>
mov    %eax,%ecx
lea    0x2f03(%rip),%rdi
mov    $0x100,%esi
lea    0xeb7(%rip),%rdx
call   1040 <strftime@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1167 <fmt_time+0x47>
movb   $0x0,0x2ede(%rip)
jmp    116e <fmt_time+0x4e>
movb   $0x0,0x2fd1(%rip)
lea    0x2ecb(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fmt_time>:
push   %rax
mov    %edi,0x4(%rsp)
lea    0x4(%rsp),%rdi
call   1030 <localtime@plt>
lea    0x2f0a(%rip),%rdi
lea    0xec3(%rip),%rdx
mov    $0x100,%esi
mov    %eax,%ecx
call   1040 <strftime@plt>
test   %eax,%eax
je     1156 <fmt_time+0x36>
movb   $0x0,0x2feb(%rip)
jmp    115d <fmt_time+0x3d>
movb   $0x0,0x2ee3(%rip)
lea    0x2edc(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@fmt_time.buffer = internal global [256 x i8] zeroinitializer
@.str = [3 x i8] c"%c\00"
define i8* @fmt_time(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = call i32 @localtime(i32* %2)
%5 = call i32 @strftime(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @fmt_time.buffer, i64 0, i64 0), i32 256, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %4)
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %1
store i8 0, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @fmt_time.buffer, i64 0, i64 0)
br label %10
9: ; preds = %1
store i8 0, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @fmt_time.buffer, i64 0, i64 255)
br label %10
10: ; preds = %9, %8
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @fmt_time.buffer, i64 0, i64 0)
}

LLVM IR (-O2):
@fmt_time.buffer = internal global [256 x i8] zeroinitializer
@.str = [3 x i8] c"%c\00"
define i8* @fmt_time(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = call i32 @localtime(i32* %2)
%4 = call i32 @strftime(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @fmt_time.buffer, i64 0, i64 0), i32 256, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %7
6: ; preds = %1
store i8 0, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @fmt_time.buffer, i64 0, i64 0)
br label %8
7: ; preds = %1
store i8 0, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @fmt_time.buffer, i64 0, i64 255)
br label %8
8: ; preds = %7, %6
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @fmt_time.buffer, i64 0, i64 0)
}