#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 tm_year;
  int tm_mon;
  int tm_mday;
  int tm_hour;
  int tm_min;
  int tm_sec;
};
typedef int /*<<< orphan*/ str;

/* Variables and functions */
int /*<<< orphan*/ localtime_r(int /*<<< orphan*/ *, struct tm *);
int /*<<< orphan*/ snprintf(char *, int, char *, int, int, int, int, int, int);
const char *nx_timestampstr(time_t t) {
  static char str[32];
  struct tm tm;
  *str = 0;
  localtime_r(&t, &tm);
  snprintf(str, sizeof(str) - 1, "%04d-%02d-%02d %02d:%02d:%02d",
           tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min,
           tm.tm_sec);
  str[sizeof(str) - 1] = 0;
  return str;
}


x86 assembly (clang, -O0):
<nx_timestampstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
movb   $0x0,0x2f0e(%rip)
lea    -0x4(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <localtime_r@plt>
mov    -0x20(%rbp),%ecx
add    $0x76c,%ecx
mov    -0x1c(%rbp),%r8d
add    $0x1,%r8d
mov    -0x18(%rbp),%r9d
mov    -0x14(%rbp),%r11d
mov    -0x10(%rbp),%r10d
mov    -0xc(%rbp),%eax
lea    0x2eda(%rip),%rdi
mov    $0x1f,%esi
lea    0xe8e(%rip),%rdx
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1040 <snprintf@plt>
movb   $0x0,0x2ed4(%rip)
lea    0x2eae(%rip),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nx_timestampstr>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %edi,0xc(%rsp)
movb   $0x0,0x2f0e(%rip)
lea    0x2f07(%rip),%r14
lea    0xc(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1030 <localtime_r@plt>
mov    $0x76c,%ecx
add    0x10(%rsp),%ecx
mov    0x14(%rsp),%r8d
mov    0x18(%rsp),%r9d
add    $0x1,%r8d
mov    0x1c(%rsp),%r10d
mov    0x20(%rsp),%ebx
mov    0x24(%rsp),%eax
sub    $0x8,%rsp
lea    0xe89(%rip),%rdx
mov    %r14,%rdi
mov    $0x1f,%esi
push   %rax
push   %rbx
push   %r10
call   1040 <snprintf@plt>
add    $0x20,%rsp
movb   $0x0,0x2ecc(%rip)
mov    %r14,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@nx_timestampstr.str = internal global [32 x i8] zeroinitializer
@.str = [30 x i8] c"%04d-%02d-%02d %02d:%02d:%02d\00"
define i8* @nx_timestampstr(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.tm
store i32 %0, i32* %2
store i8 0, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @nx_timestampstr.str, i64 0, i64 0)
%4 = call i32 @localtime_r(i32* %2, %struct.tm* %3)
%5 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 0
%6 = load i32, i32* %5
%7 = add nsw i32 %6, 1900
%8 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 1
%9 = load i32, i32* %8
%10 = add nsw i32 %9, 1
%11 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 2
%12 = load i32, i32* %11
%13 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 3
%14 = load i32, i32* %13
%15 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 4
%16 = load i32, i32* %15
%17 = getelementptr inbounds %struct.tm, %struct.tm* %3, i32 0, i32 5
%18 = load i32, i32* %17
%19 = call i32 @snprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @nx_timestampstr.str, i64 0, i64 0), i32 31, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %7, i32 %10, i32 %12, i32 %14, i32 %16, i32 %18)
store i8 0, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @nx_timestampstr.str, i64 0, i64 31)
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @nx_timestampstr.str, i64 0, i64 0)
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@nx_timestampstr.str = internal global [32 x i8] zeroinitializer
@.str = [30 x i8] c"%04d-%02d-%02d %02d:%02d:%02d\00"
define i8* @nx_timestampstr(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.tm
store i32 %0, i32* %2
%4 = bitcast %struct.tm* %3 to i8*
store i8 0, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @nx_timestampstr.str, i64 0, i64 0)
%5 = call i32 @localtime_r(i32* %2, %struct.tm* %3)
%6 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 0
%7 = load i32, i32* %6
%8 = add nsw i32 %7, 1900
%9 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 1
%10 = load i32, i32* %9
%11 = add nsw i32 %10, 1
%12 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 2
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 3
%15 = load i32, i32* %14
%16 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 4
%17 = load i32, i32* %16
%18 = getelementptr inbounds %struct.tm, %struct.tm* %3, i64 0, i32 5
%19 = load i32, i32* %18
%20 = call i32 @snprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @nx_timestampstr.str, i64 0, i64 0), i32 31, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %8, i32 %11, i32 %13, i32 %15, i32 %17, i32 %19)
store i8 0, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @nx_timestampstr.str, i64 0, i64 31)
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @nx_timestampstr.str, i64 0, i64 0)
}