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

/* Variables and functions */
char *GetMonthName(int);
int /*<<< orphan*/ InvJulianDay(double const, int *, int *, int *, int *, int *,
                                double *, int *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char, char, char, int, int, int, int,
                           int);
double time(int /*<<< orphan*/ *);
char *FriendlyTimestring(int t) {
  static char output[256];
  time_t timenow;
  if (!t)
    timenow = time(NULL);
  else
    timenow = (time_t)t;
  const double JD = timenow / 86400.0 + 2440587.5;
  int year, month, day, hour, min, status;
  double sec;
  InvJulianDay(JD, &year, &month, &day, &hour, &min, &sec, &status, output);
  char *mn = GetMonthName(month);
  sprintf(output, "%c%c%c %02d %04d %02d:%02d:%02d", mn[0], mn[1], mn[2], day,
          year, hour, min, (int)sec);
  return output;
}


x86 assembly (clang, -O0):
<FriendlyTimestring>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x68,%rsp
mov    %edi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1169 <FriendlyTimestring+0x29>
xor    %eax,%eax
mov    %eax,%edi
call   1030 <time@plt>
movsd  %xmm0,-0x18(%rbp)
jmp    1173 <FriendlyTimestring+0x33>
cvtsi2sdl -0xc(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe88(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe74(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
lea    -0x24(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
lea    -0x30(%rbp),%rcx
lea    -0x34(%rbp),%r8
lea    -0x40(%rbp),%r9
lea    -0x38(%rbp),%r10
lea    0x2e93(%rip),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1040 <InvJulianDay@plt>
mov    -0x28(%rbp),%edi
call   1060 <GetMonthName@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rax
mov    (%rax),%dl
mov    -0x48(%rbp),%rax
mov    0x1(%rax),%cl
mov    -0x48(%rbp),%rax
mov    0x2(%rax),%r8b
mov    -0x2c(%rbp),%r9d
mov    -0x24(%rbp),%ebx
mov    -0x30(%rbp),%r11d
mov    -0x34(%rbp),%r10d
cvttsd2si -0x40(%rbp),%eax
lea    0x2e49(%rip),%rdi
lea    0xe02(%rip),%rsi
movsbl %dl,%edx
movsbl %cl,%ecx
movsbl %r8b,%r8d
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
call   1050 <sprintf@plt>
lea    0x2e1b(%rip),%rax
add    $0x68,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<FriendlyTimestring>:
push   %r14
push   %rbx
sub    $0x28,%rsp
test   %edi,%edi
je     1151 <FriendlyTimestring+0x11>
cvtsi2sd %edi,%xmm0
jmp    1158 <FriendlyTimestring+0x18>
xor    %edi,%edi
call   1030 <time@plt>
divsd  0xea0(%rip),%xmm0
addsd  0xea0(%rip),%xmm0
lea    0x2ee1(%rip),%r14
lea    0x24(%rsp),%rax
lea    0x14(%rsp),%rdi
lea    0x10(%rsp),%rsi
lea    0xc(%rsp),%rdx
lea    0x8(%rsp),%rcx
lea    0x4(%rsp),%r8
lea    0x18(%rsp),%r9
push   %r14
push   %rax
call   1040 <InvJulianDay@plt>
add    $0x10,%rsp
mov    0x10(%rsp),%edi
call   1060 <GetMonthName@plt>
movsbl (%rax),%edx
movsbl 0x1(%rax),%ecx
movsbl 0x2(%rax),%r8d
mov    0xc(%rsp),%r9d
mov    0x14(%rsp),%r10d
mov    0x8(%rsp),%r11d
mov    0x4(%rsp),%eax
cvttsd2si 0x18(%rsp),%ebx
lea    0xe3d(%rip),%rsi
mov    %r14,%rdi
push   %rbx
push   %rax
push   %r11
push   %r10
call   1050 <sprintf@plt>
add    $0x20,%rsp
mov    %r14,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@FriendlyTimestring.output = internal global [256 x i8] zeroinitializer
@.str = [32 x i8] c"%c%c%c %02d %04d %02d:%02d:%02d\00"
define i8* @FriendlyTimestring(i32 %0) {
%2 = alloca i32
%3 = alloca double
%4 = alloca double
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca double
%12 = alloca i8*
store i32 %0, i32* %2
%13 = load i32, i32* %2
%14 = icmp ne i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %1
%16 = call double @time(i32* null)
store double %16, double* %3
br label %20
17: ; preds = %1
%18 = load i32, i32* %2
%19 = sitofp i32 %18 to double
store double %19, double* %3
br label %20
20: ; preds = %17, %15
%21 = load double, double* %3
%22 = fdiv double %21, 8.640000e+04
%23 = fadd double %22, 0x41429EC5C0000000
store double %23, double* %4
%24 = load double, double* %4
%25 = call i32 @InvJulianDay(double %24, i32* %5, i32* %6, i32* %7, i32* %8, i32* %9, double* %11, i32* %10, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @FriendlyTimestring.output, i64 0, i64 0))
%26 = load i32, i32* %6
%27 = call i8* @GetMonthName(i32 %26)
store i8* %27, i8** %12
%28 = load i8*, i8** %12
%29 = getelementptr inbounds i8, i8* %28, i64 0
%30 = load i8, i8* %29
%31 = load i8*, i8** %12
%32 = getelementptr inbounds i8, i8* %31, i64 1
%33 = load i8, i8* %32
%34 = load i8*, i8** %12
%35 = getelementptr inbounds i8, i8* %34, i64 2
%36 = load i8, i8* %35
%37 = load i32, i32* %7
%38 = load i32, i32* %5
%39 = load i32, i32* %8
%40 = load i32, i32* %9
%41 = load double, double* %11
%42 = fptosi double %41 to i32
%43 = call i32 @sprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @FriendlyTimestring.output, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8 signext %30, i8 signext %33, i8 signext %36, i32 %37, i32 %38, i32 %39, i32 %40, i32 %42)
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @FriendlyTimestring.output, i64 0, i64 0)
}

LLVM IR (-O2):
@FriendlyTimestring.output = internal global [256 x i8] zeroinitializer
@.str = [32 x i8] c"%c%c%c %02d %04d %02d:%02d:%02d\00"
define i8* @FriendlyTimestring(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca double
%9 = icmp eq i32 %0, 0
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = tail call double @time(i32* null)
br label %14
12: ; preds = %1
%13 = sitofp i32 %0 to double
br label %14
14: ; preds = %12, %10
%15 = phi double [ %13, %12 ], [ %11, %10 ]
%16 = fdiv double %15, 8.640000e+04
%17 = fadd double %16, 0x41429EC5C0000000
%18 = bitcast i32* %2 to i8*
%19 = bitcast i32* %3 to i8*
%20 = bitcast i32* %4 to i8*
%21 = bitcast i32* %5 to i8*
%22 = bitcast i32* %6 to i8*
%23 = bitcast i32* %7 to i8*
%24 = bitcast double* %8 to i8*
%25 = call i32 @InvJulianDay(double %17, i32* %2, i32* %3, i32* %4, i32* %5, i32* %6, double* %8, i32* %7, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @FriendlyTimestring.output, i64 0, i64 0))
%26 = load i32, i32* %3
%27 = call i8* @GetMonthName(i32 %26)
%28 = load i8, i8* %27
%29 = getelementptr inbounds i8, i8* %27, i64 1
%30 = load i8, i8* %29
%31 = getelementptr inbounds i8, i8* %27, i64 2
%32 = load i8, i8* %31
%33 = load i32, i32* %4
%34 = load i32, i32* %2
%35 = load i32, i32* %5
%36 = load i32, i32* %6
%37 = load double, double* %8
%38 = fptosi double %37 to i32
%39 = call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([256 x i8], [256 x i8]* @FriendlyTimestring.output, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8 signext %28, i8 signext %30, i8 signext %32, i32 %33, i32 %34, i32 %35, i32 %36, i32 %38)
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @FriendlyTimestring.output, i64 0, i64 0)
}