#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*/ draw_line(int, int, int, int, int);
int /*<<< orphan*/ error_out(char *);
int /*<<< orphan*/ fill_block(int, int, int, int, int);
int get_key();
int /*<<< orphan*/ print_str(char *, int, int, int, int, int);
int read_point(int, int);
int /*<<< orphan*/ set_dac_register(int, int, int, int);
scalar_t__ set_modex(int);
int /*<<< orphan*/ set_point(int, int, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ tgprintc(int, int, int, int);
int /*<<< orphan*/ tprint_str(char *, int, int, int, int);
void demo_res(int Screen_Mode, int X_max, int Y_max) {
  char *Error1 = "Failure while calling SET_MODEX";
  char *Error2 = "Failure during READ_PIXEL test";
  char *Abort_Msg = "Demo aborted by User";
  char *Demo_Msg = " This is a MODE X demo ";
  char *Scrn_Msg = "Screen Resolution is     by    ";
  char *Cont_Msg = "Press <ANY KEY> to Continue";
  char *Line_Msg = "LINE TEST";
  char *Fill_Msg = "FILL TEST";
  char *Pixel_Msg = "PIXEL TEST";
  char Text[10];
  int x1, y1, x2, y2 = 0;
  int x, y, z = 0;
  int X_Center, gap = 0;
  if (set_modex(Screen_Mode) == 0) {
    error_out(Error1);
  }
  X_Center = X_max / 2;
  x1 = 10;
  y1 = 10;
  x2 = X_max - 1;
  y2 = Y_max - 1;
  for (z = 0; z <= 3; z++) {
    y = 31 - z - z;
    draw_line(x1 + z, y1 + z, x2 - z, y1 + z, y);
    draw_line(x1 + z, y1 + z, x1 + z, y2 - z, y);
    draw_line(x1 + z, y2 - z, x2 - z, y2 - z, y);
    draw_line(x2 - z, y1 + z, x2 - z, y2 - z, y);
  }
  for (x = 0; x < (X_max / 10); x++) {
    tgprintc(48 + ((x + 1) % 10), x * 10 + 1, 1, 9 + ((x / 8) % 7));
    draw_line(x * 10 + 9, 0, x * 10 + 9, 3, 15);
  }
  for (y = 0; y < (Y_max / 10); y++) {
    tgprintc(48 + ((y + 1) % 10), 1, y * 10 + 1, 9 + ((y / 10) % 7));
    draw_line(0, y * 10 + 9, 3, y * 10 + 9, 15);
  }
  for (x = 0; x <= 63; x++) {
    z = 15 + (x * 3 / 4);
    set_dac_register(64 + x, z, z, z);
    set_dac_register(128 + x, 0, z, z);
    draw_line(103 - x, 60, 40 + x, 123, 64 + x);
    draw_line(40, 60 + x, 103, 123 - x, 128 + x);
  }
  tprint_str(Line_Msg, 9, 37, 130, 1);
  y = 60;
  gap = 0;
  for (x = 0; x <= 9; x++) {
    fill_block(120, y, 120 + x, y + gap, 64 + x);
    fill_block(140 - (15 - x), y, 150 + x, y + gap, 230 + x);
    fill_block(170 - (15 - x), y, 170, y + gap, 128 + x);
    y = y + gap + 2;
    gap++;
  }
  tprint_str(Fill_Msg, 9, 110, 46, 2);
  for (x = 190; x <= 250; x += 2) {
    for (y = 60; y <= 122; y += 2) {
      z = (x + x + y + y) & 0xff;
      set_point(x, y, z);
    }
  }
  tprint_str(Pixel_Msg, 10, 182, 130, 4);
  for (x = 190; x <= 250; x += 2) {
    for (y = 60; y <= 122; y += 2) {
      z = (x + x + y + y) & 0xff;
      if (read_point(x, y) != z) {
        error_out(Error2);
      }
    }
  }
  print_str(Demo_Msg, 23, X_Center - 92, 20, 12, 1);
  x = X_Center - 124;
  print_str(Scrn_Msg, 28, x, 30, 10, 0);
  sprintf(Text, "%3d", X_max);
  print_str(Text, 3, x + 168, 30, 13, 0);
  sprintf(Text, "%3d", Y_max);
  print_str(Text, 3, x + 224, 30, 15, 0);
  for (x = 0; x <= 15; x++) {
    set_dac_register(230 + x, 63 - x * 4, 0, 15 + x * 3);
    draw_line(30 + x, Y_max - 6 - x, X_max - 20 - x, Y_max - 6 - x, 230 + x);
  }
  tprint_str(Cont_Msg, 27, X_Center - 103, Y_max - 18, 14);
  if (get_key() == 0x001B) {
    error_out(Abort_Msg);
  }
  return;
}


x86 assembly (clang, -O0):
<demo_res>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
lea    0xe25(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xe3a(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xe4e(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xe58(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xe65(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xe7a(%rip),%rax
mov    %rax,-0x40(%rbp)
lea    0xe8b(%rip),%rax
mov    %rax,-0x48(%rbp)
lea    0xe8a(%rip),%rax
mov    %rax,-0x50(%rbp)
lea    0xe89(%rip),%rax
mov    %rax,-0x58(%rbp)
movl   $0x0,-0x74(%rbp)
movl   $0x0,-0x80(%rbp)
movl   $0x0,-0x88(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <set_modex@plt>
cmp    $0x0,%rax
jne    126a <demo_res+0xaa>
mov    -0x18(%rbp),%rdi
call   1080 <error_out@plt>
mov    -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x84(%rbp)
movl   $0xa,-0x68(%rbp)
movl   $0xa,-0x6c(%rbp)
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x70(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x74(%rbp)
movl   $0x0,-0x80(%rbp)
cmpl   $0x3,-0x80(%rbp)
jg     134c <demo_res+0x18c>
mov    $0x1f,%eax
sub    -0x80(%rbp),%eax
sub    -0x80(%rbp),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x68(%rbp),%edi
add    -0x80(%rbp),%edi
mov    -0x6c(%rbp),%esi
add    -0x80(%rbp),%esi
mov    -0x70(%rbp),%edx
sub    -0x80(%rbp),%edx
mov    -0x6c(%rbp),%ecx
add    -0x80(%rbp),%ecx
mov    -0x7c(%rbp),%r8d
call   1070 <draw_line@plt>
mov    -0x68(%rbp),%edi
add    -0x80(%rbp),%edi
mov    -0x6c(%rbp),%esi
add    -0x80(%rbp),%esi
mov    -0x68(%rbp),%edx
add    -0x80(%rbp),%edx
mov    -0x74(%rbp),%ecx
sub    -0x80(%rbp),%ecx
mov    -0x7c(%rbp),%r8d
call   1070 <draw_line@plt>
mov    -0x68(%rbp),%edi
add    -0x80(%rbp),%edi
mov    -0x74(%rbp),%esi
sub    -0x80(%rbp),%esi
mov    -0x70(%rbp),%edx
sub    -0x80(%rbp),%edx
mov    -0x74(%rbp),%ecx
sub    -0x80(%rbp),%ecx
mov    -0x7c(%rbp),%r8d
call   1070 <draw_line@plt>
mov    -0x70(%rbp),%edi
sub    -0x80(%rbp),%edi
mov    -0x6c(%rbp),%esi
add    -0x80(%rbp),%esi
mov    -0x70(%rbp),%edx
sub    -0x80(%rbp),%edx
mov    -0x74(%rbp),%ecx
sub    -0x80(%rbp),%ecx
mov    -0x7c(%rbp),%r8d
call   1070 <draw_line@plt>
mov    -0x80(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x80(%rbp)
jmp    12a2 <demo_res+0xe2>
movl   $0x0,-0x78(%rbp)
mov    -0x78(%rbp),%eax
mov    %eax,-0x8c(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x8c(%rbp),%eax
cmp    %ecx,%eax
jge    13e1 <demo_res+0x221>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
add    $0x30,%edi
imul   $0xa,-0x78(%rbp),%esi
add    $0x1,%esi
mov    -0x78(%rbp),%eax
mov    $0x8,%ecx
cltd
idiv   %ecx
mov    $0x7,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
add    $0x9,%ecx
mov    $0x1,%edx
call   1090 <tgprintc@plt>
imul   $0xa,-0x78(%rbp),%edi
add    $0x9,%edi
imul   $0xa,-0x78(%rbp),%edx
add    $0x9,%edx
xor    %esi,%esi
mov    $0x3,%ecx
mov    $0xf,%r8d
call   1070 <draw_line@plt>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    1353 <demo_res+0x193>
movl   $0x0,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
mov    %eax,-0x90(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x90(%rbp),%eax
cmp    %ecx,%eax
jge    1482 <demo_res+0x2c2>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
add    $0x30,%edi
imul   $0xa,-0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
mov    -0x7c(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    $0x7,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
mov    -0x94(%rbp),%edx
add    $0x9,%ecx
mov    $0x1,%esi
call   1090 <tgprintc@plt>
imul   $0xa,-0x7c(%rbp),%esi
add    $0x9,%esi
imul   $0xa,-0x7c(%rbp),%ecx
add    $0x9,%ecx
xor    %edi,%edi
mov    $0x3,%edx
mov    $0xf,%r8d
call   1070 <draw_line@plt>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    13e8 <demo_res+0x228>
movl   $0x0,-0x78(%rbp)
cmpl   $0x3f,-0x78(%rbp)
jg     152a <demo_res+0x36a>
imul   $0x3,-0x78(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
add    $0xf,%eax
mov    %eax,-0x80(%rbp)
mov    -0x78(%rbp),%edi
add    $0x40,%edi
mov    -0x80(%rbp),%esi
mov    -0x80(%rbp),%edx
mov    -0x80(%rbp),%ecx
call   10c0 <set_dac_register@plt>
mov    -0x78(%rbp),%edi
add    $0x80,%edi
mov    -0x80(%rbp),%edx
mov    -0x80(%rbp),%ecx
xor    %esi,%esi
call   10c0 <set_dac_register@plt>
mov    $0x67,%edi
sub    -0x78(%rbp),%edi
mov    -0x78(%rbp),%edx
add    $0x28,%edx
mov    -0x78(%rbp),%r8d
add    $0x40,%r8d
mov    $0x3c,%esi
mov    $0x7b,%ecx
call   1070 <draw_line@plt>
mov    -0x78(%rbp),%esi
add    $0x3c,%esi
mov    $0x7b,%ecx
sub    -0x78(%rbp),%ecx
mov    -0x78(%rbp),%r8d
add    $0x80,%r8d
mov    $0x28,%edi
mov    $0x67,%edx
call   1070 <draw_line@plt>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    1489 <demo_res+0x2c9>
mov    -0x48(%rbp),%rdi
mov    $0x9,%esi
mov    $0x25,%edx
mov    $0x82,%ecx
mov    $0x1,%r8d
call   1040 <tprint_str@plt>
movl   $0x3c,-0x7c(%rbp)
movl   $0x0,-0x88(%rbp)
movl   $0x0,-0x78(%rbp)
cmpl   $0x9,-0x78(%rbp)
jg     161e <demo_res+0x45e>
mov    -0x7c(%rbp),%esi
mov    -0x78(%rbp),%edx
add    $0x78,%edx
mov    -0x7c(%rbp),%ecx
add    -0x88(%rbp),%ecx
mov    -0x78(%rbp),%r8d
add    $0x40,%r8d
mov    $0x78,%edi
call   10d0 <fill_block@plt>
mov    $0xf,%eax
sub    -0x78(%rbp),%eax
mov    $0x8c,%edi
sub    %eax,%edi
mov    -0x7c(%rbp),%esi
mov    -0x78(%rbp),%edx
add    $0x96,%edx
mov    -0x7c(%rbp),%ecx
add    -0x88(%rbp),%ecx
mov    -0x78(%rbp),%r8d
add    $0xe6,%r8d
call   10d0 <fill_block@plt>
mov    $0xf,%eax
sub    -0x78(%rbp),%eax
mov    $0xaa,%edi
sub    %eax,%edi
mov    -0x7c(%rbp),%esi
mov    -0x7c(%rbp),%ecx
add    -0x88(%rbp),%ecx
mov    -0x78(%rbp),%r8d
add    $0x80,%r8d
mov    $0xaa,%edx
call   10d0 <fill_block@plt>
mov    -0x7c(%rbp),%eax
add    -0x88(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x7c(%rbp)
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    1560 <demo_res+0x3a0>
mov    -0x50(%rbp),%rdi
mov    $0x9,%esi
mov    $0x6e,%edx
mov    $0x2e,%ecx
mov    $0x2,%r8d
call   1040 <tprint_str@plt>
movl   $0xbe,-0x78(%rbp)
cmpl   $0xfa,-0x78(%rbp)
jg     16a4 <demo_res+0x4e4>
movl   $0x3c,-0x7c(%rbp)
cmpl   $0x7a,-0x7c(%rbp)
jg     1691 <demo_res+0x4d1>
mov    -0x78(%rbp),%eax
add    -0x78(%rbp),%eax
add    -0x7c(%rbp),%eax
add    -0x7c(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x80(%rbp)
mov    -0x78(%rbp),%edi
mov    -0x7c(%rbp),%esi
mov    -0x80(%rbp),%edx
call   10a0 <set_point@plt>
mov    -0x7c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x7c(%rbp)
jmp    1657 <demo_res+0x497>
jmp    1696 <demo_res+0x4d6>
mov    -0x78(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x78(%rbp)
jmp    1643 <demo_res+0x483>
mov    -0x58(%rbp),%rdi
mov    $0xa,%esi
mov    $0xb6,%edx
mov    $0x82,%ecx
mov    $0x4,%r8d
call   1040 <tprint_str@plt>
movl   $0xbe,-0x78(%rbp)
cmpl   $0xfa,-0x78(%rbp)
jg     173e <demo_res+0x57e>
movl   $0x3c,-0x7c(%rbp)
cmpl   $0x7a,-0x7c(%rbp)
jg     172b <demo_res+0x56b>
mov    -0x78(%rbp),%eax
add    -0x78(%rbp),%eax
add    -0x7c(%rbp),%eax
add    -0x7c(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x80(%rbp)
mov    -0x78(%rbp),%edi
mov    -0x7c(%rbp),%esi
call   10b0 <read_point@plt>
cmp    -0x80(%rbp),%eax
je     1718 <demo_res+0x558>
mov    -0x20(%rbp),%rdi
call   1080 <error_out@plt>
jmp    171d <demo_res+0x55d>
mov    -0x7c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x7c(%rbp)
jmp    16dd <demo_res+0x51d>
jmp    1730 <demo_res+0x570>
mov    -0x78(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x78(%rbp)
jmp    16c9 <demo_res+0x509>
mov    -0x30(%rbp),%rdi
mov    -0x84(%rbp),%edx
sub    $0x5c,%edx
mov    $0x17,%esi
mov    $0x14,%ecx
mov    $0xc,%r8d
mov    $0x1,%r9d
call   1050 <print_str@plt>
mov    -0x84(%rbp),%eax
sub    $0x7c,%eax
mov    %eax,-0x78(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x78(%rbp),%edx
mov    $0x1c,%esi
mov    $0x1e,%ecx
mov    $0xa,%r8d
xor    %r9d,%r9d
call   1050 <print_str@plt>
lea    -0x62(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0x928(%rip),%rsi
call   10e0 <sprintf@plt>
lea    -0x62(%rbp),%rdi
mov    -0x78(%rbp),%edx
add    $0xa8,%edx
mov    $0x3,%esi
mov    $0x1e,%ecx
mov    $0xd,%r8d
xor    %r9d,%r9d
call   1050 <print_str@plt>
lea    -0x62(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0x8f0(%rip),%rsi
call   10e0 <sprintf@plt>
lea    -0x62(%rbp),%rdi
mov    -0x78(%rbp),%edx
add    $0xe0,%edx
mov    $0x3,%esi
mov    $0x1e,%ecx
mov    $0xf,%r8d
xor    %r9d,%r9d
call   1050 <print_str@plt>
movl   $0x0,-0x78(%rbp)
cmpl   $0xf,-0x78(%rbp)
jg     1875 <demo_res+0x6b5>
mov    -0x78(%rbp),%edi
add    $0xe6,%edi
mov    -0x78(%rbp),%eax
shl    $0x2,%eax
mov    $0x3f,%esi
sub    %eax,%esi
imul   $0x3,-0x78(%rbp),%ecx
add    $0xf,%ecx
xor    %edx,%edx
call   10c0 <set_dac_register@plt>
mov    -0x78(%rbp),%edi
add    $0x1e,%edi
mov    -0xc(%rbp),%esi
sub    $0x6,%esi
sub    -0x78(%rbp),%esi
mov    -0x8(%rbp),%edx
sub    $0x14,%edx
sub    -0x78(%rbp),%edx
mov    -0xc(%rbp),%ecx
sub    $0x6,%ecx
sub    -0x78(%rbp),%ecx
mov    -0x78(%rbp),%r8d
add    $0xe6,%r8d
call   1070 <draw_line@plt>
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
jmp    1808 <demo_res+0x648>
mov    -0x40(%rbp),%rdi
mov    -0x84(%rbp),%edx
sub    $0x67,%edx
mov    -0xc(%rbp),%ecx
sub    $0x12,%ecx
mov    $0x1b,%esi
mov    $0xe,%r8d
call   1040 <tprint_str@plt>
mov    $0x0,%al
call   1060 <get_key@plt>
cmp    $0x1b,%eax
jne    18b1 <demo_res+0x6f1>
mov    -0x28(%rbp),%rdi
call   1080 <error_out@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<demo_res>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edx,%r14d
mov    %esi,%r15d
call   1030 <set_modex@plt>
test   %rax,%rax
jne    11ea <demo_res+0x2a>
lea    0xe1b(%rip),%rdi
call   1080 <error_out@plt>
lea    -0x1(%r15),%ebx
mov    $0xa,%edi
mov    $0xa,%esi
mov    %ebx,%edx
mov    $0xa,%ecx
mov    $0x1f,%r8d
call   1070 <draw_line@plt>
lea    -0x1(%r14),%ebp
mov    $0xa,%edi
mov    $0xa,%esi
mov    $0xa,%edx
mov    %ebp,%ecx
mov    $0x1f,%r8d
call   1070 <draw_line@plt>
mov    $0xa,%edi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
mov    $0x1f,%r8d
call   1070 <draw_line@plt>
mov    %ebx,%edi
mov    $0xa,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
mov    $0x1f,%r8d
call   1070 <draw_line@plt>
lea    -0x2(%r15),%ebx
mov    $0xb,%edi
mov    $0xb,%esi
mov    %ebx,%edx
mov    $0xb,%ecx
mov    $0x1d,%r8d
call   1070 <draw_line@plt>
lea    -0x2(%r14),%ebp
mov    $0xb,%edi
mov    $0xb,%esi
mov    $0xb,%edx
mov    %ebp,%ecx
mov    $0x1d,%r8d
call   1070 <draw_line@plt>
mov    $0xb,%edi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
mov    $0x1d,%r8d
call   1070 <draw_line@plt>
mov    %ebx,%edi
mov    $0xb,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
mov    $0x1d,%r8d
call   1070 <draw_line@plt>
lea    -0x3(%r15),%ebx
mov    $0xc,%edi
mov    $0xc,%esi
mov    %ebx,%edx
mov    $0xc,%ecx
mov    $0x1b,%r8d
call   1070 <draw_line@plt>
lea    -0x3(%r14),%ebp
mov    $0xc,%edi
mov    $0xc,%esi
mov    $0xc,%edx
mov    %ebp,%ecx
mov    $0x1b,%r8d
call   1070 <draw_line@plt>
mov    $0xc,%edi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
mov    $0x1b,%r8d
call   1070 <draw_line@plt>
mov    %ebx,%edi
mov    $0xc,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
mov    $0x1b,%r8d
call   1070 <draw_line@plt>
lea    -0x4(%r15),%ebx
mov    $0xd,%edi
mov    $0xd,%esi
mov    %ebx,%edx
mov    $0xd,%ecx
mov    $0x19,%r8d
call   1070 <draw_line@plt>
mov    %r14,0x8(%rsp)
lea    -0x4(%r14),%ebp
mov    $0xd,%edi
mov    $0xd,%esi
mov    $0xd,%edx
mov    %ebp,%ecx
mov    $0x19,%r8d
call   1070 <draw_line@plt>
mov    $0xd,%edi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
mov    $0x19,%r8d
call   1070 <draw_line@plt>
mov    %ebx,%edi
mov    $0xd,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
mov    $0x19,%r8d
call   1070 <draw_line@plt>
mov    %r15d,%r13d
shr    $0x1f,%r13d
mov    %r15,(%rsp)
cmp    $0xa,%r15d
jl     1457 <demo_res+0x297>
movslq (%rsp),%rax
imul   $0x66666667,%rax,%r14
mov    %r14,%rax
shr    $0x3f,%rax
sar    $0x22,%r14
add    %eax,%r14d
xor    %eax,%eax
mov    $0x9,%ebx
mov    $0x1,%ebp
mov    $0xcccccccd,%r15d
nop
mov    %ebp,%ecx
imul   %r15,%rcx
shr    $0x23,%rcx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
lea    0x1(%rax),%r12d
neg    %ecx
lea    (%rax,%rcx,1),%edi
add    $0x1,%edi
or     $0x30,%edi
lea    -0x8(%rbx),%esi
shr    $0x3,%eax
imul   $0x24924925,%rax,%rcx
shr    $0x20,%rcx
mov    %eax,%edx
sub    %ecx,%edx
shr    %edx
add    %ecx,%edx
shr    $0x2,%edx
lea    0x0(,%rdx,8),%ecx
sub    %ecx,%edx
lea    (%rax,%rdx,1),%ecx
add    $0x9,%ecx
mov    $0x1,%edx
call   1090 <tgprintc@plt>
mov    %ebx,%edi
xor    %esi,%esi
mov    %ebx,%edx
mov    $0x3,%ecx
mov    $0xf,%r8d
call   1070 <draw_line@plt>
add    $0xa,%ebx
add    $0x1,%ebp
mov    %r12d,%eax
cmp    %r12d,%r14d
jne    13e0 <demo_res+0x220>
add    (%rsp),%r13d
cmpl   $0xa,0x8(%rsp)
jl     151e <demo_res+0x35e>
movslq 0x8(%rsp),%rax
imul   $0x66666667,%rax,%r14
mov    %r14,%rax
shr    $0x3f,%rax
sar    $0x22,%r14
add    %eax,%r14d
xor    %eax,%eax
mov    $0x9,%ebx
mov    $0x1,%ebp
mov    $0xcccccccd,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebp,%ecx
imul   %r15,%rcx
shr    $0x23,%rcx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
lea    0x1(%rax),%r12d
neg    %ecx
lea    (%rax,%rcx,1),%edi
add    $0x1,%edi
or     $0x30,%edi
lea    -0x8(%rbx),%edx
mov    %eax,%eax
imul   %r15,%rax
shr    $0x23,%rax
imul   $0x24924925,%rax,%rcx
shr    $0x20,%rcx
mov    %eax,%esi
sub    %ecx,%esi
shr    %esi
add    %ecx,%esi
shr    $0x2,%esi
lea    0x0(,%rsi,8),%ecx
sub    %ecx,%esi
lea    (%rax,%rsi,1),%ecx
add    $0x9,%ecx
mov    $0x1,%esi
call   1090 <tgprintc@plt>
xor    %edi,%edi
mov    %ebx,%esi
mov    $0x3,%edx
mov    %ebx,%ecx
mov    $0xf,%r8d
call   1070 <draw_line@plt>
add    $0xa,%ebx
add    $0x1,%ebp
mov    %r12d,%eax
cmp    %r12d,%r14d
jne    14a0 <demo_res+0x2e0>
sar    %r13d
mov    %r13,0x10(%rsp)
mov    $0x28,%ebx
mov    $0x7b,%r13d
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r12d,%ebp
shr    $0x2,%ebp
add    $0xf,%ebp
lea    0x18(%rbx),%r14d
mov    %r14d,%edi
mov    %ebp,%esi
mov    %ebp,%edx
mov    %ebp,%ecx
call   10c0 <set_dac_register@plt>
lea    0x58(%rbx),%r15d
mov    %r15d,%edi
xor    %esi,%esi
mov    %ebp,%edx
mov    %ebp,%ecx
call   10c0 <set_dac_register@plt>
lea    -0x14(%r13),%edi
mov    $0x3c,%esi
mov    %ebx,%edx
mov    $0x7b,%ecx
mov    %r14d,%r8d
call   1070 <draw_line@plt>
lea    0x14(%rbx),%esi
mov    $0x28,%edi
mov    $0x67,%edx
mov    %r13d,%ecx
mov    %r15d,%r8d
call   1070 <draw_line@plt>
add    $0x1,%ebx
add    $0xffffffff,%r13d
add    $0x3,%r12d
cmp    $0x68,%ebx
jne    1540 <demo_res+0x380>
lea    0xaf4(%rip),%rdi
mov    $0x9,%esi
mov    $0x25,%edx
mov    $0x82,%ecx
mov    $0x1,%r8d
call   1040 <tprint_str@plt>
mov    $0x3c,%r13d
mov    $0x78,%ebx
nopl   0x0(%rax)
lea    (%rbx,%r13,1),%ebp
add    $0xffffff88,%ebp
lea    -0x38(%rbx),%r8d
mov    $0x78,%edi
mov    %r13d,%esi
mov    %ebx,%edx
mov    %ebp,%ecx
call   10d0 <fill_block@plt>
lea    0x5(%rbx),%edi
lea    0x1e(%rbx),%edx
lea    0x6e(%rbx),%r8d
mov    %r13d,%esi
mov    %ebp,%ecx
call   10d0 <fill_block@plt>
lea    0x23(%rbx),%edi
lea    0x8(%rbx),%r8d
mov    %r13d,%esi
mov    $0xaa,%edx
mov    %ebp,%ecx
call   10d0 <fill_block@plt>
add    %ebx,%r13d
add    $0xffffff8a,%r13d
add    $0x1,%ebx
cmp    $0x82,%ebx
jne    15e0 <demo_res+0x420>
lea    0xa73(%rip),%rdi
mov    $0x9,%esi
mov    $0x6e,%edx
mov    $0x2e,%ecx
mov    $0x2,%r8d
call   1040 <tprint_str@plt>
mov    $0xbe,%r15d
mov    $0x1f4,%r14d
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0x3a,%ebp
mov    %r14d,%ebx
nopl   0x0(%rax,%rax,1)
add    $0x2,%ebp
mov    %ebx,%edx
and    $0xfc,%edx
mov    %r15d,%edi
mov    %ebp,%esi
call   10a0 <set_point@plt>
add    $0x4,%ebx
cmp    $0x79,%ebp
jb     1680 <demo_res+0x4c0>
lea    0x2(%r15),%eax
add    $0x4,%r14d
cmp    $0xf9,%r15d
mov    %eax,%r15d
jb     1670 <demo_res+0x4b0>
lea    0xa04(%rip),%rdi
mov    $0xa,%esi
mov    $0xb6,%edx
mov    $0x82,%ecx
mov    $0x4,%r8d
call   1040 <tprint_str@plt>
mov    $0xbe,%r12d
mov    $0x1f4,%r15d
lea    0x93b(%rip),%r14
jmp    1705 <demo_res+0x545>
nopw   0x0(%rax,%rax,1)
lea    0x2(%r12),%eax
add    $0x4,%r15d
cmp    $0xf9,%r12d
mov    %eax,%r12d
jae    173e <demo_res+0x57e>
mov    $0x3a,%r13d
mov    %r15d,%ebp
jmp    1719 <demo_res+0x559>
add    $0x4,%ebp
cmp    $0x79,%r13d
jae    16f0 <demo_res+0x530>
add    $0x2,%r13d
mov    %ebp,%ebx
and    $0xfc,%ebx
mov    %r12d,%edi
mov    %r13d,%esi
call   10b0 <read_point@plt>
cmp    %ebx,%eax
je     1710 <demo_res+0x550>
mov    %r14,%rdi
call   1080 <error_out@plt>
jmp    1710 <demo_res+0x550>
mov    0x10(%rsp),%rbx
lea    -0x5c(%rbx),%edx
lea    0x907(%rip),%rdi
mov    $0x17,%esi
mov    $0x14,%ecx
mov    $0xc,%r8d
mov    $0x1,%r9d
call   1050 <print_str@plt>
lea    -0x7c(%rbx),%edx
lea    0x8fa(%rip),%rdi
mov    $0x1c,%esi
mov    $0x1e,%ecx
mov    $0xa,%r8d
xor    %r9d,%r9d
call   1050 <print_str@plt>
lea    0x936(%rip),%r14
lea    0x1e(%rsp),%rbp
mov    %rbp,%rdi
mov    %r14,%rsi
mov    (%rsp),%r12
mov    %r12d,%edx
call   10e0 <sprintf@plt>
lea    0x2c(%rbx),%edx
mov    %rbp,%rdi
mov    $0x3,%esi
mov    $0x1e,%ecx
mov    $0xd,%r8d
xor    %r9d,%r9d
call   1050 <print_str@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
mov    0x8(%rsp),%r15
mov    %r15d,%edx
call   10e0 <sprintf@plt>
lea    0x64(%rbx),%edx
mov    $0xf,%r13d
mov    %rbp,%rdi
mov    $0x3,%esi
mov    $0x1e,%ecx
mov    $0xf,%r8d
xor    %r9d,%r9d
call   1050 <print_str@plt>
lea    -0x6(%r15),%ebp
add    $0xffffffec,%r12d
mov    $0x3f,%ebx
mov    $0xe6,%r14d
mov    %r14d,%edi
mov    %ebx,%esi
xor    %edx,%edx
mov    %r13d,%ecx
call   10c0 <set_dac_register@plt>
lea    -0xc8(%r14),%edi
mov    %ebp,%esi
mov    %r12d,%edx
mov    %ebp,%ecx
mov    %r14d,%r8d
call   1070 <draw_line@plt>
add    $0xffffffff,%ebp
add    $0xffffffff,%r12d
add    $0xfffffffc,%ebx
add    $0x1,%r14d
add    $0x3,%r13d
cmp    $0xffffffff,%ebx
jne    1810 <demo_res+0x650>
mov    0x10(%rsp),%rdx
add    $0xffffff99,%edx
add    $0xffffffee,%r15d
lea    0x82d(%rip),%rdi
mov    $0x1b,%esi
mov    %r15d,%ecx
mov    $0xe,%r8d
call   1040 <tprint_str@plt>
xor    %eax,%eax
call   1060 <get_key@plt>
cmp    $0x1b,%eax
jne    188a <demo_res+0x6ca>
lea    0x7ba(%rip),%rdi
call   1080 <error_out@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [32 x i8] c"Failure while calling SET_MODEX\00"
@.str.1 = [31 x i8] c"Failure during READ_PIXEL test\00"
@.str.2 = [21 x i8] c"Demo aborted by User\00"
@.str.3 = [24 x i8] c" This is a MODE X demo \00"
@.str.4 = [32 x i8] c"Screen Resolution is by \00"
@.str.5 = [28 x i8] c"Press <ANY KEY> to Continue\00"
@.str.6 = [10 x i8] c"LINE TEST\00"
@.str.7 = [10 x i8] c"FILL TEST\00"
@.str.8 = [11 x i8] c"PIXEL TEST\00"
@.str.9 = [4 x i8] c"%3d\00"
define void @demo_res(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca [10 x i8]
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8** %7
store i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8** %8
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i8** %9
store i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8** %10
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i8** %11
store i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i8** %12
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i8** %13
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8** %14
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i8** %15
store i32 0, i32* %20
store i32 0, i32* %23
store i32 0, i32* %25
%26 = load i32, i32* %4
%27 = call i64 @set_modex(i32 %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %3
%30 = load i8*, i8** %7
%31 = call i32 @error_out(i8* %30)
br label %32
32: ; preds = %29, %3
%33 = load i32, i32* %5
%34 = sdiv i32 %33, 2
store i32 %34, i32* %24
store i32 10, i32* %17
store i32 10, i32* %18
%35 = load i32, i32* %5
%36 = sub nsw i32 %35, 1
store i32 %36, i32* %19
%37 = load i32, i32* %6
%38 = sub nsw i32 %37, 1
store i32 %38, i32* %20
store i32 0, i32* %23
br label %39
39: ; preds = %103, %32
%40 = load i32, i32* %23
%41 = icmp sle i32 %40, 3
br i1 %41, label %42, label %106
42: ; preds = %39
%43 = load i32, i32* %23
%44 = sub nsw i32 31, %43
%45 = load i32, i32* %23
%46 = sub nsw i32 %44, %45
store i32 %46, i32* %22
%47 = load i32, i32* %17
%48 = load i32, i32* %23
%49 = add nsw i32 %47, %48
%50 = load i32, i32* %18
%51 = load i32, i32* %23
%52 = add nsw i32 %50, %51
%53 = load i32, i32* %19
%54 = load i32, i32* %23
%55 = sub nsw i32 %53, %54
%56 = load i32, i32* %18
%57 = load i32, i32* %23
%58 = add nsw i32 %56, %57
%59 = load i32, i32* %22
%60 = call i32 @draw_line(i32 %49, i32 %52, i32 %55, i32 %58, i32 %59)
%61 = load i32, i32* %17
%62 = load i32, i32* %23
%63 = add nsw i32 %61, %62
%64 = load i32, i32* %18
%65 = load i32, i32* %23
%66 = add nsw i32 %64, %65
%67 = load i32, i32* %17
%68 = load i32, i32* %23
%69 = add nsw i32 %67, %68
%70 = load i32, i32* %20
%71 = load i32, i32* %23
%72 = sub nsw i32 %70, %71
%73 = load i32, i32* %22
%74 = call i32 @draw_line(i32 %63, i32 %66, i32 %69, i32 %72, i32 %73)
%75 = load i32, i32* %17
%76 = load i32, i32* %23
%77 = add nsw i32 %75, %76
%78 = load i32, i32* %20
%79 = load i32, i32* %23
%80 = sub nsw i32 %78, %79
%81 = load i32, i32* %19
%82 = load i32, i32* %23
%83 = sub nsw i32 %81, %82
%84 = load i32, i32* %20
%85 = load i32, i32* %23
%86 = sub nsw i32 %84, %85
%87 = load i32, i32* %22
%88 = call i32 @draw_line(i32 %77, i32 %80, i32 %83, i32 %86, i32 %87)
%89 = load i32, i32* %19
%90 = load i32, i32* %23
%91 = sub nsw i32 %89, %90
%92 = load i32, i32* %18
%93 = load i32, i32* %23
%94 = add nsw i32 %92, %93
%95 = load i32, i32* %19
%96 = load i32, i32* %23
%97 = sub nsw i32 %95, %96
%98 = load i32, i32* %20
%99 = load i32, i32* %23
%100 = sub nsw i32 %98, %99
%101 = load i32, i32* %22
%102 = call i32 @draw_line(i32 %91, i32 %94, i32 %97, i32 %100, i32 %101)
br label %103
103: ; preds = %42
%104 = load i32, i32* %23
%105 = add nsw i32 %104, 1
store i32 %105, i32* %23
br label %39
106: ; preds = %39
store i32 0, i32* %21
br label %107
107: ; preds = %132, %106
%108 = load i32, i32* %21
%109 = load i32, i32* %5
%110 = sdiv i32 %109, 10
%111 = icmp slt i32 %108, %110
br i1 %111, label %112, label %135
112: ; preds = %107
%113 = load i32, i32* %21
%114 = add nsw i32 %113, 1
%115 = srem i32 %114, 10
%116 = add nsw i32 48, %115
%117 = load i32, i32* %21
%118 = mul nsw i32 %117, 10
%119 = add nsw i32 %118, 1
%120 = load i32, i32* %21
%121 = sdiv i32 %120, 8
%122 = srem i32 %121, 7
%123 = add nsw i32 9, %122
%124 = call i32 @tgprintc(i32 %116, i32 %119, i32 1, i32 %123)
%125 = load i32, i32* %21
%126 = mul nsw i32 %125, 10
%127 = add nsw i32 %126, 9
%128 = load i32, i32* %21
%129 = mul nsw i32 %128, 10
%130 = add nsw i32 %129, 9
%131 = call i32 @draw_line(i32 %127, i32 0, i32 %130, i32 3, i32 15)
br label %132
132: ; preds = %112
%133 = load i32, i32* %21
%134 = add nsw i32 %133, 1
store i32 %134, i32* %21
br label %107
135: ; preds = %107
store i32 0, i32* %22
br label %136
136: ; preds = %161, %135
%137 = load i32, i32* %22
%138 = load i32, i32* %6
%139 = sdiv i32 %138, 10
%140 = icmp slt i32 %137, %139
br i1 %140, label %141, label %164
141: ; preds = %136
%142 = load i32, i32* %22
%143 = add nsw i32 %142, 1
%144 = srem i32 %143, 10
%145 = add nsw i32 48, %144
%146 = load i32, i32* %22
%147 = mul nsw i32 %146, 10
%148 = add nsw i32 %147, 1
%149 = load i32, i32* %22
%150 = sdiv i32 %149, 10
%151 = srem i32 %150, 7
%152 = add nsw i32 9, %151
%153 = call i32 @tgprintc(i32 %145, i32 1, i32 %148, i32 %152)
%154 = load i32, i32* %22
%155 = mul nsw i32 %154, 10
%156 = add nsw i32 %155, 9
%157 = load i32, i32* %22
%158 = mul nsw i32 %157, 10
%159 = add nsw i32 %158, 9
%160 = call i32 @draw_line(i32 0, i32 %156, i32 3, i32 %159, i32 15)
br label %161
161: ; preds = %141
%162 = load i32, i32* %22
%163 = add nsw i32 %162, 1
store i32 %163, i32* %22
br label %136
164: ; preds = %136
store i32 0, i32* %21
br label %165
165: ; preds = %198, %164
%166 = load i32, i32* %21
%167 = icmp sle i32 %166, 63
br i1 %167, label %168, label %201
168: ; preds = %165
%169 = load i32, i32* %21
%170 = mul nsw i32 %169, 3
%171 = sdiv i32 %170, 4
%172 = add nsw i32 15, %171
store i32 %172, i32* %23
%173 = load i32, i32* %21
%174 = add nsw i32 64, %173
%175 = load i32, i32* %23
%176 = load i32, i32* %23
%177 = load i32, i32* %23
%178 = call i32 @set_dac_register(i32 %174, i32 %175, i32 %176, i32 %177)
%179 = load i32, i32* %21
%180 = add nsw i32 128, %179
%181 = load i32, i32* %23
%182 = load i32, i32* %23
%183 = call i32 @set_dac_register(i32 %180, i32 0, i32 %181, i32 %182)
%184 = load i32, i32* %21
%185 = sub nsw i32 103, %184
%186 = load i32, i32* %21
%187 = add nsw i32 40, %186
%188 = load i32, i32* %21
%189 = add nsw i32 64, %188
%190 = call i32 @draw_line(i32 %185, i32 60, i32 %187, i32 123, i32 %189)
%191 = load i32, i32* %21
%192 = add nsw i32 60, %191
%193 = load i32, i32* %21
%194 = sub nsw i32 123, %193
%195 = load i32, i32* %21
%196 = add nsw i32 128, %195
%197 = call i32 @draw_line(i32 40, i32 %192, i32 103, i32 %194, i32 %196)
br label %198
198: ; preds = %168
%199 = load i32, i32* %21
%200 = add nsw i32 %199, 1
store i32 %200, i32* %21
br label %165
201: ; preds = %165
%202 = load i8*, i8** %13
%203 = call i32 @tprint_str(i8* %202, i32 9, i32 37, i32 130, i32 1)
store i32 60, i32* %22
store i32 0, i32* %25
store i32 0, i32* %21
br label %204
204: ; preds = %245, %201
%205 = load i32, i32* %21
%206 = icmp sle i32 %205, 9
br i1 %206, label %207, label %248
207: ; preds = %204
%208 = load i32, i32* %22
%209 = load i32, i32* %21
%210 = add nsw i32 120, %209
%211 = load i32, i32* %22
%212 = load i32, i32* %25
%213 = add nsw i32 %211, %212
%214 = load i32, i32* %21
%215 = add nsw i32 64, %214
%216 = call i32 @fill_block(i32 120, i32 %208, i32 %210, i32 %213, i32 %215)
%217 = load i32, i32* %21
%218 = sub nsw i32 15, %217
%219 = sub nsw i32 140, %218
%220 = load i32, i32* %22
%221 = load i32, i32* %21
%222 = add nsw i32 150, %221
%223 = load i32, i32* %22
%224 = load i32, i32* %25
%225 = add nsw i32 %223, %224
%226 = load i32, i32* %21
%227 = add nsw i32 230, %226
%228 = call i32 @fill_block(i32 %219, i32 %220, i32 %222, i32 %225, i32 %227)
%229 = load i32, i32* %21
%230 = sub nsw i32 15, %229
%231 = sub nsw i32 170, %230
%232 = load i32, i32* %22
%233 = load i32, i32* %22
%234 = load i32, i32* %25
%235 = add nsw i32 %233, %234
%236 = load i32, i32* %21
%237 = add nsw i32 128, %236
%238 = call i32 @fill_block(i32 %231, i32 %232, i32 170, i32 %235, i32 %237)
%239 = load i32, i32* %22
%240 = load i32, i32* %25
%241 = add nsw i32 %239, %240
%242 = add nsw i32 %241, 2
store i32 %242, i32* %22
%243 = load i32, i32* %25
%244 = add nsw i32 %243, 1
store i32 %244, i32* %25
br label %245
245: ; preds = %207
%246 = load i32, i32* %21
%247 = add nsw i32 %246, 1
store i32 %247, i32* %21
br label %204
248: ; preds = %204
%249 = load i8*, i8** %14
%250 = call i32 @tprint_str(i8* %249, i32 9, i32 110, i32 46, i32 2)
store i32 190, i32* %21
br label %251
251: ; preds = %275, %248
%252 = load i32, i32* %21
%253 = icmp sle i32 %252, 250
br i1 %253, label %254, label %278
254: ; preds = %251
store i32 60, i32* %22
br label %255
255: ; preds = %271, %254
%256 = load i32, i32* %22
%257 = icmp sle i32 %256, 122
br i1 %257, label %258, label %274
258: ; preds = %255
%259 = load i32, i32* %21
%260 = load i32, i32* %21
%261 = add nsw i32 %259, %260
%262 = load i32, i32* %22
%263 = add nsw i32 %261, %262
%264 = load i32, i32* %22
%265 = add nsw i32 %263, %264
%266 = and i32 %265, 255
store i32 %266, i32* %23
%267 = load i32, i32* %21
%268 = load i32, i32* %22
%269 = load i32, i32* %23
%270 = call i32 @set_point(i32 %267, i32 %268, i32 %269)
br label %271
271: ; preds = %258
%272 = load i32, i32* %22
%273 = add nsw i32 %272, 2
store i32 %273, i32* %22
br label %255
274: ; preds = %255
br label %275
275: ; preds = %274
%276 = load i32, i32* %21
%277 = add nsw i32 %276, 2
store i32 %277, i32* %21
br label %251
278: ; preds = %251
%279 = load i8*, i8** %15
%280 = call i32 @tprint_str(i8* %279, i32 10, i32 182, i32 130, i32 4)
store i32 190, i32* %21
br label %281
281: ; preds = %310, %278
%282 = load i32, i32* %21
%283 = icmp sle i32 %282, 250
br i1 %283, label %284, label %313
284: ; preds = %281
store i32 60, i32* %22
br label %285
285: ; preds = %306, %284
%286 = load i32, i32* %22
%287 = icmp sle i32 %286, 122
br i1 %287, label %288, label %309
288: ; preds = %285
%289 = load i32, i32* %21
%290 = load i32, i32* %21
%291 = add nsw i32 %289, %290
%292 = load i32, i32* %22
%293 = add nsw i32 %291, %292
%294 = load i32, i32* %22
%295 = add nsw i32 %293, %294
%296 = and i32 %295, 255
store i32 %296, i32* %23
%297 = load i32, i32* %21
%298 = load i32, i32* %22
%299 = call i32 @read_point(i32 %297, i32 %298)
%300 = load i32, i32* %23
%301 = icmp ne i32 %299, %300
br i1 %301, label %302, label %305
302: ; preds = %288
%303 = load i8*, i8** %8
%304 = call i32 @error_out(i8* %303)
br label %305
305: ; preds = %302, %288
br label %306
306: ; preds = %305
%307 = load i32, i32* %22
%308 = add nsw i32 %307, 2
store i32 %308, i32* %22
br label %285
309: ; preds = %285
br label %310
310: ; preds = %309
%311 = load i32, i32* %21
%312 = add nsw i32 %311, 2
store i32 %312, i32* %21
br label %281
313: ; preds = %281
%314 = load i8*, i8** %10
%315 = load i32, i32* %24
%316 = sub nsw i32 %315, 92
%317 = call i32 @print_str(i8* %314, i32 23, i32 %316, i32 20, i32 12, i32 1)
%318 = load i32, i32* %24
%319 = sub nsw i32 %318, 124
store i32 %319, i32* %21
%320 = load i8*, i8** %11
%321 = load i32, i32* %21
%322 = call i32 @print_str(i8* %320, i32 28, i32 %321, i32 30, i32 10, i32 0)
%323 = getelementptr inbounds [10 x i8], [10 x i8]* %16, i64 0, i64 0
%324 = load i32, i32* %5
%325 = call i32 @sprintf(i8* %323, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 %324)
%326 = getelementptr inbounds [10 x i8], [10 x i8]* %16, i64 0, i64 0
%327 = load i32, i32* %21
%328 = add nsw i32 %327, 168
%329 = call i32 @print_str(i8* %326, i32 3, i32 %328, i32 30, i32 13, i32 0)
%330 = getelementptr inbounds [10 x i8], [10 x i8]* %16, i64 0, i64 0
%331 = load i32, i32* %6
%332 = call i32 @sprintf(i8* %330, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 %331)
%333 = getelementptr inbounds [10 x i8], [10 x i8]* %16, i64 0, i64 0
%334 = load i32, i32* %21
%335 = add nsw i32 %334, 224
%336 = call i32 @print_str(i8* %333, i32 3, i32 %335, i32 30, i32 15, i32 0)
store i32 0, i32* %21
br label %337
337: ; preds = %367, %313
%338 = load i32, i32* %21
%339 = icmp sle i32 %338, 15
br i1 %339, label %340, label %370
340: ; preds = %337
%341 = load i32, i32* %21
%342 = add nsw i32 230, %341
%343 = load i32, i32* %21
%344 = mul nsw i32 %343, 4
%345 = sub nsw i32 63, %344
%346 = load i32, i32* %21
%347 = mul nsw i32 %346, 3
%348 = add nsw i32 15, %347
%349 = call i32 @set_dac_register(i32 %342, i32 %345, i32 0, i32 %348)
%350 = load i32, i32* %21
%351 = add nsw i32 30, %350
%352 = load i32, i32* %6
%353 = sub nsw i32 %352, 6
%354 = load i32, i32* %21
%355 = sub nsw i32 %353, %354
%356 = load i32, i32* %5
%357 = sub nsw i32 %356, 20
%358 = load i32, i32* %21
%359 = sub nsw i32 %357, %358
%360 = load i32, i32* %6
%361 = sub nsw i32 %360, 6
%362 = load i32, i32* %21
%363 = sub nsw i32 %361, %362
%364 = load i32, i32* %21
%365 = add nsw i32 230, %364
%366 = call i32 @draw_line(i32 %351, i32 %355, i32 %359, i32 %363, i32 %365)
br label %367
367: ; preds = %340
%368 = load i32, i32* %21
%369 = add nsw i32 %368, 1
store i32 %369, i32* %21
br label %337
370: ; preds = %337
%371 = load i8*, i8** %12
%372 = load i32, i32* %24
%373 = sub nsw i32 %372, 103
%374 = load i32, i32* %6
%375 = sub nsw i32 %374, 18
%376 = call i32 @tprint_str(i8* %371, i32 27, i32 %373, i32 %375, i32 14)
%377 = call i32 (...) @get_key()
%378 = icmp eq i32 %377, 27
br i1 %378, label %379, label %382
379: ; preds = %370
%380 = load i8*, i8** %9
%381 = call i32 @error_out(i8* %380)
br label %382
382: ; preds = %379, %370
ret void
}

LLVM IR (-O2):
@.str = [32 x i8] c"Failure while calling SET_MODEX\00"
@.str.1 = [31 x i8] c"Failure during READ_PIXEL test\00"
@.str.2 = [21 x i8] c"Demo aborted by User\00"
@.str.3 = [24 x i8] c" This is a MODE X demo \00"
@.str.4 = [32 x i8] c"Screen Resolution is by \00"
@.str.5 = [28 x i8] c"Press <ANY KEY> to Continue\00"
@.str.6 = [10 x i8] c"LINE TEST\00"
@.str.7 = [10 x i8] c"FILL TEST\00"
@.str.8 = [11 x i8] c"PIXEL TEST\00"
@.str.9 = [4 x i8] c"%3d\00"
define void @demo_res(i32 %0, i32 %1, i32 %2) {
%4 = alloca [10 x i8]
%5 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%6 = tail call i64 @set_modex(i32 %0)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %3
%9 = tail call i32 @error_out(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %8, %3
%11 = add i32 %1, -1
%12 = tail call i32 @draw_line(i32 10, i32 10, i32 %11, i32 10, i32 31)
%13 = add i32 %2, -1
%14 = tail call i32 @draw_line(i32 10, i32 10, i32 10, i32 %13, i32 31)
%15 = tail call i32 @draw_line(i32 10, i32 %13, i32 %11, i32 %13, i32 31)
%16 = tail call i32 @draw_line(i32 %11, i32 10, i32 %11, i32 %13, i32 31)
%17 = add i32 %1, -2
%18 = tail call i32 @draw_line(i32 11, i32 11, i32 %17, i32 11, i32 29)
%19 = add i32 %2, -2
%20 = tail call i32 @draw_line(i32 11, i32 11, i32 11, i32 %19, i32 29)
%21 = tail call i32 @draw_line(i32 11, i32 %19, i32 %17, i32 %19, i32 29)
%22 = tail call i32 @draw_line(i32 %17, i32 11, i32 %17, i32 %19, i32 29)
%23 = add i32 %1, -3
%24 = tail call i32 @draw_line(i32 12, i32 12, i32 %23, i32 12, i32 27)
%25 = add i32 %2, -3
%26 = tail call i32 @draw_line(i32 12, i32 12, i32 12, i32 %25, i32 27)
%27 = tail call i32 @draw_line(i32 12, i32 %25, i32 %23, i32 %25, i32 27)
%28 = tail call i32 @draw_line(i32 %23, i32 12, i32 %23, i32 %25, i32 27)
%29 = add i32 %1, -4
%30 = tail call i32 @draw_line(i32 13, i32 13, i32 %29, i32 13, i32 25)
%31 = add i32 %2, -4
%32 = tail call i32 @draw_line(i32 13, i32 13, i32 13, i32 %31, i32 25)
%33 = tail call i32 @draw_line(i32 13, i32 %31, i32 %29, i32 %31, i32 25)
%34 = tail call i32 @draw_line(i32 %29, i32 13, i32 %29, i32 %31, i32 25)
%35 = sdiv i32 %1, 2
%36 = sdiv i32 %1, 10
%37 = icmp sgt i32 %1, 9
br i1 %37, label %41, label %38
38: ; preds = %41, %10
%39 = sdiv i32 %2, 10
%40 = icmp sgt i32 %2, 9
br i1 %40, label %55, label %69
41: ; preds = %10, %41
%42 = phi i32 [ %43, %41 ], [ 0, %10 ]
%43 = add nuw nsw i32 %42, 1
%44 = urem i32 %43, 10
%45 = or i32 %44, 48
%46 = mul nuw nsw i32 %42, 10
%47 = or i32 %46, 1
%48 = lshr i32 %42, 3
%49 = urem i32 %48, 7
%50 = add nuw nsw i32 %49, 9
%51 = tail call i32 @tgprintc(i32 %45, i32 %47, i32 1, i32 %50)
%52 = add nuw nsw i32 %46, 9
%53 = tail call i32 @draw_line(i32 %52, i32 0, i32 %52, i32 3, i32 15)
%54 = icmp eq i32 %43, %36
br i1 %54, label %38, label %41
55: ; preds = %38, %55
%56 = phi i32 [ %57, %55 ], [ 0, %38 ]
%57 = add nuw nsw i32 %56, 1
%58 = urem i32 %57, 10
%59 = or i32 %58, 48
%60 = mul nuw nsw i32 %56, 10
%61 = or i32 %60, 1
%62 = udiv i32 %56, 10
%63 = urem i32 %62, 7
%64 = add nuw nsw i32 %63, 9
%65 = tail call i32 @tgprintc(i32 %59, i32 1, i32 %61, i32 %64)
%66 = add nuw nsw i32 %60, 9
%67 = tail call i32 @draw_line(i32 0, i32 %66, i32 3, i32 %66, i32 15)
%68 = icmp eq i32 %57, %39
br i1 %68, label %69, label %55
69: ; preds = %55, %38
br label %70
70: ; preds = %69, %70
%71 = phi i32 [ %85, %70 ], [ 0, %69 ]
%72 = mul nuw nsw i32 %71, 3
%73 = lshr i32 %72, 2
%74 = add nuw nsw i32 %73, 15
%75 = add nuw nsw i32 %71, 64
%76 = tail call i32 @set_dac_register(i32 %75, i32 %74, i32 %74, i32 %74)
%77 = add nuw nsw i32 %71, 128
%78 = tail call i32 @set_dac_register(i32 %77, i32 0, i32 %74, i32 %74)
%79 = sub nuw nsw i32 103, %71
%80 = add nuw nsw i32 %71, 40
%81 = tail call i32 @draw_line(i32 %79, i32 60, i32 %80, i32 123, i32 %75)
%82 = add nuw nsw i32 %71, 60
%83 = sub nuw nsw i32 123, %71
%84 = tail call i32 @draw_line(i32 40, i32 %82, i32 103, i32 %83, i32 %77)
%85 = add nuw nsw i32 %71, 1
%86 = icmp eq i32 %85, 64
br i1 %86, label %87, label %70
87: ; preds = %70
%88 = tail call i32 @tprint_str(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32 9, i32 37, i32 130, i32 1)
br label %89
89: ; preds = %87, %89
%90 = phi i32 [ 0, %87 ], [ %104, %89 ]
%91 = phi i32 [ 60, %87 ], [ %103, %89 ]
%92 = add nuw nsw i32 %90, 120
%93 = add nsw i32 %90, %91
%94 = add nuw nsw i32 %90, 64
%95 = tail call i32 @fill_block(i32 120, i32 %91, i32 %92, i32 %93, i32 %94)
%96 = add nuw nsw i32 %90, 125
%97 = add nuw nsw i32 %90, 150
%98 = add nuw nsw i32 %90, 230
%99 = tail call i32 @fill_block(i32 %96, i32 %91, i32 %97, i32 %93, i32 %98)
%100 = add nuw nsw i32 %90, 155
%101 = add nuw nsw i32 %90, 128
%102 = tail call i32 @fill_block(i32 %100, i32 %91, i32 170, i32 %93, i32 %101)
%103 = add nsw i32 %93, 2
%104 = add nuw nsw i32 %90, 1
%105 = icmp eq i32 %104, 10
br i1 %105, label %106, label %89
106: ; preds = %89
%107 = tail call i32 @tprint_str(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i32 9, i32 110, i32 46, i32 2)
br label %108
108: ; preds = %106, %118
%109 = phi i32 [ 190, %106 ], [ %119, %118 ]
br label %110
110: ; preds = %108, %110
%111 = phi i32 [ 60, %108 ], [ %116, %110 ]
%112 = add nuw nsw i32 %111, %109
%113 = shl nuw i32 %112, 1
%114 = and i32 %113, 252
%115 = tail call i32 @set_point(i32 %109, i32 %111, i32 %114)
%116 = add nuw nsw i32 %111, 2
%117 = icmp ult i32 %111, 121
br i1 %117, label %110, label %118
118: ; preds = %110
%119 = add nuw nsw i32 %109, 2
%120 = icmp ult i32 %109, 249
br i1 %120, label %108, label %121
121: ; preds = %118
%122 = tail call i32 @tprint_str(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0), i32 10, i32 182, i32 130, i32 4)
br label %123
123: ; preds = %121, %137
%124 = phi i32 [ 190, %121 ], [ %138, %137 ]
br label %125
125: ; preds = %123, %134
%126 = phi i32 [ 60, %123 ], [ %135, %134 ]
%127 = add nuw nsw i32 %126, %124
%128 = shl nuw i32 %127, 1
%129 = and i32 %128, 252
%130 = tail call i32 @read_point(i32 %124, i32 %126)
%131 = icmp eq i32 %130, %129
br i1 %131, label %134, label %132
132: ; preds = %125
%133 = tail call i32 @error_out(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0))
br label %134
134: ; preds = %125, %132
%135 = add nuw nsw i32 %126, 2
%136 = icmp ult i32 %126, 121
br i1 %136, label %125, label %137
137: ; preds = %134
%138 = add nuw nsw i32 %124, 2
%139 = icmp ult i32 %124, 249
br i1 %139, label %123, label %140
140: ; preds = %137
%141 = add nsw i32 %35, -92
%142 = tail call i32 @print_str(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 23, i32 %141, i32 20, i32 12, i32 1)
%143 = add nsw i32 %35, -124
%144 = tail call i32 @print_str(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i32 28, i32 %143, i32 30, i32 10, i32 0)
%145 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 %1)
%146 = add nsw i32 %35, 44
%147 = call i32 @print_str(i8* %5, i32 3, i32 %146, i32 30, i32 13, i32 0)
%148 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 %2)
%149 = add nsw i32 %35, 100
%150 = call i32 @print_str(i8* %5, i32 3, i32 %149, i32 30, i32 15, i32 0)
%151 = add nsw i32 %2, -6
%152 = add nsw i32 %1, -20
br label %153
153: ; preds = %140, %153
%154 = phi i32 [ 0, %140 ], [ %167, %153 ]
%155 = phi i32 [ 0, %140 ], [ %166, %153 ]
%156 = add nuw nsw i32 %155, 230
%157 = mul nsw i32 %155, -4
%158 = add nsw i32 %157, 63
%159 = mul nuw nsw i32 %155, 3
%160 = add nuw nsw i32 %159, 15
%161 = call i32 @set_dac_register(i32 %156, i32 %158, i32 0, i32 %160)
%162 = add nuw nsw i32 %155, 30
%163 = add i32 %151, %154
%164 = add i32 %152, %154
%165 = call i32 @draw_line(i32 %162, i32 %163, i32 %164, i32 %163, i32 %156)
%166 = add nuw nsw i32 %155, 1
%167 = xor i32 %155, -1
%168 = icmp eq i32 %166, 16
br i1 %168, label %169, label %153
169: ; preds = %153
%170 = add nsw i32 %35, -103
%171 = add nsw i32 %2, -18
%172 = call i32 @tprint_str(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i32 27, i32 %170, i32 %171, i32 14)
%173 = call i32 (...) @get_key()
%174 = icmp eq i32 %173, 27
br i1 %174, label %175, label %177
175: ; preds = %169
%176 = call i32 @error_out(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
br label %177
177: ; preds = %175, %169
ret void
}