#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 /*<<< orphan*/ getch();
int /*<<< orphan*/ getmaxyx(int /*<<< orphan*/, int, int);
int /*<<< orphan*/ getyx(int /*<<< orphan*/, int, int);
int /*<<< orphan*/ initscr();
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, *bt = NULL, i = 0, TT, n, maxx, maxy, x, y, Q, c, CLOCK, dec;
  float TAT, WT;
  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++;
    bt = (int *)realloc(bt, sizeof(int) * i);
    fscanf(fp, "%d", &bt[i - 1]);
    TT += bt[i - 1];
  }
  TT -= bt[i - 1];
  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) {
    i = (i + 1) % n;
    if (bt[i] == 0)
      continue;
    dec = bt[i] > Q ? Q : bt[i];
    rectangle(y, x, y + 2, x + (dec * unit));
    mvprintw(y + 1, x + (dec * unit / 2), "P%d", i + 1);
    mvprintw(y + 4, x, "%d", CLOCK);
    CLOCK += dec;
    bt[i] -= dec;
    WT += (n - c - 1) * dec;
    if (bt[i] == 0) {
      TT += CLOCK;
      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)
movq   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x0,%al
call   1060 <initscr@plt>
mov    0x2dc9(%rip),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1080 <getmaxyx@plt>
mov    -0x24(%rbp),%edx
sub    $0x1,%edx
mov    -0x20(%rbp),%ecx
sub    $0x1,%ecx
xor    %esi,%esi
mov    %esi,%edi
call   1030 <rectangle@plt>
mov    -0x24(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x20(%rbp),%eax
sub    $0x20,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xd9b(%rip),%rdx
mov    $0x0,%al
call   1100 <mvprintw@plt>
lea    -0x70(%rbp),%rsi
lea    0xdaa(%rip),%rdi
mov    $0x0,%al
call   10f0 <scanw@plt>
lea    -0x70(%rbp),%rdi
lea    0xd9b(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x78(%rbp)
jne    12e9 <main+0xf9>
mov    -0x24(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x20(%rbp),%eax
sub    $0x16,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xd65(%rip),%rdx
mov    $0x0,%al
call   1100 <mvprintw@plt>
mov    $0x0,%al
call   10e0 <noecho@plt>
mov    $0x0,%al
call   10b0 <getch@plt>
mov    $0x0,%al
call   10c0 <endwin@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1668 <main+0x478>
movl   $0x0,-0x18(%rbp)
mov    -0x78(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    130e <main+0x11e>
jmp    136c <main+0x17c>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%esi
call   10a0 <realloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x78(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
cltq
shl    $0x2,%rax
add    %rax,%rdx
lea    0xd13(%rip),%rsi
call   1070 <fscanf@plt>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    12f0 <main+0x100>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%ecx
mov    -0x18(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x78(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x24(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
add    $0x1,%edi
mov    -0x20(%rbp),%eax
sub    $0x20,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xc7f(%rip),%rdx
mov    $0x0,%al
call   1100 <mvprintw@plt>
lea    0xc94(%rip),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x0,%al
call   10f0 <scanw@plt>
mov    0x2c0b(%rip),%rax
mov    (%rax),%edi
mov    -0x2c(%rbp),%esi
mov    -0x28(%rbp),%edx
call   1050 <getyx@plt>
mov    -0x2c(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%eax
sub    $0x8,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x28(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%esi
lea    0xc44(%rip),%rdx
mov    $0x0,%al
call   1100 <mvprintw@plt>
mov    -0x2c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %eax,-0x8(%rbp)
mov    -0x20(%rbp),%eax
mov    -0x18(%rbp),%ecx
imul   -0x8(%rbp),%ecx
sub    %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%edi
mov    -0x2c(%rbp),%esi
call   1110 <move@plt>
movl   $0x0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x44(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0xffffffff,-0x14(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    15a6 <main+0x3b6>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
cltd
idivl  -0x1c(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    14a1 <main+0x2b1>
jmp    1471 <main+0x281>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
cmp    -0x30(%rbp),%eax
jle    14c0 <main+0x2d0>
mov    -0x30(%rbp),%eax
mov    %eax,-0x7c(%rbp)
jmp    14ce <main+0x2de>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x7c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%esi
mov    -0x2c(%rbp),%edx
add    $0x2,%edx
mov    -0x28(%rbp),%ecx
mov    -0x3c(%rbp),%eax
imul   -0x8(%rbp),%eax
add    %eax,%ecx
call   1030 <rectangle@plt>
mov    -0x2c(%rbp),%edi
add    $0x1,%edi
mov    -0x28(%rbp),%esi
mov    -0x3c(%rbp),%eax
imul   -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
add    %eax,%esi
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
lea    0xb46(%rip),%rdx
mov    $0x0,%al
call   1100 <mvprintw@plt>
mov    -0x2c(%rbp),%edi
add    $0x4,%edi
mov    -0x28(%rbp),%esi
mov    -0x38(%rbp),%ecx
lea    0xb2d(%rip),%rdx
mov    $0x0,%al
call   1100 <mvprintw@plt>
mov    -0x3c(%rbp),%eax
add    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x3c(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
sub    %esi,%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x1c(%rbp),%eax
sub    -0x34(%rbp),%eax
sub    $0x1,%eax
imul   -0x3c(%rbp),%eax
cvtsi2ss %eax,%xmm0
addss  -0x44(%rbp),%xmm0
movss  %xmm0,-0x44(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    1594 <main+0x3a4>
mov    -0x38(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x3c(%rbp),%eax
imul   -0x8(%rbp),%eax
add    -0x28(%rbp),%eax
mov    %eax,-0x28(%rbp)
jmp    1471 <main+0x281>
mov    -0x2c(%rbp),%edi
add    $0x4,%edi
mov    -0x28(%rbp),%esi
mov    -0x38(%rbp),%ecx
lea    0xaa6(%rip),%rdx
mov    $0x0,%al
call   1100 <mvprintw@plt>
cvtsi2ssl -0x18(%rbp),%xmm0
cvtsi2ssl -0x1c(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x40(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x20(%rbp),%eax
sub    $0x1e,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
movss  -0x40(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xa63(%rip),%rdx
mov    $0x1,%al
call   1100 <mvprintw@plt>
cvtsi2ssl -0x1c(%rbp),%xmm1
movss  -0x44(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x44(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x20(%rbp),%eax
sub    $0x1e,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
movss  -0x44(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xa3c(%rip),%rdx
mov    $0x1,%al
call   1100 <mvprintw@plt>
mov    $0x0,%al
call   10e0 <noecho@plt>
mov    $0x0,%al
call   10b0 <getch@plt>
mov    $0x0,%al
call   10c0 <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    %r15d,%r15d
xor    %eax,%eax
call   1060 <initscr@plt>
mov    0x2dd9(%rip),%rbp
mov    0x0(%rbp),%edi
call   1080 <getmaxyx@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1030 <rectangle@plt>
lea    0xdd9(%rip),%rdx
xor    %edi,%edi
xor    %esi,%esi
xor    %eax,%eax
call   1100 <mvprintw@plt>
lea    0xde8(%rip),%rdi
lea    0x20(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   10f0 <scanw@plt>
lea    0xdd5(%rip),%rsi
mov    %rbx,%rdi
call   10d0 <fopen@plt>
test   %rax,%rax
je     126f <main+0x7f>
mov    %rax,%r13
mov    %rax,%rdi
call   1090 <feof@plt>
test   %eax,%eax
je     128c <main+0x9c>
xor    %ebx,%ebx
jmp    12dd <main+0xed>
lea    0xdb0(%rip),%rdx
xor    %edi,%edi
xor    %esi,%esi
xor    %eax,%eax
call   1100 <mvprintw@plt>
mov    $0xffffffff,%r12d
jmp    1490 <main+0x2a0>
xor    %r15d,%r15d
lea    0xdc9(%rip),%r14
xor    %ebp,%ebp
xor    %ebx,%ebx
nopw   0x0(%rax,%rax,1)
lea    0x4(%rbp),%r12
mov    %rbx,%rdi
mov    %r12d,%esi
call   10a0 <realloc@plt>
mov    %rax,%rbx
add    %rax,%rbp
mov    %r13,%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
call   1070 <fscanf@plt>
mov    %r13,%rdi
call   1090 <feof@plt>
add    $0x1,%r15d
mov    %r12,%rbp
test   %eax,%eax
je     12a0 <main+0xb0>
mov    0x2d0b(%rip),%rbp
lea    -0x1(%r15),%r14d
mov    %r13,%rdi
call   1040 <fclose@plt>
lea    0xd4c(%rip),%rdx
xor    %r12d,%r12d
mov    $0x1,%edi
xor    %esi,%esi
xor    %eax,%eax
call   1100 <mvprintw@plt>
lea    0xd57(%rip),%rdi
lea    0x1c(%rsp),%rsi
xor    %eax,%eax
call   10f0 <scanw@plt>
mov    0x0(%rbp),%edi
call   1050 <getyx@plt>
lea    0xd32(%rip),%rdx
xor    %esi,%esi
xor    %eax,%eax
call   1100 <mvprintw@plt>
xor    %edi,%edi
call   1110 <move@plt>
xorps  %xmm1,%xmm1
mov    $0x0,%ecx
xorps  %xmm0,%xmm0
cmp    $0x2,%r15d
jl     1425 <main+0x235>
mov    $0xffffffff,%ebp
xorps  %xmm0,%xmm0
movl   $0x0,0xc(%rsp)
xor    %esi,%esi
xor    %eax,%eax
nopl   0x0(%rax)
mov    %esi,0x18(%rsp)
mov    %eax,0x10(%rsp)
movss  %xmm0,0x14(%rsp)
xchg   %ax,%ax
add    $0x1,%ebp
mov    %ebp,%eax
cltd
idiv   %r14d
mov    %edx,%ebp
movslq %edx,%r15
mov    (%rbx,%r15,4),%r13d
test   %r13d,%r13d
je     1370 <main+0x180>
mov    0x1c(%rsp),%eax
cmp    %eax,%r13d
cmovg  %eax,%r13d
xor    %esi,%esi
xor    %ecx,%ecx
call   1030 <rectangle@plt>
lea    0x1(%r15),%ecx
xor    %esi,%esi
lea    0xcb6(%rip),%rdx
xor    %eax,%eax
call   1100 <mvprintw@plt>
xor    %esi,%esi
lea    0xca7(%rip),%rdx
mov    0xc(%rsp),%r12d
mov    %r12d,%ecx
xor    %eax,%eax
call   1100 <mvprintw@plt>
add    %r13d,%r12d
mov    0x18(%rsp),%esi
mov    %esi,%eax
not    %eax
add    %r14d,%eax
imul   %r13d,%eax
xor    %ecx,%ecx
sub    %r13d,(%rbx,%r15,4)
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movss  0x14(%rsp),%xmm1
addss  %xmm0,%xmm1
movaps %xmm1,%xmm0
mov    $0x0,%eax
mov    %r12d,0xc(%rsp)
cmove  %r12d,%eax
sete   %cl
mov    0x10(%rsp),%edx
add    %eax,%edx
mov    %edx,%eax
add    %ecx,%esi
cmp    %esi,%r14d
jg     1360 <main+0x170>
xorps  %xmm1,%xmm1
cvtsi2ss %eax,%xmm1
xor    %r12d,%r12d
mov    0xc(%rsp),%ecx
movss  %xmm1,0x10(%rsp)
movss  %xmm0,0x14(%rsp)
lea    0xc27(%rip),%rdx
xor    %esi,%esi
xor    %eax,%eax
call   1100 <mvprintw@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %r14d,%xmm0
movss  %xmm0,0xc(%rsp)
movss  0x10(%rsp),%xmm1
divss  %xmm0,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xbfb(%rip),%rdx
xor    %esi,%esi
mov    $0x1,%al
call   1100 <mvprintw@plt>
movss  0x14(%rsp),%xmm0
divss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xbfa(%rip),%rdx
xor    %esi,%esi
mov    $0x1,%al
call   1100 <mvprintw@plt>
xor    %eax,%eax
call   10e0 <noecho@plt>
xor    %eax,%eax
call   10b0 <getch@plt>
xor    %eax,%eax
call   10c0 <endwin@plt>
mov    %r12d,%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 = [3 x i8] c"%d\00"
@.str.5 = [25 x i8] c"Enter the time quantum: \00"
@.str.6 = [9 x i8] c"G-Chart:\00"
@.str.7 = [4 x i8] c"P%d\00"
@.str.8 = [31 x i8] c"Average turn-around time: %.2f\00"
@.str.9 = [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 float
%16 = alloca float
%17 = alloca [32 x i8]
%18 = alloca i32*
store i32 0, i32* %1
store i32* null, i32** %3
store i32 0, i32* %4
%19 = call i32 (...) @initscr()
%20 = load i32, i32* @stdscr
%21 = load i32, i32* %8
%22 = load i32, i32* %7
%23 = call i32 @getmaxyx(i32 %20, i32 %21, i32 %22)
%24 = load i32, i32* %8
%25 = sub nsw i32 %24, 1
%26 = load i32, i32* %7
%27 = sub nsw i32 %26, 1
%28 = call i32 @rectangle(i32 0, i32 0, i32 %25, i32 %27)
%29 = load i32, i32* %8
%30 = sdiv i32 %29, 4
%31 = load i32, i32* %7
%32 = sub nsw i32 %31, 32
%33 = sdiv i32 %32, 2
%34 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %30, i32 %33, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%35 = getelementptr inbounds [32 x i8], [32 x i8]* %17, i64 0, i64 0
%36 = call i32 (i8*, ...) @scanw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %35)
%37 = getelementptr inbounds [32 x i8], [32 x i8]* %17, i64 0, i64 0
%38 = call i32* @fopen(i8* %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %38, i32** %18
%39 = load i32*, i32** %18
%40 = icmp eq i32* %39, null
br i1 %40, label %41, label %51
41: ; preds = %0
%42 = load i32, i32* %8
%43 = sdiv i32 %42, 2
%44 = load i32, i32* %7
%45 = sub nsw i32 %44, 22
%46 = sdiv i32 %45, 2
%47 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %43, i32 %46, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%48 = call i32 (...) @noecho()
%49 = call i32 (...) @getch()
%50 = call i32 (...) @endwin()
store i32 -1, i32* %1
br label %262
51: ; preds = %0
store i32 0, i32* %5
br label %52
52: ; preds = %57, %51
%53 = load i32*, i32** %18
%54 = call i32 @feof(i32* %53)
%55 = icmp ne i32 %54, 0
%56 = xor i1 %55, true
br i1 %56, label %57, label %82
57: ; preds = %52
%58 = load i32, i32* %4
%59 = add nsw i32 %58, 1
store i32 %59, i32* %4
%60 = load i32*, i32** %3
%61 = load i32, i32* %4
%62 = sext i32 %61 to i64
%63 = mul i64 4, %62
%64 = trunc i64 %63 to i32
%65 = call i64 @realloc(i32* %60, i32 %64)
%66 = inttoptr i64 %65 to i32*
store i32* %66, i32** %3
%67 = load i32*, i32** %18
%68 = load i32*, i32** %3
%69 = load i32, i32* %4
%70 = sub nsw i32 %69, 1
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i32, i32* %68, i64 %71
%73 = call i32 @fscanf(i32* %67, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %72)
%74 = load i32*, i32** %3
%75 = load i32, i32* %4
%76 = sub nsw i32 %75, 1
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds i32, i32* %74, i64 %77
%79 = load i32, i32* %78
%80 = load i32, i32* %5
%81 = add nsw i32 %80, %79
store i32 %81, i32* %5
br label %52
82: ; preds = %52
%83 = load i32*, i32** %3
%84 = load i32, i32* %4
%85 = sub nsw i32 %84, 1
%86 = sext i32 %85 to i64
%87 = getelementptr inbounds i32, i32* %83, i64 %86
%88 = load i32, i32* %87
%89 = load i32, i32* %5
%90 = sub nsw i32 %89, %88
store i32 %90, i32* %5
%91 = load i32*, i32** %18
%92 = call i32 @fclose(i32* %91)
%93 = load i32, i32* %4
%94 = sub nsw i32 %93, 1
store i32 %94, i32* %6
%95 = load i32, i32* %8
%96 = sdiv i32 %95, 4
%97 = add nsw i32 %96, 1
%98 = load i32, i32* %7
%99 = sub nsw i32 %98, 32
%100 = sdiv i32 %99, 2
%101 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %97, i32 %100, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%102 = call i32 (i8*, ...) @scanw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %11)
%103 = load i32, i32* @stdscr
%104 = load i32, i32* %10
%105 = load i32, i32* %9
%106 = call i32 @getyx(i32 %103, i32 %104, i32 %105)
%107 = load i32, i32* %10
%108 = add nsw i32 %107, 4
store i32 %108, i32* %10
%109 = load i32, i32* %7
%110 = sub nsw i32 %109, 8
%111 = sdiv i32 %110, 2
store i32 %111, i32* %9
%112 = load i32, i32* %10
%113 = load i32, i32* %9
%114 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %112, i32 %113, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%115 = load i32, i32* %10
%116 = add nsw i32 %115, 2
store i32 %116, i32* %10
%117 = load i32, i32* %7
%118 = load i32, i32* %5
%119 = sdiv i32 %117, %118
store i32 %119, i32* %2
%120 = load i32, i32* %7
%121 = load i32, i32* %5
%122 = load i32, i32* %2
%123 = mul nsw i32 %121, %122
%124 = sub nsw i32 %120, %123
%125 = sdiv i32 %124, 2
store i32 %125, i32* %9
%126 = load i32, i32* %9
%127 = load i32, i32* %10
%128 = call i32 @move(i32 %126, i32 %127)
store i32 0, i32* %5
store float 0.000000e+00, float* %16
store i32 0, i32* %12
store i32 -1, i32* %4
store i32 0, i32* %13
br label %129
129: ; preds = %220, %144, %82
%130 = load i32, i32* %12
%131 = load i32, i32* %6
%132 = icmp slt i32 %130, %131
br i1 %132, label %133, label %226
133: ; preds = %129
%134 = load i32, i32* %4
%135 = add nsw i32 %134, 1
%136 = load i32, i32* %6
%137 = srem i32 %135, %136
store i32 %137, i32* %4
%138 = load i32*, i32** %3
%139 = load i32, i32* %4
%140 = sext i32 %139 to i64
%141 = getelementptr inbounds i32, i32* %138, i64 %140
%142 = load i32, i32* %141
%143 = icmp eq i32 %142, 0
br i1 %143, label %144, label %145
144: ; preds = %133
br label %129
145: ; preds = %133
%146 = load i32*, i32** %3
%147 = load i32, i32* %4
%148 = sext i32 %147 to i64
%149 = getelementptr inbounds i32, i32* %146, i64 %148
%150 = load i32, i32* %149
%151 = load i32, i32* %11
%152 = icmp sgt i32 %150, %151
br i1 %152, label %153, label %155
153: ; preds = %145
%154 = load i32, i32* %11
br label %161
155: ; preds = %145
%156 = load i32*, i32** %3
%157 = load i32, i32* %4
%158 = sext i32 %157 to i64
%159 = getelementptr inbounds i32, i32* %156, i64 %158
%160 = load i32, i32* %159
br label %161
161: ; preds = %155, %153
%162 = phi i32 [ %154, %153 ], [ %160, %155 ]
store i32 %162, i32* %14
%163 = load i32, i32* %10
%164 = load i32, i32* %9
%165 = load i32, i32* %10
%166 = add nsw i32 %165, 2
%167 = load i32, i32* %9
%168 = load i32, i32* %14
%169 = load i32, i32* %2
%170 = mul nsw i32 %168, %169
%171 = add nsw i32 %167, %170
%172 = call i32 @rectangle(i32 %163, i32 %164, i32 %166, i32 %171)
%173 = load i32, i32* %10
%174 = add nsw i32 %173, 1
%175 = load i32, i32* %9
%176 = load i32, i32* %14
%177 = load i32, i32* %2
%178 = mul nsw i32 %176, %177
%179 = sdiv i32 %178, 2
%180 = add nsw i32 %175, %179
%181 = load i32, i32* %4
%182 = add nsw i32 %181, 1
%183 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %174, i32 %180, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %182)
%184 = load i32, i32* %10
%185 = add nsw i32 %184, 4
%186 = load i32, i32* %9
%187 = load i32, i32* %13
%188 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %185, i32 %186, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %187)
%189 = load i32, i32* %14
%190 = load i32, i32* %13
%191 = add nsw i32 %190, %189
store i32 %191, i32* %13
%192 = load i32, i32* %14
%193 = load i32*, i32** %3
%194 = load i32, i32* %4
%195 = sext i32 %194 to i64
%196 = getelementptr inbounds i32, i32* %193, i64 %195
%197 = load i32, i32* %196
%198 = sub nsw i32 %197, %192
store i32 %198, i32* %196
%199 = load i32, i32* %6
%200 = load i32, i32* %12
%201 = sub nsw i32 %199, %200
%202 = sub nsw i32 %201, 1
%203 = load i32, i32* %14
%204 = mul nsw i32 %202, %203
%205 = sitofp i32 %204 to float
%206 = load float, float* %16
%207 = fadd float %206, %205
store float %207, float* %16
%208 = load i32*, i32** %3
%209 = load i32, i32* %4
%210 = sext i32 %209 to i64
%211 = getelementptr inbounds i32, i32* %208, i64 %210
%212 = load i32, i32* %211
%213 = icmp eq i32 %212, 0
br i1 %213, label %214, label %220
214: ; preds = %161
%215 = load i32, i32* %13
%216 = load i32, i32* %5
%217 = add nsw i32 %216, %215
store i32 %217, i32* %5
%218 = load i32, i32* %12
%219 = add nsw i32 %218, 1
store i32 %219, i32* %12
br label %220
220: ; preds = %214, %161
%221 = load i32, i32* %14
%222 = load i32, i32* %2
%223 = mul nsw i32 %221, %222
%224 = load i32, i32* %9
%225 = add nsw i32 %224, %223
store i32 %225, i32* %9
br label %129
226: ; preds = %129
%227 = load i32, i32* %10
%228 = add nsw i32 %227, 4
%229 = load i32, i32* %9
%230 = load i32, i32* %13
%231 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %228, i32 %229, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %230)
%232 = load i32, i32* %5
%233 = sitofp i32 %232 to float
%234 = load i32, i32* %6
%235 = sitofp i32 %234 to float
%236 = fdiv float %233, %235
store float %236, float* %15
%237 = load i32, i32* %10
%238 = add nsw i32 %237, 8
store i32 %238, i32* %10
%239 = load i32, i32* %10
%240 = load i32, i32* %7
%241 = sub nsw i32 %240, 30
%242 = sdiv i32 %241, 2
%243 = load float, float* %15
%244 = fpext float %243 to double
%245 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %239, i32 %242, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0), double %244)
%246 = load i32, i32* %6
%247 = sitofp i32 %246 to float
%248 = load float, float* %16
%249 = fdiv float %248, %247
store float %249, float* %16
%250 = load i32, i32* %10
%251 = add nsw i32 %250, 2
store i32 %251, i32* %10
%252 = load i32, i32* %10
%253 = load i32, i32* %7
%254 = sub nsw i32 %253, 30
%255 = sdiv i32 %254, 2
%256 = load float, float* %16
%257 = fpext float %256 to double
%258 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %252, i32 %255, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0), double %257)
%259 = call i32 (...) @noecho()
%260 = call i32 (...) @getch()
%261 = call i32 (...) @endwin()
store i32 0, i32* %1
br label %262
262: ; preds = %226, %41
%263 = load i32, i32* %1
ret i32 %263
}

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 = [3 x i8] c"%d\00"
@.str.5 = [25 x i8] c"Enter the time quantum: \00"
@.str.6 = [9 x i8] c"G-Chart:\00"
@.str.7 = [4 x i8] c"P%d\00"
@.str.8 = [31 x i8] c"Average turn-around time: %.2f\00"
@.str.9 = [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 %33
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 %96
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, 2
%24 = call i64 @realloc(i32* %20, i32 %23)
%25 = inttoptr i64 %24 to i32*
%26 = getelementptr inbounds i32, i32* %25, i64 %19
%27 = call i32 @fscanf(i32* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %26)
%28 = call i32 @feof(i32* %11)
%29 = icmp eq i32 %28, 0
br i1 %29, label %18, label %30
30: ; preds = %18
%31 = trunc i64 %21 to i32
%32 = inttoptr i64 %24 to i32*
br label %33
33: ; preds = %30, %13
%34 = phi i32 [ 0, %13 ], [ %31, %30 ]
%35 = phi i32* [ null, %13 ], [ %32, %30 ]
%36 = add nsw i32 %34, -1
%37 = call i32 @fclose(i32* %11)
%38 = 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))
%39 = call i32 (i8*, ...) @scanw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%40 = load i32, i32* @stdscr
%41 = call i32 @getyx(i32 %40, i32 undef, i32 undef)
%42 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 undef, i32 0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%43 = call i32 @move(i32 0, i32 undef)
%44 = icmp sgt i32 %34, 1
br i1 %44, label %45, label %84
45: ; preds = %33, %59
%46 = phi float [ %75, %59 ], [ 0.000000e+00, %33 ]
%47 = phi i32 [ %54, %59 ], [ -1, %33 ]
%48 = phi i32 [ %68, %59 ], [ 0, %33 ]
%49 = phi i32 [ %80, %59 ], [ 0, %33 ]
%50 = phi i32 [ %78, %59 ], [ 0, %33 ]
br label %51
51: ; preds = %45, %51
%52 = phi i32 [ %54, %51 ], [ %47, %45 ]
%53 = add nsw i32 %52, 1
%54 = srem i32 %53, %36
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i32, i32* %35, i64 %55
%57 = load i32, i32* %56
%58 = icmp eq i32 %57, 0
br i1 %58, label %51, label %59
59: ; preds = %51
%60 = getelementptr inbounds i32, i32* %35, i64 %55
%61 = load i32, i32* %1
%62 = icmp sgt i32 %57, %61
%63 = select i1 %62, i32 %61, i32 %57
%64 = call i32 @rectangle(i32 undef, i32 0, i32 undef, i32 0)
%65 = add nsw i32 %54, 1
%66 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 undef, i32 0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i32 %65)
%67 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 undef, i32 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %48)
%68 = add nsw i32 %63, %48
%69 = load i32, i32* %60
%70 = sub nsw i32 %69, %63
store i32 %70, i32* %60
%71 = xor i32 %49, -1
%72 = add i32 %36, %71
%73 = mul nsw i32 %63, %72
%74 = sitofp i32 %73 to float
%75 = fadd float %46, %74
%76 = icmp eq i32 %70, 0
%77 = select i1 %76, i32 %68, i32 0
%78 = add nsw i32 %77, %50
%79 = zext i1 %76 to i32
%80 = add nuw nsw i32 %49, %79
%81 = icmp sgt i32 %36, %80
br i1 %81, label %45, label %82
82: ; preds = %59
%83 = sitofp i32 %78 to float
br label %84
84: ; preds = %82, %33
%85 = phi float [ 0.000000e+00, %33 ], [ %83, %82 ]
%86 = phi i32 [ 0, %33 ], [ %68, %82 ]
%87 = phi float [ 0.000000e+00, %33 ], [ %75, %82 ]
%88 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 undef, i32 0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %86)
%89 = sitofp i32 %36 to float
%90 = fdiv float %85, %89
%91 = fpext float %90 to double
%92 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 undef, i32 0, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0), double %91)
%93 = fdiv float %87, %89
%94 = fpext float %93 to double
%95 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 undef, i32 0, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0), double %94)
br label %96
96: ; preds = %84, %16
%97 = phi i32 [ -1, %16 ], [ 0, %84 ]
%98 = call i32 (...) @noecho()
%99 = call i32 (...) @getch()
%100 = call i32 (...) @endwin()
ret i32 %97
}