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

/* Variables and functions */
int /*<<< orphan*/ abort();
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char const *,
                           unsigned int, char const *, char *);
int /*<<< orphan*/ stderr;
void panic_kernel(const char *file, unsigned int line, const char *func) {
  (void)fprintf(stderr, "%s:%u: %s%sPhtreads kernel panic.\n", file, line,
                func ? func : "", func ? ": " : "");
  (void)fflush(stderr);
  abort();
}


x86 assembly (clang, -O0):
<panic_kernel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2e96(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1175 <panic_kernel+0x45>
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    1185 <panic_kernel+0x55>
lea    0xea6(%rip),%rax
mov    %rax,-0x38(%rbp)
jmp    1185 <panic_kernel+0x55>
mov    -0x1c(%rbp),%ecx
mov    -0x28(%rbp),%rdx
mov    -0x2c(%rbp),%edi
mov    -0x38(%rbp),%r8
mov    -0x18(%rbp),%rsi
lea    0xe84(%rip),%r9
lea    0xe7e(%rip),%rax
cmp    $0x0,%rsi
cmovne %rax,%r9
lea    0xe4c(%rip),%rsi
call   1040 <fprintf@plt>
mov    0x2e20(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    $0x0,%al
call   1030 <abort@plt>

x86 assembly (clang, -O2):
<panic_kernel>:
push   %rbx
mov    %rdx,%r8
mov    %esi,%ecx
mov    %rdi,%rdx
mov    0x2ea0(%rip),%rbx
test   %r8,%r8
lea    0xed8(%rip),%rax
cmove  %rax,%r8
mov    (%rbx),%edi
lea    0xecc(%rip),%r9
cmove  %rax,%r9
lea    0xe9e(%rip),%rsi
call   1040 <fprintf@plt>
mov    (%rbx),%edi
call   1050 <fflush@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [35 x i8] c"%s:%u: %s%sPhtreads kernel panic.\0A\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [3 x i8] c": \00"
define void @panic_kernel(i8* %0, i32 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %4
%9 = load i32, i32* %5
%10 = load i8*, i8** %6
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %14
12: ; preds = %3
%13 = load i8*, i8** %6
br label %15
14: ; preds = %3
br label %15
15: ; preds = %14, %12
%16 = phi i8* [ %13, %12 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), %14 ]
%17 = load i8*, i8** %6
%18 = icmp ne i8* %17, null
%19 = zext i1 %18 to i64
%20 = select i1 %18, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0)
%21 = call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %8, i32 %9, i8* %16, i8* %20)
%22 = load i32, i32* @stderr
%23 = call i32 @fflush(i32 %22)
%24 = call i32 (...) @abort()
unreachable
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [35 x i8] c"%s:%u: %s%sPhtreads kernel panic.\0A\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [3 x i8] c": \00"
define void @panic_kernel(i8* %0, i32 %1, i8* %2) {
%4 = load i32, i32* @stderr
%5 = icmp eq i8* %2, null
%6 = select i1 %5, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* %2
%7 = select i1 %5, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0)
%8 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %1, i8* %6, i8* %7)
%9 = load i32, i32* @stderr
%10 = tail call i32 @fflush(i32 %9)
%11 = tail call i32 (...) @abort()
unreachable
}