#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 port_byte_in(int);
int /*<<< orphan*/ port_byte_out(int, int);
void main() {
  port_byte_out(0x3d4, 14);
  int position = port_byte_in(0x3d5);
  position = position << 8;
  port_byte_out(0x3d4, 15);
  position += port_byte_in(0x3d5);
  int offset_from_vga = position * 2;
  char *vga = (char *)0xb8000;
  vga[offset_from_vga] = 'H';
  vga[offset_from_vga++] = 0x0f;
  vga[offset_from_vga++] = 'A';
  vga[offset_from_vga++] = 0x0f;
  vga[offset_from_vga++] = 'S';
  vga[offset_from_vga++] = 0x0f;
  vga[offset_from_vga++] = 'G';
  vga[offset_from_vga++] = 0x0f;
  vga[offset_from_vga++] = 'E';
  vga[offset_from_vga++] = 0x0f;
  vga[offset_from_vga++] = 'E';
  vga[offset_from_vga + 1] = 0x0f;
  vga[offset_from_vga++] = 'K';
  vga[offset_from_vga + 1] = 0x0f;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x3d4,%edi
mov    $0xe,%esi
call   1030 <port_byte_out@plt>
mov    $0x3d5,%edi
call   1040 <port_byte_in@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x8,%eax
mov    %eax,-0x4(%rbp)
mov    $0x3d4,%edi
mov    $0xf,%esi
call   1030 <port_byte_out@plt>
mov    $0x3d5,%edi
call   1040 <port_byte_in@plt>
add    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    $0xb8000,%eax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x8(%rbp),%rcx
movb   $0x48,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x8(%rbp)
movslq %ecx,%rcx
movb   $0xf,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x8(%rbp)
movslq %ecx,%rcx
movb   $0x41,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x8(%rbp)
movslq %ecx,%rcx
movb   $0xf,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x8(%rbp)
movslq %ecx,%rcx
movb   $0x53,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x8(%rbp)
movslq %ecx,%rcx
movb   $0xf,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x8(%rbp)
movslq %ecx,%rcx
movb   $0x47,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x8(%rbp)
movslq %ecx,%rcx
movb   $0xf,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x8(%rbp)
movslq %ecx,%rcx
movb   $0x45,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x8(%rbp)
movslq %ecx,%rcx
movb   $0xf,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x8(%rbp)
movslq %ecx,%rcx
movb   $0x45,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0xf,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x8(%rbp)
movslq %ecx,%rcx
movb   $0x4b,(%rax,%rcx,1)
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
movb   $0xf,(%rax,%rcx,1)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x3d4,%edi
mov    $0xe,%esi
call   1030 <port_byte_out@plt>
mov    $0x3d5,%edi
call   1040 <port_byte_in@plt>
mov    %eax,%ebx
shl    $0x8,%ebx
mov    $0x3d4,%edi
mov    $0xf,%esi
call   1030 <port_byte_out@plt>
mov    $0x3d5,%edi
call   1040 <port_byte_in@plt>
add    %ebx,%eax
movslq %eax,%rcx
lea    (%rcx,%rcx,1),%rax
cltq
movb   $0xf,0xb8000(%rcx,%rcx,1)
0f
lea    0x2(%rax),%ecx
movb   $0x41,0xb8001(%rax)
lea    0x3(%rax),%edx
movslq %ecx,%rcx
movb   $0xf,0xb8000(%rcx)
lea    0x4(%rax),%ecx
movslq %edx,%rdx
movb   $0x53,0xb8000(%rdx)
lea    0x5(%rax),%edx
movslq %ecx,%rcx
movb   $0xf,0xb8000(%rcx)
lea    0x6(%rax),%ecx
movslq %edx,%rdx
movb   $0x47,0xb8000(%rdx)
lea    0x7(%rax),%edx
movslq %ecx,%rcx
movb   $0xf,0xb8000(%rcx)
lea    0x8(%rax),%ecx
movslq %edx,%rdx
movb   $0x45,0xb8000(%rdx)
lea    0x9(%rax),%edx
movslq %ecx,%rcx
movb   $0xf,0xb8000(%rcx)
lea    0xa(%rax),%ecx
movslq %edx,%rdx
movb   $0x45,0xb8000(%rdx)
lea    0xb(%rax),%edx
movslq %edx,%rdx
movb   $0xf,0xb8000(%rdx)
movslq %ecx,%rcx
movb   $0x4b,0xb8000(%rcx)
add    $0xc,%eax
cltq
movb   $0xf,0xb8000(%rax)
pop    %rbx
ret

LLVM IR (-O0):
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8*
%4 = call i32 @port_byte_out(i32 980, i32 14)
%5 = call i32 @port_byte_in(i32 981)
store i32 %5, i32* %1
%6 = load i32, i32* %1
%7 = shl i32 %6, 8
store i32 %7, i32* %1
%8 = call i32 @port_byte_out(i32 980, i32 15)
%9 = call i32 @port_byte_in(i32 981)
%10 = load i32, i32* %1
%11 = add nsw i32 %10, %9
store i32 %11, i32* %1
%12 = load i32, i32* %1
%13 = mul nsw i32 %12, 2
store i32 %13, i32* %2
store i8* inttoptr (i64 753664 to i8*), i8** %3
%14 = load i8*, i8** %3
%15 = load i32, i32* %2
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
store i8 72, i8* %17
%18 = load i8*, i8** %3
%19 = load i32, i32* %2
%20 = add nsw i32 %19, 1
store i32 %20, i32* %2
%21 = sext i32 %19 to i64
%22 = getelementptr inbounds i8, i8* %18, i64 %21
store i8 15, i8* %22
%23 = load i8*, i8** %3
%24 = load i32, i32* %2
%25 = add nsw i32 %24, 1
store i32 %25, i32* %2
%26 = sext i32 %24 to i64
%27 = getelementptr inbounds i8, i8* %23, i64 %26
store i8 65, i8* %27
%28 = load i8*, i8** %3
%29 = load i32, i32* %2
%30 = add nsw i32 %29, 1
store i32 %30, i32* %2
%31 = sext i32 %29 to i64
%32 = getelementptr inbounds i8, i8* %28, i64 %31
store i8 15, i8* %32
%33 = load i8*, i8** %3
%34 = load i32, i32* %2
%35 = add nsw i32 %34, 1
store i32 %35, i32* %2
%36 = sext i32 %34 to i64
%37 = getelementptr inbounds i8, i8* %33, i64 %36
store i8 83, i8* %37
%38 = load i8*, i8** %3
%39 = load i32, i32* %2
%40 = add nsw i32 %39, 1
store i32 %40, i32* %2
%41 = sext i32 %39 to i64
%42 = getelementptr inbounds i8, i8* %38, i64 %41
store i8 15, i8* %42
%43 = load i8*, i8** %3
%44 = load i32, i32* %2
%45 = add nsw i32 %44, 1
store i32 %45, i32* %2
%46 = sext i32 %44 to i64
%47 = getelementptr inbounds i8, i8* %43, i64 %46
store i8 71, i8* %47
%48 = load i8*, i8** %3
%49 = load i32, i32* %2
%50 = add nsw i32 %49, 1
store i32 %50, i32* %2
%51 = sext i32 %49 to i64
%52 = getelementptr inbounds i8, i8* %48, i64 %51
store i8 15, i8* %52
%53 = load i8*, i8** %3
%54 = load i32, i32* %2
%55 = add nsw i32 %54, 1
store i32 %55, i32* %2
%56 = sext i32 %54 to i64
%57 = getelementptr inbounds i8, i8* %53, i64 %56
store i8 69, i8* %57
%58 = load i8*, i8** %3
%59 = load i32, i32* %2
%60 = add nsw i32 %59, 1
store i32 %60, i32* %2
%61 = sext i32 %59 to i64
%62 = getelementptr inbounds i8, i8* %58, i64 %61
store i8 15, i8* %62
%63 = load i8*, i8** %3
%64 = load i32, i32* %2
%65 = add nsw i32 %64, 1
store i32 %65, i32* %2
%66 = sext i32 %64 to i64
%67 = getelementptr inbounds i8, i8* %63, i64 %66
store i8 69, i8* %67
%68 = load i8*, i8** %3
%69 = load i32, i32* %2
%70 = add nsw i32 %69, 1
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i8, i8* %68, i64 %71
store i8 15, i8* %72
%73 = load i8*, i8** %3
%74 = load i32, i32* %2
%75 = add nsw i32 %74, 1
store i32 %75, i32* %2
%76 = sext i32 %74 to i64
%77 = getelementptr inbounds i8, i8* %73, i64 %76
store i8 75, i8* %77
%78 = load i8*, i8** %3
%79 = load i32, i32* %2
%80 = add nsw i32 %79, 1
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i8, i8* %78, i64 %81
store i8 15, i8* %82
ret void
}

