#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*/ demo_res(int, int, int);
int /*<<< orphan*/ dos_print(char *);
int /*<<< orphan*/ init_random();
int /*<<< orphan*/ load_shapes();
int /*<<< orphan*/ page_demo();
int /*<<< orphan*/ set_video_mode(int);
int main(int argc, char *argv[]) {
  init_random();
  load_shapes();
  demo_res(0, 320, 200);
  demo_res(1, 320, 400);
  demo_res(2, 360, 200);
  demo_res(3, 360, 400);
  demo_res(4, 320, 240);
  demo_res(5, 320, 480);
  demo_res(6, 360, 240);
  demo_res(7, 360, 480);
  page_demo();
  set_video_mode(3);
  dos_print("This Mode X Demo is Finished");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1030 <init_random@plt>
mov    $0x0,%al
call   1080 <load_shapes@plt>
xor    %edi,%edi
mov    $0x140,%esi
mov    $0xc8,%edx
call   1050 <demo_res@plt>
mov    $0x1,%edi
mov    $0x140,%esi
mov    $0x190,%edx
call   1050 <demo_res@plt>
mov    $0x2,%edi
mov    $0x168,%esi
mov    $0xc8,%edx
call   1050 <demo_res@plt>
mov    $0x3,%edi
mov    $0x168,%esi
mov    $0x190,%edx
call   1050 <demo_res@plt>
mov    $0x4,%edi
mov    $0x140,%esi
mov    $0xf0,%edx
call   1050 <demo_res@plt>
mov    $0x5,%edi
mov    $0x140,%esi
mov    $0x1e0,%edx
call   1050 <demo_res@plt>
mov    $0x6,%edi
mov    $0x168,%esi
mov    $0xf0,%edx
call   1050 <demo_res@plt>
mov    $0x7,%edi
mov    $0x168,%esi
mov    $0x1e0,%edx
call   1050 <demo_res@plt>
mov    $0x0,%al
call   1060 <page_demo@plt>
mov    $0x3,%edi
call   1070 <set_video_mode@plt>
lea    0xdc7(%rip),%rdi
call   1040 <dos_print@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1030 <init_random@plt>
xor    %eax,%eax
call   1080 <load_shapes@plt>
xor    %edi,%edi
mov    $0x140,%esi
mov    $0xc8,%edx
call   1050 <demo_res@plt>
mov    $0x1,%edi
mov    $0x140,%esi
mov    $0x190,%edx
call   1050 <demo_res@plt>
mov    $0x2,%edi
mov    $0x168,%esi
mov    $0xc8,%edx
call   1050 <demo_res@plt>
mov    $0x3,%edi
mov    $0x168,%esi
mov    $0x190,%edx
call   1050 <demo_res@plt>
mov    $0x4,%edi
mov    $0x140,%esi
mov    $0xf0,%edx
call   1050 <demo_res@plt>
mov    $0x5,%edi
mov    $0x140,%esi
mov    $0x1e0,%edx
call   1050 <demo_res@plt>
mov    $0x6,%edi
mov    $0x168,%esi
mov    $0xf0,%edx
call   1050 <demo_res@plt>
mov    $0x7,%edi
mov    $0x168,%esi
mov    $0x1e0,%edx
call   1050 <demo_res@plt>
xor    %eax,%eax
call   1060 <page_demo@plt>
mov    $0x3,%edi
call   1070 <set_video_mode@plt>
lea    0xddc(%rip),%rdi
call   1040 <dos_print@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [29 x i8] c"This Mode X Demo is Finished\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = call i32 (...) @init_random()
%7 = call i32 (...) @load_shapes()
%8 = call i32 @demo_res(i32 0, i32 320, i32 200)
%9 = call i32 @demo_res(i32 1, i32 320, i32 400)
%10 = call i32 @demo_res(i32 2, i32 360, i32 200)
%11 = call i32 @demo_res(i32 3, i32 360, i32 400)
%12 = call i32 @demo_res(i32 4, i32 320, i32 240)
%13 = call i32 @demo_res(i32 5, i32 320, i32 480)
%14 = call i32 @demo_res(i32 6, i32 360, i32 240)
%15 = call i32 @demo_res(i32 7, i32 360, i32 480)
%16 = call i32 (...) @page_demo()
%17 = call i32 @set_video_mode(i32 3)
%18 = call i32 @dos_print(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"This Mode X Demo is Finished\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @init_random()
%4 = tail call i32 (...) @load_shapes()
%5 = tail call i32 @demo_res(i32 0, i32 320, i32 200)
%6 = tail call i32 @demo_res(i32 1, i32 320, i32 400)
%7 = tail call i32 @demo_res(i32 2, i32 360, i32 200)
%8 = tail call i32 @demo_res(i32 3, i32 360, i32 400)
%9 = tail call i32 @demo_res(i32 4, i32 320, i32 240)
%10 = tail call i32 @demo_res(i32 5, i32 320, i32 480)
%11 = tail call i32 @demo_res(i32 6, i32 360, i32 240)
%12 = tail call i32 @demo_res(i32 7, i32 360, i32 480)
%13 = tail call i32 (...) @page_demo()
%14 = tail call i32 @set_video_mode(i32 3)
%15 = tail call i32 @dos_print(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
ret i32 0
}