#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*/ kernel_assert_clear();
int /*<<< orphan*/ kernel_assert_print(char const *, int, unsigned int);
unsigned int kernel_assert_strlen(char const *);
int /*<<< orphan*/ kernel_halt();
void kernel_assert(int testarg, const char *file, const char *line) {
  unsigned int location = 0;
  if (testarg == 0) {
    kernel_assert_clear();
    kernel_assert_print("ix: assert '", 12, location);
    location += 12;
    kernel_assert_print(file, kernel_assert_strlen(file), location);
    location += kernel_assert_strlen(file);
    kernel_assert_print(":", 1, location);
    location += 1;
    kernel_assert_print(line, kernel_assert_strlen(line), location);
    location += kernel_assert_strlen(line);
    kernel_assert_print("' failed. HLT", 13, location);
    location += 13;
    kernel_halt();
  }
}


x86 assembly (clang, -O0):
<kernel_assert>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x0,-0x4(%rbp)
jne    1225 <kernel_assert+0xe5>
mov    $0x0,%al
call   1040 <kernel_assert_clear@plt>
mov    -0x1c(%rbp),%edx
lea    0xe8b(%rip),%rdi
mov    $0xc,%esi
call   1060 <kernel_assert_print@plt>
mov    -0x1c(%rbp),%eax
add    $0xc,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <kernel_assert_strlen@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%esi
mov    -0x1c(%rbp),%edx
call   1060 <kernel_assert_print@plt>
mov    -0x10(%rbp),%rdi
call   1030 <kernel_assert_strlen@plt>
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edx
lea    0xe4d(%rip),%rdi
mov    $0x1,%esi
call   1060 <kernel_assert_print@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <kernel_assert_strlen@plt>
mov    -0x28(%rbp),%rdi
mov    %eax,%esi
mov    -0x1c(%rbp),%edx
call   1060 <kernel_assert_print@plt>
mov    -0x18(%rbp),%rdi
call   1030 <kernel_assert_strlen@plt>
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edx
lea    0xe04(%rip),%rdi
mov    $0xd,%esi
call   1060 <kernel_assert_print@plt>
mov    -0x1c(%rbp),%eax
add    $0xd,%eax
mov    %eax,-0x1c(%rbp)
mov    $0x0,%al
call   1050 <kernel_halt@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kernel_assert>:
test   %edi,%edi
je     1145 <kernel_assert+0x5>
ret
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
xor    %eax,%eax
call   1040 <kernel_assert_clear@plt>
lea    0xea3(%rip),%rdi
mov    $0xc,%esi
xor    %edx,%edx
call   1060 <kernel_assert_print@plt>
mov    %rbx,%rdi
call   1030 <kernel_assert_strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    $0xc,%edx
call   1060 <kernel_assert_print@plt>
mov    %rbx,%rdi
call   1030 <kernel_assert_strlen@plt>
mov    %eax,%ebx
lea    0xc(%rbx),%edx
lea    0xe79(%rip),%rdi
mov    $0x1,%esi
call   1060 <kernel_assert_print@plt>
lea    0xd(%rbx),%ebp
mov    %r14,%rdi
call   1030 <kernel_assert_strlen@plt>
mov    %r14,%rdi
mov    %eax,%esi
mov    %ebp,%edx
call   1060 <kernel_assert_print@plt>
mov    %r14,%rdi
call   1030 <kernel_assert_strlen@plt>
lea    (%rax,%rbx,1),%edx
add    $0xd,%edx
lea    0xe45(%rip),%rdi
mov    $0xd,%esi
call   1060 <kernel_assert_print@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <kernel_halt@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"ix: assert '\00"
@.str.1 = [2 x i8] c":\00"
@.str.2 = [14 x i8] c"' failed. HLT\00"
define void @kernel_assert(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i32 0, i32* %7
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %43
10: ; preds = %3
%11 = call i32 (...) @kernel_assert_clear()
%12 = load i32, i32* %7
%13 = call i32 @kernel_assert_print(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 12, i32 %12)
%14 = load i32, i32* %7
%15 = add i32 %14, 12
store i32 %15, i32* %7
%16 = load i8*, i8** %5
%17 = load i8*, i8** %5
%18 = call i32 @kernel_assert_strlen(i8* %17)
%19 = load i32, i32* %7
%20 = call i32 @kernel_assert_print(i8* %16, i32 %18, i32 %19)
%21 = load i8*, i8** %5
%22 = call i32 @kernel_assert_strlen(i8* %21)
%23 = load i32, i32* %7
%24 = add i32 %23, %22
store i32 %24, i32* %7
%25 = load i32, i32* %7
%26 = call i32 @kernel_assert_print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 %25)
%27 = load i32, i32* %7
%28 = add i32 %27, 1
store i32 %28, i32* %7
%29 = load i8*, i8** %6
%30 = load i8*, i8** %6
%31 = call i32 @kernel_assert_strlen(i8* %30)
%32 = load i32, i32* %7
%33 = call i32 @kernel_assert_print(i8* %29, i32 %31, i32 %32)
%34 = load i8*, i8** %6
%35 = call i32 @kernel_assert_strlen(i8* %34)
%36 = load i32, i32* %7
%37 = add i32 %36, %35
store i32 %37, i32* %7
%38 = load i32, i32* %7
%39 = call i32 @kernel_assert_print(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 13, i32 %38)
%40 = load i32, i32* %7
%41 = add i32 %40, 13
store i32 %41, i32* %7
%42 = call i32 (...) @kernel_halt()
br label %43
43: ; preds = %10, %3
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"ix: assert '\00"
@.str.1 = [2 x i8] c":\00"
@.str.2 = [14 x i8] c"' failed. HLT\00"
define void @kernel_assert(i32 %0, i8* %1, i8* %2) {
%4 = icmp eq i32 %0, 0
br i1 %4, label %5, label %20
5: ; preds = %3
%6 = tail call i32 (...) @kernel_assert_clear()
%7 = tail call i32 @kernel_assert_print(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 12, i32 0)
%8 = tail call i32 @kernel_assert_strlen(i8* %1)
%9 = tail call i32 @kernel_assert_print(i8* %1, i32 %8, i32 12)
%10 = tail call i32 @kernel_assert_strlen(i8* %1)
%11 = add i32 %10, 12
%12 = tail call i32 @kernel_assert_print(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 %11)
%13 = add i32 %10, 13
%14 = tail call i32 @kernel_assert_strlen(i8* %2)
%15 = tail call i32 @kernel_assert_print(i8* %2, i32 %14, i32 %13)
%16 = tail call i32 @kernel_assert_strlen(i8* %2)
%17 = add i32 %16, %13
%18 = tail call i32 @kernel_assert_print(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 13, i32 %17)
%19 = tail call i32 (...) @kernel_halt()
br label %20
20: ; preds = %5, %3
ret void
}