#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *, int *);
int /*<<< orphan*/ getch();
int /*<<< orphan*/ getmaxyx(int /*<<< orphan*/, int, int);
int /*<<< orphan*/ getyx(int /*<<< orphan*/, int, int);
int /*<<< orphan*/ initscr();
scalar_t__ malloc(int);
int /*<<< orphan*/ move(int, int);
int /*<<< orphan*/ mvprintw(int, int, char *, ...);
int /*<<< orphan*/ noecho();
scalar_t__ realloc(int **, int);
int /*<<< orphan*/ rectangle(int, int, int, int);
int /*<<< orphan*/ scanw(char *, ...);
int /*<<< orphan*/ stdscr;
int main() {
  int unit, proc, i = 0, CLOCK = 0, N, TT = 0, **queue = NULL, x, y, maxx, maxy,
                  Q, c, dec, wait;
  float TAT = 0, WT = 0;
  char file[32];
  FILE *fp;
  initscr();
  getmaxyx(stdscr, maxy, maxx);
  rectangle(0, 0, maxy - 1, maxx - 1);
  mvprintw(maxy / 4, (maxx - 32) / 2, "Enter the filename to  be read: ");
  scanw("%s", file);
  fp = fopen(file, "r");
  if (fp == NULL) {
    mvprintw(maxy / 2, (maxx - 22) / 2, "Error opening file!!!");
    noecho();
    getch();
    endwin();
    return -1;
  }
  TT = 0;
  while (!feof(fp)) {
    i++;
    queue = (int **)realloc(queue, sizeof(int *) * i);
    queue[i - 1] = (int *)malloc(sizeof(int) * 4);
    queue[i - 1][3] = i - 1;
    fscanf(fp, "%d%d", &(queue[i - 1][1]), &(queue[i - 1][0]));
    TT += queue[i - 1][0];
  }
  fclose(fp);
  N = i - 1;
  mvprintw((maxy / 4) + 1, (maxx - 32) / 2, "Enter the time quantum: ");
  scanw("%d", &Q);
  getyx(stdscr, y, x);
  y += 4;
  x = (maxx - 8) / 2;
  mvprintw(y, x, "G-Chart:");
  y += 2;
  unit = maxx / TT;
  x = (maxx - (TT * unit)) / 2;
  move(x, y);
  WT = TT = 0;
  c = 0;
  i = -1;
  CLOCK = 0;
  while (c < N) {
    proc = 0;
    for (i = wait = 0; i < N; i++) {
      if (queue[i][0] == 9999 || CLOCK < queue[i][1])
        continue;
      wait++;
      if (queue[i][0] < queue[proc][0])
        proc = i;
    }
    dec = queue[proc][0] > Q ? Q : queue[proc][0];
    rectangle(y, x, y + 2, x + (dec * unit));
    mvprintw(y + 1, x + (dec * unit / 2), "P%d", queue[proc][3] + 1);
    mvprintw(y + 4, x, "%d", CLOCK);
    CLOCK += dec;
    queue[proc][0] -= dec;
    WT += wait * dec;
    if (queue[proc][0] == 0) {
      TT += CLOCK;
      queue[proc][0] = 9999;
      c++;
    }
    x += (dec * unit);
  }
  mvprintw(y + 4, x, "%d", CLOCK);
  TAT = (float)TT / N;
  y += 8;
  mvprintw(y, (maxx - 30) / 2, "Average turn-around time: %.2f", TAT);
  WT /= N;
  y += 2;
  mvprintw(y, (maxx - 30) / 2, "Average waiting time: %.2f", WT);
  noecho();
  getch();
  endwin();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4c(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x50(%rbp)
mov    $0x0,%al
call   1060 <initscr@plt>
mov    0x2d9b(%rip),%rax
mov    (%rax),%edi
mov    -0x38(%rbp),%esi
mov    -0x34(%rbp),%edx
call   1080 <getmaxyx@plt>
mov    -0x38(%rbp),%edx
sub    $0x1,%edx
mov    -0x34(%rbp),%ecx
sub    $0x1,%ecx
xor    %esi,%esi
mov    %esi,%edi
call   1030 <rectangle@plt>
mov    -0x38(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x34(%rbp),%eax
sub    $0x20,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xd6d(%rip),%rdx
mov    $0x0,%al
call   1110 <mvprintw@plt>
lea    -0x70(%rbp),%rsi
lea    0xd7c(%rip),%rdi
mov    $0x0,%al
call   1100 <scanw@plt>
lea    -0x70(%rbp),%rdi
lea    0xd6d(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x78(%rbp)
jne    1317 <main+0x117>
mov    -0x38(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x34(%rbp),%eax
sub    $0x16,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xd37(%rip),%rdx
mov    $0x0,%al
call   1110 <mvprintw@plt>
mov    $0x0,%al
call   10f0 <noecho@plt>
mov    $0x0,%al
call   10c0 <getch@plt>
mov    $0x0,%al
call   10d0 <endwin@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1765 <main+0x565>
movl   $0x0,-0x1c(%rbp)
mov    -0x78(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    133c <main+0x13c>
jmp    13e8 <main+0x1e8>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x28(%rbp),%rdi
movslq -0x10(%rbp),%rax
shl    $0x3,%rax
mov    %eax,%esi
call   10b0 <realloc@plt>
mov    %rax,-0x28(%rbp)
mov    $0x10,%edi
call   10a0 <malloc@plt>
mov    %rax,%rdx
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%edx
sub    $0x1,%edx
movslq %edx,%rdx
mov    (%rax,%rdx,8),%rax
mov    %ecx,0xc(%rax)
mov    -0x78(%rbp),%rdi
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rdx
add    $0x4,%rdx
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rcx
lea    0xc77(%rip),%rsi
call   1070 <fscanf@plt>
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    (%rax),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    131e <main+0x11e>
mov    -0x78(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x38(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
add    $0x1,%edi
mov    -0x34(%rbp),%eax
sub    $0x20,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xc20(%rip),%rdx
mov    $0x0,%al
call   1110 <mvprintw@plt>
lea    0xc35(%rip),%rdi
lea    -0x3c(%rbp),%rsi
mov    $0x0,%al
call   1100 <scanw@plt>
mov    0x2ba7(%rip),%rax
mov    (%rax),%edi
mov    -0x30(%rbp),%esi
mov    -0x2c(%rbp),%edx
call   1050 <getyx@plt>
mov    -0x30(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x30(%rbp)
mov    -0x34(%rbp),%eax
sub    $0x8,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%edi
mov    -0x2c(%rbp),%esi
lea    0xbe5(%rip),%rdx
mov    $0x0,%al
call   1110 <mvprintw@plt>
mov    -0x30(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x30(%rbp)
mov    -0x34(%rbp),%eax
cltd
idivl  -0x1c(%rbp)
mov    %eax,-0x8(%rbp)
mov    -0x34(%rbp),%eax
mov    -0x1c(%rbp),%ecx
imul   -0x8(%rbp),%ecx
sub    %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x30(%rbp),%esi
call   1120 <move@plt>
movl   $0x0,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x50(%rbp)
movl   $0x0,-0x40(%rbp)
movl   $0xffffffff,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x40(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    16a3 <main+0x4a3>
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    157b <main+0x37b>
mov    -0x28(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
cmpl   $0x270f,(%rax)
je     1532 <main+0x332>
mov    -0x14(%rbp),%eax
mov    -0x28(%rbp),%rcx
movslq -0x10(%rbp),%rdx
mov    (%rcx,%rdx,8),%rcx
cmp    0x4(%rcx),%eax
jge    1537 <main+0x337>
jmp    156d <main+0x36d>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
mov    -0x28(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    (%rax),%eax
mov    -0x28(%rbp),%rcx
movslq -0xc(%rbp),%rdx
mov    (%rcx,%rdx,8),%rcx
cmp    (%rcx),%eax
jge    1568 <main+0x368>
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    156d <main+0x36d>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    14f6 <main+0x2f6>
mov    -0x28(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    (%rax),%eax
cmp    -0x3c(%rbp),%eax
jle    159d <main+0x39d>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x7c(%rbp)
jmp    15ae <main+0x3ae>
mov    -0x28(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    (%rax),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x30(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%edx
add    $0x2,%edx
mov    -0x2c(%rbp),%ecx
mov    -0x44(%rbp),%eax
imul   -0x8(%rbp),%eax
add    %eax,%ecx
call   1030 <rectangle@plt>
mov    -0x30(%rbp),%edi
add    $0x1,%edi
mov    -0x2c(%rbp),%esi
mov    -0x44(%rbp),%eax
imul   -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
add    %eax,%esi
mov    -0x28(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    0xc(%rax),%ecx
add    $0x1,%ecx
lea    0xa5f(%rip),%rdx
mov    $0x0,%al
call   1110 <mvprintw@plt>
mov    -0x30(%rbp),%edi
add    $0x4,%edi
mov    -0x2c(%rbp),%esi
mov    -0x14(%rbp),%ecx
lea    0xa46(%rip),%rdx
mov    $0x0,%al
call   1110 <mvprintw@plt>
mov    -0x44(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x44(%rbp),%edx
mov    -0x28(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    (%rax),%ecx
sub    %edx,%ecx
mov    %ecx,(%rax)
mov    -0x48(%rbp),%eax
imul   -0x44(%rbp),%eax
cvtsi2ss %eax,%xmm0
addss  -0x50(%rbp),%xmm0
movss  %xmm0,-0x50(%rbp)
mov    -0x28(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
cmpl   $0x0,(%rax)
jne    1691 <main+0x491>
mov    -0x14(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movl   $0x270f,(%rax)
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
mov    -0x44(%rbp),%eax
imul   -0x8(%rbp),%eax
add    -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    14d5 <main+0x2d5>
mov    -0x30(%rbp),%edi
add    $0x4,%edi
mov    -0x2c(%rbp),%esi
mov    -0x14(%rbp),%ecx
lea    0x9ae(%rip),%rdx
mov    $0x0,%al
call   1110 <mvprintw@plt>
cvtsi2ssl -0x1c(%rbp),%xmm0
cvtsi2ssl -0x18(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x4c(%rbp)
mov    -0x30(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%edi
mov    -0x34(%rbp),%eax
sub    $0x1e,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
movss  -0x4c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0x96b(%rip),%rdx
mov    $0x1,%al
call   1110 <mvprintw@plt>
cvtsi2ssl -0x18(%rbp),%xmm1
movss  -0x50(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x50(%rbp)
mov    -0x30(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%edi
mov    -0x34(%rbp),%eax
sub    $0x1e,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
movss  -0x50(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0x944(%rip),%rdx
mov    $0x1,%al
call   1110 <mvprintw@plt>
mov    $0x0,%al
call   10f0 <noecho@plt>
mov    $0x0,%al
call   10c0 <getch@plt>
mov    $0x0,%al
call   10d0 <endwin@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
xor    %r12d,%r12d
xor    %eax,%eax
call   1060 <initscr@plt>
mov    0x2dc9(%rip),%rbp
mov    0x0(%rbp),%edi
call   1080 <getmaxyx@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1030 <rectangle@plt>
lea    0xdc9(%rip),%rdx
xor    %edi,%edi
xor    %esi,%esi
xor    %eax,%eax
call   1110 <mvprintw@plt>
lea    0xdd8(%rip),%rdi
lea    0x20(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1100 <scanw@plt>
lea    0xdc5(%rip),%rsi
mov    %rbx,%rdi
call   10e0 <fopen@plt>
test   %rax,%rax
je     1282 <main+0x82>
mov    %rax,%r14
mov    %rax,%rdi
call   1090 <feof@plt>
test   %eax,%eax
je     129e <main+0x9e>
xor    %ebx,%ebx
jmp    12ff <main+0xff>
lea    0xd9d(%rip),%rdx
xor    %edi,%edi
xor    %esi,%esi
xor    %eax,%eax
call   1110 <mvprintw@plt>
mov    $0xffffffff,%ebx
jmp    14ed <main+0x2ed>
mov    $0x8,%r13d
xor    %r12d,%r12d
lea    0xd8e(%rip),%r15
xor    %ebx,%ebx
mov    %r12,%rbp
add    $0x1,%r12
mov    %rbx,%rdi
mov    %r13d,%esi
call   10b0 <realloc@plt>
mov    %rax,%rbx
mov    $0x10,%edi
call   10a0 <malloc@plt>
mov    %rax,(%rbx,%rbp,8)
mov    %ebp,0xc(%rax)
lea    0x4(%rax),%rdx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rax,%rcx
call   1070 <fscanf@plt>
mov    %r14,%rdi
call   1090 <feof@plt>
add    $0x8,%r13d
test   %eax,%eax
je     12b0 <main+0xb0>
mov    0x2ce9(%rip),%rbp
mov    %r14,%rdi
call   1040 <fclose@plt>
lea    -0x1(%r12),%eax
mov    %eax,0x18(%rsp)
lea    0xd2a(%rip),%rdx
mov    $0x1,%edi
xor    %esi,%esi
xor    %eax,%eax
call   1110 <mvprintw@plt>
lea    0xd38(%rip),%rdi
lea    0x1c(%rsp),%rsi
xor    %eax,%eax
call   1100 <scanw@plt>
mov    0x0(%rbp),%edi
call   1050 <getyx@plt>
lea    0xd13(%rip),%rdx
xor    %esi,%esi
xor    %eax,%eax
call   1110 <mvprintw@plt>
xor    %edi,%edi
call   1120 <move@plt>
xorps  %xmm1,%xmm1
mov    $0x0,%ebp
movl   $0x0,0x14(%rsp)
cmp    $0x2,%r12d
jl     1483 <main+0x283>
mov    0x18(%rsp),%r15d
xorps  %xmm1,%xmm1
xor    %eax,%eax
movl   $0x0,0x14(%rsp)
xor    %ebp,%ebp
jmp    13bd <main+0x1bd>
nopw   0x0(%rax,%rax,1)
add    %ebp,0x14(%rsp)
movl   $0x270f,(%rax)
mov    0xc(%rsp),%eax
add    $0x1,%eax
movss  0x10(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2ss %r13d,%xmm0
addss  %xmm0,%xmm1
cmp    0x18(%rsp),%eax
jge    1483 <main+0x283>
mov    %eax,0xc(%rsp)
xor    %eax,%eax
xor    %r13d,%r13d
xor    %ecx,%ecx
jmp    13df <main+0x1df>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r13d
mov    %esi,%ecx
add    $0x1,%rax
cmp    %rax,%r15
je     1410 <main+0x210>
mov    (%rbx,%rax,8),%rsi
mov    (%rsi),%edx
cmp    $0x270f,%edx
je     13d6 <main+0x1d6>
cmp    0x4(%rsi),%ebp
jl     13d6 <main+0x1d6>
movslq %ecx,%rsi
mov    (%rbx,%rsi,8),%rdi
mov    %eax,%esi
cmp    (%rdi),%edx
jl     13d0 <main+0x1d0>
mov    %ecx,%esi
jmp    13d0 <main+0x1d0>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movss  %xmm1,0x10(%rsp)
movslq %ecx,%r12
mov    (%rbx,%r12,8),%rax
mov    (%rax),%r14d
mov    0x1c(%rsp),%eax
cmp    %eax,%r14d
cmovg  %eax,%r14d
xor    %esi,%esi
xor    %ecx,%ecx
call   1030 <rectangle@plt>
mov    (%rbx,%r12,8),%rax
mov    0xc(%rax),%ecx
add    $0x1,%ecx
xor    %esi,%esi
lea    0xc1c(%rip),%rdx
xor    %eax,%eax
call   1110 <mvprintw@plt>
xor    %esi,%esi
lea    0xc0d(%rip),%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   1110 <mvprintw@plt>
add    %r14d,%ebp
mov    (%rbx,%r12,8),%rax
imul   %r14d,%r13d
sub    %r14d,(%rax)
je     1390 <main+0x190>
movss  0x10(%rsp),%xmm1
mov    0xc(%rsp),%eax
jmp    13a7 <main+0x1a7>
movss  %xmm1,0x10(%rsp)
lea    0xbd4(%rip),%rdx
xor    %esi,%esi
mov    %ebp,%ecx
xor    %eax,%eax
call   1110 <mvprintw@plt>
xorps  %xmm0,%xmm0
cvtsi2ssl 0x14(%rsp),%xmm0
xorps  %xmm1,%xmm1
cvtsi2ssl 0x18(%rsp),%xmm1
movss  %xmm1,0xc(%rsp)
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xba5(%rip),%rdx
xor    %esi,%esi
mov    $0x1,%al
call   1110 <mvprintw@plt>
movss  0x10(%rsp),%xmm0
divss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xba4(%rip),%rdx
xor    %esi,%esi
mov    $0x1,%al
call   1110 <mvprintw@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   10f0 <noecho@plt>
xor    %eax,%eax
call   10c0 <getch@plt>
xor    %eax,%eax
call   10d0 <endwin@plt>
mov    %ebx,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stdscr = global i32 0
@.str = [33 x i8] c"Enter the filename to be read: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [22 x i8] c"Error opening file!!!\00"
@.str.4 = [5 x i8] c"%d%d\00"
@.str.5 = [25 x i8] c"Enter the time quantum: \00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [9 x i8] c"G-Chart:\00"
@.str.8 = [4 x i8] c"P%d\00"
@.str.9 = [31 x i8] c"Average turn-around time: %.2f\00"
@.str.10 = [27 x i8] c"Average waiting time: %.2f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32**
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca float
%18 = alloca float
%19 = alloca [32 x i8]
%20 = alloca i32*
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %7
store i32** null, i32*** %8
store float 0.000000e+00, float* %17
store float 0.000000e+00, float* %18
%21 = call i32 (...) @initscr()
%22 = load i32, i32* @stdscr
%23 = load i32, i32* %12
%24 = load i32, i32* %11
%25 = call i32 @getmaxyx(i32 %22, i32 %23, i32 %24)
%26 = load i32, i32* %12
%27 = sub nsw i32 %26, 1
%28 = load i32, i32* %11
%29 = sub nsw i32 %28, 1
%30 = call i32 @rectangle(i32 0, i32 0, i32 %27, i32 %29)
%31 = load i32, i32* %12
%32 = sdiv i32 %31, 4
%33 = load i32, i32* %11
%34 = sub nsw i32 %33, 32
%35 = sdiv i32 %34, 2
%36 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %32, i32 %35, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%37 = getelementptr inbounds [32 x i8], [32 x i8]* %19, i64 0, i64 0
%38 = call i32 (i8*, ...) @scanw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %37)
%39 = getelementptr inbounds [32 x i8], [32 x i8]* %19, i64 0, i64 0
%40 = call i32* @fopen(i8* %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %40, i32** %20
%41 = load i32*, i32** %20
%42 = icmp eq i32* %41, null
br i1 %42, label %43, label %53
43: ; preds = %0
%44 = load i32, i32* %12
%45 = sdiv i32 %44, 2
%46 = load i32, i32* %11
%47 = sub nsw i32 %46, 22
%48 = sdiv i32 %47, 2
%49 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %45, i32 %48, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%50 = call i32 (...) @noecho()
%51 = call i32 (...) @getch()
%52 = call i32 (...) @endwin()
store i32 -1, i32* %1
br label %337
53: ; preds = %0
store i32 0, i32* %7
br label %54
54: ; preds = %59, %53
%55 = load i32*, i32** %20
%56 = call i32 @feof(i32* %55)
%57 = icmp ne i32 %56, 0
%58 = xor i1 %57, true
br i1 %58, label %59, label %111
59: ; preds = %54
%60 = load i32, i32* %4
%61 = add nsw i32 %60, 1
store i32 %61, i32* %4
%62 = load i32**, i32*** %8
%63 = load i32, i32* %4
%64 = sext i32 %63 to i64
%65 = mul i64 8, %64
%66 = trunc i64 %65 to i32
%67 = call i64 @realloc(i32** %62, i32 %66)
%68 = inttoptr i64 %67 to i32**
store i32** %68, i32*** %8
%69 = call i64 @malloc(i32 16)
%70 = inttoptr i64 %69 to i32*
%71 = load i32**, i32*** %8
%72 = load i32, i32* %4
%73 = sub nsw i32 %72, 1
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i32*, i32** %71, i64 %74
store i32* %70, i32** %75
%76 = load i32, i32* %4
%77 = sub nsw i32 %76, 1
%78 = load i32**, i32*** %8
%79 = load i32, i32* %4
%80 = sub nsw i32 %79, 1
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i32*, i32** %78, i64 %81
%83 = load i32*, i32** %82
%84 = getelementptr inbounds i32, i32* %83, i64 3
store i32 %77, i32* %84
%85 = load i32*, i32** %20
%86 = load i32**, i32*** %8
%87 = load i32, i32* %4
%88 = sub nsw i32 %87, 1
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds i32*, i32** %86, i64 %89
%91 = load i32*, i32** %90
%92 = getelementptr inbounds i32, i32* %91, i64 1
%93 = load i32**, i32*** %8
%94 = load i32, i32* %4
%95 = sub nsw i32 %94, 1
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds i32*, i32** %93, i64 %96
%98 = load i32*, i32** %97
%99 = getelementptr inbounds i32, i32* %98, i64 0
%100 = call i32 @fscanf(i32* %85, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32* %92, i32* %99)
%101 = load i32**, i32*** %8
%102 = load i32, i32* %4
%103 = sub nsw i32 %102, 1
%104 = sext i32 %103 to i64
%105 = getelementptr inbounds i32*, i32** %101, i64 %104
%106 = load i32*, i32** %105
%107 = getelementptr inbounds i32, i32* %106, i64 0
%108 = load i32, i32* %107
%109 = load i32, i32* %7
%110 = add nsw i32 %109, %108
store i32 %110, i32* %7
br label %54
111: ; preds = %54
%112 = load i32*, i32** %20
%113 = call i32 @fclose(i32* %112)
%114 = load i32, i32* %4
%115 = sub nsw i32 %114, 1
store i32 %115, i32* %6
%116 = load i32, i32* %12
%117 = sdiv i32 %116, 4
%118 = add nsw i32 %117, 1
%119 = load i32, i32* %11
%120 = sub nsw i32 %119, 32
%121 = sdiv i32 %120, 2
%122 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %118, i32 %121, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%123 = call i32 (i8*, ...) @scanw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %13)
%124 = load i32, i32* @stdscr
%125 = load i32, i32* %10
%126 = load i32, i32* %9
%127 = call i32 @getyx(i32 %124, i32 %125, i32 %126)
%128 = load i32, i32* %10
%129 = add nsw i32 %128, 4
store i32 %129, i32* %10
%130 = load i32, i32* %11
%131 = sub nsw i32 %130, 8
%132 = sdiv i32 %131, 2
store i32 %132, i32* %9
%133 = load i32, i32* %10
%134 = load i32, i32* %9
%135 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %133, i32 %134, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%136 = load i32, i32* %10
%137 = add nsw i32 %136, 2
store i32 %137, i32* %10
%138 = load i32, i32* %11
%139 = load i32, i32* %7
%140 = sdiv i32 %138, %139
store i32 %140, i32* %2
%141 = load i32, i32* %11
%142 = load i32, i32* %7
%143 = load i32, i32* %2
%144 = mul nsw i32 %142, %143
%145 = sub nsw i32 %141, %144
%146 = sdiv i32 %145, 2
store i32 %146, i32* %9
%147 = load i32, i32* %9
%148 = load i32, i32* %10
%149 = call i32 @move(i32 %147, i32 %148)
store i32 0, i32* %7
store float 0.000000e+00, float* %18
store i32 0, i32* %14
store i32 -1, i32* %4
store i32 0, i32* %5
br label %150
150: ; preds = %295, %111
%151 = load i32, i32* %14
%152 = load i32, i32* %6
%153 = icmp slt i32 %151, %152
br i1 %153, label %154, label %301
154: ; preds = %150
store i32 0, i32* %3
store i32 0, i32* %16
store i32 0, i32* %4
br label %155
155: ; preds = %200, %154
%156 = load i32, i32* %4
%157 = load i32, i32* %6
%158 = icmp slt i32 %156, %157
br i1 %158, label %159, label %203
159: ; preds = %155
%160 = load i32**, i32*** %8
%161 = load i32, i32* %4
%162 = sext i32 %161 to i64
%163 = getelementptr inbounds i32*, i32** %160, i64 %162
%164 = load i32*, i32** %163
%165 = getelementptr inbounds i32, i32* %164, i64 0
%166 = load i32, i32* %165
%167 = icmp eq i32 %166, 9999
br i1 %167, label %178, label %168
168: ; preds = %159
%169 = load i32, i32* %5
%170 = load i32**, i32*** %8
%171 = load i32, i32* %4
%172 = sext i32 %171 to i64
%173 = getelementptr inbounds i32*, i32** %170, i64 %172
%174 = load i32*, i32** %173
%175 = getelementptr inbounds i32, i32* %174, i64 1
%176 = load i32, i32* %175
%177 = icmp slt i32 %169, %176
br i1 %177, label %178, label %179
178: ; preds = %168, %159
br label %200
179: ; preds = %168
%180 = load i32, i32* %16
%181 = add nsw i32 %180, 1
store i32 %181, i32* %16
%182 = load i32**, i32*** %8
%183 = load i32, i32* %4
%184 = sext i32 %183 to i64
%185 = getelementptr inbounds i32*, i32** %182, i64 %184
%186 = load i32*, i32** %185
%187 = getelementptr inbounds i32, i32* %186, i64 0
%188 = load i32, i32* %187
%189 = load i32**, i32*** %8
%190 = load i32, i32* %3
%191 = sext i32 %190 to i64
%192 = getelementptr inbounds i32*, i32** %189, i64 %191
%193 = load i32*, i32** %192
%194 = getelementptr inbounds i32, i32* %193, i64 0
%195 = load i32, i32* %194
%196 = icmp slt i32 %188, %195
br i1 %196, label %197, label %199
197: ; preds = %179
%198 = load i32, i32* %4
store i32 %198, i32* %3
br label %199
199: ; preds = %197, %179
br label %200
200: ; preds = %199, %178
%201 = load i32, i32* %4
%202 = add nsw i32 %201, 1
store i32 %202, i32* %4
br label %155
203: ; preds = %155
%204 = load i32**, i32*** %8
%205 = load i32, i32* %3
%206 = sext i32 %205 to i64
%207 = getelementptr inbounds i32*, i32** %204, i64 %206
%208 = load i32*, i32** %207
%209 = getelementptr inbounds i32, i32* %208, i64 0
%210 = load i32, i32* %209
%211 = load i32, i32* %13
%212 = icmp sgt i32 %210, %211
br i1 %212, label %213, label %215
213: ; preds = %203
%214 = load i32, i32* %13
br label %223
215: ; preds = %203
%216 = load i32**, i32*** %8
%217 = load i32, i32* %3
%218 = sext i32 %217 to i64
%219 = getelementptr inbounds i32*, i32** %216, i64 %218
%220 = load i32*, i32** %219
%221 = getelementptr inbounds i32, i32* %220, i64 0
%222 = load i32, i32* %221
br label %223
223: ; preds = %215, %213
%224 = phi i32 [ %214, %213 ], [ %222, %215 ]
store i32 %224, i32* %15
%225 = load i32, i32* %10
%226 = load i32, i32* %9
%227 = load i32, i32* %10
%228 = add nsw i32 %227, 2
%229 = load i32, i32* %9
%230 = load i32, i32* %15
%231 = load i32, i32* %2
%232 = mul nsw i32 %230, %231
%233 = add nsw i32 %229, %232
%234 = call i32 @rectangle(i32 %225, i32 %226, i32 %228, i32 %233)
%235 = load i32, i32* %10
%236 = add nsw i32 %235, 1
%237 = load i32, i32* %9
%238 = load i32, i32* %15
%239 = load i32, i32* %2
%240 = mul nsw i32 %238, %239
%241 = sdiv i32 %240, 2
%242 = add nsw i32 %237, %241
%243 = load i32**, i32*** %8
%244 = load i32, i32* %3
%245 = sext i32 %244 to i64
%246 = getelementptr inbounds i32*, i32** %243, i64 %245
%247 = load i32*, i32** %246
%248 = getelementptr inbounds i32, i32* %247, i64 3
%249 = load i32, i32* %248
%250 = add nsw i32 %249, 1
%251 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %236, i32 %242, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 %250)
%252 = load i32, i32* %10
%253 = add nsw i32 %252, 4
%254 = load i32, i32* %9
%255 = load i32, i32* %5
%256 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %253, i32 %254, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %255)
%257 = load i32, i32* %15
%258 = load i32, i32* %5
%259 = add nsw i32 %258, %257
store i32 %259, i32* %5
%260 = load i32, i32* %15
%261 = load i32**, i32*** %8
%262 = load i32, i32* %3
%263 = sext i32 %262 to i64
%264 = getelementptr inbounds i32*, i32** %261, i64 %263
%265 = load i32*, i32** %264
%266 = getelementptr inbounds i32, i32* %265, i64 0
%267 = load i32, i32* %266
%268 = sub nsw i32 %267, %260
store i32 %268, i32* %266
%269 = load i32, i32* %16
%270 = load i32, i32* %15
%271 = mul nsw i32 %269, %270
%272 = sitofp i32 %271 to float
%273 = load float, float* %18
%274 = fadd float %273, %272
store float %274, float* %18
%275 = load i32**, i32*** %8
%276 = load i32, i32* %3
%277 = sext i32 %276 to i64
%278 = getelementptr inbounds i32*, i32** %275, i64 %277
%279 = load i32*, i32** %278
%280 = getelementptr inbounds i32, i32* %279, i64 0
%281 = load i32, i32* %280
%282 = icmp eq i32 %281, 0
br i1 %282, label %283, label %295
283: ; preds = %223
%284 = load i32, i32* %5
%285 = load i32, i32* %7
%286 = add nsw i32 %285, %284
store i32 %286, i32* %7
%287 = load i32**, i32*** %8
%288 = load i32, i32* %3
%289 = sext i32 %288 to i64
%290 = getelementptr inbounds i32*, i32** %287, i64 %289
%291 = load i32*, i32** %290
%292 = getelementptr inbounds i32, i32* %291, i64 0
store i32 9999, i32* %292
%293 = load i32, i32* %14
%294 = add nsw i32 %293, 1
store i32 %294, i32* %14
br label %295
295: ; preds = %283, %223
%296 = load i32, i32* %15
%297 = load i32, i32* %2
%298 = mul nsw i32 %296, %297
%299 = load i32, i32* %9
%300 = add nsw i32 %299, %298
store i32 %300, i32* %9
br label %150
301: ; preds = %150
%302 = load i32, i32* %10
%303 = add nsw i32 %302, 4
%304 = load i32, i32* %9
%305 = load i32, i32* %5
%306 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %303, i32 %304, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %305)
%307 = load i32, i32* %7
%308 = sitofp i32 %307 to float
%309 = load i32, i32* %6
%310 = sitofp i32 %309 to float
%311 = fdiv float %308, %310
store float %311, float* %17
%312 = load i32, i32* %10
%313 = add nsw i32 %312, 8
store i32 %313, i32* %10
%314 = load i32, i32* %10
%315 = load i32, i32* %11
%316 = sub nsw i32 %315, 30
%317 = sdiv i32 %316, 2
%318 = load float, float* %17
%319 = fpext float %318 to double
%320 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %314, i32 %317, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), double %319)
%321 = load i32, i32* %6
%322 = sitofp i32 %321 to float
%323 = load float, float* %18
%324 = fdiv float %323, %322
store float %324, float* %18
%325 = load i32, i32* %10
%326 = add nsw i32 %325, 2
store i32 %326, i32* %10
%327 = load i32, i32* %10
%328 = load i32, i32* %11
%329 = sub nsw i32 %328, 30
%330 = sdiv i32 %329, 2
%331 = load float, float* %18
%332 = fpext float %331 to double
%333 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %327, i32 %330, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0), double %332)
%334 = call i32 (...) @noecho()
%335 = call i32 (...) @getch()
%336 = call i32 (...) @endwin()
store i32 0, i32* %1
br label %337
337: ; preds = %301, %43
%338 = load i32, i32* %1
ret i32 %338
}

LLVM IR (-O2):
@stdscr = global i32 0
@.str = [33 x i8] c"Enter the filename to be read: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [22 x i8] c"Error opening file!!!\00"
@.str.4 = [5 x i8] c"%d%d\00"
@.str.5 = [25 x i8] c"Enter the time quantum: \00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [9 x i8] c"G-Chart:\00"
@.str.8 = [4 x i8] c"P%d\00"
@.str.9 = [31 x i8] c"Average turn-around time: %.2f\00"
@.str.10 = [27 x i8] c"Average waiting time: %.2f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [32 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (...) @initscr()
%6 = load i32, i32* @stdscr
%7 = tail call i32 @getmaxyx(i32 %6, i32 undef, i32 undef)
%8 = tail call i32 @rectangle(i32 0, i32 0, i32 undef, i32 undef)
%9 = tail call i32 (i32, i32, i8*, ...) @mvprintw(i32 0, i32 0, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%11 = call i32* @fopen(i8* %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %16, label %13
13: ; preds = %0
%14 = call i32 @feof(i32* %11)
%15 = icmp eq i32 %14, 0
br i1 %15, label %18, label %38
16: ; preds = %0
%17 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 0, i32 0, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
br label %126
18: ; preds = %13, %18
%19 = phi i64 [ %21, %18 ], [ 0, %13 ]
%20 = phi i32** [ %25, %18 ], [ null, %13 ]
%21 = add nuw i64 %19, 1
%22 = trunc i64 %21 to i32
%23 = shl i32 %22, 3
%24 = call i64 @realloc(i32** %20, i32 %23)
%25 = inttoptr i64 %24 to i32**
%26 = call i64 @malloc(i32 16)
%27 = inttoptr i64 %26 to i32*
%28 = getelementptr inbounds i32*, i32** %25, i64 %19
store i32* %27, i32** %28
%29 = getelementptr inbounds i32, i32* %27, i64 3
%30 = trunc i64 %19 to i32
store i32 %30, i32* %29
%31 = getelementptr inbounds i32, i32* %27, i64 1
%32 = call i32 @fscanf(i32* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32* %31, i32* %27)
%33 = call i32 @feof(i32* %11)
%34 = icmp eq i32 %33, 0
br i1 %34, label %18, label %35
35: ; preds = %18
%36 = trunc i64 %21 to i32
%37 = inttoptr i64 %24 to i32**
br label %38
38: ; preds = %35, %13
%39 = phi i32 [ 0, %13 ], [ %36, %35 ]
%40 = phi i32** [ null, %13 ], [ %37, %35 ]
%41 = call i32 @fclose(i32* %11)
%42 = add i32 %39, -1
%43 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 1, i32 0, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%44 = call i32 (i8*, ...) @scanw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %1)
%45 = load i32, i32* @stdscr
%46 = call i32 @getyx(i32 %45, i32 undef, i32 undef)
%47 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 undef, i32 0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%48 = call i32 @move(i32 0, i32 undef)
%49 = icmp sgt i32 %39, 1
br i1 %49, label %50, label %113
50: ; preds = %38
%51 = zext i32 %42 to i64
br label %52
52: ; preds = %109, %50
%53 = phi float [ 0.000000e+00, %50 ], [ %104, %109 ]
%54 = phi i32 [ 0, %50 ], [ %111, %109 ]
%55 = phi i32 [ 0, %50 ], [ %110, %109 ]
%56 = phi i32 [ 0, %50 ], [ %98, %109 ]
br label %57
57: ; preds = %52, %78
%58 = phi i64 [ 0, %52 ], [ %81, %78 ]
%59 = phi i32 [ 0, %52 ], [ %80, %78 ]
%60 = phi i32 [ 0, %52 ], [ %79, %78 ]
%61 = getelementptr inbounds i32*, i32** %40, i64 %58
%62 = load i32*, i32** %61
%63 = load i32, i32* %62
%64 = icmp eq i32 %63, 9999
br i1 %64, label %78, label %65
65: ; preds = %57
%66 = getelementptr inbounds i32, i32* %62, i64 1
%67 = load i32, i32* %66
%68 = icmp slt i32 %56, %67
br i1 %68, label %78, label %69
69: ; preds = %65
%70 = add nsw i32 %59, 1
%71 = sext i32 %60 to i64
%72 = getelementptr inbounds i32*, i32** %40, i64 %71
%73 = load i32*, i32** %72
%74 = load i32, i32* %73
%75 = icmp slt i32 %63, %74
%76 = trunc i64 %58 to i32
%77 = select i1 %75, i32 %76, i32 %60
br label %78
78: ; preds = %69, %57, %65
%79 = phi i32 [ %60, %57 ], [ %60, %65 ], [ %77, %69 ]
%80 = phi i32 [ %59, %57 ], [ %59, %65 ], [ %70, %69 ]
%81 = add nuw nsw i64 %58, 1
%82 = icmp eq i64 %81, %51
br i1 %82, label %83, label %57
83: ; preds = %78
%84 = sext i32 %79 to i64
%85 = getelementptr inbounds i32*, i32** %40, i64 %84
%86 = load i32*, i32** %85
%87 = load i32, i32* %86
%88 = load i32, i32* %1
%89 = icmp sgt i32 %87, %88
%90 = select i1 %89, i32 %88, i32 %87
%91 = call i32 @rectangle(i32 undef, i32 0, i32 undef, i32 0)
%92 = load i32*, i32** %85
%93 = getelementptr inbounds i32, i32* %92, i64 3
%94 = load i32, i32* %93
%95 = add nsw i32 %94, 1
%96 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 undef, i32 0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0), i32 %95)
%97 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 undef, i32 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %56)
%98 = add nsw i32 %90, %56
%99 = load i32*, i32** %85
%100 = load i32, i32* %99
%101 = sub nsw i32 %100, %90
store i32 %101, i32* %99
%102 = mul nsw i32 %90, %80
%103 = sitofp i32 %102 to float
%104 = fadd float %53, %103
%105 = icmp eq i32 %101, 0
br i1 %105, label %106, label %109
106: ; preds = %83
%107 = add nsw i32 %98, %55
store i32 9999, i32* %99
%108 = add nsw i32 %54, 1
br label %109
109: ; preds = %106, %83
%110 = phi i32 [ %107, %106 ], [ %55, %83 ]
%111 = phi i32 [ %108, %106 ], [ %54, %83 ]
%112 = icmp slt i32 %111, %42
br i1 %112, label %52, label %113
113: ; preds = %109, %38
%114 = phi i32 [ 0, %38 ], [ %98, %109 ]
%115 = phi i32 [ 0, %38 ], [ %110, %109 ]
%116 = phi float [ 0.000000e+00, %38 ], [ %104, %109 ]
%117 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 undef, i32 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32 %114)
%118 = sitofp i32 %115 to float
%119 = sitofp i32 %42 to float
%120 = fdiv float %118, %119
%121 = fpext float %120 to double
%122 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 undef, i32 0, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), double %121)
%123 = fdiv float %116, %119
%124 = fpext float %123 to double
%125 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 undef, i32 0, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0), double %124)
br label %126
126: ; preds = %113, %16
%127 = phi i32 [ -1, %16 ], [ 0, %113 ]
%128 = call i32 (...) @noecho()
%129 = call i32 (...) @getch()
%130 = call i32 (...) @endwin()
ret i32 %127
}