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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ localtime_r(int /*<<< orphan*/ *, struct tm *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ vfprintf(int /*<<< orphan*/, char const *,
                            int /*<<< orphan*/);
void log_write_stdout(int priority, const char *fmt, va_list ap) {
  time_t now;
  struct tm tm;
  char buf[32];
  now = time(NULL);
  localtime_r(&now, &tm);
  strftime(buf, sizeof(buf), "%Y/%m/%d %H:%M:%S", &tm);
  fprintf(stderr, "%s ", buf);
  vfprintf(stderr, fmt, ap);
}


x86 assembly (clang, -O0):
<log_write_stdout>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1050 <time@plt>
mov    %eax,-0x18(%rbp)
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <localtime_r@plt>
lea    -0x40(%rbp),%rdi
mov    $0x20,%esi
lea    0xe75(%rip),%rdx
lea    -0x20(%rbp),%rcx
call   1060 <strftime@plt>
mov    0x2e45(%rip),%rax
mov    (%rax),%edi
lea    -0x40(%rbp),%rdx
lea    0xe6a(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1070 <vfprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<log_write_stdout>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %edx,%r14d
mov    %rsi,%r15
xor    %edi,%edi
call   1050 <time@plt>
mov    %eax,0x4(%rsp)
lea    0x4(%rsp),%rdi
lea    0x8(%rsp),%rbp
mov    %rbp,%rsi
call   1030 <localtime_r@plt>
lea    0xe7c(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x20,%esi
mov    %rbp,%rcx
call   1060 <strftime@plt>
mov    0x2e40(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xe68(%rip),%rsi
mov    %rbx,%rdx
call   1040 <fprintf@plt>
mov    0x0(%rbp),%edi
mov    %r15,%rsi
mov    %r14d,%edx
call   1070 <vfprintf@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [18 x i8] c"%Y/%m/%d %H:%M:%S\00"
@stderr = global i32 0
@.str.1 = [4 x i8] c"%s \00"
define void @log_write_stdout(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.tm
%9 = alloca [32 x i8]
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%10 = call i32 @time(i32* null)
store i32 %10, i32* %7
%11 = call i32 @localtime_r(i32* %7, %struct.tm* %8)
%12 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%13 = call i32 @strftime(i8* %12, i32 32, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %8)
%14 = load i32, i32* @stderr
%15 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%16 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %5
%19 = load i32, i32* %6
%20 = call i32 @vfprintf(i32 %17, i8* %18, i32 %19)
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [18 x i8] c"%Y/%m/%d %H:%M:%S\00"
@stderr = global i32 0
@.str.1 = [4 x i8] c"%s \00"
define void @log_write_stdout(i32 %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca %struct.tm
%6 = alloca [32 x i8]
%7 = bitcast i32* %4 to i8*
%8 = bitcast %struct.tm* %5 to i8*
%9 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%10 = tail call i32 @time(i32* null)
store i32 %10, i32* %4
%11 = call i32 @localtime_r(i32* %4, %struct.tm* %5)
%12 = call i32 @strftime(i8* %9, i32 32, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %5)
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%15 = load i32, i32* @stderr
%16 = call i32 @vfprintf(i32 %15, i8* %1, i32 %2)
ret void
}