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

/* Variables and functions */
int /*<<< orphan*/ _set_color(char, int);
void main() {
  int i;
  char *msg = "!!! I am a external program! - Hello, World !!!\n";
  uint16_t *_video_memory = (void *)0xc00B8000;
  for (i = 0; msg[i] != '\0'; i++)
    _video_memory[i] = _set_color(msg[i], 0x80);
  for (;;)
    ;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xee1(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    $0xc00b8000,%eax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1179 <main+0x69>
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    $0x80,%esi
movsbl (%rax,%rcx,1),%edi
call   1030 <_set_color@plt>
mov    %eax,%edx
mov    -0x18(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1133 <main+0x23>
jmp    117e <main+0x6e>
jmp    117e <main+0x6e>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
xor    %ebx,%ebx
lea    0xee2(%rip),%r14
mov    $0xc00b8000,%r15d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl (%rbx,%r14,1),%edi
mov    $0x80,%esi
call   1030 <_set_color@plt>
mov    %eax,(%r15,%rbx,4)
add    $0x1,%rbx
cmp    $0x30,%rbx
jne    1130 <main+0x20>
nopl   (%rax)
jmp    1150 <main+0x40>

LLVM IR (-O0):
@.str = [49 x i8] c"!!! I am a external program! - Hello, World !!!\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32*
store i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0), i8** %2
store i32* inttoptr (i64 3221979136 to i32*), i32** %3
store i32 0, i32* %1
br label %4
4: ; preds = %23, %0
%5 = load i8*, i8** %2
%6 = load i32, i32* %1
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %5, i64 %7
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %26
12: ; preds = %4
%13 = load i8*, i8** %2
%14 = load i32, i32* %1
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = load i8, i8* %16
%18 = call i32 @_set_color(i8 signext %17, i32 128)
%19 = load i32*, i32** %3
%20 = load i32, i32* %1
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i32, i32* %19, i64 %21
store i32 %18, i32* %22
br label %23
23: ; preds = %12
%24 = load i32, i32* %1
%25 = add nsw i32 %24, 1
store i32 %25, i32* %1
br label %4
26: ; preds = %4
br label %27
27: ; preds = %27, %26
br label %27
}

LLVM IR (-O2):
@.str = [49 x i8] c"!!! I am a external program! - Hello, World !!!\0A\00"
define void @main() {
br label %1
1: ; preds = %0, %1
%2 = phi i64 [ 0, %0 ], [ %7, %1 ]
%3 = getelementptr inbounds [49 x i8], [49 x i8]* @.str, i64 0, i64 %2
%4 = load i8, i8* %3
%5 = tail call i32 @_set_color(i8 signext %4, i32 128)
%6 = getelementptr inbounds i32, i32* inttoptr (i64 3221979136 to i32*), i64 %2
store i32 %5, i32* %6
%7 = add nuw nsw i64 %2, 1
%8 = icmp eq i64 %7, 48
br i1 %8, label %9, label %1
9: ; preds = %1, %9
br label %9
}