#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 *calloc(int, int);
int check();
int /*<<< orphan*/ delete (int, int *);
int /*<<< orphan*/ display(int *);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ insert(int, int, int *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ refresh();
int /*<<< orphan*/ scanf(char *, int *, ...);
int main() {
  int *ARR = calloc(50, sizeof(int));
  int i, pos, val;
  refresh();
  printf("          WELCOME TO OUR PROGRAM\n");
  while (1) {
    printf("          Please choose from available options:-\n");
    printf("****************************************************\n");
    printf("     ENTER 1 TO INSERT\n");
    printf("     Enter 2 To delete\n");
    printf("     ENTER 3 TO displaqy\n");
    printf("     Enter 4 To exit\n");
    scanf("%d", &i);
    switch (i) {
    case 1:
      printf("Enter position and value to be inserted :  ");
      int flag = check();
      if (flag == 0) {
        printf("Array is full\n");
        printf("Enter a character to continue :");
        getchar();
        getchar();
        break;
      }
      scanf("%d %d", &pos, &val);
      insert(pos, val, ARR);
      break;
    case 2:
      printf("Enter position from which we need to perform deletion: \n");
      scanf("%d", &pos);
      int flag1 = check();
      if (flag1 == 1) {
        printf("Array is empty\n");
        printf("Enter a character to continue :");
        getchar();
        getchar();
        break;
      }
      delete (pos, ARR);
      break;
    case 3:
      printf("Elements of arrays are as follows\n");
      display(ARR);
      printf("Enter a character to continue :");
      getchar();
      getchar();
      break;
    case 4:
      printf("Thanks for using program\n");
      return 0;
    }
    refresh();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x32,%edi
mov    $0x4,%esi
call   1050 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1070 <refresh@plt>
lea    0xe50(%rip),%rdi
call   1040 <printf@plt>
lea    0xe66(%rip),%rdi
call   1040 <printf@plt>
lea    0xe8c(%rip),%rdi
call   1040 <printf@plt>
lea    0xeb6(%rip),%rdi
call   1040 <printf@plt>
lea    0xec2(%rip),%rdi
call   1040 <printf@plt>
lea    0xece(%rip),%rdi
call   1040 <printf@plt>
lea    0xedc(%rip),%rdi
call   1040 <printf@plt>
lea    0xf44(%rip),%rdi
xor    %eax,%eax
lea    -0x14(%rbp),%rsi
call   1080 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x3,%eax
ja     1373 <main+0x1e3>
mov    -0x30(%rbp),%rax
lea    0xdc1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeab(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   10a0 <check@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    1293 <main+0x103>
lea    0xeb7(%rip),%rdi
call   1040 <printf@plt>
lea    0xeba(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
jmp    1373 <main+0x1e3>
lea    0xebb(%rip),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
mov    $0x0,%al
call   1080 <scanf@plt>
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1090 <insert@plt>
jmp    1373 <main+0x1e3>
lea    0xe97(%rip),%rdi
call   1040 <printf@plt>
lea    0xe88(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
mov    $0x0,%al
call   10a0 <check@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x1,-0x24(%rbp)
jne    131a <main+0x18a>
lea    0xe9e(%rip),%rdi
call   1040 <printf@plt>
lea    0xe33(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
jmp    1373 <main+0x1e3>
mov    -0x18(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   10b0 <delete@plt>
jmp    1373 <main+0x1e3>
lea    0xe72(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <display@plt>
lea    0xdee(%rip),%rdi
call   1040 <printf@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
jmp    1373 <main+0x1e3>
lea    0xe61(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret
mov    $0x0,%al
call   1070 <refresh@plt>
jmp    11c5 <main+0x35>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    $0x32,%edi
mov    $0x4,%esi
call   1060 <calloc@plt>
mov    %rax,0x8(%rsp)
xor    %eax,%eax
call   1080 <refresh@plt>
lea    0xe92(%rip),%rdi
call   1030 <puts@plt>
lea    0xf24(%rip),%rbx
lea    0xf34(%rip),%rbp
lea    0xf46(%rip),%r14
lea    0xe6e(%rip),%r15
lea    0x14(%rsp),%r12
lea    0xe03(%rip),%r13
jmp    1237 <main+0x97>
nop
lea    0xf57(%rip),%rdi
call   1030 <puts@plt>
mov    0x8(%rsp),%rdi
call   1040 <display@plt>
lea    0xe1f(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
xor    %eax,%eax
call   1080 <refresh@plt>
lea    0xe45(%rip),%rdi
call   1030 <puts@plt>
lea    0xe6a(%rip),%rdi
call   1030 <puts@plt>
lea    0xe93(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
mov    0x14(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     1230 <main+0x90>
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
jmp    *%rax
lea    0xd73(%rip),%rdi
call   1050 <printf@plt>
xor    %eax,%eax
call   10b0 <check@plt>
test   %eax,%eax
je     1323 <main+0x183>
lea    0xda8(%rip),%rdi
lea    0x4(%rsp),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   1090 <scanf@plt>
mov    0x4(%rsp),%edi
mov    0x10(%rsp),%esi
mov    0x8(%rsp),%rdx
call   10a0 <insert@plt>
jmp    1230 <main+0x90>
nopl   0x0(%rax)
lea    0xe99(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1090 <scanf@plt>
xor    %eax,%eax
call   10b0 <check@plt>
cmp    $0x1,%eax
jne    1310 <main+0x170>
lea    0xeaa(%rip),%rdi
jmp    132a <main+0x18a>
mov    0x4(%rsp),%edi
mov    0x8(%rsp),%rsi
call   10c0 <delete@plt>
jmp    1230 <main+0x90>
lea    0xe9d(%rip),%rdi
call   1030 <puts@plt>
jmp    1216 <main+0x76>
lea    0xe0a(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c" WELCOME TO OUR PROGRAM\0A\00"
@.str.1 = [50 x i8] c" Please choose from available options:-\0A\00"
@.str.2 = [54 x i8] c"****************************************************\0A\00"
@.str.3 = [24 x i8] c" ENTER 1 TO INSERT\0A\00"
@.str.4 = [24 x i8] c" Enter 2 To delete\0A\00"
@.str.5 = [26 x i8] c" ENTER 3 TO displaqy\0A\00"
@.str.6 = [22 x i8] c" Enter 4 To exit\0A\00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [44 x i8] c"Enter position and value to be inserted : \00"
@.str.9 = [15 x i8] c"Array is full\0A\00"
@.str.10 = [32 x i8] c"Enter a character to continue :\00"
@.str.11 = [6 x i8] c"%d %d\00"
@.str.12 = [57 x i8] c"Enter position from which we need to perform deletion: \0A\00"
@.str.13 = [16 x i8] c"Array is empty\0A\00"
@.str.14 = [35 x i8] c"Elements of arrays are as follows\0A\00"
@.str.15 = [26 x i8] c"Thanks for using program\0A\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
store i32 0, i32* %1
%8 = call i32* @calloc(i32 50, i32 4)
store i32* %8, i32** %2
%9 = call i32 (...) @refresh()
%10 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %0, %60
%12 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%17 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
%18 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %3)
%19 = load i32, i32* %3
switch i32 %19, label %60 [
i32 1, label %20
i32 2, label %36
i32 3, label %51
i32 4, label %58
]
20: ; preds = %11
%21 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.8, i64 0, i64 0))
%22 = call i32 (...) @check()
store i32 %22, i32* %6
%23 = load i32, i32* %6
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %20
%26 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%27 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0))
%28 = call i32 (...) @getchar()
%29 = call i32 (...) @getchar()
br label %60
30: ; preds = %20
%31 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i32* %4, i32* %5)
%32 = load i32, i32* %4
%33 = load i32, i32* %5
%34 = load i32*, i32** %2
%35 = call i32 @insert(i32 %32, i32 %33, i32* %34)
br label %60
36: ; preds = %11
%37 = call i32 @printf(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.12, i64 0, i64 0))
%38 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %4)
%39 = call i32 (...) @check()
store i32 %39, i32* %7
%40 = load i32, i32* %7
%41 = icmp eq i32 %40, 1
br i1 %41, label %42, label %47
42: ; preds = %36
%43 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.13, i64 0, i64 0))
%44 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0))
%45 = call i32 (...) @getchar()
%46 = call i32 (...) @getchar()
br label %60
47: ; preds = %36
%48 = load i32, i32* %4
%49 = load i32*, i32** %2
%50 = call i32 @delete(i32 %48, i32* %49)
br label %60
51: ; preds = %11
%52 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.14, i64 0, i64 0))
%53 = load i32*, i32** %2
%54 = call i32 @display(i32* %53)
%55 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0))
%56 = call i32 (...) @getchar()
%57 = call i32 (...) @getchar()
br label %60
58: ; preds = %11
%59 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.15, i64 0, i64 0))
ret i32 0
60: ; preds = %11, %51, %47, %42, %30, %25
%61 = call i32 (...) @refresh()
br label %11
}

