void boot() {
  char *str = "my first kernel";
  char *vidptr = (char *)0xb8000;
  unsigned int i = 0;
  unsigned int j = 0;
  unsigned int screensize;
  screensize = 80 * 25 * 2;
  while (j < screensize) {
    vidptr[j] = ' ';
    vidptr[j + 1] = 0x07;
    j = j + 2;
  }
  j = 0;
  while (str[j] != '\0') {
    vidptr[i] = str[j];
    vidptr[i + 1] = 0x07;
    ++j;
    i = i + 2;
  }
  asm("hlt");
}


x86 assembly (clang, -O0):
<boot>:
push   %rbp
mov    %rsp,%rbp
lea    0xef5(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    $0xb8000,%eax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0xfa0,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jae    1162 <boot+0x62>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
movb   $0x20,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,%ecx
movb   $0x7,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x18(%rbp)
jmp    112d <boot+0x2d>
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11b8 <boot+0xb8>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    (%rax,%rcx,1),%dl
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,%ecx
movb   $0x7,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
jmp    1169 <boot+0x69>
hlt
pop    %rbp
ret

x86 assembly (clang, -O2):
<boot>:
mov    $0xb8070,%eax
xor    %ecx,%ecx
movaps 0xef2(%rip),%xmm0
xchg   %ax,%ax
movaps %xmm0,-0x70(%rax,%rcx,2)
movaps %xmm0,-0x60(%rax,%rcx,2)
cmp    $0x7c0,%rcx
je     1146 <boot+0x46>
movaps %xmm0,-0x50(%rax,%rcx,2)
movaps %xmm0,-0x40(%rax,%rcx,2)
movaps %xmm0,-0x30(%rax,%rcx,2)
movaps %xmm0,-0x20(%rax,%rcx,2)
movaps %xmm0,-0x10(%rax,%rcx,2)
movaps %xmm0,(%rax,%rcx,2)
add    $0x40,%rcx
jmp    1110 <boot+0x10>
movb   $0x6d,0xb8000
6d
movb   $0x7,0xb8001
07
movb   $0x79,0xb8002
79
movb   $0x7,0xb8003
07
movb   $0x20,0xb8004
20
movb   $0x7,0xb8005
07
movb   $0x66,0xb8006
66
movb   $0x7,0xb8007
07
movb   $0x69,0xb8008
69
movb   $0x7,0xb8009
07
movb   $0x72,0xb800a
72
movb   $0x7,0xb800b
07
movb   $0x73,0xb800c
73
movb   $0x7,0xb800d
07
movb   $0x74,0xb800e
74
movb   $0x7,0xb800f
07
movb   $0x20,0xb8010
20
movb   $0x7,0xb8011
07
movb   $0x6b,0xb8012
6b
movb   $0x7,0xb8013
07
movb   $0x65,0xb8014
65
movb   $0x7,0xb8015
07
movb   $0x72,0xb8016
72
movb   $0x7,0xb8017
07
movb   $0x6e,0xb8018
6e
movb   $0x7,0xb8019
07
movb   $0x65,0xb801a
65
movb   $0x7,0xb801b
07
movb   $0x6c,0xb801c
6c
movb   $0x7,0xb801d
07
hlt
ret

LLVM IR (-O0):
@.str = [16 x i8] c"my first kernel\00"
define void @boot() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8** %1
store i8* inttoptr (i64 753664 to i8*), i8** %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 4000, i32* %5
br label %6
6: ; preds = %10, %0
%7 = load i32, i32* %4
%8 = load i32, i32* %5
%9 = icmp ult i32 %7, %8
br i1 %9, label %10, label %22
10: ; preds = %6
%11 = load i8*, i8** %2
%12 = load i32, i32* %4
%13 = zext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
store i8 32, i8* %14
%15 = load i8*, i8** %2
%16 = load i32, i32* %4
%17 = add i32 %16, 1
%18 = zext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %15, i64 %18
store i8 7, i8* %19
%20 = load i32, i32* %4
%21 = add i32 %20, 2
store i32 %21, i32* %4
br label %6
22: ; preds = %6
store i32 0, i32* %4
br label %23
23: ; preds = %31, %22
%24 = load i8*, i8** %1
%25 = load i32, i32* %4
%26 = zext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %50
31: ; preds = %23
%32 = load i8*, i8** %1
%33 = load i32, i32* %4
%34 = zext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = load i8, i8* %35
%37 = load i8*, i8** %2
%38 = load i32, i32* %3
%39 = zext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %37, i64 %39
store i8 %36, i8* %40
%41 = load i8*, i8** %2
%42 = load i32, i32* %3
%43 = add i32 %42, 1
%44 = zext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %41, i64 %44
store i8 7, i8* %45
%46 = load i32, i32* %4
%47 = add i32 %46, 1
store i32 %47, i32* %4
%48 = load i32, i32* %3
%49 = add i32 %48, 2
store i32 %49, i32* %3
br label %23
50: ; preds = %23
ret void
}