LLVM IR (-O2):
define void @main() {
%1 = tail call i32 @port_byte_out(i32 980, i32 14)
%2 = tail call i32 @port_byte_in(i32 981)
%3 = shl i32 %2, 8
%4 = tail call i32 @port_byte_out(i32 980, i32 15)
%5 = tail call i32 @port_byte_in(i32 981)
%6 = add nsw i32 %5, %3
%7 = shl nsw i32 %6, 1
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* inttoptr (i64 753664 to i8*), i64 %8
%10 = or i32 %7, 1
store i8 15, i8* %9
%11 = add i32 %7, 2
%12 = sext i32 %10 to i64
%13 = getelementptr inbounds i8, i8* inttoptr (i64 753664 to i8*), i64 %12
store i8 65, i8* %13
%14 = add i32 %7, 3
%15 = sext i32 %11 to i64
%16 = getelementptr inbounds i8, i8* inttoptr (i64 753664 to i8*), i64 %15
store i8 15, i8* %16
%17 = add i32 %7, 4
%18 = sext i32 %14 to i64
%19 = getelementptr inbounds i8, i8* inttoptr (i64 753664 to i8*), i64 %18
store i8 83, i8* %19
%20 = add i32 %7, 5
%21 = sext i32 %17 to i64
%22 = getelementptr inbounds i8, i8* inttoptr (i64 753664 to i8*), i64 %21
store i8 15, i8* %22
%23 = add i32 %7, 6
%24 = sext i32 %20 to i64
%25 = getelementptr inbounds i8, i8* inttoptr (i64 753664 to i8*), i64 %24
store i8 71, i8* %25
%26 = add i32 %7, 7
%27 = sext i32 %23 to i64
%28 = getelementptr inbounds i8, i8* inttoptr (i64 753664 to i8*), i64 %27
store i8 15, i8* %28
%29 = add i32 %7, 8
%30 = sext i32 %26 to i64
%31 = getelementptr inbounds i8, i8* inttoptr (i64 753664 to i8*), i64 %30
store i8 69, i8* %31
%32 = add i32 %7, 9
%33 = sext i32 %29 to i64
%34 = getelementptr inbounds i8, i8* inttoptr (i64 753664 to i8*), i64 %33
store i8 15, i8* %34
%35 = add i32 %7, 10
%36 = sext i32 %32 to i64
%37 = getelementptr inbounds i8, i8* inttoptr (i64 753664 to i8*), i64 %36
store i8 69, i8* %37
%38 = add i32 %7, 11
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* inttoptr (i64 753664 to i8*), i64 %39
store i8 15, i8* %40
%41 = sext i32 %35 to i64
%42 = getelementptr inbounds i8, i8* inttoptr (i64 753664 to i8*), i64 %41
store i8 75, i8* %42
%43 = add i32 %7, 12
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* inttoptr (i64 753664 to i8*), i64 %44
store i8 15, i8* %45
ret void
}