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

/* Variables and functions */
int /*<<< orphan*/ console_init(int, int);
int /*<<< orphan*/ console_puts(char *);
int /*<<< orphan*/ gpu_clear(int /*<<< orphan*/);
int /*<<< orphan*/ gpu_init(int, int);
int /*<<< orphan*/ gpu_putchar(char, int, int, int);
int /*<<< orphan*/ log_init();
void kmain(uint32_t r0, uint32_t r1, uint32_t atags) {
  log_init();
  gpu_init(800, 600);
  gpu_clear(0);
  gpu_putchar('A', 10, 10, (0 << 16 | 0 << 8 | 255));
  console_init(800, 600);
  console_puts(
      "ABCDEFGHIJKLMNOPQRSTUVXYZ abcdefghijklmnopqrstuvxyz \n0123456789\n");
  console_puts("Hejj\b du!\n");
}


x86 assembly (clang, -O0):
<kmain>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    $0x0,%al
call   1040 <log_init@plt>
mov    $0x320,%edi
mov    $0x258,%esi
call   1070 <gpu_init@plt>
xor    %edi,%edi
call   1060 <gpu_clear@plt>
mov    $0x41,%edi
mov    $0xa,%edx
mov    $0xff,%ecx
mov    %edx,%esi
call   1080 <gpu_putchar@plt>
mov    $0x320,%edi
mov    $0x258,%esi
call   1030 <console_init@plt>
lea    0xe46(%rip),%rdi
call   1050 <console_puts@plt>
lea    0xe7b(%rip),%rdi
call   1050 <console_puts@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<kmain>:
push   %rax
xor    %eax,%eax
call   1040 <log_init@plt>
mov    $0x320,%edi
mov    $0x258,%esi
call   1070 <gpu_init@plt>
xor    %edi,%edi
call   1060 <gpu_clear@plt>
mov    $0x41,%edi
mov    $0xa,%esi
mov    $0xa,%edx
mov    $0xff,%ecx
call   1080 <gpu_putchar@plt>
mov    $0x320,%edi
mov    $0x258,%esi
call   1030 <console_init@plt>
lea    0xe53(%rip),%rdi
call   1050 <console_puts@plt>
lea    0xe88(%rip),%rdi
pop    %rax
jmp    1050 <console_puts@plt>

LLVM IR (-O0):
@.str = [65 x i8] c"ABCDEFGHIJKLMNOPQRSTUVXYZ abcdefghijklmnopqrstuvxyz \0A0123456789\0A\00"
@.str.1 = [11 x i8] c"Hejj\08 du!\0A\00"
define void @kmain(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = call i32 (...) @log_init()
%8 = call i32 @gpu_init(i32 800, i32 600)
%9 = call i32 @gpu_clear(i32 0)
%10 = call i32 @gpu_putchar(i8 signext 65, i32 10, i32 10, i32 255)
%11 = call i32 @console_init(i32 800, i32 600)
%12 = call i32 @console_puts(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @console_puts(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [65 x i8] c"ABCDEFGHIJKLMNOPQRSTUVXYZ abcdefghijklmnopqrstuvxyz \0A0123456789\0A\00"
@.str.1 = [11 x i8] c"Hejj\08 du!\0A\00"
define void @kmain(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32 (...) @log_init()
%5 = tail call i32 @gpu_init(i32 800, i32 600)
%6 = tail call i32 @gpu_clear(i32 0)
%7 = tail call i32 @gpu_putchar(i8 signext 65, i32 10, i32 10, i32 255)
%8 = tail call i32 @console_init(i32 800, i32 600)
%9 = tail call i32 @console_puts(i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @console_puts(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
ret void
}