#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 binary(int *, int /*<<< orphan*/, int, int);
int fact(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ getchar();
int linear(int *, int, int);
scalar_t__ malloc(int);
int permut(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int /*<<< orphan*/ stdin;
int sum(int *, int);
int main() {
  int a, b, val, choice, res, i, pos, *arr;
  char ch = 'y';
  while (ch != 'N' && ch != 'n') {
    printf("Enter your choice :\n");
    printf("1. Factorial of a no.\n");
    printf("2. Binary Search on an array\n");
    printf("3. Linear Search on an array\n");
    printf("4. Summation of Elements of an array\n");
    printf("5. Permutation\n");
    scanf("%d", &choice);
    switch (choice) {
    case 1:
      printf("\n\nEnter the no. ");
      scanf("%d", &a);
      res = fact(a);
      printf("\nFactorial of the number is %d", res);
      break;
    case 2:
      printf("\n\nEnter size of the array ");
      scanf("%d", &a);
      arr = (int *)malloc(a * sizeof(int));
      printf("\nEnter elements in to the array (Ascending Order): ");
      for (i = 0; i < a; i++) {
        scanf("%d", &arr[i]);
      }
      printf("\nEnter value search ");
      scanf("%d", &val);
      pos = binary(arr, 0, a - 1, val);
      if (pos != -1)
        printf("\nElement Found at position %d", pos + 1);
      else
        printf("\nElement Not Found");
      break;
    case 3:
      printf("\n\nEnter size of the array");
      scanf("%d", &a);
      arr = (int *)malloc(a * sizeof(int));
      printf("\nEnter elements in to the array :");
      for (i = 0; i < a; i++) {
        scanf("%d", &arr[i]);
      }
      printf("\nEnter value search ");
      scanf("%d", &val);
      pos = linear(arr, a, val);
      if (pos != -1)
        printf("\nElement Found at position %d", pos + 1);
      else
        printf("\nElement Not Found");
      break;
    case 4:
      printf("\n\nEnter size of the array ");
      scanf("%d", &a);
      arr = (int *)malloc(a * sizeof(int));
      printf("\nEnter elements in to the array :");
      for (i = 0; i < a; i++) {
        scanf("%d", &arr[i]);
      }
      a = sum(arr, a);
      printf("\nSum of the Elements is %d", a);
      break;
    case 5:
      printf("\nEnter n and r for nPr: ");
      scanf("%d %d", &a, &b);
      res = permut(a, b);
      printf("\nPermutation %dP%d is %d", a, b, res);
      break;
    default:
      printf("\nInvalid Option Entered,Please try again");
      getchar();
      continue;
    }
    getchar();
    printf("\nDo you want to do more ");
    fflush(stdin);
    scanf("%c", &ch);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movb   $0x79,-0x29(%rbp)
movsbl -0x29(%rbp),%ecx
xor    %eax,%eax
cmp    $0x4e,%ecx
mov    %al,-0x2a(%rbp)
je     11d2 <main+0x32>
movsbl -0x29(%rbp),%eax
cmp    $0x6e,%eax
setne  %al
mov    %al,-0x2a(%rbp)
mov    -0x2a(%rbp),%al
test   $0x1,%al
jne    11e2 <main+0x42>
jmp    15d4 <main+0x434>
lea    0xe2b(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x39(%rbp)
call   1040 <printf@plt>
mov    -0x39(%rbp),%al
lea    0xe2c(%rip),%rdi
call   1040 <printf@plt>
mov    -0x39(%rbp),%al
lea    0xe34(%rip),%rdi
call   1040 <printf@plt>
mov    -0x39(%rbp),%al
lea    0xe43(%rip),%rdi
call   1040 <printf@plt>
mov    -0x39(%rbp),%al
lea    0xe52(%rip),%rdi
call   1040 <printf@plt>
mov    -0x39(%rbp),%al
lea    0xe69(%rip),%rdi
call   1040 <printf@plt>
mov    -0x39(%rbp),%al
lea    0xfa2(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   10c0 <scanf@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x38(%rbp)
sub    $0x4,%eax
ja     1580 <main+0x3e0>
mov    -0x38(%rbp),%rax
lea    0xd8f(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf5b(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   10c0 <scanf@plt>
mov    -0x8(%rbp),%edi
call   10a0 <fact@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    159a <main+0x3fa>
lea    0xe20(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xf1a(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   10c0 <scanf@plt>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x28(%rbp)
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    133a <main+0x19a>
mov    -0x28(%rbp),%rsi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   10c0 <scanf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1303 <main+0x163>
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe9b(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   10c0 <scanf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%edx
sub    $0x1,%edx
mov    -0x10(%rbp),%ecx
xor    %esi,%esi
call   1030 <binary@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xffffffff,-0x20(%rbp)
je     1394 <main+0x1f4>
mov    -0x20(%rbp),%esi
add    $0x1,%esi
lea    0xdbe(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13a2 <main+0x202>
lea    0xdc9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    159a <main+0x3fa>
lea    0xdc9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe2e(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   10c0 <scanf@plt>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x28(%rbp)
lea    0xdb0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1426 <main+0x286>
mov    -0x28(%rbp),%rsi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xdd9(%rip),%rdi
mov    $0x0,%al
call   10c0 <scanf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    13ef <main+0x24f>
lea    0xd04(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdaf(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   10c0 <scanf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1060 <linear@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xffffffff,-0x20(%rbp)
je     147b <main+0x2db>
mov    -0x20(%rbp),%esi
add    $0x1,%esi
lea    0xcd7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1489 <main+0x2e9>
lea    0xce2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    159a <main+0x3fa>
lea    0xc4d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd47(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   10c0 <scanf@plt>
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1080 <malloc@plt>
mov    %rax,-0x28(%rbp)
lea    0xcc9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    150d <main+0x36d>
mov    -0x28(%rbp),%rsi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xcf2(%rip),%rdi
mov    $0x0,%al
call   10c0 <scanf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    14d6 <main+0x336>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1070 <sum@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xc8d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    159a <main+0x3fa>
lea    0xc95(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xca0(%rip),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
mov    $0x0,%al
call   10c0 <scanf@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   10b0 <permut@plt>
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xc79(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    159a <main+0x3fa>
lea    0xc7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
jmp    11b3 <main+0x13>
mov    $0x0,%al
call   1050 <getchar@plt>
lea    0xc87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2a32(%rip),%rax
mov    (%rax),%edi
call   1090 <fflush@plt>
lea    0xc84(%rip),%rdi
lea    -0x29(%rbp),%rsi
mov    $0x0,%al
call   10c0 <scanf@plt>
jmp    11b3 <main+0x13>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movb   $0x79,0xb(%rsp)
lea    0xfe3(%rip),%r15
lea    0xff0(%rip),%r13
lea    0xfff(%rip),%r12
lea    0x1015(%rip),%rbp
lea    0x102b(%rip),%rbx
lea    0xf5f(%rip),%r14
jmp    126a <main+0xba>
nop
add    $0x1,%eax
lea    0xeae(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xfa3(%rip),%r15
lea    0xfb0(%rip),%r13
lea    0xfbf(%rip),%r12
lea    0xfd5(%rip),%rbp
lea    0xfeb(%rip),%rbx
xor    %eax,%eax
call   1060 <getchar@plt>
lea    0xf5d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2da6(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
lea    0xf5a(%rip),%rdi
lea    0xb(%rsp),%rsi
xor    %eax,%eax
call   10d0 <scanf@plt>
mov    0xb(%rsp),%al
and    $0xdf,%al
cmp    $0x4e,%al
je     156e <main+0x3be>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xf9d(%rip),%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   10d0 <scanf@plt>
mov    0x14(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x4,%eax
ja     1304 <main+0x154>
lea    0xd40(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xd44(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   10d0 <scanf@plt>
mov    0x4(%rsp),%edi
call   10b0 <fact@plt>
lea    0xd2f(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1226 <main+0x76>
lea    0xe5d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
jmp    125c <main+0xac>
lea    0xd1f(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   10d0 <scanf@plt>
mov    0x4(%rsp),%edi
shl    $0x2,%edi
call   1090 <malloc@plt>
mov    %rax,%r12
lea    0xd0e(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x0,0x4(%rsp)
jle    138f <main+0x1df>
mov    %r12,%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   10d0 <scanf@plt>
add    $0x1,%rbp
movslq 0x4(%rsp),%rax
add    $0x4,%rbx
cmp    %rax,%rbp
jl     1370 <main+0x1c0>
lea    0xcfd(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   10d0 <scanf@plt>
mov    0x4(%rsp),%edx
add    $0xffffffff,%edx
mov    0xc(%rsp),%ecx
mov    %r12,%rdi
xor    %esi,%esi
call   1040 <binary@plt>
cmp    $0xffffffff,%eax
jne    11f0 <main+0x40>
jmp    1475 <main+0x2c5>
lea    0xd03(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   10d0 <scanf@plt>
mov    0x4(%rsp),%edi
shl    $0x2,%edi
call   1090 <malloc@plt>
mov    %rax,%r12
lea    0xcf1(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
cmpl   $0x0,0x4(%rsp)
jle    143f <main+0x28f>
mov    %r12,%rbx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   10d0 <scanf@plt>
add    $0x1,%rbp
movslq 0x4(%rsp),%rax
add    $0x4,%rbx
cmp    %rax,%rbp
jl     1420 <main+0x270>
lea    0xc4d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   10d0 <scanf@plt>
mov    0x4(%rsp),%esi
mov    0xc(%rsp),%edx
mov    %r12,%rdi
call   1070 <linear@plt>
cmp    $0xffffffff,%eax
jne    11f0 <main+0x40>
lea    0xc4a(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1203 <main+0x53>
lea    0xbb5(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r14,%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   10d0 <scanf@plt>
mov    0x4(%rsp),%edi
shl    $0x2,%edi
call   1090 <malloc@plt>
mov    %rax,%r12
lea    0xc38(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
jle    14fd <main+0x34d>
mov    %r12,%rbx
xor    %ebp,%ebp
nop
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   10d0 <scanf@plt>
add    $0x1,%rbp
movslq 0x4(%rsp),%rsi
add    $0x4,%rbx
cmp    %rsi,%rbp
jl     14d0 <main+0x320>
lea    0xcb7(%rip),%r15
lea    0xcc4(%rip),%r13
mov    %r12,%rdi
call   1080 <sum@plt>
mov    %eax,0x4(%rsp)
lea    0xc05(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1211 <main+0x61>
lea    0xc0b(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xc16(%rip),%rdi
lea    0x4(%rsp),%rsi
lea    0x10(%rsp),%rdx
xor    %eax,%eax
call   10d0 <scanf@plt>
mov    0x4(%rsp),%edi
mov    0x10(%rsp),%esi
call   10c0 <permut@plt>
mov    0x4(%rsp),%esi
mov    0x10(%rsp),%edx
lea    0xbef(%rip),%rdi
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1226 <main+0x76>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Enter your choice :\0A\00"
@.str.1 = [23 x i8] c"1. Factorial of a no.\0A\00"
@.str.2 = [30 x i8] c"2. Binary Search on an array\0A\00"
@.str.3 = [30 x i8] c"3. Linear Search on an array\0A\00"
@.str.4 = [38 x i8] c"4. Summation of Elements of an array\0A\00"
@.str.5 = [16 x i8] c"5. Permutation\0A\00"
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [17 x i8] c"\0A\0AEnter the no. \00"
@.str.8 = [31 x i8] c"\0AFactorial of the number is %d\00"
@.str.9 = [27 x i8] c"\0A\0AEnter size of the array \00"
@.str.10 = [52 x i8] c"\0AEnter elements in to the array (Ascending Order): \00"
@.str.11 = [21 x i8] c"\0AEnter value search \00"
@.str.12 = [30 x i8] c"\0AElement Found at position %d\00"
@.str.13 = [19 x i8] c"\0AElement Not Found\00"
@.str.14 = [26 x i8] c"\0A\0AEnter size of the array\00"
@.str.15 = [34 x i8] c"\0AEnter elements in to the array :\00"
@.str.16 = [27 x i8] c"\0ASum of the Elements is %d\00"
@.str.17 = [25 x i8] c"\0AEnter n and r for nPr: \00"
@.str.18 = [6 x i8] c"%d %d\00"
@.str.19 = [25 x i8] c"\0APermutation %dP%d is %d\00"
@.str.20 = [41 x i8] c"\0AInvalid Option Entered,Please try again\00"
@.str.21 = [25 x i8] c"\0ADo you want to do more \00"
@stdin = global i32 0
@.str.22 = [3 x i8] c"%c\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 i8
store i32 0, i32* %1
store i8 121, i8* %10
br label %11
11: ; preds = %158, %155, %0
%12 = load i8, i8* %10
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 78
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = load i8, i8* %10
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 110
br label %19
19: ; preds = %15, %11
%20 = phi i1 [ false, %11 ], [ %18, %15 ]
br i1 %20, label %21, label %164
21: ; preds = %19
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0))
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.5, i64 0, i64 0))
%28 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %5)
%29 = load i32, i32* %5
switch i32 %29, label %155 [
i32 1, label %30
i32 2, label %37
i32 3, label %77
i32 4, label %116
i32 5, label %145
]
30: ; preds = %21
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
%32 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%33 = load i32, i32* %2
%34 = call i32 @fact(i32 %33)
store i32 %34, i32* %6
%35 = load i32, i32* %6
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0), i32 %35)
br label %158
37: ; preds = %21
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0))
%39 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%40 = load i32, i32* %2
%41 = sext i32 %40 to i64
%42 = mul i64 %41, 4
%43 = trunc i64 %42 to i32
%44 = call i64 @malloc(i32 %43)
%45 = inttoptr i64 %44 to i32*
store i32* %45, i32** %9
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.10, i64 0, i64 0))
store i32 0, i32* %7
br label %47
47: ; preds = %57, %37
%48 = load i32, i32* %7
%49 = load i32, i32* %2
%50 = icmp slt i32 %48, %49
br i1 %50, label %51, label %60
51: ; preds = %47
%52 = load i32*, i32** %9
%53 = load i32, i32* %7
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i32, i32* %52, i64 %54
%56 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %55)
br label %57
57: ; preds = %51
%58 = load i32, i32* %7
%59 = add nsw i32 %58, 1
store i32 %59, i32* %7
br label %47
60: ; preds = %47
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0))
%62 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %4)
%63 = load i32*, i32** %9
%64 = load i32, i32* %2
%65 = sub nsw i32 %64, 1
%66 = load i32, i32* %4
%67 = call i32 @binary(i32* %63, i32 0, i32 %65, i32 %66)
store i32 %67, i32* %8
%68 = load i32, i32* %8
%69 = icmp ne i32 %68, -1
br i1 %69, label %70, label %74
70: ; preds = %60
%71 = load i32, i32* %8
%72 = add nsw i32 %71, 1
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.12, i64 0, i64 0), i32 %72)
br label %76
74: ; preds = %60
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.13, i64 0, i64 0))
br label %76
76: ; preds = %74, %70
br label %158
77: ; preds = %21
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.14, i64 0, i64 0))
%79 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%80 = load i32, i32* %2
%81 = sext i32 %80 to i64
%82 = mul i64 %81, 4
%83 = trunc i64 %82 to i32
%84 = call i64 @malloc(i32 %83)
%85 = inttoptr i64 %84 to i32*
store i32* %85, i32** %9
%86 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.15, i64 0, i64 0))
store i32 0, i32* %7
br label %87
87: ; preds = %97, %77
%88 = load i32, i32* %7
%89 = load i32, i32* %2
%90 = icmp slt i32 %88, %89
br i1 %90, label %91, label %100
91: ; preds = %87
%92 = load i32*, i32** %9
%93 = load i32, i32* %7
%94 = sext i32 %93 to i64
%95 = getelementptr inbounds i32, i32* %92, i64 %94
%96 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %95)
br label %97
97: ; preds = %91
%98 = load i32, i32* %7
%99 = add nsw i32 %98, 1
store i32 %99, i32* %7
br label %87
100: ; preds = %87
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0))
%102 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %4)
%103 = load i32*, i32** %9
%104 = load i32, i32* %2
%105 = load i32, i32* %4
%106 = call i32 @linear(i32* %103, i32 %104, i32 %105)
store i32 %106, i32* %8
%107 = load i32, i32* %8
%108 = icmp ne i32 %107, -1
br i1 %108, label %109, label %113
109: ; preds = %100
%110 = load i32, i32* %8
%111 = add nsw i32 %110, 1
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.12, i64 0, i64 0), i32 %111)
br label %115
113: ; preds = %100
%114 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.13, i64 0, i64 0))
br label %115
115: ; preds = %113, %109
br label %158
116: ; preds = %21
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0))
%118 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%119 = load i32, i32* %2
%120 = sext i32 %119 to i64
%121 = mul i64 %120, 4
%122 = trunc i64 %121 to i32
%123 = call i64 @malloc(i32 %122)
%124 = inttoptr i64 %123 to i32*
store i32* %124, i32** %9
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.15, i64 0, i64 0))
store i32 0, i32* %7
br label %126
126: ; preds = %136, %116
%127 = load i32, i32* %7
%128 = load i32, i32* %2
%129 = icmp slt i32 %127, %128
br i1 %129, label %130, label %139
130: ; preds = %126
%131 = load i32*, i32** %9
%132 = load i32, i32* %7
%133 = sext i32 %132 to i64
%134 = getelementptr inbounds i32, i32* %131, i64 %133
%135 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %134)
br label %136
136: ; preds = %130
%137 = load i32, i32* %7
%138 = add nsw i32 %137, 1
store i32 %138, i32* %7
br label %126
139: ; preds = %126
%140 = load i32*, i32** %9
%141 = load i32, i32* %2
%142 = call i32 @sum(i32* %140, i32 %141)
store i32 %142, i32* %2
%143 = load i32, i32* %2
%144 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.16, i64 0, i64 0), i32 %143)
br label %158
145: ; preds = %21
%146 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.17, i64 0, i64 0))
%147 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.18, i64 0, i64 0), i32* %2, i32* %3)
%148 = load i32, i32* %2
%149 = load i32, i32* %3
%150 = call i32 @permut(i32 %148, i32 %149)
store i32 %150, i32* %6
%151 = load i32, i32* %2
%152 = load i32, i32* %3
%153 = load i32, i32* %6
%154 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.19, i64 0, i64 0), i32 %151, i32 %152, i32 %153)
br label %158
155: ; preds = %21
%156 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.20, i64 0, i64 0))
%157 = call i32 (...) @getchar()
br label %11
158: ; preds = %145, %139, %115, %76, %30
%159 = call i32 (...) @getchar()
%160 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.21, i64 0, i64 0))
%161 = load i32, i32* @stdin
%162 = call i32 @fflush(i32 %161)
%163 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.22, i64 0, i64 0), i8* %10)
br label %11
164: ; preds = %19
ret i32 0
}

