void main() {
  char *str = "Hello, World!";
  char *vid = (char *)0xb8000;
  unsigned int i = 0;
  unsigned int j = 0;
  while (j < 80 * 25 * 2) {
    vid[j] = ' ';
    vid[j + 1] = 0x07;
    j += 2;
  }
  j = 0;
  while (str[j] != '\0') {
    vid[i] = str[j];
    vid[i + 1] = 0x07;
    i += 2;
    j += 1;
  }
}


x86 assembly (clang, -O0):
<main>:
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)
cmpl   $0xfa0,-0x18(%rbp)
jae    115c <main+0x5c>
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    1126 <main+0x26>
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     11b2 <main+0xb2>
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    -0x14(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1163 <main+0x63>
pop    %rbp
ret

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

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

LLVM IR (-O2):
define void @main() {
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 72, i8* inttoptr (i64 753664 to i8*)
store i8 7, i8* inttoptr (i64 753665 to i8*)
store i8 101, i8* inttoptr (i64 753666 to i8*)
store i8 7, i8* inttoptr (i64 753667 to i8*)
store i8 108, i8* inttoptr (i64 753668 to i8*)
store i8 7, i8* inttoptr (i64 753669 to i8*)
store i8 108, i8* inttoptr (i64 753670 to i8*)
store i8 7, i8* inttoptr (i64 753671 to i8*)
store i8 111, i8* inttoptr (i64 753672 to i8*)
store i8 7, i8* inttoptr (i64 753673 to i8*)
store i8 44, i8* inttoptr (i64 753674 to i8*)
store i8 7, i8* inttoptr (i64 753675 to i8*)
store i8 32, i8* inttoptr (i64 753676 to i8*)
store i8 7, i8* inttoptr (i64 753677 to i8*)
store i8 87, i8* inttoptr (i64 753678 to i8*)
store i8 7, i8* inttoptr (i64 753679 to i8*)
store i8 111, i8* inttoptr (i64 753680 to i8*)
store i8 7, i8* inttoptr (i64 753681 to i8*)
store i8 114, i8* inttoptr (i64 753682 to i8*)
store i8 7, i8* inttoptr (i64 753683 to i8*)
store i8 108, i8* inttoptr (i64 753684 to i8*)
store i8 7, i8* inttoptr (i64 753685 to i8*)
store i8 100, i8* inttoptr (i64 753686 to i8*)
store i8 7, i8* inttoptr (i64 753687 to i8*)
store i8 33, i8* inttoptr (i64 753688 to i8*)
store i8 7, i8* inttoptr (i64 753689 to i8*)
ret void
}