#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 */
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, unsigned int *);
int main() {
  unsigned int firstInt;
  unsigned int secondInt;
  unsigned int quotient = 0;
  unsigned int rmainder;
  unsigned int isPrime = 1;
  int testQuotient;
  int output;
  int loopRunning = 1;
  char option;
  while (loopRunning) {
    printf("\nSelect one of the following options: \n(1) Multiply by "
           "adding\n(2) Divide by subtracting\n(3) Factorial\n(4) "
           "isPrimeOrNot\n(5) Exit\n\tEnter Option:");
    option = getchar();
    switch (option) {
    case '1':
      printf("Please enter a positive integer: ");
      scanf("%d", &firstInt);
      printf("Please enter another positive integer: ");
      scanf("%d", &secondInt);
      output = firstInt;
      for (int i = 1; i < secondInt; i += 1) {
        output += firstInt;
      }
      printf("Your answer is %d\n", output);
      break;
    case '2':
      printf("Please enter a positive integer: ");
      scanf("%d", &firstInt);
      printf("Please enter another positive integer: ");
      scanf("%d", &secondInt);
      if (secondInt > firstInt) {
        printf("The second integer must be larger than the first!\n");
      } else {
        rmainder = firstInt;
        testQuotient = rmainder - secondInt;
        while (testQuotient > -1) {
          rmainder = rmainder - secondInt;
          testQuotient -= secondInt;
          quotient += 1;
        }
        printf("The quotient is %d\n", quotient);
        printf("The remainder is %d\n", rmainder);
      }
      break;
    case '3':
      printf("Please enter a positive integer: ");
      scanf("%d", &firstInt);
      if (firstInt < 1) {
        printf("The number must be a positive integer.\n");
      } else {
        output = firstInt;
        for (int i = 1; i < firstInt; i += 1) {
          output *= firstInt - i;
        }
        printf("Your answer is %d\n", output);
      }
      break;
    case '4':
      printf("Please enter a positive integer: ");
      scanf("%d", &firstInt);
      for (int i = 2; i < firstInt; i += 1) {
        if (firstInt % i == 0) {
          isPrime = 0;
        }
      }
      if (isPrime) {
        printf("%d is a prime number.\n", firstInt);
      } else {
        printf("%d is not a prime number.\n");
      }
      break;
    case '5':
      loopRunning = 0;
      break;
    default:
      printf("Please enter a valid number between 1 and 5.\n");
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x1,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     1416 <main+0x2e6>
lea    0xeaf(%rip),%rdi
xor    %eax,%eax
mov    %al,-0x41(%rbp)
call   1030 <printf@plt>
mov    -0x41(%rbp),%al
call   1040 <getchar@plt>
mov    %al,-0x25(%rbp)
movsbl -0x25(%rbp),%eax
add    $0xffffffcf,%eax
mov    %eax,%ecx
mov    %rcx,-0x40(%rbp)
sub    $0x4,%eax
ja     1403 <main+0x2d3>
mov    -0x40(%rbp),%rax
lea    0xe65(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xef8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf0c(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xeff(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeee(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
movl   $0x1,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    1210 <main+0xe0>
mov    -0x8(%rbp),%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11ed <main+0xbd>
mov    -0x20(%rbp),%esi
lea    0xed6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1411 <main+0x2e1>
lea    0xe76(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8a(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe6c(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jbe    1281 <main+0x151>
lea    0xe8e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12de <main+0x1ae>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jle    12bc <main+0x18c>
mov    -0x14(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%ecx
mov    -0x1c(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1290 <main+0x160>
mov    -0x10(%rbp),%esi
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1411 <main+0x2e1>
lea    0xdb9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdcd(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jae    131e <main+0x1ee>
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1363 <main+0x233>
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
movl   $0x1,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    1352 <main+0x222>
mov    -0x8(%rbp),%eax
sub    -0x30(%rbp),%eax
imul   -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    132b <main+0x1fb>
mov    -0x20(%rbp),%esi
lea    0xd94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1411 <main+0x2e1>
lea    0xd34(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd48(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x2,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x8(%rbp),%eax
jae    13c4 <main+0x294>
mov    -0x8(%rbp),%eax
xor    %edx,%edx
divl   -0x34(%rbp)
cmp    $0x0,%edx
jne    13b1 <main+0x281>
movl   $0x0,-0x18(%rbp)
jmp    13b6 <main+0x286>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    138d <main+0x25d>
cmpl   $0x0,-0x18(%rbp)
je     13e4 <main+0x2b4>
mov    -0x8(%rbp),%esi
lea    0xdaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13f2 <main+0x2c2>
lea    0xdb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1411 <main+0x2e1>
movl   $0x0,-0x24(%rbp)
jmp    1411 <main+0x2e1>
lea    0xdaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1154 <main+0x24>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf32(%rip),%r15
lea    0xf17(%rip),%rbp
lea    0xfb3(%rip),%r14
xor    %r12d,%r12d
jmp    15ae <main+0x46e>
lea    0x10b8(%rip),%rdi
call   1030 <puts@plt>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
movsbl %al,%eax
add    $0xffffffcf,%eax
cmp    $0x4,%eax
ja     1168 <main+0x28>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf7e(%rip),%rbx
mov    %rbx,%rdi
mov    %rsp,%rsi
call   1060 <scanf@plt>
lea    0xf6f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
mov    $0x1,%eax
cmove  %eax,%esi
imul   (%rsp),%esi
lea    0xf6a(%rip),%rdi
jmp    155f <main+0x41f>
mov    %r14,%rbx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf26(%rip),%rbp
mov    %rbp,%rdi
mov    %rsp,%rsi
call   1060 <scanf@plt>
lea    0xf17(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%eax
mov    (%rsp),%r14d
cmp    %eax,%r14d
jae    14d7 <main+0x397>
lea    0xfa8(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%r14
lea    0xe14(%rip),%rbp
jmp    1180 <main+0x40>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec3(%rip),%rdi
mov    %rsp,%rsi
call   1060 <scanf@plt>
mov    (%rsp),%esi
test   %esi,%esi
je     1500 <main+0x3c0>
cmp    $0x1,%esi
je     1558 <main+0x418>
lea    -0x1(%rsi),%ecx
mov    $0x1,%eax
mov    %esi,%edx
cmp    $0x8,%ecx
jb     1545 <main+0x405>
mov    %ecx,%eax
and    $0xfffffff8,%eax
movd   %esi,%xmm1
movaps 0xd4f(%rip),%xmm0
movss  %xmm1,%xmm0
movd   %esi,%xmm1
pshufd $0x0,%xmm1,%xmm8
lea    -0x8(%rax),%edi
mov    %edi,%edx
shr    $0x3,%edx
add    $0x1,%edx
test   %edi,%edi
je     156b <main+0x42b>
mov    %edx,%edi
and    $0xfffffffe,%edi
movdqa 0xd41(%rip),%xmm3
movdqa 0xd29(%rip),%xmm2
movdqa 0xd40(%rip),%xmm9
movdqa 0xd47(%rip),%xmm10
movdqa 0xd4e(%rip),%xmm11
movdqa 0xd55(%rip),%xmm12
nopl   0x0(%rax,%rax,1)
movdqa %xmm8,%xmm4
psubd  %xmm3,%xmm4
movdqa %xmm4,%xmm5
psubd  %xmm9,%xmm5
pshufd $0xf5,%xmm4,%xmm6
pshufd $0xf5,%xmm0,%xmm7
pmuludq %xmm6,%xmm7
pmuludq %xmm4,%xmm0
pshufd $0xf5,%xmm5,%xmm6
pshufd $0xf5,%xmm2,%xmm1
pmuludq %xmm6,%xmm1
pmuludq %xmm2,%xmm5
movdqa %xmm4,%xmm2
psubd  %xmm10,%xmm2
psubd  %xmm11,%xmm4
pmuludq %xmm2,%xmm0
pshufd $0xe8,%xmm0,%xmm0
pshufd $0xf5,%xmm2,%xmm2
pmuludq %xmm7,%xmm2
pshufd $0xe8,%xmm2,%xmm2
punpckldq %xmm2,%xmm0
pmuludq %xmm4,%xmm5
pshufd $0xe8,%xmm5,%xmm2
pshufd $0xf5,%xmm4,%xmm4
pmuludq %xmm1,%xmm4
pshufd $0xe8,%xmm4,%xmm1
punpckldq %xmm1,%xmm2
paddd  %xmm12,%xmm3
add    $0xfffffffe,%edi
jne    1310 <main+0x1d0>
test   $0x1,%dl
je     13f7 <main+0x2b7>
psubd  %xmm3,%xmm8
movdqa %xmm8,%xmm1
psubd  %xmm9,%xmm1
pshufd $0xf5,%xmm8,%xmm3
pmuludq %xmm0,%xmm8
pshufd $0xf5,%xmm0,%xmm0
pshufd $0xe8,%xmm8,%xmm4
pmuludq %xmm3,%xmm0
pshufd $0xe8,%xmm0,%xmm0
punpckldq %xmm0,%xmm4
pshufd $0xf5,%xmm1,%xmm0
pmuludq %xmm2,%xmm1
pshufd $0xf5,%xmm2,%xmm2
pshufd $0xe8,%xmm1,%xmm1
pmuludq %xmm0,%xmm2
pshufd $0xe8,%xmm2,%xmm0
punpckldq %xmm0,%xmm1
movdqa %xmm4,%xmm0
movdqa %xmm1,%xmm2
pshufd $0xf5,%xmm0,%xmm1
pshufd $0xf5,%xmm2,%xmm3
pmuludq %xmm1,%xmm3
pmuludq %xmm0,%xmm2
pshufd $0xee,%xmm2,%xmm0
pmuludq %xmm2,%xmm0
pshufd $0xaa,%xmm3,%xmm1
pmuludq %xmm3,%xmm1
pmuludq %xmm0,%xmm1
movd   %xmm1,%edx
cmp    %eax,%ecx
jne    1542 <main+0x402>
mov    %edx,%esi
jmp    1558 <main+0x418>
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xcf2(%rip),%rdi
mov    %rsp,%rsi
call   1060 <scanf@plt>
mov    (%rsp),%esi
cmp    $0x3,%esi
jb     14b8 <main+0x378>
mov    $0x2,%ecx
je     149f <main+0x35f>
lea    -0x2(%rsi),%edi
and    $0xfffffffe,%edi
neg    %edi
mov    $0x2,%ebx
nopw   0x0(%rax,%rax,1)
mov    %esi,%eax
xor    %edx,%edx
div    %ebx
mov    %edx,%ecx
lea    0x1(%rbx),%ebp
mov    %esi,%eax
xor    %edx,%edx
div    %ebp
test   %ecx,%ecx
cmove  %ecx,%r13d
test   %edx,%edx
cmove  %edx,%r13d
mov    %ebx,%ecx
add    $0x2,%ecx
lea    (%rdi,%rbx,1),%eax
add    $0x2,%eax
mov    %ecx,%ebx
cmp    $0x2,%eax
jne    1470 <main+0x330>
test   $0x1,%sil
lea    0xbc6(%rip),%rbp
je     14b8 <main+0x378>
mov    %esi,%eax
xor    %edx,%edx
div    %ecx
test   %edx,%edx
cmove  %edx,%r13d
test   %r13d,%r13d
jne    15a0 <main+0x460>
xor    %r13d,%r13d
lea    0xce8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1180 <main+0x40>
js     1511 <main+0x3d1>
mov    %eax,%ecx
neg    %ecx
lea    0xb8c(%rip),%rbp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
sub    %eax,%r14d
add    $0x1,%r12d
mov    %ecx,%edx
add    %r14d,%edx
jns    14f0 <main+0x3b0>
jmp    1518 <main+0x3d8>
lea    0xcc7(%rip),%rdi
call   1030 <puts@plt>
jmp    1180 <main+0x40>
lea    0xb58(%rip),%rbp
lea    0xc54(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xc57(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%r14
jmp    1180 <main+0x40>
or     $0x1,%eax
sub    %eax,%esi
mov    %esi,%eax
mov    %edx,%esi
nopl   0x0(%rax,%rax,1)
imul   %eax,%esi
add    $0xffffffff,%eax
jne    1550 <main+0x410>
lea    0xc01(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1180 <main+0x40>
movdqa 0xaad(%rip),%xmm3
movdqa 0xa95(%rip),%xmm2
movdqa 0xaac(%rip),%xmm9
test   $0x1,%dl
jne    139d <main+0x25d>
jmp    13f7 <main+0x2b7>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xbf5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%r13d
jmp    1180 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [143 x i8] c"\0ASelect one of the following options: \0A(1) Multiply by adding\0A(2) Divide by subtracting\0A(3) Factorial\0A(4) isPrimeOrNot\0A(5) Exit\0A\09Enter Option:\00"
@.str.1 = [34 x i8] c"Please enter a positive integer: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [40 x i8] c"Please enter another positive integer: \00"
@.str.4 = [19 x i8] c"Your answer is %d\0A\00"
@.str.5 = [51 x i8] c"The second integer must be larger than the first!\0A\00"
@.str.6 = [20 x i8] c"The quotient is %d\0A\00"
@.str.7 = [21 x i8] c"The remainder is %d\0A\00"
@.str.8 = [40 x i8] c"The number must be a positive integer.\0A\00"
@.str.9 = [23 x i8] c"%d is a prime number.\0A\00"
@.str.10 = [27 x i8] c"%d is not a prime number.\0A\00"
@.str.11 = [46 x i8] c"Please enter a valid number between 1 and 5.\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
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
store i32 1, i32* %6
store i32 1, i32* %9
br label %14
14: ; preds = %130, %0
%15 = load i32, i32* %9
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %131
17: ; preds = %14
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([143 x i8], [143 x i8]* @.str, i64 0, i64 0))
%19 = call signext i8 (...) @getchar()
store i8 %19, i8* %10
%20 = load i8, i8* %10
%21 = sext i8 %20 to i32
switch i32 %21, label %128 [
i32 49, label %22
i32 50, label %42
i32 51, label %75
i32 52, label %101
i32 53, label %127
]
22: ; preds = %17
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%27 = load i32, i32* %2
store i32 %27, i32* %8
store i32 1, i32* %11
br label %28
28: ; preds = %36, %22
%29 = load i32, i32* %11
%30 = load i32, i32* %3
%31 = icmp ult i32 %29, %30
br i1 %31, label %32, label %39
32: ; preds = %28
%33 = load i32, i32* %2
%34 = load i32, i32* %8
%35 = add i32 %34, %33
store i32 %35, i32* %8
br label %36
36: ; preds = %32
%37 = load i32, i32* %11
%38 = add nsw i32 %37, 1
store i32 %38, i32* %11
br label %28
39: ; preds = %28
%40 = load i32, i32* %8
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %40)
br label %130
42: ; preds = %17
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%44 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%46 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%47 = load i32, i32* %3
%48 = load i32, i32* %2
%49 = icmp ugt i32 %47, %48
br i1 %49, label %50, label %52
50: ; preds = %42
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.5, i64 0, i64 0))
br label %74
52: ; preds = %42
%53 = load i32, i32* %2
store i32 %53, i32* %5
%54 = load i32, i32* %5
%55 = load i32, i32* %3
%56 = sub i32 %54, %55
store i32 %56, i32* %7
br label %57
57: ; preds = %60, %52
%58 = load i32, i32* %7
%59 = icmp sgt i32 %58, -1
br i1 %59, label %60, label %69
60: ; preds = %57
%61 = load i32, i32* %5
%62 = load i32, i32* %3
%63 = sub i32 %61, %62
store i32 %63, i32* %5
%64 = load i32, i32* %3
%65 = load i32, i32* %7
%66 = sub i32 %65, %64
store i32 %66, i32* %7
%67 = load i32, i32* %4
%68 = add i32 %67, 1
store i32 %68, i32* %4
br label %57
69: ; preds = %57
%70 = load i32, i32* %4
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %70)
%72 = load i32, i32* %5
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i32 %72)
br label %74
74: ; preds = %69, %50
br label %130
75: ; preds = %17
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%77 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%78 = load i32, i32* %2
%79 = icmp ult i32 %78, 1
br i1 %79, label %80, label %82
80: ; preds = %75
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.8, i64 0, i64 0))
br label %100
82: ; preds = %75
%83 = load i32, i32* %2
store i32 %83, i32* %8
store i32 1, i32* %12
br label %84
84: ; preds = %94, %82
%85 = load i32, i32* %12
%86 = load i32, i32* %2
%87 = icmp ult i32 %85, %86
br i1 %87, label %88, label %97
88: ; preds = %84
%89 = load i32, i32* %2
%90 = load i32, i32* %12
%91 = sub i32 %89, %90
%92 = load i32, i32* %8
%93 = mul i32 %92, %91
store i32 %93, i32* %8
br label %94
94: ; preds = %88
%95 = load i32, i32* %12
%96 = add nsw i32 %95, 1
store i32 %96, i32* %12
br label %84
97: ; preds = %84
%98 = load i32, i32* %8
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %98)
br label %100
100: ; preds = %97, %80
br label %130
101: ; preds = %17
%102 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%103 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
store i32 2, i32* %13
br label %104
104: ; preds = %115, %101
%105 = load i32, i32* %13
%106 = load i32, i32* %2
%107 = icmp ult i32 %105, %106
br i1 %107, label %108, label %118
108: ; preds = %104
%109 = load i32, i32* %2
%110 = load i32, i32* %13
%111 = urem i32 %109, %110
%112 = icmp eq i32 %111, 0
br i1 %112, label %113, label %114
113: ; preds = %108
store i32 0, i32* %6
br label %114
114: ; preds = %113, %108
br label %115
115: ; preds = %114
%116 = load i32, i32* %13
%117 = add nsw i32 %116, 1
store i32 %117, i32* %13
br label %104
118: ; preds = %104
%119 = load i32, i32* %6
%120 = icmp ne i32 %119, 0
br i1 %120, label %121, label %124
121: ; preds = %118
%122 = load i32, i32* %2
%123 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i32 %122)
br label %126
124: ; preds = %118
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0))
br label %126
126: ; preds = %124, %121
br label %130
127: ; preds = %17
store i32 0, i32* %9
br label %130
128: ; preds = %17
%129 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.11, i64 0, i64 0))
br label %130
130: ; preds = %128, %127, %126, %100, %74, %39
br label %14
131: ; preds = %14
%132 = load i32, i32* %1
ret i32 %132
}

LLVM IR (-O2):
@.str = [143 x i8] c"\0ASelect one of the following options: \0A(1) Multiply by adding\0A(2) Divide by subtracting\0A(3) Factorial\0A(4) isPrimeOrNot\0A(5) Exit\0A\09Enter Option:\00"
@.str.1 = [34 x i8] c"Please enter a positive integer: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [40 x i8] c"Please enter another positive integer: \00"
@.str.4 = [19 x i8] c"Your answer is %d\0A\00"
@.str.6 = [20 x i8] c"The quotient is %d\0A\00"
@.str.7 = [21 x i8] c"The remainder is %d\0A\00"
@.str.9 = [23 x i8] c"%d is a prime number.\0A\00"
@.str.10 = [27 x i8] c"%d is not a prime number.\0A\00"
@str = [39 x i8] c"The number must be a positive integer.\00"
@str.12 = [50 x i8] c"The second integer must be larger than the first!\00"
@str.13 = [45 x i8] c"Please enter a valid number between 1 and 5.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
br label %5
5: ; preds = %162, %0
%6 = phi i32 [ 0, %0 ], [ %163, %162 ]
%7 = phi i32 [ 1, %0 ], [ %164, %162 ]
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([143 x i8], [143 x i8]* @.str, i64 0, i64 0))
%9 = call signext i8 (...) @getchar()
%10 = sext i8 %9 to i32
switch i32 %10, label %167 [
i32 49, label %11
i32 50, label %22
i32 51, label %48
i32 52, label %123
i32 53, label %169
]
11: ; preds = %5
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%16 = load i32, i32* %1
%17 = load i32, i32* %2
%18 = icmp ugt i32 %17, 1
%19 = select i1 %18, i32 %17, i32 1
%20 = mul i32 %16, %19
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %20)
br label %162
22: ; preds = %5
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%24 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0))
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%27 = load i32, i32* %2
%28 = load i32, i32* %1
%29 = icmp ult i32 %28, %27
br i1 %29, label %33, label %30
30: ; preds = %22
%31 = sub i32 %28, %27
%32 = icmp sgt i32 %31, -1
br i1 %32, label %35, label %43
33: ; preds = %22
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.12, i64 0, i64 0))
br label %162
35: ; preds = %30, %35
%36 = phi i32 [ %41, %35 ], [ %31, %30 ]
%37 = phi i32 [ %40, %35 ], [ %6, %30 ]
%38 = phi i32 [ %39, %35 ], [ %28, %30 ]
%39 = sub i32 %38, %27
%40 = add i32 %37, 1
%41 = sub i32 %36, %27
%42 = icmp sgt i32 %41, -1
br i1 %42, label %35, label %43
43: ; preds = %35, %30
%44 = phi i32 [ %28, %30 ], [ %39, %35 ]
%45 = phi i32 [ %6, %30 ], [ %40, %35 ]
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %45)
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i32 %44)
br label %162
48: ; preds = %5
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%50 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%51 = load i32, i32* %1
switch i32 %51, label %52 [
i32 0, label %111
i32 1, label %113
]
52: ; preds = %48
%53 = add i32 %51, -1
%54 = icmp ult i32 %53, 8
br i1 %54, label %108, label %55
55: ; preds = %52
%56 = and i32 %53, -8
%57 = or i32 %56, 1
%58 = insertelement <4 x i32> <i32 poison, i32 1, i32 1, i32 1>, i32 %51, i64 0
%59 = insertelement <4 x i32> poison, i32 %51, i64 0
%60 = shufflevector <4 x i32> %59, <4 x i32> poison, <4 x i32> zeroinitializer
%61 = insertelement <4 x i32> poison, i32 %51, i64 0
%62 = shufflevector <4 x i32> %61, <4 x i32> poison, <4 x i32> zeroinitializer
%63 = add i32 %56, -8
%64 = lshr exact i32 %63, 3
%65 = add nuw nsw i32 %64, 1
%66 = and i32 %65, 1
%67 = icmp eq i32 %63, 0
br i1 %67, label %89, label %68
68: ; preds = %55
%69 = and i32 %65, 1073741822
br label %70
70: ; preds = %70, %68
%71 = phi <4 x i32> [ <i32 1, i32 2, i32 3, i32 4>, %68 ], [ %86, %70 ]
%72 = phi <4 x i32> [ %58, %68 ], [ %84, %70 ]
%73 = phi <4 x i32> [ <i32 1, i32 1, i32 1, i32 1>, %68 ], [ %85, %70 ]
%74 = phi i32 [ 0, %68 ], [ %87, %70 ]
%75 = add <4 x i32> %71, <i32 4, i32 4, i32 4, i32 4>
%76 = sub <4 x i32> %60, %71
%77 = sub <4 x i32> %62, %75
%78 = mul <4 x i32> %76, %72
%79 = mul <4 x i32> %77, %73
%80 = add <4 x i32> %71, <i32 8, i32 8, i32 8, i32 8>
%81 = add <4 x i32> %71, <i32 12, i32 12, i32 12, i32 12>
%82 = sub <4 x i32> %60, %80
%83 = sub <4 x i32> %62, %81
%84 = mul <4 x i32> %82, %78
%85 = mul <4 x i32> %83, %79
%86 = add <4 x i32> %71, <i32 16, i32 16, i32 16, i32 16>
%87 = add i32 %74, 2
%88 = icmp eq i32 %87, %69
br i1 %88, label %89, label %70
89: ; preds = %70, %55
%90 = phi <4 x i32> [ undef, %55 ], [ %84, %70 ]
%91 = phi <4 x i32> [ undef, %55 ], [ %85, %70 ]
%92 = phi <4 x i32> [ <i32 1, i32 2, i32 3, i32 4>, %55 ], [ %86, %70 ]
%93 = phi <4 x i32> [ %58, %55 ], [ %84, %70 ]
%94 = phi <4 x i32> [ <i32 1, i32 1, i32 1, i32 1>, %55 ], [ %85, %70 ]
%95 = icmp eq i32 %66, 0
br i1 %95, label %102, label %96
96: ; preds = %89
%97 = add <4 x i32> %92, <i32 4, i32 4, i32 4, i32 4>
%98 = sub <4 x i32> %60, %92
%99 = sub <4 x i32> %62, %97
%100 = mul <4 x i32> %98, %93
%101 = mul <4 x i32> %99, %94
br label %102
102: ; preds = %89, %96
%103 = phi <4 x i32> [ %90, %89 ], [ %100, %96 ]
%104 = phi <4 x i32> [ %91, %89 ], [ %101, %96 ]
%105 = mul <4 x i32> %104, %103
%106 = call i32 @llvm.vector.reduce.mul.v4i32(<4 x i32> %105)
%107 = icmp eq i32 %53, %56
br i1 %107, label %113, label %108
108: ; preds = %52, %102
%109 = phi i32 [ 1, %52 ], [ %57, %102 ]
%110 = phi i32 [ %51, %52 ], [ %106, %102 ]
br label %116
111: ; preds = %48
%112 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
br label %162
113: ; preds = %116, %102, %48
%114 = phi i32 [ %51, %48 ], [ %106, %102 ], [ %120, %116 ]
%115 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i32 %114)
br label %162
116: ; preds = %108, %116
%117 = phi i32 [ %121, %116 ], [ %109, %108 ]
%118 = phi i32 [ %120, %116 ], [ %110, %108 ]
%119 = sub i32 %51, %117
%120 = mul i32 %119, %118
%121 = add nuw nsw i32 %117, 1
%122 = icmp eq i32 %121, %51
br i1 %122, label %113, label %116
123: ; preds = %5
%124 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
%125 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%126 = load i32, i32* %1
%127 = icmp ugt i32 %126, 2
br i1 %127, label %128, label %143
128: ; preds = %123
%129 = and i32 %126, 1
%130 = icmp eq i32 %126, 3
br i1 %130, label %134, label %131
131: ; preds = %128
%132 = add i32 %126, -2
%133 = and i32 %132, -2
br label %146
134: ; preds = %146, %128
%135 = phi i32 [ undef, %128 ], [ %156, %146 ]
%136 = phi i32 [ 2, %128 ], [ %157, %146 ]
%137 = phi i32 [ %7, %128 ], [ %156, %146 ]
%138 = icmp eq i32 %129, 0
br i1 %138, label %143, label %139
139: ; preds = %134
%140 = urem i32 %126, %136
%141 = icmp eq i32 %140, 0
%142 = select i1 %141, i32 0, i32 %137
br label %143
143: ; preds = %139, %134, %123
%144 = phi i32 [ %7, %123 ], [ %135, %134 ], [ %142, %139 ]
%145 = icmp eq i32 %144, 0
br i1 %145, label %165, label %160
146: ; preds = %146, %131
%147 = phi i32 [ 2, %131 ], [ %157, %146 ]
%148 = phi i32 [ %7, %131 ], [ %156, %146 ]
%149 = phi i32 [ 0, %131 ], [ %158, %146 ]
%150 = urem i32 %126, %147
%151 = icmp eq i32 %150, 0
%152 = or i32 %147, 1
%153 = urem i32 %126, %152
%154 = icmp eq i32 %153, 0
%155 = select i1 %154, i1 true, i1 %151
%156 = select i1 %155, i32 0, i32 %148
%157 = add nuw nsw i32 %147, 2
%158 = add i32 %149, 2
%159 = icmp eq i32 %158, %133
br i1 %159, label %134, label %146
160: ; preds = %143
%161 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.9, i64 0, i64 0), i32 %126)
br label %162
162: ; preds = %160, %165, %111, %113, %33, %43, %167, %11
%163 = phi i32 [ %6, %167 ], [ %6, %160 ], [ %6, %165 ], [ %6, %111 ], [ %6, %113 ], [ %6, %33 ], [ %45, %43 ], [ %6, %11 ]
%164 = phi i32 [ %7, %167 ], [ 1, %160 ], [ 0, %165 ], [ %7, %111 ], [ %7, %113 ], [ %7, %33 ], [ %7, %43 ], [ %7, %11 ]
br label %5
165: ; preds = %143
%166 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.10, i64 0, i64 0))
br label %162
167: ; preds = %5
%168 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @str.13, i64 0, i64 0))
br label %162
169: ; preds = %5
ret i32 0
}