#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*/ printf(char *, ...);
int strlen(char const *);
int /*<<< orphan*/ vprintf(char const *, int /*<<< orphan*/);
void nullpo_info_core(const char *file, int line, const char *func,
                      const char *fmt, va_list ap) {
  if (file == NULL)
    file = "??";
  func = func == NULL ? "unknown" : func[0] == '\0' ? "unknown" : func;
  printf("--- nullpo info --------------------------------------------\n");
  printf("%s:%d: in func `%s'\n", file, line, func);
  if (fmt != NULL) {
    if (fmt[0] != '\0') {
      vprintf(fmt, ap);
      if (fmt[strlen(fmt) - 1] != '\n')
        printf("\n");
    }
  }
  printf("--- end nullpo info ----------------------------------------\n");
}


x86 assembly (clang, -O0):
<nullpo_info_core>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1161 <nullpo_info_core+0x31>
lea    0xea3(%rip),%rax
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    117c <nullpo_info_core+0x4c>
lea    0xe90(%rip),%rax
mov    %rax,-0x30(%rbp)
jmp    11ac <nullpo_info_core+0x7c>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    119c <nullpo_info_core+0x6c>
lea    0xe70(%rip),%rax
mov    %rax,-0x38(%rbp)
jmp    11a4 <nullpo_info_core+0x74>
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rcx
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x20(%rbp)
je     1244 <nullpo_info_core+0x114>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     123f <nullpo_info_core+0x10f>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%esi
call   1050 <vprintf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
je     123a <nullpo_info_core+0x10a>
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    123f <nullpo_info_core+0x10f>
jmp    1244 <nullpo_info_core+0x114>
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nullpo_info_core>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %r8d,%r14d
mov    %rcx,%r12
mov    %esi,%r15d
test   %rdi,%rdi
lea    0xe95(%rip),%rbp
cmovne %rdi,%rbp
test   %rdx,%rdx
je     1184 <nullpo_info_core+0x34>
cmpb   $0x0,(%rdx)
lea    0xe85(%rip),%rbx
cmovne %rdx,%rbx
jmp    118b <nullpo_info_core+0x3b>
lea    0xe78(%rip),%rbx
lea    0xe8e(%rip),%rdi
call   1040 <puts@plt>
lea    0xe6d(%rip),%rdi
mov    %rbp,%rsi
mov    %r15d,%edx
mov    %rbx,%rcx
xor    %eax,%eax
call   1060 <printf@plt>
test   %r12,%r12
je     11e1 <nullpo_info_core+0x91>
cmpb   $0x0,(%r12)
je     11e1 <nullpo_info_core+0x91>
mov    %r12,%rdi
mov    %r14d,%esi
call   1070 <vprintf@plt>
mov    %r12,%rdi
call   1050 <strlen@plt>
cltq
cmpb   $0xa,-0x1(%rax,%r12,1)
je     11e1 <nullpo_info_core+0x91>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe75(%rip),%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <puts@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"??\00"
@.str.1 = [8 x i8] c"unknown\00"
@.str.2 = [62 x i8] c"--- nullpo info --------------------------------------------\0A\00"
@.str.3 = [21 x i8] c"%s:%d: in func `%s'\0A\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [62 x i8] c"--- end nullpo info ----------------------------------------\0A\00"
define void @nullpo_info_core(i8* %0, i32 %1, i8* %2, i8* %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i32 %4, i32* %10
%11 = load i8*, i8** %6
%12 = icmp eq i8* %11, null
br i1 %12, label %13, label %14
13: ; preds = %5
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %6
br label %14
14: ; preds = %13, %5
%15 = load i8*, i8** %8
%16 = icmp eq i8* %15, null
br i1 %16, label %17, label %18
17: ; preds = %14
br label %29
18: ; preds = %14
%19 = load i8*, i8** %8
%20 = getelementptr inbounds i8, i8* %19, i64 0
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %18
br label %27
25: ; preds = %18
%26 = load i8*, i8** %8
br label %27
27: ; preds = %25, %24
%28 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), %24 ], [ %26, %25 ]
br label %29
29: ; preds = %27, %17
%30 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), %17 ], [ %28, %27 ]
store i8* %30, i8** %8
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.2, i64 0, i64 0))
%32 = load i8*, i8** %6
%33 = load i32, i32* %7
%34 = load i8*, i8** %8
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %32, i32 %33, i8* %34)
%36 = load i8*, i8** %9
%37 = icmp ne i8* %36, null
br i1 %37, label %38, label %61
38: ; preds = %29
%39 = load i8*, i8** %9
%40 = getelementptr inbounds i8, i8* %39, i64 0
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %60
44: ; preds = %38
%45 = load i8*, i8** %9
%46 = load i32, i32* %10
%47 = call i32 @vprintf(i8* %45, i32 %46)
%48 = load i8*, i8** %9
%49 = load i8*, i8** %9
%50 = call i32 @strlen(i8* %49)
%51 = sub nsw i32 %50, 1
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %48, i64 %52
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = icmp ne i32 %55, 10
br i1 %56, label %57, label %59
57: ; preds = %44
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %59
59: ; preds = %57, %44
br label %60
60: ; preds = %59, %38
br label %61
61: ; preds = %60, %29
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.5, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"??\00"
@.str.1 = [8 x i8] c"unknown\00"
@.str.3 = [21 x i8] c"%s:%d: in func `%s'\0A\00"
@str = [61 x i8] c"--- nullpo info --------------------------------------------\00"
@str.6 = [61 x i8] c"--- end nullpo info ----------------------------------------\00"
define void @nullpo_info_core(i8* %0, i32 %1, i8* %2, i8* %3, i32 %4) {
%6 = icmp eq i8* %0, null
%7 = select i1 %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0
%8 = icmp eq i8* %2, null
br i1 %8, label %13, label %9
9: ; preds = %5
%10 = load i8, i8* %2
%11 = icmp eq i8 %10, 0
%12 = select i1 %11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %2
br label %13
13: ; preds = %5, %9
%14 = phi i8* [ %12, %9 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), %5 ]
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @str, i64 0, i64 0))
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), i8* %7, i32 %1, i8* %14)
%17 = icmp eq i8* %3, null
br i1 %17, label %31, label %18
18: ; preds = %13
%19 = load i8, i8* %3
%20 = icmp eq i8 %19, 0
br i1 %20, label %31, label %21
21: ; preds = %18
%22 = tail call i32 @vprintf(i8* %3, i32 %4)
%23 = tail call i32 @strlen(i8* %3)
%24 = add nsw i32 %23, -1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %3, i64 %25
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 10
br i1 %28, label %31, label %29
29: ; preds = %21
%30 = tail call i32 @putchar(i32 10)
br label %31
31: ; preds = %18, %29, %21, %13
%32 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([61 x i8], [61 x i8]* @str.6, i64 0, i64 0))
ret void
}