#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char const *);
int /*<<< orphan*/ *stderr;
int /*<<< orphan*/ *stdout;
int /*<<< orphan*/ vfprintf(int /*<<< orphan*/ *, char const *,
                            int /*<<< orphan*/);
void __valog(int level, const char *prefix, const char *fmt, va_list va) {
  FILE *f = level <= 1 ? stderr : stdout;
  if (prefix)
    fprintf(f, "%s", prefix);
  vfprintf(f, fmt, va);
}


x86 assembly (clang, -O0):
<__valog>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
cmpl   $0x1,-0x4(%rbp)
jg     1153 <__valog+0x33>
mov    0x2e99(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
jmp    1161 <__valog+0x41>
mov    0x2e7e(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1188 <__valog+0x68>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe7d(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1040 <vfprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__valog>:
push   %rbp
push   %r14
push   %rbx
mov    %ecx,%r14d
mov    %rdx,%rbx
cmp    $0x2,%edi
jge    1138 <__valog+0x18>
mov    0x2eaa(%rip),%rax
jmp    113f <__valog+0x1f>
mov    0x2e99(%rip),%rax
mov    (%rax),%rbp
test   %rsi,%rsi
je     1152 <__valog+0x32>
mov    %rsi,%rdi
mov    %rbp,%rsi
call   1030 <fputs@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <vfprintf@plt>

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

LLVM IR (-O2):
@stderr = global i32* null
@stdout = global i32* null
define void @__valog(i32 %0, i8* %1, i8* nocapture %2, i32 %3) {
%5 = icmp slt i32 %0, 2
%6 = load i32*, i32** @stderr
%7 = load i32*, i32** @stdout
%8 = select i1 %5, i32* %6, i32* %7
%9 = icmp eq i8* %1, null
br i1 %9, label %12, label %10
10: ; preds = %4
%11 = tail call i32 @fputs(i8* %1, i32* %8)
br label %12
12: ; preds = %10, %4
%13 = tail call i32 @vfprintf(i32* %8, i8* %2, i32 %3)
ret void
}