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

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int localtime_r(int /*<<< orphan*/ *, struct tm *);
int snprintf(char *, size_t, char *, int, int, int, int, int, int);
int dl_print_local_time(char *buf, int buf_size, time_t timestamp) {
  struct tm t;
  assert(localtime_r(&timestamp, &t));
  assert(buf_size > 0);
  return snprintf(buf, (size_t)buf_size,
                  "[%4d-%02d-%02d %02d:%02d:%02d local] ", t.tm_year + 1900,
                  t.tm_mon + 1, t.tm_mday, t.tm_hour, t.tm_min, t.tm_sec);
}


x86 assembly (clang, -O0):
<dl_print_local_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    -0x10(%rbp),%rdi
lea    -0x28(%rbp),%rsi
call   1030 <localtime_r@plt>
mov    %eax,%edi
call   1050 <assert@plt>
cmpl   $0x0,-0xc(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0x8(%rbp),%rdi
movslq -0xc(%rbp),%rsi
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    0xe6a(%rip),%rdx
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1040 <snprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dl_print_local_time>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %esi,%ebp
mov    %rdi,%r14
mov    %edx,0x4(%rsp)
lea    0x4(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1030 <localtime_r@plt>
mov    %eax,%edi
call   1050 <assert@plt>
xor    %edi,%edi
test   %ebp,%ebp
setg   %dil
call   1050 <assert@plt>
movslq %ebp,%rsi
mov    $0x76c,%ecx
add    0x8(%rsp),%ecx
mov    0xc(%rsp),%r8d
mov    0x10(%rsp),%r9d
add    $0x1,%r8d
mov    0x14(%rsp),%eax
mov    0x18(%rsp),%ebp
mov    0x1c(%rsp),%ebx
sub    $0x8,%rsp
lea    0xe6b(%rip),%rdx
mov    %r14,%rdi
push   %rbx
push   %rbp
push   %rax
call   1040 <snprintf@plt>
add    $0x40,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [38 x i8] c"[%4d-%02d-%02d %02d:%02d:%02d local] \00"
define i32 @dl_print_local_time(i8* %0, i32 %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.tm
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = call i32 @localtime_r(i32* %6, %struct.tm* %7)
%9 = call i32 @assert(i32 %8)
%10 = load i32, i32* %5
%11 = icmp sgt i32 %10, 0
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = load i8*, i8** %4
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds %struct.tm, %struct.tm* %7, i32 0, i32 0
%18 = load i32, i32* %17
%19 = add nsw i32 %18, 1900
%20 = getelementptr inbounds %struct.tm, %struct.tm* %7, i32 0, i32 1
%21 = load i32, i32* %20
%22 = add nsw i32 %21, 1
%23 = getelementptr inbounds %struct.tm, %struct.tm* %7, i32 0, i32 2
%24 = load i32, i32* %23
%25 = getelementptr inbounds %struct.tm, %struct.tm* %7, i32 0, i32 3
%26 = load i32, i32* %25
%27 = getelementptr inbounds %struct.tm, %struct.tm* %7, i32 0, i32 4
%28 = load i32, i32* %27
%29 = getelementptr inbounds %struct.tm, %struct.tm* %7, i32 0, i32 5
%30 = load i32, i32* %29
%31 = call i32 @snprintf(i8* %14, i64 %16, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %19, i32 %22, i32 %24, i32 %26, i32 %28, i32 %30)
ret i32 %31
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32, i32, i32, i32 }
@.str = [38 x i8] c"[%4d-%02d-%02d %02d:%02d:%02d local] \00"
define i32 @dl_print_local_time(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca %struct.tm
store i32 %2, i32* %4
%6 = bitcast %struct.tm* %5 to i8*
%7 = call i32 @localtime_r(i32* %4, %struct.tm* %5)
%8 = call i32 @assert(i32 %7)
%9 = icmp sgt i32 %1, 0
%10 = zext i1 %9 to i32
%11 = call i32 @assert(i32 %10)
%12 = sext i32 %1 to i64
%13 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 0
%14 = load i32, i32* %13
%15 = add nsw i32 %14, 1900
%16 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 1
%17 = load i32, i32* %16
%18 = add nsw i32 %17, 1
%19 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 2
%20 = load i32, i32* %19
%21 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 3
%22 = load i32, i32* %21
%23 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 4
%24 = load i32, i32* %23
%25 = getelementptr inbounds %struct.tm, %struct.tm* %5, i64 0, i32 5
%26 = load i32, i32* %25
%27 = call i32 @snprintf(i8* %0, i64 %12, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0), i32 %15, i32 %18, i32 %20, i32 %22, i32 %24, i32 %26)
ret i32 %27
}