LLVM IR (-O2):
@.str.6 = [3 x i8] c"%d\00"
@.str.7 = [17 x i8] c"\0A\0AEnter the no. \00"
@.str.8 = [31 x i8] c"\0AFactorial of the number is %d\00"
@.str.9 = [27 x i8] c"\0A\0AEnter size of the array \00"
@.str.10 = [52 x i8] c"\0AEnter elements in to the array (Ascending Order): \00"
@.str.11 = [21 x i8] c"\0AEnter value search \00"
@.str.12 = [30 x i8] c"\0AElement Found at position %d\00"
@.str.13 = [19 x i8] c"\0AElement Not Found\00"
@.str.14 = [26 x i8] c"\0A\0AEnter size of the array\00"
@.str.15 = [34 x i8] c"\0AEnter elements in to the array :\00"
@.str.16 = [27 x i8] c"\0ASum of the Elements is %d\00"
@.str.17 = [25 x i8] c"\0AEnter n and r for nPr: \00"
@.str.18 = [6 x i8] c"%d %d\00"
@.str.19 = [25 x i8] c"\0APermutation %dP%d is %d\00"
@.str.20 = [41 x i8] c"\0AInvalid Option Entered,Please try again\00"
@.str.21 = [25 x i8] c"\0ADo you want to do more \00"
@stdin = global i32 0
@.str.22 = [3 x i8] c"%c\00"
@str = [20 x i8] c"Enter your choice :\00"
@str.23 = [22 x i8] c"1. Factorial of a no.\00"
@str.24 = [29 x i8] c"2. Binary Search on an array\00"
@str.25 = [29 x i8] c"3. Linear Search on an array\00"
@str.26 = [37 x i8] c"4. Summation of Elements of an array\00"
@str.27 = [15 x i8] c"5. Permutation\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
%6 = bitcast i32* %1 to i8*
%7 = bitcast i32* %2 to i8*
%8 = bitcast i32* %3 to i8*
%9 = bitcast i32* %4 to i8*
store i8 121, i8* %5
br label %10
10: ; preds = %0, %120
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%12 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.23, i64 0, i64 0))
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.24, i64 0, i64 0))
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.25, i64 0, i64 0))
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.26, i64 0, i64 0))
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.27, i64 0, i64 0))
%17 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %4)
%18 = load i32, i32* %4
switch i32 %18, label %117 [
i32 1, label %19
i32 2, label %25
i32 3, label %56
i32 4, label %86
i32 5, label %108
]
19: ; preds = %10
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0))
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %1)
%22 = load i32, i32* %1
%23 = call i32 @fact(i32 %22)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.8, i64 0, i64 0), i32 %23)
br label %124
25: ; preds = %10
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0))
%27 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %1)
%28 = load i32, i32* %1
%29 = shl i32 %28, 2
%30 = call i64 @malloc(i32 %29)
%31 = inttoptr i64 %30 to i32*
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.10, i64 0, i64 0))
%33 = load i32, i32* %1
%34 = icmp sgt i32 %33, 0
br i1 %34, label %35, label %43
35: ; preds = %25, %35
%36 = phi i64 [ %39, %35 ], [ 0, %25 ]
%37 = getelementptr inbounds i32, i32* %31, i64 %36
%38 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %37)
%39 = add nuw nsw i64 %36, 1
%40 = load i32, i32* %1
%41 = sext i32 %40 to i64
%42 = icmp slt i64 %39, %41
br i1 %42, label %35, label %43
43: ; preds = %35, %25
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0))
%45 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %3)
%46 = load i32, i32* %1
%47 = add nsw i32 %46, -1
%48 = load i32, i32* %3
%49 = call i32 @binary(i32* %31, i32 0, i32 %47, i32 %48)
%50 = icmp eq i32 %49, -1
br i1 %50, label %54, label %51
51: ; preds = %43
%52 = add nuw nsw i32 %49, 1
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.12, i64 0, i64 0), i32 %52)
br label %124
54: ; preds = %43
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.13, i64 0, i64 0))
br label %124
56: ; preds = %10
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.14, i64 0, i64 0))
%58 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %1)
%59 = load i32, i32* %1
%60 = shl i32 %59, 2
%61 = call i64 @malloc(i32 %60)
%62 = inttoptr i64 %61 to i32*
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.15, i64 0, i64 0))
%64 = load i32, i32* %1
%65 = icmp sgt i32 %64, 0
br i1 %65, label %66, label %74
66: ; preds = %56, %66
%67 = phi i64 [ %70, %66 ], [ 0, %56 ]
%68 = getelementptr inbounds i32, i32* %62, i64 %67
%69 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %68)
%70 = add nuw nsw i64 %67, 1
%71 = load i32, i32* %1
%72 = sext i32 %71 to i64
%73 = icmp slt i64 %70, %72
br i1 %73, label %66, label %74
74: ; preds = %66, %56
%75 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0))
%76 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %3)
%77 = load i32, i32* %1
%78 = load i32, i32* %3
%79 = call i32 @linear(i32* %62, i32 %77, i32 %78)
%80 = icmp eq i32 %79, -1
br i1 %80, label %84, label %81
81: ; preds = %74
%82 = add nuw nsw i32 %79, 1
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.12, i64 0, i64 0), i32 %82)
br label %124
84: ; preds = %74
%85 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.13, i64 0, i64 0))
br label %124
86: ; preds = %10
%87 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0))
%88 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %1)
%89 = load i32, i32* %1
%90 = shl i32 %89, 2
%91 = call i64 @malloc(i32 %90)
%92 = inttoptr i64 %91 to i32*
%93 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.15, i64 0, i64 0))
%94 = load i32, i32* %1
%95 = icmp sgt i32 %94, 0
br i1 %95, label %96, label %104
96: ; preds = %86, %96
%97 = phi i64 [ %100, %96 ], [ 0, %86 ]
%98 = getelementptr inbounds i32, i32* %92, i64 %97
%99 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.6, i64 0, i64 0), i32* %98)
%100 = add nuw nsw i64 %97, 1
%101 = load i32, i32* %1
%102 = sext i32 %101 to i64
%103 = icmp slt i64 %100, %102
br i1 %103, label %96, label %104
104: ; preds = %96, %86
%105 = phi i32 [ %94, %86 ], [ %101, %96 ]
%106 = call i32 @sum(i32* %92, i32 %105)
store i32 %106, i32* %1
%107 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.16, i64 0, i64 0), i32 %106)
br label %124
108: ; preds = %10
%109 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.17, i64 0, i64 0))
%110 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.18, i64 0, i64 0), i32* %1, i32* %2)
%111 = load i32, i32* %1
%112 = load i32, i32* %2
%113 = call i32 @permut(i32 %111, i32 %112)
%114 = load i32, i32* %1
%115 = load i32, i32* %2
%116 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.19, i64 0, i64 0), i32 %114, i32 %115, i32 %113)
br label %124
117: ; preds = %10
%118 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.20, i64 0, i64 0))
%119 = call i32 (...) @getchar()
br label %120
120: ; preds = %117, %124
%121 = load i8, i8* %5
%122 = and i8 %121, -33
%123 = icmp eq i8 %122, 78
br i1 %123, label %130, label %10
124: ; preds = %81, %84, %51, %54, %108, %104, %19
%125 = call i32 (...) @getchar()
%126 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.21, i64 0, i64 0))
%127 = load i32, i32* @stdin
%128 = call i32 @fflush(i32 %127)
%129 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.22, i64 0, i64 0), i8* %5)
br label %120
130: ; preds = %120
ret i32 0
}