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

/* Variables and functions */
int asprintf(char **, char *, char const *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ vfprintf(int /*<<< orphan*/, char const *,
                            int /*<<< orphan*/);
void vlog(const char *fmt, va_list ap) {
  char *nfmt;
  if (asprintf(&nfmt, "%s\n", fmt) == -1) {
    vfprintf(stderr, fmt, ap);
    fprintf(stderr, "\n");
  } else {
    vfprintf(stderr, nfmt, ap);
    free(nfmt);
  }
  fflush(stderr);
}


x86 assembly (clang, -O0):
<vlog>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdx
lea    -0x18(%rbp),%rdi
lea    0xe92(%rip),%rsi
call   1060 <asprintf@plt>
cmp    $0xffffffff,%eax
jne    11ab <vlog+0x5b>
mov    0x2e5d(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1070 <vfprintf@plt>
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
lea    0xe61(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11c9 <vlog+0x79>
mov    0x2e2e(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1070 <vfprintf@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vlog>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xe9c(%rip),%rsi
lea    0x8(%rsp),%rdi
mov    %rbx,%rdx
call   1060 <asprintf@plt>
mov    0x2e68(%rip),%r14
mov    (%r14),%edi
cmp    $0xffffffff,%eax
je     1198 <vlog+0x48>
mov    0x8(%rsp),%rsi
mov    %ebp,%edx
call   1070 <vfprintf@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
jmp    11b1 <vlog+0x61>
mov    %rbx,%rsi
mov    %ebp,%edx
call   1070 <vfprintf@plt>
mov    (%r14),%edi
lea    0xe56(%rip),%rsi
call   1040 <fprintf@plt>
mov    (%r14),%edi
call   1050 <fflush@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@stderr = global i32 0
@.str.1 = [2 x i8] c"\0A\00"
define void @vlog(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i8*, i8** %3
%7 = call i32 @asprintf(i8** %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %16
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %3
%12 = load i32, i32* %4
%13 = call i32 @vfprintf(i32 %10, i8* %11, i32 %12)
%14 = load i32, i32* @stderr
%15 = call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %23
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = load i8*, i8** %5
%19 = load i32, i32* %4
%20 = call i32 @vfprintf(i32 %17, i8* %18, i32 %19)
%21 = load i8*, i8** %5
%22 = call i32 @free(i8* %21)
br label %23
23: ; preds = %16, %9
%24 = load i32, i32* @stderr
%25 = call i32 @fflush(i32 %24)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
@stderr = global i32 0
@.str.1 = [2 x i8] c"\0A\00"
define void @vlog(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = call i32 @asprintf(i8** %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = icmp eq i32 %5, -1
%7 = load i32, i32* @stderr
br i1 %6, label %8, label %12
8: ; preds = %2
%9 = call i32 @vfprintf(i32 %7, i8* %0, i32 %1)
%10 = load i32, i32* @stderr
%11 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %17
12: ; preds = %2
%13 = load i8*, i8** %3
%14 = call i32 @vfprintf(i32 %7, i8* %13, i32 %1)
%15 = load i8*, i8** %3
%16 = call i32 @free(i8* %15)
br label %17
17: ; preds = %12, %8
%18 = load i32, i32* @stderr
%19 = call i32 @fflush(i32 %18)
ret void
}