LLVM IR (-O2):
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [44 x i8] c"Enter position and value to be inserted : \00"
@.str.10 = [32 x i8] c"Enter a character to continue :\00"
@.str.11 = [6 x i8] c"%d %d\00"
@str = [33 x i8] c" WELCOME TO OUR PROGRAM\00"
@str.16 = [49 x i8] c" Please choose from available options:-\00"
@str.17 = [53 x i8] c"****************************************************\00"
@str.18 = [23 x i8] c" ENTER 1 TO INSERT\00"
@str.19 = [23 x i8] c" Enter 2 To delete\00"
@str.20 = [25 x i8] c" ENTER 3 TO displaqy\00"
@str.21 = [21 x i8] c" Enter 4 To exit\00"
@str.22 = [25 x i8] c"Thanks for using program\00"
@str.23 = [34 x i8] c"Elements of arrays are as follows\00"
@str.24 = [56 x i8] c"Enter position from which we need to perform deletion: \00"
@str.25 = [15 x i8] c"Array is empty\00"
@str.26 = [14 x i8] c"Array is full\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = tail call i32* @calloc(i32 50, i32 4)
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = tail call i32 (...) @refresh()
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
br label %10
10: ; preds = %54, %0
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @str.16, i64 0, i64 0))
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.17, i64 0, i64 0))
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.18, i64 0, i64 0))
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.19, i64 0, i64 0))
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.20, i64 0, i64 0))
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.21, i64 0, i64 0))
%17 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %1)
%18 = load i32, i32* %1
switch i32 %18, label %54 [
i32 1, label %19
i32 2, label %33
i32 3, label %46
i32 4, label %52
]
19: ; preds = %10
%20 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.8, i64 0, i64 0))
%21 = call i32 (...) @check()
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %19
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.26, i64 0, i64 0))
%25 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0))
%26 = call i32 (...) @getchar()
%27 = call i32 (...) @getchar()
br label %54
28: ; preds = %19
%29 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.11, i64 0, i64 0), i32* %2, i32* %3)
%30 = load i32, i32* %2
%31 = load i32, i32* %3
%32 = call i32 @insert(i32 %30, i32 %31, i32* %4)
br label %54
33: ; preds = %10
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @str.24, i64 0, i64 0))
%35 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %2)
%36 = call i32 (...) @check()
%37 = icmp eq i32 %36, 1
br i1 %37, label %38, label %43
38: ; preds = %33
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.25, i64 0, i64 0))
%40 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0))
%41 = call i32 (...) @getchar()
%42 = call i32 (...) @getchar()
br label %54
43: ; preds = %33
%44 = load i32, i32* %2
%45 = call i32 @delete(i32 %44, i32* %4)
br label %54
46: ; preds = %10
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.23, i64 0, i64 0))
%48 = call i32 @display(i32* %4)
%49 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.10, i64 0, i64 0))
%50 = call i32 (...) @getchar()
%51 = call i32 (...) @getchar()
br label %54
52: ; preds = %10
%53 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.22, i64 0, i64 0))
ret i32 0
54: ; preds = %10, %46, %43, %38, %28, %23
%55 = call i32 (...) @refresh()
br label %10
}