#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*/ SlowEffect(int, int);
int inportb(int);
int /*<<< orphan*/ printString(char *);
void main() {
  int anim = 0;
  printString("VESA Video Driver Demo\n");
  printString("Hello,World!\n");
  while (1) {
    while ((inportb(0x3DA) & 0x08))
      ;
    while (!(inportb(0x3DA) & 0x08))
      ;
    for (int x = 300; x < 600; x++)
      for (int y = 300; y < 600; y++) {
        if ((450 - x) * (450 - x) + (450 - y) * (450 - y) < anim * anim)
          SlowEffect(1024 * y + x, 0x2281337);
        else
          SlowEffect(1024 * y + x, 0x0);
      }
    anim++;
    anim %= 100;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1030 <printString@plt>
lea    0xec6(%rip),%rdi
call   1030 <printString@plt>
jmp    115c <main+0x2c>
mov    $0x3da,%edi
call   1050 <inportb@plt>
and    $0x8,%eax
cmp    $0x0,%eax
je     1177 <main+0x47>
jmp    115c <main+0x2c>
jmp    117c <main+0x4c>
mov    $0x3da,%edi
call   1050 <inportb@plt>
and    $0x8,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    119e <main+0x6e>
jmp    11a3 <main+0x73>
jmp    117c <main+0x4c>
movl   $0x12c,-0x8(%rbp)
cmpl   $0x258,-0x8(%rbp)
jge    1250 <main+0x120>
movl   $0x12c,-0xc(%rbp)
cmpl   $0x258,-0xc(%rbp)
jge    123d <main+0x10d>
mov    $0x1c2,%eax
sub    -0x8(%rbp),%eax
mov    $0x1c2,%ecx
sub    -0x8(%rbp),%ecx
imul   %ecx,%eax
mov    $0x1c2,%ecx
sub    -0xc(%rbp),%ecx
mov    $0x1c2,%edx
sub    -0xc(%rbp),%edx
imul   %edx,%ecx
add    %ecx,%eax
mov    -0x4(%rbp),%ecx
imul   -0x4(%rbp),%ecx
cmp    %ecx,%eax
jge    121a <main+0xea>
mov    -0xc(%rbp),%edi
shl    $0xa,%edi
add    -0x8(%rbp),%edi
mov    $0x2281337,%esi
call   1040 <SlowEffect@plt>
jmp    122a <main+0xfa>
mov    -0xc(%rbp),%edi
shl    $0xa,%edi
add    -0x8(%rbp),%edi
xor    %esi,%esi
call   1040 <SlowEffect@plt>
jmp    122f <main+0xff>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11be <main+0x8e>
jmp    1242 <main+0x112>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11aa <main+0x7a>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x4(%rbp)
jmp    1157 <main+0x27>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xebe(%rip),%rdi
call   1030 <printString@plt>
lea    0xeca(%rip),%rdi
call   1030 <printString@plt>
xor    %ebx,%ebx
jmp    1180 <main+0x50>
mov    (%rsp),%rbx
add    $0x1,%ebx
movslq %ebx,%rbx
imul   $0x51eb851f,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
sub    %eax,%ebx
nopw   0x0(%rax,%rax,1)
mov    $0x3da,%edi
call   1050 <inportb@plt>
test   $0x8,%al
jne    1180 <main+0x50>
xchg   %ax,%ax
mov    $0x3da,%edi
call   1050 <inportb@plt>
test   $0x8,%al
je     1190 <main+0x60>
mov    %rbx,(%rsp)
mov    %ebx,%r13d
imul   %ebx,%r13d
mov    $0x12c,%r15d
mov    $0x4b12c,%r12d
jmp    11d1 <main+0xa1>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r15d
add    $0x1,%r12d
cmp    $0x258,%r15d
je     1157 <main+0x27>
mov    $0x1c2,%ebp
sub    %r15d,%ebp
imul   %ebp,%ebp
mov    $0x96,%r14d
mov    %r12d,%ebx
jmp    120a <main+0xda>
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
call   1040 <SlowEffect@plt>
add    $0x400,%ebx
add    $0xffffffff,%r14d
cmp    $0xffffff6a,%r14d
je     11c0 <main+0x90>
mov    %r14d,%eax
imul   %r14d,%eax
add    %ebp,%eax
mov    $0x2281337,%esi
cmp    %r13d,%eax
jb     11f0 <main+0xc0>
xor    %esi,%esi
jmp    11f0 <main+0xc0>

LLVM IR (-O0):
@.str = [24 x i8] c"VESA Video Driver Demo\0A\00"
@.str.1 = [14 x i8] c"Hello,World!\0A\00"
define void @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @printString(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @printString(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %6
6: ; preds = %0, %63
br label %7
7: ; preds = %11, %6
%8 = call i32 @inportb(i32 986)
%9 = and i32 %8, 8
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %7
br label %7
12: ; preds = %7
br label %13
13: ; preds = %18, %12
%14 = call i32 @inportb(i32 986)
%15 = and i32 %14, 8
%16 = icmp ne i32 %15, 0
%17 = xor i1 %16, true
br i1 %17, label %18, label %19
18: ; preds = %13
br label %13
19: ; preds = %13
store i32 300, i32* %2
br label %20
20: ; preds = %60, %19
%21 = load i32, i32* %2
%22 = icmp slt i32 %21, 600
br i1 %22, label %23, label %63
23: ; preds = %20
store i32 300, i32* %3
br label %24
24: ; preds = %56, %23
%25 = load i32, i32* %3
%26 = icmp slt i32 %25, 600
br i1 %26, label %27, label %59
27: ; preds = %24
%28 = load i32, i32* %2
%29 = sub nsw i32 450, %28
%30 = load i32, i32* %2
%31 = sub nsw i32 450, %30
%32 = mul nsw i32 %29, %31
%33 = load i32, i32* %3
%34 = sub nsw i32 450, %33
%35 = load i32, i32* %3
%36 = sub nsw i32 450, %35
%37 = mul nsw i32 %34, %36
%38 = add nsw i32 %32, %37
%39 = load i32, i32* %1
%40 = load i32, i32* %1
%41 = mul nsw i32 %39, %40
%42 = icmp slt i32 %38, %41
br i1 %42, label %43, label %49
43: ; preds = %27
%44 = load i32, i32* %3
%45 = mul nsw i32 1024, %44
%46 = load i32, i32* %2
%47 = add nsw i32 %45, %46
%48 = call i32 @SlowEffect(i32 %47, i32 36180791)
br label %55
49: ; preds = %27
%50 = load i32, i32* %3
%51 = mul nsw i32 1024, %50
%52 = load i32, i32* %2
%53 = add nsw i32 %51, %52
%54 = call i32 @SlowEffect(i32 %53, i32 0)
br label %55
55: ; preds = %49, %43
br label %56
56: ; preds = %55
%57 = load i32, i32* %3
%58 = add nsw i32 %57, 1
store i32 %58, i32* %3
br label %24
59: ; preds = %24
br label %60
60: ; preds = %59
%61 = load i32, i32* %2
%62 = add nsw i32 %61, 1
store i32 %62, i32* %2
br label %20
63: ; preds = %20
%64 = load i32, i32* %1
%65 = add nsw i32 %64, 1
store i32 %65, i32* %1
%66 = load i32, i32* %1
%67 = srem i32 %66, 100
store i32 %67, i32* %1
br label %6
}

LLVM IR (-O2):
@.str = [24 x i8] c"VESA Video Driver Demo\0A\00"
@.str.1 = [14 x i8] c"Hello,World!\0A\00"
define void @main() {
%1 = tail call i32 @printString(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @printString(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %3
3: ; preds = %19, %0
%4 = phi i32 [ 0, %0 ], [ %21, %19 ]
br label %5
5: ; preds = %5, %3
%6 = tail call i32 @inportb(i32 986)
%7 = and i32 %6, 8
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %5
9: ; preds = %5, %9
%10 = tail call i32 @inportb(i32 986)
%11 = and i32 %10, 8
%12 = icmp eq i32 %11, 0
br i1 %12, label %9, label %13
13: ; preds = %9
%14 = mul nsw i32 %4, %4
br label %15
15: ; preds = %13, %22
%16 = phi i32 [ 300, %13 ], [ %23, %22 ]
%17 = sub nsw i32 450, %16
%18 = mul nsw i32 %17, %17
br label %25
19: ; preds = %22
%20 = add nsw i32 %4, 1
%21 = srem i32 %20, 100
br label %3
22: ; preds = %25
%23 = add nuw nsw i32 %16, 1
%24 = icmp eq i32 %23, 600
br i1 %24, label %19, label %15
25: ; preds = %15, %25
%26 = phi i32 [ 300, %15 ], [ %35, %25 ]
%27 = sub nsw i32 450, %26
%28 = mul nsw i32 %27, %27
%29 = add nuw nsw i32 %28, %18
%30 = icmp ult i32 %29, %14
%31 = shl nuw nsw i32 %26, 10
%32 = add nuw nsw i32 %31, %16
%33 = select i1 %30, i32 36180791, i32 0
%34 = tail call i32 @SlowEffect(i32 %32, i32 %33)
%35 = add nuw nsw i32 %26, 1
%36 = icmp eq i32 %35, 600
br i1 %36, label %22, label %25
}