#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 /*<<< orphan*/ __outb(int, int);
int /*<<< orphan*/ cprint(int /*<<< orphan*/, int, char *);
int /*<<< orphan*/ serial_echo_init();
int /*<<< orphan*/ serial_echo_print(char *);
void display_init(void) {
  int i;
  volatile char *pp;
  __outb(0x0F, 0x03D4);
  __outb(0xFF, 0x03D5);
  __outb(0x0E, 0x03D4);
  __outb(0xFF, 0x03D5);
  serial_echo_init();
  serial_echo_print("[LINE_SCROLL;24r");
  serial_echo_print("[H[2J");
  serial_echo_print("[37m[44m");
  serial_echo_print("[0m");
  serial_echo_print("[37m[44m");
  for (i = 0, pp = (char *)(0xb8000); i < 80 * 24; i++) {
    *pp++ = ' ';
    *pp++ = 0x17;
  }
  for (i = 0, pp = (char *)(0xb8000 + 1); i < 28; i++, pp += 2) {
    *pp = 0x20;
  }
  cprint(0, 0, "      Memtest86  5.01        ");
  for (i = 0, pp = (char *)(0xb8000 + 1); i < 2; i++, pp += 30) {
    *pp = 0xA4;
  }
  cprint(0, 15, "+");
  for (i = 0, pp = (char *)(0xb8000 + 1 + (24 * 160)); i < 80; i++, pp += 2) {
    *pp = 0x71;
  }
  serial_echo_print("[0m");
}


