#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*/ core_main_main();
int /*<<< orphan*/ hal_cpu_init();
int /*<<< orphan*/ hal_debug_init();
int /*<<< orphan*/ hal_early_print_init();
int /*<<< orphan*/ hal_early_print_printf(char *, ...);
int /*<<< orphan*/ hal_exception_init();
int /*<<< orphan*/ hal_io_init();
int /*<<< orphan*/ hal_io_int_enable();
int /*<<< orphan*/ hal_io_irq_enable_all();
int /*<<< orphan*/ hal_kparam_init();
int /*<<< orphan*/ hal_mmu_init();
int /*<<< orphan*/ private_hal_init_analyse_bootloader_info(void *);
int /*<<< orphan*/ private_hal_init_arch_init();
void kinit(void *p_bootloader_info) {
  private_hal_init_arch_init();
  hal_early_print_init();
  hal_early_print_printf("%s loading...\n", "Sandnix kernel 0.0.2");
  private_hal_init_analyse_bootloader_info(p_bootloader_info);
  hal_kparam_init();
  hal_io_init();
  hal_cpu_init();
  hal_mmu_init();
  hal_exception_init();
  hal_debug_init();
  hal_io_int_enable();
  hal_io_irq_enable_all();
  hal_early_print_printf("\nCalling kernel main...\n\n");
  core_main_main();
  return;
}


x86 assembly (clang, -O0):
<kinit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   10c0 <private_hal_init_arch_init@plt>
mov    $0x0,%al
call   1090 <hal_early_print_init@plt>
lea    0xe0f(%rip),%rdi
lea    0xe17(%rip),%rsi
mov    $0x0,%al
call   10e0 <hal_early_print_printf@plt>
mov    -0x8(%rbp),%rdi
call   1080 <private_hal_init_analyse_bootloader_info@plt>
mov    $0x0,%al
call   10b0 <hal_kparam_init@plt>
mov    $0x0,%al
call   1070 <hal_io_init@plt>
mov    $0x0,%al
call   10d0 <hal_cpu_init@plt>
mov    $0x0,%al
call   10a0 <hal_mmu_init@plt>
mov    $0x0,%al
call   1050 <hal_exception_init@plt>
mov    $0x0,%al
call   1030 <hal_debug_init@plt>
mov    $0x0,%al
call   10f0 <hal_io_int_enable@plt>
mov    $0x0,%al
call   1040 <hal_io_irq_enable_all@plt>
lea    0xddd(%rip),%rdi
mov    $0x0,%al
call   10e0 <hal_early_print_printf@plt>
mov    $0x0,%al
call   1060 <core_main_main@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kinit>:
push   %rbx
mov    %rdi,%rbx
xor    %eax,%eax
call   10c0 <private_hal_init_arch_init@plt>
xor    %eax,%eax
call   1090 <hal_early_print_init@plt>
lea    0xe17(%rip),%rdi
lea    0xe1f(%rip),%rsi
xor    %eax,%eax
call   10e0 <hal_early_print_printf@plt>
mov    %rbx,%rdi
call   1080 <private_hal_init_analyse_bootloader_info@plt>
xor    %eax,%eax
call   10b0 <hal_kparam_init@plt>
xor    %eax,%eax
call   1070 <hal_io_init@plt>
xor    %eax,%eax
call   10d0 <hal_cpu_init@plt>
xor    %eax,%eax
call   10a0 <hal_mmu_init@plt>
xor    %eax,%eax
call   1050 <hal_exception_init@plt>
xor    %eax,%eax
call   1030 <hal_debug_init@plt>
xor    %eax,%eax
call   10f0 <hal_io_int_enable@plt>
xor    %eax,%eax
call   1040 <hal_io_irq_enable_all@plt>
lea    0xde6(%rip),%rdi
xor    %eax,%eax
call   10e0 <hal_early_print_printf@plt>
xor    %eax,%eax
pop    %rbx
jmp    1060 <core_main_main@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"%s loading...\0A\00"
@.str.1 = [21 x i8] c"Sandnix kernel 0.0.2\00"
@.str.2 = [26 x i8] c"\0ACalling kernel main...\0A\0A\00"
define void @kinit(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = call i32 (...) @private_hal_init_arch_init()
%4 = call i32 (...) @hal_early_print_init()
%5 = call i32 (i8*, ...) @hal_early_print_printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%6 = load i8*, i8** %2
%7 = call i32 @private_hal_init_analyse_bootloader_info(i8* %6)
%8 = call i32 (...) @hal_kparam_init()
%9 = call i32 (...) @hal_io_init()
%10 = call i32 (...) @hal_cpu_init()
%11 = call i32 (...) @hal_mmu_init()
%12 = call i32 (...) @hal_exception_init()
%13 = call i32 (...) @hal_debug_init()
%14 = call i32 (...) @hal_io_int_enable()
%15 = call i32 (...) @hal_io_irq_enable_all()
%16 = call i32 (i8*, ...) @hal_early_print_printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 (...) @core_main_main()
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"%s loading...\0A\00"
@.str.1 = [21 x i8] c"Sandnix kernel 0.0.2\00"
@.str.2 = [26 x i8] c"\0ACalling kernel main...\0A\0A\00"
define void @kinit(i8* %0) {
%2 = tail call i32 (...) @private_hal_init_arch_init()
%3 = tail call i32 (...) @hal_early_print_init()
%4 = tail call i32 (i8*, ...) @hal_early_print_printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%5 = tail call i32 @private_hal_init_analyse_bootloader_info(i8* %0)
%6 = tail call i32 (...) @hal_kparam_init()
%7 = tail call i32 (...) @hal_io_init()
%8 = tail call i32 (...) @hal_cpu_init()
%9 = tail call i32 (...) @hal_mmu_init()
%10 = tail call i32 (...) @hal_exception_init()
%11 = tail call i32 (...) @hal_debug_init()
%12 = tail call i32 (...) @hal_io_int_enable()
%13 = tail call i32 (...) @hal_io_irq_enable_all()
%14 = tail call i32 (i8*, ...) @hal_early_print_printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0))
%15 = tail call i32 (...) @core_main_main()
ret void
}