#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 /*<<< orphan*/ tm_sec;
};

/* Variables and functions */
int /*<<< orphan*/ gmtime_r(int /*<<< orphan*/ *, struct tm *);
int snprintf(char *, int, char *, int, int, int, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int format_cur_time(char *buf, int buf_len) {
  time_t ttNow;
  struct tm tmNow;
  ttNow = time(NULL);
  gmtime_r(&ttNow, &tmNow);
  return snprintf(buf, buf_len, "%04d%02d%02d-%02d:%02d:%02d\t",
                  tmNow.tm_year + 1900, tmNow.tm_mon + 1, tmNow.tm_mday,
                  tmNow.tm_hour, tmNow.tm_min, tmNow.tm_sec);
}


x86 assembly (clang, -O0):
<format_cur_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,-0x10(%rbp)
lea    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1040 <gmtime_r@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x28(%rbp),%ecx
add    $0x76c,%ecx
mov    -0x24(%rbp),%r8d
add    $0x1,%r8d
mov    -0x20(%rbp),%r9d
mov    -0x1c(%rbp),%r11d
mov    -0x18(%rbp),%r10d
mov    -0x14(%rbp),%eax
lea    0xe7a(%rip),%rdx
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1030 <snprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<format_cur_time>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %esi,%r14d
mov    %rdi,%r15
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1040 <gmtime_r@plt>
mov    $0x76c,%ecx
add    0x10(%rsp),%ecx
mov    0x14(%rsp),%r8d
mov    0x18(%rsp),%r9d
add    $0x1,%r8d
mov    0x1c(%rsp),%eax
mov    0x20(%rsp),%ebp
mov    0x24(%rsp),%ebx
sub    $0x8,%rsp
lea    0xe78(%rip),%rdx
mov    %r15,%rdi
mov    %r14d,%esi
push   %rbx
push   %rbp
push   %rax
call   1030 <snprintf@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [29 x i8] c"%04d%02d%02d-%02d:%02d:%02d\09\00"
define i32 @format_cur_time(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.tm
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = call i32 @time(i32* null)
store i32 %7, i32* %5
%8 = call i32 @gmtime_r(i32* %5, %struct.tm* %6)
%9 = load i8*, i8** %3
%10 = load i32, i32* %4
%11 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 0
%12 = load i32, i32* %11
%13 = add nsw i32 %12, 1900
%14 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 1
%15 = load i32, i32* %14
%16 = add nsw i32 %15, 1
%17 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 2
%18 = load i32, i32* %17
%19 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 3
%20 = load i32, i32* %19
%21 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 4
%22 = load i32, i32* %21
%23 = getelementptr inbounds %struct.tm, %struct.tm* %6, i32 0, i32 5
%24 = load i32, i32* %23
%25 = call i32 @snprintf(i8* %9, i32 %10, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %16, i32 %18, i32 %20, i32 %22, i32 %24)
ret i32 %25
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [29 x i8] c"%04d%02d%02d-%02d:%02d:%02d\09\00"
define i32 @format_cur_time(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca %struct.tm
%5 = bitcast i32* %3 to i8*
%6 = bitcast %struct.tm* %4 to i8*
%7 = tail call i32 @time(i32* null)
store i32 %7, i32* %3
%8 = call i32 @gmtime_r(i32* %3, %struct.tm* %4)
%9 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 0
%10 = load i32, i32* %9
%11 = add nsw i32 %10, 1900
%12 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 1
%13 = load i32, i32* %12
%14 = add nsw i32 %13, 1
%15 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 2
%16 = load i32, i32* %15
%17 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 3
%18 = load i32, i32* %17
%19 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 4
%20 = load i32, i32* %19
%21 = getelementptr inbounds %struct.tm, %struct.tm* %4, i64 0, i32 5
%22 = load i32, i32* %21
%23 = call i32 @snprintf(i8* %0, i32 %1, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %14, i32 %16, i32 %18, i32 %20, i32 %22)
ret i32 %23
}