#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*/ 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;
  serial_echo_init();
  serial_echo_print("\x1B[LINE_SCROLL;24r");
  serial_echo_print("\x1B[H\x1B[2J");
  serial_echo_print("\x1B[37m\x1B[44m");
  serial_echo_print("\x1B[0m");
  serial_echo_print("\x1B[37m\x1B[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  v4.20      ");
  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("\x1B[0m");
}


x86 assembly (clang, -O0):
<display_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <serial_echo_init@plt>
lea    0xeba(%rip),%rdi
call   1050 <serial_echo_print@plt>
lea    0xec0(%rip),%rdi
call   1050 <serial_echo_print@plt>
lea    0xebc(%rip),%rdi
call   1050 <serial_echo_print@plt>
lea    0xebb(%rip),%rdi
call   1050 <serial_echo_print@plt>
lea    0xea4(%rip),%rdi
call   1050 <serial_echo_print@plt>
movl   $0x0,-0x4(%rbp)
mov    $0xb8000,%eax
mov    %rax,-0x10(%rbp)
cmpl   $0x780,-0x4(%rbp)
jge    11ca <display_init+0x9a>
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    118b <display_init+0x5b>
movl   $0x0,-0x4(%rbp)
mov    $0xb8001,%eax
mov    %rax,-0x10(%rbp)
cmpl   $0x1c,-0x4(%rbp)
jge    1205 <display_init+0xd5>
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    11da <display_init+0xaa>
xor    %esi,%esi
lea    0xe1c(%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    1250 <display_init+0x120>
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    1225 <display_init+0xf5>
xor    %edi,%edi
mov    $0xf,%esi
lea    0xde9(%rip),%rdx
call   1030 <cprint@plt>
movl   $0x0,-0x4(%rbp)
mov    $0xb8f01,%eax
mov    %rax,-0x10(%rbp)
cmpl   $0x50,-0x4(%rbp)
jge    129e <display_init+0x16e>
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    1273 <display_init+0x143>
lea    0xd80(%rip),%rdi
call   1050 <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
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <serial_echo_init@plt>
lea    0xeb5(%rip),%rdi
call   1050 <serial_echo_print@plt>
lea    0xebb(%rip),%rdi
call   1050 <serial_echo_print@plt>
lea    0xeb7(%rip),%r14
mov    %r14,%rdi
call   1050 <serial_echo_print@plt>
lea    0xeb3(%rip),%rdi
call   1050 <serial_echo_print@plt>
mov    %r14,%rdi
call   1050 <serial_echo_print@plt>
nop
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    1180 <display_init+0x50>
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    0xd58(%rip),%rdx
xor    %ebx,%ebx
xor    %edi,%edi
xor    %esi,%esi
call   1030 <cprint@plt>
movb   $0xa4,0xb8001
a4
movb   $0xa4,0xb801f
a4
lea    0xd53(%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    1300 <display_init+0x1d0>
lea    0xcbb(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <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 = [29 x i8] c" Memtest86 v4.20 \00"
@.str.5 = [2 x i8] c"+\00"
define void @display_init() {
%1 = alloca i32
%2 = alloca i8*
%3 = call i32 (...) @serial_echo_init()
%4 = call i32 @serial_echo_print(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @serial_echo_print(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @serial_echo_print(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @serial_echo_print(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%8 = 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 %9
9: ; preds = %17, %0
%10 = load i32, i32* %1
%11 = icmp slt i32 %10, 1920
br i1 %11, label %12, label %20
12: ; preds = %9
%13 = load i8*, i8** %2
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %2
store volatile i8 32, i8* %13
%15 = load i8*, i8** %2
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %2
store volatile i8 23, i8* %15
br label %17
17: ; preds = %12
%18 = load i32, i32* %1
%19 = add nsw i32 %18, 1
store i32 %19, i32* %1
br label %9
20: ; preds = %9
store i32 0, i32* %1
store i8* inttoptr (i64 753665 to i8*), i8** %2
br label %21
21: ; preds = %26, %20
%22 = load i32, i32* %1
%23 = icmp slt i32 %22, 28
br i1 %23, label %24, label %31
24: ; preds = %21
%25 = load i8*, i8** %2
store volatile i8 32, i8* %25
br label %26
26: ; preds = %24
%27 = load i32, i32* %1
%28 = add nsw i32 %27, 1
store i32 %28, i32* %1
%29 = load i8*, i8** %2
%30 = getelementptr inbounds i8, i8* %29, i64 2
store i8* %30, i8** %2
br label %21
31: ; preds = %21
%32 = call i32 @cprint(i32 0, i32 0, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %1
store i8* inttoptr (i64 753665 to i8*), i8** %2
br label %33
33: ; preds = %38, %31
%34 = load i32, i32* %1
%35 = icmp slt i32 %34, 2
br i1 %35, label %36, label %43
36: ; preds = %33
%37 = load i8*, i8** %2
store volatile i8 -92, i8* %37
br label %38
38: ; preds = %36
%39 = load i32, i32* %1
%40 = add nsw i32 %39, 1
store i32 %40, i32* %1
%41 = load i8*, i8** %2
%42 = getelementptr inbounds i8, i8* %41, i64 30
store i8* %42, i8** %2
br label %33
43: ; preds = %33
%44 = 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 %45
45: ; preds = %50, %43
%46 = load i32, i32* %1
%47 = icmp slt i32 %46, 80
br i1 %47, label %48, label %55
48: ; preds = %45
%49 = load i8*, i8** %2
store volatile i8 113, i8* %49
br label %50
50: ; preds = %48
%51 = load i32, i32* %1
%52 = add nsw i32 %51, 1
store i32 %52, i32* %1
%53 = load i8*, i8** %2
%54 = getelementptr inbounds i8, i8* %53, i64 2
store i8* %54, i8** %2
br label %45
55: ; preds = %45
%56 = 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 = [29 x i8] c" Memtest86 v4.20 \00"
@.str.5 = [2 x i8] c"+\00"
define void @display_init() {
%1 = tail call i32 (...) @serial_echo_init()
%2 = tail call i32 @serial_echo_print(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @serial_echo_print(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%4 = tail call i32 @serial_echo_print(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%5 = tail call i32 @serial_echo_print(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
%6 = tail call i32 @serial_echo_print(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
br label %7
7: ; preds = %7, %0
%8 = phi i8* [ inttoptr (i64 753664 to i8*), %0 ], [ %25, %7 ]
%9 = phi i32 [ 0, %0 ], [ %26, %7 ]
%10 = getelementptr inbounds i8, i8* %8, i64 1
store volatile i8 32, i8* %8
%11 = getelementptr inbounds i8, i8* %8, i64 2
store volatile i8 23, i8* %10
%12 = getelementptr inbounds i8, i8* %8, i64 3
store volatile i8 32, i8* %11
%13 = getelementptr inbounds i8, i8* %8, i64 4
store volatile i8 23, i8* %12
%14 = getelementptr inbounds i8, i8* %8, i64 5
store volatile i8 32, i8* %13
%15 = getelementptr inbounds i8, i8* %8, i64 6
store volatile i8 23, i8* %14
%16 = getelementptr inbounds i8, i8* %8, i64 7
store volatile i8 32, i8* %15
%17 = getelementptr inbounds i8, i8* %8, i64 8
store volatile i8 23, i8* %16
%18 = getelementptr inbounds i8, i8* %8, i64 9
store volatile i8 32, i8* %17
%19 = getelementptr inbounds i8, i8* %8, i64 10
store volatile i8 23, i8* %18
%20 = getelementptr inbounds i8, i8* %8, i64 11
store volatile i8 32, i8* %19
%21 = getelementptr inbounds i8, i8* %8, i64 12
store volatile i8 23, i8* %20
%22 = getelementptr inbounds i8, i8* %8, i64 13
store volatile i8 32, i8* %21
%23 = getelementptr inbounds i8, i8* %8, i64 14
store volatile i8 23, i8* %22
%24 = getelementptr inbounds i8, i8* %8, i64 15
store volatile i8 32, i8* %23
%25 = getelementptr inbounds i8, i8* %8, i64 16
store volatile i8 23, i8* %24
%26 = add nuw nsw i32 %9, 8
%27 = icmp eq i32 %26, 1920
br i1 %27, label %28, label %7
28: ; preds = %7
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*)
%29 = tail call i32 @cprint(i32 0, i32 0, i8* getelementptr inbounds ([29 x i8], [29 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*)
%30 = 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 %31
31: ; preds = %31, %28
%32 = phi i8* [ inttoptr (i64 757505 to i8*), %28 ], [ %44, %31 ]
%33 = phi i32 [ 0, %28 ], [ %43, %31 ]
store volatile i8 113, i8* %32
%34 = getelementptr inbounds i8, i8* %32, i64 2
store volatile i8 113, i8* %34
%35 = getelementptr inbounds i8, i8* %32, i64 4
store volatile i8 113, i8* %35
%36 = getelementptr inbounds i8, i8* %32, i64 6
store volatile i8 113, i8* %36
%37 = getelementptr inbounds i8, i8* %32, i64 8
store volatile i8 113, i8* %37
%38 = getelementptr inbounds i8, i8* %32, i64 10
store volatile i8 113, i8* %38
%39 = getelementptr inbounds i8, i8* %32, i64 12
store volatile i8 113, i8* %39
%40 = getelementptr inbounds i8, i8* %32, i64 14
store volatile i8 113, i8* %40
%41 = getelementptr inbounds i8, i8* %32, i64 16
store volatile i8 113, i8* %41
%42 = getelementptr inbounds i8, i8* %32, i64 18
store volatile i8 113, i8* %42
%43 = add nuw nsw i32 %33, 10
%44 = getelementptr inbounds i8, i8* %32, i64 20
%45 = icmp eq i32 %43, 80
br i1 %45, label %46, label %31
46: ; preds = %31
%47 = tail call i32 @serial_echo_print(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
ret void
}