#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 *, char *);
int /*<<< orphan*/ stdscr;
int main() {
  int unit, *bt = NULL, i = 0, TT, T, n, maxx, maxy, x, y;
  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;
  getyx(stdscr, y, x);
  y += 4;
  x = (maxx - 8) / 2;
  WT = T = 0;
  mvprintw(y, x, "G-Chart:");
  y += 2;
  unit = maxx / TT;
  x = (maxx - (TT * unit)) / 2;
  move(x, y);
  for (i = 0; i < n; i++) {
    rectangle(y, x, y + 2, x + (bt[i] * unit));
    mvprintw(y + 1, x + (bt[i] * unit / 2), "P%d", i + 1);
    mvprintw(y + 4, x, "%d", T);
    T += bt[i];
    WT += T;
    x += (bt[i] * unit);
  }
  mvprintw(y + 4, x, "%d", T);
  WT = (WT - T) / n;
  TAT = (float)TT / n + WT;
  y += 8;
  mvprintw(y, (maxx - 30) / 2, "Average turn-around time: %.2f", TAT);
  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    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    $0x0,%al
call   1060 <initscr@plt>
mov    0x2dcc(%rip),%rax
mov    (%rax),%edi
mov    -0x28(%rbp),%esi
mov    -0x24(%rbp),%edx
call   1080 <getmaxyx@plt>
mov    -0x28(%rbp),%edx
sub    $0x1,%edx
mov    -0x24(%rbp),%ecx
sub    $0x1,%ecx
xor    %esi,%esi
mov    %esi,%edi
call   1030 <rectangle@plt>
mov    -0x28(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x24(%rbp),%eax
sub    $0x20,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xd9e(%rip),%rdx
mov    $0x0,%al
call   1100 <mvprintw@plt>
lea    -0x60(%rbp),%rsi
lea    0xdad(%rip),%rdi
call   10f0 <scanw@plt>
lea    -0x60(%rbp),%rdi
lea    0xda0(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
jne    12e4 <main+0xf4>
mov    -0x28(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
mov    -0x24(%rbp),%eax
sub    $0x16,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xd6a(%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    15b3 <main+0x3c3>
movl   $0x0,-0x18(%rbp)
mov    -0x68(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1309 <main+0x119>
jmp    1367 <main+0x177>
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    -0x68(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
cltq
shl    $0x2,%rax
add    %rax,%rdx
lea    0xcff(%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    12eb <main+0xfb>
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    -0x68(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    0x2c50(%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    -0x24(%rbp),%eax
sub    $0x8,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x38(%rbp)
mov    -0x30(%rbp),%edi
mov    -0x2c(%rbp),%esi
lea    0xc61(%rip),%rdx
mov    $0x0,%al
call   1100 <mvprintw@plt>
mov    -0x30(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x30(%rbp)
mov    -0x24(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %eax,-0x8(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x18(%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   1110 <move@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    14e3 <main+0x2f3>
mov    -0x30(%rbp),%edi
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%edx
add    $0x2,%edx
mov    -0x2c(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%r8
mov    (%rax,%r8,4),%eax
imul   -0x8(%rbp),%eax
add    %eax,%ecx
call   1030 <rectangle@plt>
mov    -0x30(%rbp),%edi
add    $0x1,%edi
mov    -0x2c(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
imul   -0x8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
add    %eax,%esi
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
lea    0xbc6(%rip),%rdx
mov    $0x0,%al
call   1100 <mvprintw@plt>
mov    -0x30(%rbp),%edi
add    $0x4,%edi
mov    -0x2c(%rbp),%esi
mov    -0x1c(%rbp),%ecx
lea    0xbad(%rip),%rdx
mov    $0x0,%al
call   1100 <mvprintw@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cvtsi2ssl -0x1c(%rbp),%xmm0
addss  -0x38(%rbp),%xmm0
movss  %xmm0,-0x38(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
imul   -0x8(%rbp),%eax
add    -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    141e <main+0x22e>
mov    -0x30(%rbp),%edi
add    $0x4,%edi
mov    -0x2c(%rbp),%esi
mov    -0x1c(%rbp),%ecx
lea    0xb50(%rip),%rdx
mov    $0x0,%al
call   1100 <mvprintw@plt>
movss  -0x38(%rbp),%xmm0
cvtsi2ssl -0x1c(%rbp),%xmm1
subss  %xmm1,%xmm0
cvtsi2ssl -0x20(%rbp),%xmm1
divss  %xmm1,%xmm0
movss  %xmm0,-0x38(%rbp)
cvtsi2ssl -0x18(%rbp),%xmm0
cvtsi2ssl -0x20(%rbp),%xmm1
divss  %xmm1,%xmm0
addss  -0x38(%rbp),%xmm0
movss  %xmm0,-0x34(%rbp)
mov    -0x30(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%edi
mov    -0x24(%rbp),%eax
sub    $0x1e,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
movss  -0x34(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xaec(%rip),%rdx
mov    $0x1,%al
call   1100 <mvprintw@plt>
mov    -0x30(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%edi
mov    -0x24(%rbp),%eax
sub    $0x1e,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
movss  -0x38(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xad8(%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    $0x70,%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    0x2dd9(%rip),%rax
mov    (%rax),%edi
call   1080 <getmaxyx@plt>
xor    %edi,%edi
xor    %esi,%esi
call   1030 <rectangle@plt>
lea    0xdda(%rip),%rdx
xor    %edi,%edi
xor    %esi,%esi
xor    %eax,%eax
call   1100 <mvprintw@plt>
lea    0xde9(%rip),%rdi
lea    0x20(%rsp),%rbx
mov    %rbx,%rsi
call   10f0 <scanw@plt>
lea    0xdd8(%rip),%rsi
mov    %rbx,%rdi
call   10d0 <fopen@plt>
test   %rax,%rax
je     1363 <main+0x173>
mov    %rax,%r15
mov    %rax,%rdi
call   1090 <feof@plt>
mov    $0x1,%r14d
xor    %ebp,%ebp
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    0x4(%rbp),%rbx
mov    %r13,%rdi
mov    %ebx,%esi
call   10a0 <realloc@plt>
mov    %rax,%r13
lea    (%rax,%rbp,1),%rdx
mov    %r15,%rdi
lea    0xda7(%rip),%rsi
call   1070 <fscanf@plt>
add    0x0(%r13,%rbp,1),%r12d
mov    %r15,%rdi
call   1090 <feof@plt>
add    $0xffffffffffffffff,%r14
mov    %rbx,%rbp
test   %eax,%eax
je     1280 <main+0x90>
mov    %r14,%rax
neg    %rax
mov    %rax,0x18(%rsp)
mov    %eax,%eax
sub    0x0(%r13,%rax,4),%r12d
mov    %r15,%rdi
call   1040 <fclose@plt>
mov    0x2d0b(%rip),%rax
mov    (%rax),%edi
call   1050 <getyx@plt>
lea    0xd51(%rip),%rdx
xor    %esi,%esi
xor    %eax,%eax
call   1100 <mvprintw@plt>
xor    %edi,%edi
call   1110 <move@plt>
test   %r14d,%r14d
je     137f <main+0x18f>
neg    %r14d
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
xor    %r15d,%r15d
xor    %ebp,%ebp
nop
xor    %esi,%esi
xor    %ecx,%ecx
call   1030 <rectangle@plt>
lea    0x1(%r15),%rbx
xor    %esi,%esi
lea    0xd1f(%rip),%rdx
mov    %ebx,%ecx
xor    %eax,%eax
call   1100 <mvprintw@plt>
xor    %esi,%esi
lea    0xd0e(%rip),%rdx
mov    %ebp,%ecx
xor    %eax,%eax
call   1100 <mvprintw@plt>
add    0x0(%r13,%r15,4),%ebp
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
movaps (%rsp),%xmm1
addss  %xmm0,%xmm1
movaps %xmm1,(%rsp)
mov    %rbx,%r15
cmp    %rbx,%r14
jne    1310 <main+0x120>
jmp    1388 <main+0x198>
lea    0xcbc(%rip),%rdx
xor    %edi,%edi
xor    %esi,%esi
xor    %eax,%eax
call   1100 <mvprintw@plt>
mov    $0xffffffff,%ebx
jmp    1401 <main+0x211>
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
xor    %ebp,%ebp
lea    0xcb7(%rip),%rdx
xor    %esi,%esi
mov    %ebp,%ecx
xor    %eax,%eax
call   1100 <mvprintw@plt>
xorps  %xmm0,%xmm0
cvtsi2ss %ebp,%xmm0
xorps  %xmm1,%xmm1
cvtsi2ssl 0x18(%rsp),%xmm1
cvtsi2ss %r12d,%xmm2
movaps (%rsp),%xmm3
subss  %xmm0,%xmm3
unpcklps %xmm3,%xmm2
shufps $0x0,%xmm1,%xmm1
divps  %xmm1,%xmm2
movaps %xmm2,%xmm0
shufps $0x55,%xmm2,%xmm0
movaps %xmm0,(%rsp)
addss  %xmm0,%xmm2
xorps  %xmm0,%xmm0
cvtss2sd %xmm2,%xmm0
lea    0xc6b(%rip),%rdx
xor    %esi,%esi
mov    $0x1,%al
call   1100 <mvprintw@plt>
movaps (%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xc72(%rip),%rdx
xor    %esi,%esi
mov    $0x1,%al
call   1100 <mvprintw@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   10e0 <noecho@plt>
xor    %eax,%eax
call   10b0 <getch@plt>
xor    %eax,%eax
call   10c0 <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 = [3 x i8] c"%d\00"
@.str.5 = [9 x i8] c"G-Chart:\00"
@.str.6 = [4 x i8] c"P%d\00"
@.str.7 = [31 x i8] c"Average turn-around time: %.2f\00"
@.str.8 = [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 float
%13 = alloca float
%14 = alloca [32 x i8]
%15 = alloca i32*
store i32 0, i32* %1
store i32* null, i32** %3
store i32 0, i32* %4
%16 = call i32 (...) @initscr()
%17 = load i32, i32* @stdscr
%18 = load i32, i32* %9
%19 = load i32, i32* %8
%20 = call i32 @getmaxyx(i32 %17, i32 %18, i32 %19)
%21 = load i32, i32* %9
%22 = sub nsw i32 %21, 1
%23 = load i32, i32* %8
%24 = sub nsw i32 %23, 1
%25 = call i32 @rectangle(i32 0, i32 0, i32 %22, i32 %24)
%26 = load i32, i32* %9
%27 = sdiv i32 %26, 4
%28 = load i32, i32* %8
%29 = sub nsw i32 %28, 32
%30 = sdiv i32 %29, 2
%31 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %27, i32 %30, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%32 = getelementptr inbounds [32 x i8], [32 x i8]* %14, i64 0, i64 0
%33 = call i32 @scanw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %32)
%34 = getelementptr inbounds [32 x i8], [32 x i8]* %14, i64 0, i64 0
%35 = call i32* @fopen(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %35, i32** %15
%36 = load i32*, i32** %15
%37 = icmp eq i32* %36, null
br i1 %37, label %38, label %48
38: ; preds = %0
%39 = load i32, i32* %9
%40 = sdiv i32 %39, 2
%41 = load i32, i32* %8
%42 = sub nsw i32 %41, 22
%43 = sdiv i32 %42, 2
%44 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %40, i32 %43, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%45 = call i32 (...) @noecho()
%46 = call i32 (...) @getch()
%47 = call i32 (...) @endwin()
store i32 -1, i32* %1
br label %221
48: ; preds = %0
store i32 0, i32* %5
br label %49
49: ; preds = %54, %48
%50 = load i32*, i32** %15
%51 = call i32 @feof(i32* %50)
%52 = icmp ne i32 %51, 0
%53 = xor i1 %52, true
br i1 %53, label %54, label %79
54: ; preds = %49
%55 = load i32, i32* %4
%56 = add nsw i32 %55, 1
store i32 %56, i32* %4
%57 = load i32*, i32** %3
%58 = load i32, i32* %4
%59 = sext i32 %58 to i64
%60 = mul i64 4, %59
%61 = trunc i64 %60 to i32
%62 = call i64 @realloc(i32* %57, i32 %61)
%63 = inttoptr i64 %62 to i32*
store i32* %63, i32** %3
%64 = load i32*, i32** %15
%65 = load i32*, i32** %3
%66 = load i32, i32* %4
%67 = sub nsw i32 %66, 1
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i32, i32* %65, i64 %68
%70 = call i32 @fscanf(i32* %64, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %69)
%71 = load i32*, i32** %3
%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
%76 = load i32, i32* %75
%77 = load i32, i32* %5
%78 = add nsw i32 %77, %76
store i32 %78, i32* %5
br label %49
79: ; preds = %49
%80 = load i32*, i32** %3
%81 = load i32, i32* %4
%82 = sub nsw i32 %81, 1
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i32, i32* %80, i64 %83
%85 = load i32, i32* %84
%86 = load i32, i32* %5
%87 = sub nsw i32 %86, %85
store i32 %87, i32* %5
%88 = load i32*, i32** %15
%89 = call i32 @fclose(i32* %88)
%90 = load i32, i32* %4
%91 = sub nsw i32 %90, 1
store i32 %91, i32* %7
%92 = load i32, i32* @stdscr
%93 = load i32, i32* %11
%94 = load i32, i32* %10
%95 = call i32 @getyx(i32 %92, i32 %93, i32 %94)
%96 = load i32, i32* %11
%97 = add nsw i32 %96, 4
store i32 %97, i32* %11
%98 = load i32, i32* %8
%99 = sub nsw i32 %98, 8
%100 = sdiv i32 %99, 2
store i32 %100, i32* %10
store i32 0, i32* %6
store float 0.000000e+00, float* %13
%101 = load i32, i32* %11
%102 = load i32, i32* %10
%103 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %101, i32 %102, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%104 = load i32, i32* %11
%105 = add nsw i32 %104, 2
store i32 %105, i32* %11
%106 = load i32, i32* %8
%107 = load i32, i32* %5
%108 = sdiv i32 %106, %107
store i32 %108, i32* %2
%109 = load i32, i32* %8
%110 = load i32, i32* %5
%111 = load i32, i32* %2
%112 = mul nsw i32 %110, %111
%113 = sub nsw i32 %109, %112
%114 = sdiv i32 %113, 2
store i32 %114, i32* %10
%115 = load i32, i32* %10
%116 = load i32, i32* %11
%117 = call i32 @move(i32 %115, i32 %116)
store i32 0, i32* %4
br label %118
118: ; preds = %177, %79
%119 = load i32, i32* %4
%120 = load i32, i32* %7
%121 = icmp slt i32 %119, %120
br i1 %121, label %122, label %180
122: ; preds = %118
%123 = load i32, i32* %11
%124 = load i32, i32* %10
%125 = load i32, i32* %11
%126 = add nsw i32 %125, 2
%127 = load i32, i32* %10
%128 = load i32*, i32** %3
%129 = load i32, i32* %4
%130 = sext i32 %129 to i64
%131 = getelementptr inbounds i32, i32* %128, i64 %130
%132 = load i32, i32* %131
%133 = load i32, i32* %2
%134 = mul nsw i32 %132, %133
%135 = add nsw i32 %127, %134
%136 = call i32 @rectangle(i32 %123, i32 %124, i32 %126, i32 %135)
%137 = load i32, i32* %11
%138 = add nsw i32 %137, 1
%139 = load i32, i32* %10
%140 = load i32*, i32** %3
%141 = load i32, i32* %4
%142 = sext i32 %141 to i64
%143 = getelementptr inbounds i32, i32* %140, i64 %142
%144 = load i32, i32* %143
%145 = load i32, i32* %2
%146 = mul nsw i32 %144, %145
%147 = sdiv i32 %146, 2
%148 = add nsw i32 %139, %147
%149 = load i32, i32* %4
%150 = add nsw i32 %149, 1
%151 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %138, i32 %148, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %150)
%152 = load i32, i32* %11
%153 = add nsw i32 %152, 4
%154 = load i32, i32* %10
%155 = load i32, i32* %6
%156 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %153, i32 %154, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %155)
%157 = load i32*, i32** %3
%158 = load i32, i32* %4
%159 = sext i32 %158 to i64
%160 = getelementptr inbounds i32, i32* %157, i64 %159
%161 = load i32, i32* %160
%162 = load i32, i32* %6
%163 = add nsw i32 %162, %161
store i32 %163, i32* %6
%164 = load i32, i32* %6
%165 = sitofp i32 %164 to float
%166 = load float, float* %13
%167 = fadd float %166, %165
store float %167, float* %13
%168 = load i32*, i32** %3
%169 = load i32, i32* %4
%170 = sext i32 %169 to i64
%171 = getelementptr inbounds i32, i32* %168, i64 %170
%172 = load i32, i32* %171
%173 = load i32, i32* %2
%174 = mul nsw i32 %172, %173
%175 = load i32, i32* %10
%176 = add nsw i32 %175, %174
store i32 %176, i32* %10
br label %177
177: ; preds = %122
%178 = load i32, i32* %4
%179 = add nsw i32 %178, 1
store i32 %179, i32* %4
br label %118
180: ; preds = %118
%181 = load i32, i32* %11
%182 = add nsw i32 %181, 4
%183 = load i32, i32* %10
%184 = load i32, i32* %6
%185 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %182, i32 %183, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %184)
%186 = load float, float* %13
%187 = load i32, i32* %6
%188 = sitofp i32 %187 to float
%189 = fsub float %186, %188
%190 = load i32, i32* %7
%191 = sitofp i32 %190 to float
%192 = fdiv float %189, %191
store float %192, float* %13
%193 = load i32, i32* %5
%194 = sitofp i32 %193 to float
%195 = load i32, i32* %7
%196 = sitofp i32 %195 to float
%197 = fdiv float %194, %196
%198 = load float, float* %13
%199 = fadd float %197, %198
store float %199, float* %12
%200 = load i32, i32* %11
%201 = add nsw i32 %200, 8
store i32 %201, i32* %11
%202 = load i32, i32* %11
%203 = load i32, i32* %8
%204 = sub nsw i32 %203, 30
%205 = sdiv i32 %204, 2
%206 = load float, float* %12
%207 = fpext float %206 to double
%208 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %202, i32 %205, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), double %207)
%209 = load i32, i32* %11
%210 = add nsw i32 %209, 2
store i32 %210, i32* %11
%211 = load i32, i32* %11
%212 = load i32, i32* %8
%213 = sub nsw i32 %212, 30
%214 = sdiv i32 %213, 2
%215 = load float, float* %13
%216 = fpext float %215 to double
%217 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 %211, i32 %214, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0), double %216)
%218 = call i32 (...) @noecho()
%219 = call i32 (...) @getch()
%220 = call i32 (...) @endwin()
store i32 0, i32* %1
br label %221
221: ; preds = %180, %38
%222 = load i32, i32* %1
ret i32 %222
}

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 = [9 x i8] c"G-Chart:\00"
@.str.6 = [4 x i8] c"P%d\00"
@.str.7 = [31 x i8] c"Average turn-around time: %.2f\00"
@.str.8 = [27 x i8] c"Average waiting time: %.2f\00"
define i32 @main() {
%1 = alloca [32 x i8]
%2 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (...) @initscr()
%4 = load i32, i32* @stdscr
%5 = tail call i32 @getmaxyx(i32 %4, i32 undef, i32 undef)
%6 = tail call i32 @rectangle(i32 0, i32 0, i32 undef, i32 undef)
%7 = 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))
%8 = call i32 @scanw(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%9 = call i32* @fopen(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %14, label %11
11: ; preds = %0
%12 = call i32 @feof(i32* %9)
%13 = icmp eq i32 %12, 0
br label %16
14: ; preds = %0
%15 = 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 %79
16: ; preds = %11, %16
%17 = phi i64 [ 0, %11 ], [ %20, %16 ]
%18 = phi i32* [ null, %11 ], [ %24, %16 ]
%19 = phi i32 [ 0, %11 ], [ %28, %16 ]
%20 = add nuw i64 %17, 1
%21 = trunc i64 %20 to i32
%22 = shl i32 %21, 2
%23 = call i64 @realloc(i32* %18, i32 %22)
%24 = inttoptr i64 %23 to i32*
%25 = getelementptr inbounds i32, i32* %24, i64 %17
%26 = call i32 @fscanf(i32* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %25)
%27 = load i32, i32* %25
%28 = add nsw i32 %27, %19
%29 = call i32 @feof(i32* %9)
%30 = icmp eq i32 %29, 0
br i1 %30, label %16, label %31
31: ; preds = %16
%32 = inttoptr i64 %23 to i32*
%33 = trunc i64 %17 to i32
%34 = and i64 %17, 4294967295
%35 = getelementptr inbounds i32, i32* %32, i64 %34
%36 = load i32, i32* %35
%37 = sub nsw i32 %28, %36
%38 = call i32 @fclose(i32* %9)
%39 = load i32, i32* @stdscr
%40 = call i32 @getyx(i32 %39, i32 undef, i32 undef)
%41 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 undef, i32 0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
%42 = call i32 @move(i32 0, i32 undef)
%43 = icmp eq i32 %33, 0
br i1 %43, label %59, label %44
44: ; preds = %31, %44
%45 = phi i64 [ %50, %44 ], [ 0, %31 ]
%46 = phi float [ %57, %44 ], [ 0.000000e+00, %31 ]
%47 = phi i32 [ %55, %44 ], [ 0, %31 ]
%48 = getelementptr inbounds i32, i32* %32, i64 %45
%49 = call i32 @rectangle(i32 undef, i32 0, i32 undef, i32 0)
%50 = add nuw nsw i64 %45, 1
%51 = trunc i64 %50 to i32
%52 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 undef, i32 0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %51)
%53 = 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 %47)
%54 = load i32, i32* %48
%55 = add nsw i32 %54, %47
%56 = sitofp i32 %55 to float
%57 = fadd float %46, %56
%58 = icmp eq i64 %50, %34
br i1 %58, label %59, label %44
59: ; preds = %44, %31
%60 = phi i32 [ 0, %31 ], [ %55, %44 ]
%61 = phi float [ 0.000000e+00, %31 ], [ %57, %44 ]
%62 = 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 %60)
%63 = sitofp i32 %60 to float
%64 = fsub float %61, %63
%65 = sitofp i32 %33 to float
%66 = sitofp i32 %37 to float
%67 = insertelement <2 x float> poison, float %66, i64 0
%68 = insertelement <2 x float> %67, float %64, i64 1
%69 = insertelement <2 x float> poison, float %65, i64 0
%70 = shufflevector <2 x float> %69, <2 x float> poison, <2 x i32> zeroinitializer
%71 = fdiv <2 x float> %68, %70
%72 = extractelement <2 x float> %71, i64 0
%73 = extractelement <2 x float> %71, i64 1
%74 = fadd float %72, %73
%75 = fpext float %74 to double
%76 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 undef, i32 0, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0), double %75)
%77 = fpext float %73 to double
%78 = call i32 (i32, i32, i8*, ...) @mvprintw(i32 undef, i32 0, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0), double %77)
br label %79
79: ; preds = %59, %14
%80 = phi i32 [ -1, %14 ], [ 0, %59 ]
%81 = call i32 (...) @noecho()
%82 = call i32 (...) @getch()
%83 = call i32 (...) @endwin()
ret i32 %80
}