#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 scalar_t__ time_t;
struct tm {
  int dummy;
};
typedef int /*<<< orphan*/ s;

/* Variables and functions */
int /*<<< orphan*/ localtime_r(scalar_t__ const *, struct tm *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
char *timetostr(const time_t rawtime) {
  static char s[20];
  struct tm tminfo;
  if (rawtime != 0) {
    localtime_r(&rawtime, &tminfo);
    strftime(s, sizeof(s), "%Y.%m.%d %H:%M:%S", &tminfo);
  } else
    s[0] = '\0';
  return s;
}


x86 assembly (clang, -O0):
<timetostr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1165 <timetostr+0x45>
lea    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <localtime_r@plt>
lea    0x2ef5(%rip),%rdi
mov    $0x14,%esi
lea    0xea9(%rip),%rdx
lea    -0x10(%rbp),%rcx
call   1040 <strftime@plt>
jmp    116c <timetostr+0x4c>
movb   $0x0,0x2ed4(%rip)
lea    0x2ecd(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timetostr>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,0x8(%rsp)
test   %rdi,%rdi
je     115c <timetostr+0x3c>
lea    0x8(%rsp),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1030 <localtime_r@plt>
lea    0x2efa(%rip),%rdi
lea    0xeb3(%rip),%rdx
mov    $0x14,%esi
mov    %rbx,%rcx
call   1040 <strftime@plt>
jmp    1163 <timetostr+0x43>
movb   $0x0,0x2edd(%rip)
lea    0x2ed6(%rip),%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@timetostr.s = internal global [20 x i8] zeroinitializer
@.str = [18 x i8] c"%Y.%m.%d %H:%M:%S\00"
define i8* @timetostr(i64 %0) {
%2 = alloca i64
%3 = alloca %struct.tm
store i64 %0, i64* %2
%4 = load i64, i64* %2
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %1
%7 = call i32 @localtime_r(i64* %2, %struct.tm* %3)
%8 = call i32 @strftime(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @timetostr.s, i64 0, i64 0), i32 20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %3)
br label %10
9: ; preds = %1
store i8 0, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @timetostr.s, i64 0, i64 0)
br label %10
10: ; preds = %9, %6
ret i8* getelementptr inbounds ([20 x i8], [20 x i8]* @timetostr.s, i64 0, i64 0)
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@timetostr.s = internal global [20 x i8] zeroinitializer
@.str = [18 x i8] c"%Y.%m.%d %H:%M:%S\00"
define i8* @timetostr(i64 %0) {
%2 = alloca i64
%3 = alloca %struct.tm
store i64 %0, i64* %2
%4 = bitcast %struct.tm* %3 to i8*
%5 = icmp eq i64 %0, 0
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = call i32 @localtime_r(i64* %2, %struct.tm* %3)
%8 = call i32 @strftime(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @timetostr.s, i64 0, i64 0), i32 20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %3)
br label %10
9: ; preds = %1
store i8 0, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @timetostr.s, i64 0, i64 0)
br label %10
10: ; preds = %9, %6
ret i8* getelementptr inbounds ([20 x i8], [20 x i8]* @timetostr.s, i64 0, i64 0)
}