LLVM IR (-O2):
define void @boot() {
br label %1
1: ; preds = %12, %0
%2 = phi i64 [ 0, %0 ], [ %34, %12 ]
%3 = shl nuw i64 %2, 1
%4 = or i64 %3, 1
%5 = or i64 %3, 17
%6 = getelementptr inbounds i8, i8* inttoptr (i64 753663 to i8*), i64 %4
%7 = bitcast i8* %6 to <16 x i8>*
%8 = getelementptr inbounds i8, i8* inttoptr (i64 753663 to i8*), i64 %5
%9 = bitcast i8* %8 to <16 x i8>*
store <16 x i8> <i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7>, <16 x i8>* %7
store <16 x i8> <i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7>, <16 x i8>* %9
%10 = or i64 %2, 16
%11 = icmp eq i64 %10, 2000
br i1 %11, label %35, label %12
12: ; preds = %1
%13 = shl nuw i64 %10, 1
%14 = or i64 %13, 1
%15 = or i64 %13, 17
%16 = getelementptr inbounds i8, i8* inttoptr (i64 753663 to i8*), i64 %14
%17 = bitcast i8* %16 to <16 x i8>*
%18 = getelementptr inbounds i8, i8* inttoptr (i64 753663 to i8*), i64 %15
%19 = bitcast i8* %18 to <16 x i8>*
store <16 x i8> <i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7>, <16 x i8>* %17
store <16 x i8> <i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7>, <16 x i8>* %19
%20 = shl nuw i64 %2, 1
%21 = or i64 %20, 65
%22 = or i64 %20, 81
%23 = getelementptr inbounds i8, i8* inttoptr (i64 753663 to i8*), i64 %21
%24 = bitcast i8* %23 to <16 x i8>*
%25 = getelementptr inbounds i8, i8* inttoptr (i64 753663 to i8*), i64 %22
%26 = bitcast i8* %25 to <16 x i8>*
store <16 x i8> <i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7>, <16 x i8>* %24
store <16 x i8> <i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7>, <16 x i8>* %26
%27 = shl nuw i64 %2, 1
%28 = or i64 %27, 97
%29 = or i64 %27, 113
%30 = getelementptr inbounds i8, i8* inttoptr (i64 753663 to i8*), i64 %28
%31 = bitcast i8* %30 to <16 x i8>*
%32 = getelementptr inbounds i8, i8* inttoptr (i64 753663 to i8*), i64 %29
%33 = bitcast i8* %32 to <16 x i8>*
store <16 x i8> <i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7>, <16 x i8>* %31
store <16 x i8> <i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7, i8 32, i8 7>, <16 x i8>* %33
%34 = add nuw nsw i64 %2, 64
br label %1
35: ; preds = %1
store i8 109, i8* inttoptr (i64 753664 to i8*)
store i8 7, i8* inttoptr (i64 753665 to i8*)
store i8 121, i8* inttoptr (i64 753666 to i8*)
store i8 7, i8* inttoptr (i64 753667 to i8*)
store i8 32, i8* inttoptr (i64 753668 to i8*)
store i8 7, i8* inttoptr (i64 753669 to i8*)
store i8 102, i8* inttoptr (i64 753670 to i8*)
store i8 7, i8* inttoptr (i64 753671 to i8*)
store i8 105, i8* inttoptr (i64 753672 to i8*)
store i8 7, i8* inttoptr (i64 753673 to i8*)
store i8 114, i8* inttoptr (i64 753674 to i8*)
store i8 7, i8* inttoptr (i64 753675 to i8*)
store i8 115, i8* inttoptr (i64 753676 to i8*)
store i8 7, i8* inttoptr (i64 753677 to i8*)
store i8 116, i8* inttoptr (i64 753678 to i8*)
store i8 7, i8* inttoptr (i64 753679 to i8*)
store i8 32, i8* inttoptr (i64 753680 to i8*)
store i8 7, i8* inttoptr (i64 753681 to i8*)
store i8 107, i8* inttoptr (i64 753682 to i8*)
store i8 7, i8* inttoptr (i64 753683 to i8*)
store i8 101, i8* inttoptr (i64 753684 to i8*)
store i8 7, i8* inttoptr (i64 753685 to i8*)
store i8 114, i8* inttoptr (i64 753686 to i8*)
store i8 7, i8* inttoptr (i64 753687 to i8*)
store i8 110, i8* inttoptr (i64 753688 to i8*)
store i8 7, i8* inttoptr (i64 753689 to i8*)
store i8 101, i8* inttoptr (i64 753690 to i8*)
store i8 7, i8* inttoptr (i64 753691 to i8*)
store i8 108, i8* inttoptr (i64 753692 to i8*)
store i8 7, i8* inttoptr (i64 753693 to i8*)
tail call void asm sideeffect "hlt", "~{dirflag},~{fpsr},~{flags}"()
ret void
}