#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ vfprintf(int /*<<< orphan*/, char const *,
                            int /*<<< orphan*/);
void _debug(const char *pfx, const char *msg, va_list ap) {
  if (pfx)
    fprintf(stderr, "%s", pfx);
  vfprintf(stderr, msg, ap);
  fprintf(stderr, "\n");
}


x86 assembly (clang, -O0):
<_debug>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1159 <_debug+0x39>
mov    0x2e9b(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xeae(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <vfprintf@plt>
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
lea    0xe85(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_debug>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %rsi,%rbx
test   %rdi,%rdi
je     1149 <_debug+0x29>
mov    %rdi,%rdx
mov    0x2ea7(%rip),%rax
mov    (%rax),%edi
lea    0xebe(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x2e90(%rip),%rbp
mov    0x0(%rbp),%edi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1040 <vfprintf@plt>
mov    0x0(%rbp),%edi
lea    0xe9b(%rip),%rsi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <fprintf@plt>

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @_debug(i8* %0, i8* %1, i32 %2) {
%4 = icmp eq i8* %0, null
br i1 %4, label %8, label %5
5: ; preds = %3
%6 = load i32, i32* @stderr
%7 = tail call i32 (i32, i8*, ...) @fprintf(i32 %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %8
8: ; preds = %5, %3
%9 = load i32, i32* @stderr
%10 = tail call i32 @vfprintf(i32 %9, i8* %1, i32 %2)
%11 = load i32, i32* @stderr
%12 = tail call i32 (i32, i8*, ...) @fprintf(i32 %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}