x86 assembly (clang, -O0):
<display_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0xf,%edi
mov    $0x3d4,%esi
call   1040 <__outb@plt>
mov    $0xff,%edi
mov    $0x3d5,%esi
call   1040 <__outb@plt>
mov    $0xe,%edi
mov    $0x3d4,%esi
call   1040 <__outb@plt>
mov    $0xff,%edi
mov    $0x3d5,%esi
call   1040 <__outb@plt>
mov    $0x0,%al
call   1050 <serial_echo_init@plt>
lea    0xe6e(%rip),%rdi
call   1060 <serial_echo_print@plt>
lea    0xe74(%rip),%rdi
call   1060 <serial_echo_print@plt>
lea    0xe70(%rip),%rdi
call   1060 <serial_echo_print@plt>
lea    0xe6f(%rip),%rdi
call   1060 <serial_echo_print@plt>
lea    0xe58(%rip),%rdi
call   1060 <serial_echo_print@plt>
movl   $0x0,-0x4(%rbp)
mov    $0xb8000,%eax
mov    %rax,-0x10(%rbp)
cmpl   $0x780,-0x4(%rbp)
jge    1216 <display_init+0xd6>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x20,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movb   $0x17,(%rax)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    11d7 <display_init+0x97>
movl   $0x0,-0x4(%rbp)
mov    $0xb8001,%eax
mov    %rax,-0x10(%rbp)
cmpl   $0x1c,-0x4(%rbp)
jge    1251 <display_init+0x111>
mov    -0x10(%rbp),%rax
movb   $0x20,(%rax)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
jmp    1226 <display_init+0xe6>
xor    %esi,%esi
lea    0xdd0(%rip),%rdx
mov    %esi,%edi
call   1030 <cprint@plt>
movl   $0x0,-0x4(%rbp)
mov    $0xb8001,%eax
mov    %rax,-0x10(%rbp)
cmpl   $0x2,-0x4(%rbp)
jge    129c <display_init+0x15c>
mov    -0x10(%rbp),%rax
movb   $0xa4,(%rax)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1e,%rax
mov    %rax,-0x10(%rbp)
jmp    1271 <display_init+0x131>
xor    %edi,%edi
mov    $0xf,%esi
lea    0xd9e(%rip),%rdx
call   1030 <cprint@plt>
movl   $0x0,-0x4(%rbp)
mov    $0xb8f01,%eax
mov    %rax,-0x10(%rbp)
cmpl   $0x50,-0x4(%rbp)
jge    12ea <display_init+0x1aa>
mov    -0x10(%rbp),%rax
movb   $0x71,(%rax)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x10(%rbp),%rax
add    $0x2,%rax
mov    %rax,-0x10(%rbp)
jmp    12bf <display_init+0x17f>
lea    0xd34(%rip),%rdi
call   1060 <serial_echo_print@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_init>:
push   %r15
push   %r14
push   %rbx
mov    $0xb8000,%r15d
mov    $0xf,%edi
mov    $0x3d4,%esi
call   1040 <__outb@plt>
mov    $0xff,%edi
mov    $0x3d5,%esi
call   1040 <__outb@plt>
mov    $0xe,%edi
mov    $0x3d4,%esi
call   1040 <__outb@plt>
mov    $0xff,%edi
mov    $0x3d5,%esi
call   1040 <__outb@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <serial_echo_init@plt>
lea    0xe69(%rip),%rdi
call   1060 <serial_echo_print@plt>
lea    0xe6f(%rip),%rdi
call   1060 <serial_echo_print@plt>
lea    0xe6b(%rip),%r14
mov    %r14,%rdi
call   1060 <serial_echo_print@plt>
lea    0xe67(%rip),%rdi
call   1060 <serial_echo_print@plt>
mov    %r14,%rdi
call   1060 <serial_echo_print@plt>
nopl   0x0(%rax,%rax,1)
movb   $0x20,(%r15,%rbx,2)
movb   $0x17,0x1(%r15,%rbx,2)
movb   $0x20,0x2(%r15,%rbx,2)
movb   $0x17,0x3(%r15,%rbx,2)
movb   $0x20,0x4(%r15,%rbx,2)
movb   $0x17,0x5(%r15,%rbx,2)
movb   $0x20,0x6(%r15,%rbx,2)
movb   $0x17,0x7(%r15,%rbx,2)
movb   $0x20,0x8(%r15,%rbx,2)
movb   $0x17,0x9(%r15,%rbx,2)
movb   $0x20,0xa(%r15,%rbx,2)
movb   $0x17,0xb(%r15,%rbx,2)
movb   $0x20,0xc(%r15,%rbx,2)
movb   $0x17,0xd(%r15,%rbx,2)
movb   $0x20,0xe(%r15,%rbx,2)
movb   $0x17,0xf(%r15,%rbx,2)
add    $0x8,%rbx
cmp    $0x780,%ebx
jne    11d0 <display_init+0x90>
movb   $0x20,0xb8001
20
movb   $0x20,0xb8003
20
movb   $0x20,0xb8005
20
movb   $0x20,0xb8007
20
movb   $0x20,0xb8009
20
movb   $0x20,0xb800b
20
movb   $0x20,0xb800d
20
movb   $0x20,0xb800f
20
movb   $0x20,0xb8011
20
movb   $0x20,0xb8013
20
movb   $0x20,0xb8015
20
movb   $0x20,0xb8017
20
movb   $0x20,0xb8019
20
movb   $0x20,0xb801b
20
movb   $0x20,0xb801d
20
movb   $0x20,0xb801f
20
movb   $0x20,0xb8021
20
movb   $0x20,0xb8023
20
movb   $0x20,0xb8025
20
movb   $0x20,0xb8027
20
movb   $0x20,0xb8029
20
movb   $0x20,0xb802b
20
movb   $0x20,0xb802d
20
movb   $0x20,0xb802f
20
movb   $0x20,0xb8031
20
movb   $0x20,0xb8033
20
movb   $0x20,0xb8035
20
movb   $0x20,0xb8037
20
lea    0xd08(%rip),%rdx
xor    %ebx,%ebx
xor    %edi,%edi
xor    %esi,%esi
call   1030 <cprint@plt>
movb   $0xa4,0xb8001
a4
movb   $0xa4,0xb801f
a4
lea    0xd04(%rip),%rdx
xor    %edi,%edi
mov    $0xf,%esi
call   1030 <cprint@plt>
movb   $0x71,0xf01(%r15,%rbx,2)
movb   $0x71,0xf03(%r15,%rbx,2)
movb   $0x71,0xf05(%r15,%rbx,2)
movb   $0x71,0xf07(%r15,%rbx,2)
movb   $0x71,0xf09(%r15,%rbx,2)
movb   $0x71,0xf0b(%r15,%rbx,2)
movb   $0x71,0xf0d(%r15,%rbx,2)
movb   $0x71,0xf0f(%r15,%rbx,2)
movb   $0x71,0xf11(%r15,%rbx,2)
movb   $0x71,0xf13(%r15,%rbx,2)
add    $0xa,%rbx
cmp    $0x50,%ebx
jne    1350 <display_init+0x210>
lea    0xc6b(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1060 <serial_echo_print@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"\1B[LINE_SCROLL;24r\00"
@.str.1 = [8 x i8] c"\1B[H\1B[2J\00"
@.str.2 = [11 x i8] c"\1B[37m\1B[44m\00"
@.str.3 = [5 x i8] c"\1B[0m\00"
@.str.4 = [30 x i8] c" Memtest86 5.01 \00"
@.str.5 = [2 x i8] c"+\00"
define void @display_init() {
%1 = alloca i32
%2 = alloca i8*
%3 = call i32 @__outb(i32 15, i32 980)
%4 = call i32 @__outb(i32 255, i32 981)
%5 = call i32 @__outb(i32 14, i32 980)
%6 = call i32 @__outb(i32 255, i32 981)
%7 = call i32 (...) @serial_echo_init()
%8 = call i32 @serial_echo_print(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @serial_echo_print(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @serial_echo_print(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @serial_echo_print(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @serial_echo_print(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
store i8* inttoptr (i64 753664 to i8*), i8** %2
br label %13
13: ; preds = %21, %0
%14 = load i32, i32* %1
%15 = icmp slt i32 %14, 1920
br i1 %15, label %16, label %24
16: ; preds = %13
%17 = load i8*, i8** %2
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %2
store volatile i8 32, i8* %17
%19 = load i8*, i8** %2
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %2
store volatile i8 23, i8* %19
br label %21
21: ; preds = %16
%22 = load i32, i32* %1
%23 = add nsw i32 %22, 1
store i32 %23, i32* %1
br label %13
24: ; preds = %13
store i32 0, i32* %1
store i8* inttoptr (i64 753665 to i8*), i8** %2
br label %25
25: ; preds = %30, %24
%26 = load i32, i32* %1
%27 = icmp slt i32 %26, 28
br i1 %27, label %28, label %35
28: ; preds = %25
%29 = load i8*, i8** %2
store volatile i8 32, i8* %29
br label %30
30: ; preds = %28
%31 = load i32, i32* %1
%32 = add nsw i32 %31, 1
store i32 %32, i32* %1
%33 = load i8*, i8** %2
%34 = getelementptr inbounds i8, i8* %33, i64 2
store i8* %34, i8** %2
br label %25
35: ; preds = %25
%36 = call i32 @cprint(i32 0, i32 0, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %1
store i8* inttoptr (i64 753665 to i8*), i8** %2
br label %37
37: ; preds = %42, %35
%38 = load i32, i32* %1
%39 = icmp slt i32 %38, 2
br i1 %39, label %40, label %47
40: ; preds = %37
%41 = load i8*, i8** %2
store volatile i8 -92, i8* %41
br label %42
42: ; preds = %40
%43 = load i32, i32* %1
%44 = add nsw i32 %43, 1
store i32 %44, i32* %1
%45 = load i8*, i8** %2
%46 = getelementptr inbounds i8, i8* %45, i64 30
store i8* %46, i8** %2
br label %37
47: ; preds = %37
%48 = call i32 @cprint(i32 0, i32 15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %1
store i8* inttoptr (i64 757505 to i8*), i8** %2
br label %49
49: ; preds = %54, %47
%50 = load i32, i32* %1
%51 = icmp slt i32 %50, 80
br i1 %51, label %52, label %59
52: ; preds = %49
%53 = load i8*, i8** %2
store volatile i8 113, i8* %53
br label %54
54: ; preds = %52
%55 = load i32, i32* %1
%56 = add nsw i32 %55, 1
store i32 %56, i32* %1
%57 = load i8*, i8** %2
%58 = getelementptr inbounds i8, i8* %57, i64 2
store i8* %58, i8** %2
br label %49
59: ; preds = %49
%60 = call i32 @serial_echo_print(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"\1B[LINE_SCROLL;24r\00"
@.str.1 = [8 x i8] c"\1B[H\1B[2J\00"
@.str.2 = [11 x i8] c"\1B[37m\1B[44m\00"
@.str.3 = [5 x i8] c"\1B[0m\00"
@.str.4 = [30 x i8] c" Memtest86 5.01 \00"
@.str.5 = [2 x i8] c"+\00"
define void @display_init() {
%1 = tail call i32 @__outb(i32 15, i32 980)
%2 = tail call i32 @__outb(i32 255, i32 981)
%3 = tail call i32 @__outb(i32 14, i32 980)
%4 = tail call i32 @__outb(i32 255, i32 981)
%5 = tail call i32 (...) @serial_echo_init()
%6 = tail call i32 @serial_echo_print(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @serial_echo_print(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 @serial_echo_print(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%9 = tail call i32 @serial_echo_print(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%10 = tail call i32 @serial_echo_print(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %11
11: ; preds = %11, %0
%12 = phi i8* [ inttoptr (i64 753664 to i8*), %0 ], [ %29, %11 ]
%13 = phi i32 [ 0, %0 ], [ %30, %11 ]
%14 = getelementptr inbounds i8, i8* %12, i64 1
store volatile i8 32, i8* %12
%15 = getelementptr inbounds i8, i8* %12, i64 2
store volatile i8 23, i8* %14
%16 = getelementptr inbounds i8, i8* %12, i64 3
store volatile i8 32, i8* %15
%17 = getelementptr inbounds i8, i8* %12, i64 4
store volatile i8 23, i8* %16
%18 = getelementptr inbounds i8, i8* %12, i64 5
store volatile i8 32, i8* %17
%19 = getelementptr inbounds i8, i8* %12, i64 6
store volatile i8 23, i8* %18
%20 = getelementptr inbounds i8, i8* %12, i64 7
store volatile i8 32, i8* %19
%21 = getelementptr inbounds i8, i8* %12, i64 8
store volatile i8 23, i8* %20
%22 = getelementptr inbounds i8, i8* %12, i64 9
store volatile i8 32, i8* %21
%23 = getelementptr inbounds i8, i8* %12, i64 10
store volatile i8 23, i8* %22
%24 = getelementptr inbounds i8, i8* %12, i64 11
store volatile i8 32, i8* %23
%25 = getelementptr inbounds i8, i8* %12, i64 12
store volatile i8 23, i8* %24
%26 = getelementptr inbounds i8, i8* %12, i64 13
store volatile i8 32, i8* %25
%27 = getelementptr inbounds i8, i8* %12, i64 14
store volatile i8 23, i8* %26
%28 = getelementptr inbounds i8, i8* %12, i64 15
store volatile i8 32, i8* %27
%29 = getelementptr inbounds i8, i8* %12, i64 16
store volatile i8 23, i8* %28
%30 = add nuw nsw i32 %13, 8
%31 = icmp eq i32 %30, 1920
br i1 %31, label %32, label %11
32: ; preds = %11
store volatile i8 32, i8* inttoptr (i64 753665 to i8*)
store volatile i8 32, i8* inttoptr (i64 753667 to i8*)
store volatile i8 32, i8* inttoptr (i64 753669 to i8*)
store volatile i8 32, i8* inttoptr (i64 753671 to i8*)
store volatile i8 32, i8* inttoptr (i64 753673 to i8*)
store volatile i8 32, i8* inttoptr (i64 753675 to i8*)
store volatile i8 32, i8* inttoptr (i64 753677 to i8*)
store volatile i8 32, i8* inttoptr (i64 753679 to i8*)
store volatile i8 32, i8* inttoptr (i64 753681 to i8*)
store volatile i8 32, i8* inttoptr (i64 753683 to i8*)
store volatile i8 32, i8* inttoptr (i64 753685 to i8*)
store volatile i8 32, i8* inttoptr (i64 753687 to i8*)
store volatile i8 32, i8* inttoptr (i64 753689 to i8*)
store volatile i8 32, i8* inttoptr (i64 753691 to i8*)
store volatile i8 32, i8* inttoptr (i64 753693 to i8*)
store volatile i8 32, i8* inttoptr (i64 753695 to i8*)
store volatile i8 32, i8* inttoptr (i64 753697 to i8*)
store volatile i8 32, i8* inttoptr (i64 753699 to i8*)
store volatile i8 32, i8* inttoptr (i64 753701 to i8*)
store volatile i8 32, i8* inttoptr (i64 753703 to i8*)
store volatile i8 32, i8* inttoptr (i64 753705 to i8*)
store volatile i8 32, i8* inttoptr (i64 753707 to i8*)
store volatile i8 32, i8* inttoptr (i64 753709 to i8*)
store volatile i8 32, i8* inttoptr (i64 753711 to i8*)
store volatile i8 32, i8* inttoptr (i64 753713 to i8*)
store volatile i8 32, i8* inttoptr (i64 753715 to i8*)
store volatile i8 32, i8* inttoptr (i64 753717 to i8*)
store volatile i8 32, i8* inttoptr (i64 753719 to i8*)
%33 = tail call i32 @cprint(i32 0, i32 0, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
store volatile i8 -92, i8* inttoptr (i64 753665 to i8*)
store volatile i8 -92, i8* inttoptr (i64 753695 to i8*)
%34 = tail call i32 @cprint(i32 0, i32 15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
br label %35
35: ; preds = %35, %32
%36 = phi i8* [ inttoptr (i64 757505 to i8*), %32 ], [ %48, %35 ]
%37 = phi i32 [ 0, %32 ], [ %47, %35 ]
store volatile i8 113, i8* %36
%38 = getelementptr inbounds i8, i8* %36, i64 2
store volatile i8 113, i8* %38
%39 = getelementptr inbounds i8, i8* %36, i64 4
store volatile i8 113, i8* %39
%40 = getelementptr inbounds i8, i8* %36, i64 6
store volatile i8 113, i8* %40
%41 = getelementptr inbounds i8, i8* %36, i64 8
store volatile i8 113, i8* %41
%42 = getelementptr inbounds i8, i8* %36, i64 10
store volatile i8 113, i8* %42
%43 = getelementptr inbounds i8, i8* %36, i64 12
store volatile i8 113, i8* %43
%44 = getelementptr inbounds i8, i8* %36, i64 14
store volatile i8 113, i8* %44
%45 = getelementptr inbounds i8, i8* %36, i64 16
store volatile i8 113, i8* %45
%46 = getelementptr inbounds i8, i8* %36, i64 18
store volatile i8 113, i8* %46
%47 = add nuw nsw i32 %37, 10
%48 = getelementptr inbounds i8, i8* %36, i64 20
%49 = icmp eq i32 %47, 80
br i1 %49, label %50, label %35
50: ; preds = %35
%51 = tail call i32 @serial_echo_print(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
ret void
}