int c_start() {
  int i, j;
  char *hello = "Hello, World!";
  char *buffer = (char *)0xB8000;
  i = 0;
  while (i < 80 * 25 * 2) {
    buffer[i] = ' ';
    buffer[i + 1] = 0x00;
    i += 2;
  }
  i = 0;
  j = 0;
  while (hello[i] != '\0') {
    buffer[j] = hello[i];
    buffer[j + 1] = 0x02;
    i++;
    j += 2;
  }
  return 0;
}


x86 assembly (clang, -O0):
<c_start>:
push   %rbp
mov    %rsp,%rbp
lea    0xef5(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    $0xb8000,%eax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x4(%rbp)
cmpl   $0xfa0,-0x4(%rbp)
jge    1157 <c_start+0x57>
mov    -0x18(%rbp),%rax
movslq -0x4(%rbp),%rcx
movb   $0x20,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    -0x4(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x4(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x4(%rbp)
jmp    111f <c_start+0x1f>
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11b8 <c_start+0xb8>
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%rax
movslq -0x8(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x2,(%rax,%rcx,1)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x8(%rbp)
jmp    1165 <c_start+0x65>
xor    %eax,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<c_start>:
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 <c_start+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 <c_start+0x10>
movb   $0x48,0xb8000
48
movb   $0x2,0xb8001
02
movb   $0x65,0xb8002
65
movb   $0x2,0xb8003
02
movb   $0x6c,0xb8004
6c
movb   $0x2,0xb8005
02
movb   $0x6c,0xb8006
6c
movb   $0x2,0xb8007
02
movb   $0x6f,0xb8008
6f
movb   $0x2,0xb8009
02
movb   $0x2c,0xb800a
2c
movb   $0x2,0xb800b
02
movb   $0x20,0xb800c
20
movb   $0x2,0xb800d
02
movb   $0x57,0xb800e
57
movb   $0x2,0xb800f
02
movb   $0x6f,0xb8010
6f
movb   $0x2,0xb8011
02
movb   $0x72,0xb8012
72
movb   $0x2,0xb8013
02
movb   $0x6c,0xb8014
6c
movb   $0x2,0xb8015
02
movb   $0x64,0xb8016
64
movb   $0x2,0xb8017
02
movb   $0x21,0xb8018
21
movb   $0x2,0xb8019
02
xor    %eax,%eax
ret

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

LLVM IR (-O2):
define i32 @c_start() {
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 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0>, <16 x i8>* %7
store <16 x i8> <i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0>, <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 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0>, <16 x i8>* %17
store <16 x i8> <i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0>, <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 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0>, <16 x i8>* %24
store <16 x i8> <i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0>, <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 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0>, <16 x i8>* %31
store <16 x i8> <i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0, i8 32, i8 0>, <16 x i8>* %33
%34 = add nuw nsw i64 %2, 64
br label %1
35: ; preds = %1
store i8 72, i8* inttoptr (i64 753664 to i8*)
store i8 2, i8* inttoptr (i64 753665 to i8*)
store i8 101, i8* inttoptr (i64 753666 to i8*)
store i8 2, i8* inttoptr (i64 753667 to i8*)
store i8 108, i8* inttoptr (i64 753668 to i8*)
store i8 2, i8* inttoptr (i64 753669 to i8*)
store i8 108, i8* inttoptr (i64 753670 to i8*)
store i8 2, i8* inttoptr (i64 753671 to i8*)
store i8 111, i8* inttoptr (i64 753672 to i8*)
store i8 2, i8* inttoptr (i64 753673 to i8*)
store i8 44, i8* inttoptr (i64 753674 to i8*)
store i8 2, i8* inttoptr (i64 753675 to i8*)
store i8 32, i8* inttoptr (i64 753676 to i8*)
store i8 2, i8* inttoptr (i64 753677 to i8*)
store i8 87, i8* inttoptr (i64 753678 to i8*)
store i8 2, i8* inttoptr (i64 753679 to i8*)
store i8 111, i8* inttoptr (i64 753680 to i8*)
store i8 2, i8* inttoptr (i64 753681 to i8*)
store i8 114, i8* inttoptr (i64 753682 to i8*)
store i8 2, i8* inttoptr (i64 753683 to i8*)
store i8 108, i8* inttoptr (i64 753684 to i8*)
store i8 2, i8* inttoptr (i64 753685 to i8*)
store i8 100, i8* inttoptr (i64 753686 to i8*)
store i8 2, i8* inttoptr (i64 753687 to i8*)
store i8 33, i8* inttoptr (i64 753688 to i8*)
store i8 2, i8* inttoptr (i64 753689 to i8*)
ret i32 0
}