#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 */
scalar_t__ clear_input_value();
int /*<<< orphan*/ printf(char *, ...);
int rand();
int scanf(char *, ...);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  char menu_input;
  int amount_of_questions;
  int amount_of_questions_confirmation;
  int user_input;
  int questions_correct;
  int questions_incorrect;
  int round_complete;
  char error_check[3] = {'0'};
  int random[3] = {0};
  int i;
  menu_input = '0';
  amount_of_questions = 1;
  amount_of_questions_confirmation = 0;
  user_input = 0;
  questions_correct = 0;
  questions_incorrect = 0;
  round_complete = 0;
  i = 0;
  srand(time(NULL));
  do {
    menu_input = '0';
    error_check[0] = '0';
    printf("___________________________________________________________________"
           "__________\nWelcome to the Mathematics Quiz Game!\n\nPlease select "
           "one of the 4 options below:\n1.\tSelect the number of questions in "
           "the round (Default of 1 question)\n2.\tStart the Mathematics Game "
           "with %d round/s\n3.\tSee how many questions you got correct or "
           "incorrect\n4.\tEXIT the "
           "game\n_____________________________________________________________"
           "________________\n\n\n",
           amount_of_questions);
    if ((scanf("%1s%c", &menu_input, &error_check[0]) != 2 ||
         error_check[0] != '\n') &&
        clear_input_value()) {
      printf("You entered an Invaild Character\n\n\n\n");
    } else {
      switch (menu_input) {
      case '1': {
        amount_of_questions = 0;
        amount_of_questions_confirmation = 0;
        error_check[1] = '0';
        while (amount_of_questions_confirmation != 1) {
          printf("\n\n\n\nEnter the number of questions to be asked for this "
                 "round of the quiz (Maximum of %d questions allowed)\n",
                 5);
          if ((scanf("%d%c", &amount_of_questions, &error_check[1]) != 2 ||
               error_check[1] != '\n') &&
              clear_input_value()) {
            printf("You entered an Invaild Character\n");
          } else {
            if (amount_of_questions <= 5 && amount_of_questions > 0) {
              printf("\n\n\n\n");
              amount_of_questions_confirmation++;
            } else {
              printf("You entered an Invaild Round Quanitity\n");
            }
          }
        }
        break;
      }
      case '2': {
        round_complete = 0;
        questions_correct = 0;
        questions_incorrect = 0;
        error_check[2] = '0';
        printf("\n\n\n\nThis game will consist of %d rounds.\nAll answers will "
               "be whole numbers (Meaning no remainders)\n\n",
               amount_of_questions);
        for (i = 0; i < amount_of_questions; ++i) {
          random[0] = rand() % 21;
          random[1] = rand() % 21;
          random[2] = random[0] + random[1];
          printf("Question %d.\t%d + %d =\n", i + 1, random[0], random[1]);
          if ((scanf("%d%c", &user_input, &error_check[2]) != 2 ||
               error_check[2] != '\n') &&
              clear_input_value()) {
            printf("You entered an Invaild Character\n\n\n");
            i = i - 1;
          } else {
            if (user_input == random[2]) {
              printf("\nWell done you got that correct\n\n\n\n\n");
              questions_correct++;
            } else {
              printf("\nSorry that was incorrect\n\tThe correct answer was "
                     "%d\n\n\n\n\n",
                     random[2]);
              questions_incorrect++;
            }
          }
          round_complete = 1;
        }
        break;
      }
      case '3': {
        if (round_complete == 1) {
          printf("\n\n\n\n\nYou've just completed a game of %d round/s\nOut of "
                 "those %d round/s\n\n",
                 amount_of_questions, amount_of_questions);
          printf("You got:\n\t\t %d Correct\t\t%d Incorrect\n\n\n\n\n",
                 questions_correct, questions_incorrect);
        } else {
          printf("You have not completed a round\n\n\n\n");
        }
        break;
      }
      case '4': {
        printf("\n\n\n\n\n\n***************************************************"
               "*************************\n*\n*  Thank you for playing the "
               "Mathematics Quiz "
               "Game\n*\tGoodbye\n*\n******************************************"
               "**********************************\n\n");
        break;
      }
      default: {
        printf("\nYou entered an Invaild Option\n\n\n\n");
      }
      }
    }
  } while (menu_input != '4');
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xe8a(%rip),%ax
mov    %ax,-0x23(%rbp)
mov    0xe82(%rip),%al
mov    %al,-0x21(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
movb   $0x30,-0x5(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x34(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
movb   $0x30,-0x5(%rbp)
movb   $0x30,-0x23(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x23(%rbp),%rdx
lea    0xfb4(%rip),%rdi
lea    -0x5(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
cmp    $0x2,%eax
jne    122d <main+0xbd>
movsbl -0x23(%rbp),%eax
cmp    $0xa,%eax
je     1251 <main+0xe1>
mov    $0x0,%al
call   1050 <clear_input_value@plt>
cmp    $0x0,%rax
je     1251 <main+0xe1>
lea    0xf81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    14fd <main+0x38d>
movsbl -0x5(%rbp),%eax
add    $0xffffffcf,%eax
mov    %eax,%ecx
mov    %rcx,-0x40(%rbp)
sub    $0x3,%eax
ja     14ea <main+0x37a>
mov    -0x40(%rbp),%rax
lea    0xd8e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movb   $0x30,-0x22(%rbp)
cmpl   $0x1,-0x10(%rbp)
je     1346 <main+0x1d6>
lea    0xf4d(%rip),%rdi
mov    $0x5,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x23(%rbp),%rdx
add    $0x1,%rdx
lea    0xf9e(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
cmp    $0x2,%eax
jne    12da <main+0x16a>
movsbl -0x22(%rbp),%eax
cmp    $0xa,%eax
je     12fe <main+0x18e>
mov    $0x0,%al
call   1050 <clear_input_value@plt>
cmp    $0x0,%rax
je     12fe <main+0x18e>
lea    0xf6a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1341 <main+0x1d1>
cmpl   $0x5,-0xc(%rbp)
jg     132e <main+0x1be>
cmpl   $0x0,-0xc(%rbp)
jle    132e <main+0x1be>
lea    0x1088(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    133c <main+0x1cc>
lea    0xf49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1341 <main+0x1d1>
jmp    128d <main+0x11d>
jmp    14f8 <main+0x388>
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movb   $0x30,-0x21(%rbp)
mov    -0xc(%rbp),%esi
lea    0xf38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1488 <main+0x318>
mov    $0x0,%al
call   1090 <rand@plt>
mov    $0x15,%ecx
cltd
idiv   %ecx
mov    %edx,-0x30(%rbp)
mov    $0x0,%al
call   1090 <rand@plt>
mov    $0x15,%ecx
cltd
idiv   %ecx
mov    %edx,-0x2c(%rbp)
mov    -0x30(%rbp),%eax
add    -0x2c(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x34(%rbp),%esi
add    $0x1,%esi
mov    -0x30(%rbp),%edx
mov    -0x2c(%rbp),%ecx
lea    0xf43(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x23(%rbp),%rdx
add    $0x2,%rdx
lea    0xe79(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1080 <scanf@plt>
cmp    $0x2,%eax
jne    13ff <main+0x28f>
movsbl -0x21(%rbp),%eax
cmp    $0xa,%eax
je     142c <main+0x2bc>
mov    $0x0,%al
call   1050 <clear_input_value@plt>
cmp    $0x0,%rax
je     142c <main+0x2bc>
lea    0xf0c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1473 <main+0x303>
mov    -0x14(%rbp),%eax
cmp    -0x28(%rbp),%eax
jne    1454 <main+0x2e4>
lea    0xf08(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    146e <main+0x2fe>
mov    -0x28(%rbp),%esi
lea    0xf0e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1473 <main+0x303>
movl   $0x1,-0x20(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    137c <main+0x20c>
jmp    14f8 <main+0x388>
cmpl   $0x1,-0x20(%rbp)
jne    14c4 <main+0x354>
mov    -0xc(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xf02(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xf38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    14d2 <main+0x362>
lea    0xf4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    14f8 <main+0x388>
lea    0xf5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    14f8 <main+0x388>
lea    0x102f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    14fd <main+0x38d>
jmp    1502 <main+0x392>
movsbl -0x5(%rbp),%eax
cmp    $0x34,%eax
jne    11e8 <main+0x78>
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   $0x0,0x6(%rsp)
movw   $0x30,0x4(%rsp)
movl   $0x1,0x8(%rsp)
movl   $0x0,0x14(%rsp)
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    $0x1,%esi
lea    0x5(%rsp),%rbp
lea    0xe5a(%rip),%r15
lea    0x1000(%rip),%rbx
lea    0x106b(%rip),%r12
lea    0x8(%rsp),%r13
movl   $0x0,0x10(%rsp)
movl   $0x0,0xc(%rsp)
xor    %r14d,%r14d
nop
movb   $0x30,0x7(%rsp)
movb   $0x30,0x4(%rsp)
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
lea    0x7(%rsp),%rsi
lea    0x4(%rsp),%rdx
xor    %eax,%eax
call   1080 <scanf@plt>
cmp    $0x2,%eax
jne    1214 <main+0xa4>
cmpb   $0xa,0x4(%rsp)
je     1230 <main+0xc0>
xor    %eax,%eax
call   1050 <clear_input_value@plt>
test   %rax,%rax
je     1230 <main+0xc0>
lea    0x12f0(%rip),%rdi
jmp    1470 <main+0x300>
nopl   0x0(%rax)
movsbl 0x7(%rsp),%eax
add    $0xffffffcf,%eax
cmp    $0x3,%eax
ja     12c0 <main+0x150>
lea    0xdb8(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x0,0x8(%rsp)
movb   $0x30,0x5(%rsp)
jmp    127c <main+0x10c>
mov    0x8(%rsp),%eax
add    $0xffffffff,%eax
lea    0x123f(%rip),%rdi
cmp    $0x5,%eax
jb     1465 <main+0x2f5>
call   1030 <puts@plt>
lea    0xf43(%rip),%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1080 <scanf@plt>
cmp    $0x2,%eax
jne    12ab <main+0x13b>
cmpb   $0xa,0x5(%rsp)
je     1260 <main+0xf0>
xor    %eax,%eax
call   1050 <clear_input_value@plt>
lea    0x121b(%rip),%rdi
test   %rax,%rax
jne    1277 <main+0x107>
jmp    1260 <main+0xf0>
lea    0x122e(%rip),%rdi
jmp    1470 <main+0x300>
movb   $0x30,0x6(%rsp)
mov    0x8(%rsp),%esi
movl   $0x0,0x10(%rsp)
lea    0xf53(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
cmpl   $0x0,0x8(%rsp)
movl   $0x0,0xc(%rsp)
mov    $0x0,%r14d
jle    1475 <main+0x305>
xor    %r15d,%r15d
movl   $0x0,0xc(%rsp)
movl   $0x0,0x10(%rsp)
jmp    1344 <main+0x1d4>
nopl   0x0(%rax)
lea    0xf8d(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
addl   $0x1,0xc(%rsp)
mov    %ebx,%r15d
cmp    0x8(%rsp),%r15d
jge    1485 <main+0x315>
xor    %eax,%eax
call   1090 <rand@plt>
movslq %eax,%rbp
imul   $0x30c30c31,%rbp,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
lea    (%rax,%rax,4),%ecx
lea    (%rax,%rcx,4),%eax
sub    %eax,%ebp
xor    %eax,%eax
call   1090 <rand@plt>
movslq %eax,%r14
imul   $0x30c30c31,%r14,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
lea    (%rax,%rax,4),%ecx
lea    (%rax,%rcx,4),%eax
sub    %eax,%r14d
lea    0x1(%r15),%ebx
lea    0xf00(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r14d,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
lea    0x14(%rsp),%rsi
lea    0x6(%rsp),%rdx
xor    %eax,%eax
call   1080 <scanf@plt>
cmp    $0x2,%eax
jne    13ca <main+0x25a>
cmpb   $0xa,0x6(%rsp)
je     1400 <main+0x290>
xor    %eax,%eax
call   1050 <clear_input_value@plt>
test   %rax,%rax
je     1400 <main+0x290>
lea    0x10ad(%rip),%rdi
call   1030 <puts@plt>
cmp    0x8(%rsp),%r15d
jl     1344 <main+0x1d4>
jmp    1485 <main+0x315>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    %ebp,%r14d
cmp    %r14d,0x14(%rsp)
jne    1320 <main+0x1b0>
lea    0x1051(%rip),%rdi
call   1030 <puts@plt>
addl   $0x1,0x10(%rsp)
jmp    1336 <main+0x1c6>
cmp    $0x1,%r14d
jne    14a0 <main+0x330>
mov    0x8(%rsp),%edx
lea    0xeb9(%rip),%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xef3(%rip),%rdi
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%r14d
jmp    1475 <main+0x305>
lea    0xeff(%rip),%rdi
jmp    1470 <main+0x300>
lea    0xe7e(%rip),%rdi
nopl   0x0(%rax)
call   1030 <puts@plt>
cmpb   $0x34,0x7(%rsp)
je     14b1 <main+0x341>
mov    0x8(%rsp),%esi
jmp    11e0 <main+0x70>
mov    $0x1,%r14d
lea    0x5(%rsp),%rbp
lea    0xb7c(%rip),%r15
lea    0xd22(%rip),%rbx
jmp    1475 <main+0x305>
lea    0xf9d(%rip),%rdi
call   1030 <puts@plt>
xor    %r14d,%r14d
jmp    1475 <main+0x305>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.error_check = [3 x i8] c"0\00\00"
@.str = [429 x i8] c"_____________________________________________________________________________\0AWelcome to the Mathematics Quiz Game!\0A\0APlease select one of the 4 options below:\0A1.\09Select the number of questions in the round (Default of 1 question)\0A2.\09Start the Mathematics Game with %d round/s\0A3.\09See how many questions you got correct or incorrect\0A4.\09EXIT the game\0A_____________________________________________________________________________\0A\0A\0A\00"
@.str.1 = [6 x i8] c"%1s%c\00"
@.str.2 = [37 x i8] c"You entered an Invaild Character\0A\0A\0A\0A\00"
@.str.3 = [108 x i8] c"\0A\0A\0A\0AEnter the number of questions to be asked for this round of the quiz (Maximum of %d questions allowed)\0A\00"
@.str.4 = [5 x i8] c"%d%c\00"
@.str.5 = [34 x i8] c"You entered an Invaild Character\0A\00"
@.str.6 = [5 x i8] c"\0A\0A\0A\0A\00"
@.str.7 = [40 x i8] c"You entered an Invaild Round Quanitity\0A\00"
@.str.8 = [101 x i8] c"\0A\0A\0A\0AThis game will consist of %d rounds.\0AAll answers will be whole numbers (Meaning no remainders)\0A\0A\00"
@.str.9 = [24 x i8] c"Question %d.\09%d + %d =\0A\00"
@.str.10 = [36 x i8] c"You entered an Invaild Character\0A\0A\0A\00"
@.str.11 = [37 x i8] c"\0AWell done you got that correct\0A\0A\0A\0A\0A\00"
@.str.12 = [58 x i8] c"\0ASorry that was incorrect\0A\09The correct answer was %d\0A\0A\0A\0A\0A\00"
@.str.13 = [74 x i8] c"\0A\0A\0A\0A\0AYou've just completed a game of %d round/s\0AOut of those %d round/s\0A\0A\00"
@.str.14 = [42 x i8] c"You got:\0A\09\09 %d Correct\09\09%d Incorrect\0A\0A\0A\0A\0A\00"
@.str.15 = [35 x i8] c"You have not completed a round\0A\0A\0A\0A\00"
@.str.16 = [227 x i8] c"\0A\0A\0A\0A\0A\0A****************************************************************************\0A*\0A* Thank you for playing the Mathematics Quiz Game\0A*\09Goodbye\0A*\0A****************************************************************************\0A\0A\00"
@.str.17 = [35 x i8] c"\0AYou entered an Invaild Option\0A\0A\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [3 x i8]
%10 = alloca [3 x i32]
%11 = alloca i32
store i32 0, i32* %1
%12 = bitcast [3 x i8]* %9 to i8*
%13 = bitcast [3 x i32]* %10 to i8*
store i8 48, i8* %2
store i32 1, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %11
%14 = call i32 @time(i32* null)
%15 = call i32 @srand(i32 %14)
br label %16
16: ; preds = %154, %0
store i8 48, i8* %2
%17 = getelementptr inbounds [3 x i8], [3 x i8]* %9, i64 0, i64 0
store i8 48, i8* %17
%18 = load i32, i32* %3
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([429 x i8], [429 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = getelementptr inbounds [3 x i8], [3 x i8]* %9, i64 0, i64 0
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %2, i8* %20)
%22 = icmp ne i32 %21, 2
br i1 %22, label %28, label %23
23: ; preds = %16
%24 = getelementptr inbounds [3 x i8], [3 x i8]* %9, i64 0, i64 0
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 10
br i1 %27, label %28, label %33
28: ; preds = %23, %16
%29 = call i64 (...) @clear_input_value()
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %28
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0))
br label %153
33: ; preds = %28, %23
%34 = load i8, i8* %2
%35 = sext i8 %34 to i32
switch i32 %35, label %150 [
i32 49, label %36
i32 50, label %71
i32 51, label %135
i32 52, label %148
]
36: ; preds = %33
store i32 0, i32* %3
store i32 0, i32* %4
%37 = getelementptr inbounds [3 x i8], [3 x i8]* %9, i64 0, i64 1
store i8 48, i8* %37
br label %38
38: ; preds = %69, %36
%39 = load i32, i32* %4
%40 = icmp ne i32 %39, 1
br i1 %40, label %41, label %70
41: ; preds = %38
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([108 x i8], [108 x i8]* @.str.3, i64 0, i64 0), i32 5)
%43 = getelementptr inbounds [3 x i8], [3 x i8]* %9, i64 0, i64 1
%44 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32* %3, i8* %43)
%45 = icmp ne i32 %44, 2
br i1 %45, label %51, label %46
46: ; preds = %41
%47 = getelementptr inbounds [3 x i8], [3 x i8]* %9, i64 0, i64 1
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp ne i32 %49, 10
br i1 %50, label %51, label %56
51: ; preds = %46, %41
%52 = call i64 (...) @clear_input_value()
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %56
54: ; preds = %51
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0))
br label %69
56: ; preds = %51, %46
%57 = load i32, i32* %3
%58 = icmp sle i32 %57, 5
br i1 %58, label %59, label %66
59: ; preds = %56
%60 = load i32, i32* %3
%61 = icmp sgt i32 %60, 0
br i1 %61, label %62, label %66
62: ; preds = %59
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%64 = load i32, i32* %4
%65 = add nsw i32 %64, 1
store i32 %65, i32* %4
br label %68
66: ; preds = %59, %56
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0))
br label %68
68: ; preds = %66, %62
br label %69
69: ; preds = %68, %54
br label %38
70: ; preds = %38
br label %152
71: ; preds = %33
store i32 0, i32* %8
store i32 0, i32* %6
store i32 0, i32* %7
%72 = getelementptr inbounds [3 x i8], [3 x i8]* %9, i64 0, i64 2
store i8 48, i8* %72
%73 = load i32, i32* %3
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([101 x i8], [101 x i8]* @.str.8, i64 0, i64 0), i32 %73)
store i32 0, i32* %11
br label %75
75: ; preds = %131, %71
%76 = load i32, i32* %11
%77 = load i32, i32* %3
%78 = icmp slt i32 %76, %77
br i1 %78, label %79, label %134
79: ; preds = %75
%80 = call i32 (...) @rand()
%81 = srem i32 %80, 21
%82 = getelementptr inbounds [3 x i32], [3 x i32]* %10, i64 0, i64 0
store i32 %81, i32* %82
%83 = call i32 (...) @rand()
%84 = srem i32 %83, 21
%85 = getelementptr inbounds [3 x i32], [3 x i32]* %10, i64 0, i64 1
store i32 %84, i32* %85
%86 = getelementptr inbounds [3 x i32], [3 x i32]* %10, i64 0, i64 0
%87 = load i32, i32* %86
%88 = getelementptr inbounds [3 x i32], [3 x i32]* %10, i64 0, i64 1
%89 = load i32, i32* %88
%90 = add nsw i32 %87, %89
%91 = getelementptr inbounds [3 x i32], [3 x i32]* %10, i64 0, i64 2
store i32 %90, i32* %91
%92 = load i32, i32* %11
%93 = add nsw i32 %92, 1
%94 = getelementptr inbounds [3 x i32], [3 x i32]* %10, i64 0, i64 0
%95 = load i32, i32* %94
%96 = getelementptr inbounds [3 x i32], [3 x i32]* %10, i64 0, i64 1
%97 = load i32, i32* %96
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i32 %93, i32 %95, i32 %97)
%99 = getelementptr inbounds [3 x i8], [3 x i8]* %9, i64 0, i64 2
%100 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32* %5, i8* %99)
%101 = icmp ne i32 %100, 2
br i1 %101, label %107, label %102
102: ; preds = %79
%103 = getelementptr inbounds [3 x i8], [3 x i8]* %9, i64 0, i64 2
%104 = load i8, i8* %103
%105 = sext i8 %104 to i32
%106 = icmp ne i32 %105, 10
br i1 %106, label %107, label %114
107: ; preds = %102, %79
%108 = call i64 (...) @clear_input_value()
%109 = icmp ne i64 %108, 0
br i1 %109, label %110, label %114
110: ; preds = %107
%111 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.10, i64 0, i64 0))
%112 = load i32, i32* %11
%113 = sub nsw i32 %112, 1
store i32 %113, i32* %11
br label %130
114: ; preds = %107, %102
%115 = load i32, i32* %5
%116 = getelementptr inbounds [3 x i32], [3 x i32]* %10, i64 0, i64 2
%117 = load i32, i32* %116
%118 = icmp eq i32 %115, %117
br i1 %118, label %119, label %123
119: ; preds = %114
%120 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.11, i64 0, i64 0))
%121 = load i32, i32* %6
%122 = add nsw i32 %121, 1
store i32 %122, i32* %6
br label %129
123: ; preds = %114
%124 = getelementptr inbounds [3 x i32], [3 x i32]* %10, i64 0, i64 2
%125 = load i32, i32* %124
%126 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.12, i64 0, i64 0), i32 %125)
%127 = load i32, i32* %7
%128 = add nsw i32 %127, 1
store i32 %128, i32* %7
br label %129
129: ; preds = %123, %119
br label %130
130: ; preds = %129, %110
store i32 1, i32* %8
br label %131
131: ; preds = %130
%132 = load i32, i32* %11
%133 = add nsw i32 %132, 1
store i32 %133, i32* %11
br label %75
134: ; preds = %75
br label %152
135: ; preds = %33
%136 = load i32, i32* %8
%137 = icmp eq i32 %136, 1
br i1 %137, label %138, label %145
138: ; preds = %135
%139 = load i32, i32* %3
%140 = load i32, i32* %3
%141 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.13, i64 0, i64 0), i32 %139, i32 %140)
%142 = load i32, i32* %6
%143 = load i32, i32* %7
%144 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.14, i64 0, i64 0), i32 %142, i32 %143)
br label %147
145: ; preds = %135
%146 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.15, i64 0, i64 0))
br label %147
147: ; preds = %145, %138
br label %152
148: ; preds = %33
%149 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([227 x i8], [227 x i8]* @.str.16, i64 0, i64 0))
br label %152
150: ; preds = %33
%151 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.17, i64 0, i64 0))
br label %152
152: ; preds = %150, %148, %147, %134, %70
br label %153
153: ; preds = %152, %31
br label %154
154: ; preds = %153
%155 = load i8, i8* %2
%156 = sext i8 %155 to i32
%157 = icmp ne i32 %156, 52
br i1 %157, label %16, label %158
158: ; preds = %154
ret i32 0
}

LLVM IR (-O2):
@__const.main.error_check = [3 x i8] c"0\00\00"
@.str = [429 x i8] c"_____________________________________________________________________________\0AWelcome to the Mathematics Quiz Game!\0A\0APlease select one of the 4 options below:\0A1.\09Select the number of questions in the round (Default of 1 question)\0A2.\09Start the Mathematics Game with %d round/s\0A3.\09See how many questions you got correct or incorrect\0A4.\09EXIT the game\0A_____________________________________________________________________________\0A\0A\0A\00"
@.str.1 = [6 x i8] c"%1s%c\00"
@.str.3 = [108 x i8] c"\0A\0A\0A\0AEnter the number of questions to be asked for this round of the quiz (Maximum of %d questions allowed)\0A\00"
@.str.4 = [5 x i8] c"%d%c\00"
@.str.8 = [101 x i8] c"\0A\0A\0A\0AThis game will consist of %d rounds.\0AAll answers will be whole numbers (Meaning no remainders)\0A\0A\00"
@.str.9 = [24 x i8] c"Question %d.\09%d + %d =\0A\00"
@.str.12 = [58 x i8] c"\0ASorry that was incorrect\0A\09The correct answer was %d\0A\0A\0A\0A\0A\00"
@.str.13 = [74 x i8] c"\0A\0A\0A\0A\0AYou've just completed a game of %d round/s\0AOut of those %d round/s\0A\0A\00"
@.str.14 = [42 x i8] c"You got:\0A\09\09 %d Correct\09\09%d Incorrect\0A\0A\0A\0A\0A\00"
@str = [226 x i8] c"\0A\0A\0A\0A\0A\0A****************************************************************************\0A*\0A* Thank you for playing the Mathematics Quiz Game\0A*\09Goodbye\0A*\0A****************************************************************************\0A\00"
@str.18 = [34 x i8] c"You have not completed a round\0A\0A\0A\00"
@str.19 = [36 x i8] c"\0AWell done you got that correct\0A\0A\0A\0A\00"
@str.20 = [35 x i8] c"You entered an Invaild Character\0A\0A\00"
@str.21 = [39 x i8] c"You entered an Invaild Round Quanitity\00"
@str.22 = [4 x i8] c"\0A\0A\0A\00"
@str.23 = [33 x i8] c"You entered an Invaild Character\00"
@str.24 = [34 x i8] c"\0AYou entered an Invaild Option\0A\0A\0A\00"
@str.25 = [36 x i8] c"You entered an Invaild Character\0A\0A\0A\00"
define i32 @main() {
%1 = alloca i8
%2 = alloca i32
%3 = alloca i32
%4 = alloca [3 x i8]
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 0
store i32 1, i32* %2
store i32 0, i32* %3
%8 = tail call i32 @time(i32* null)
%9 = tail call i32 @srand(i32 %8)
%10 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 2
%11 = getelementptr inbounds [3 x i8], [3 x i8]* %4, i64 0, i64 1
br label %12
12: ; preds = %110, %0
%13 = phi i32 [ 1, %0 ], [ %111, %110 ]
%14 = phi i32 [ 0, %0 ], [ %105, %110 ]
%15 = phi i32 [ 0, %0 ], [ %106, %110 ]
%16 = phi i32 [ 0, %0 ], [ %107, %110 ]
store i8 48, i8* %1
store i8 48, i8* %7
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([429 x i8], [429 x i8]* @.str, i64 0, i64 0), i32 %13)
%18 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* %7)
%19 = icmp ne i32 %18, 2
%20 = load i8, i8* %7
%21 = icmp ne i8 %20, 10
%22 = select i1 %19, i1 true, i1 %21
br i1 %22, label %23, label %28
23: ; preds = %12
%24 = call i64 (...) @clear_input_value()
%25 = icmp eq i64 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %23
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.25, i64 0, i64 0))
br label %104
28: ; preds = %12, %23
%29 = load i8, i8* %1
%30 = sext i8 %29 to i32
switch i32 %30, label %100 [
i32 49, label %31
i32 50, label %49
i32 51, label %90
i32 52, label %98
]
31: ; preds = %28
store i32 0, i32* %2
store i8 48, i8* %11
br label %32
32: ; preds = %46, %31
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([108 x i8], [108 x i8]* @.str.3, i64 0, i64 0), i32 5)
%34 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32* %2, i8* %11)
%35 = icmp ne i32 %34, 2
%36 = load i8, i8* %11
%37 = icmp ne i8 %36, 10
%38 = select i1 %35, i1 true, i1 %37
br i1 %38, label %39, label %42
39: ; preds = %32
%40 = call i64 (...) @clear_input_value()
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %46
42: ; preds = %32, %39
%43 = load i32, i32* %2
%44 = add i32 %43, -1
%45 = icmp ult i32 %44, 5
br i1 %45, label %102, label %46
46: ; preds = %42, %39
%47 = phi i8* [ getelementptr inbounds ([33 x i8], [33 x i8]* @str.23, i64 0, i64 0), %39 ], [ getelementptr inbounds ([39 x i8], [39 x i8]* @str.21, i64 0, i64 0), %42 ]
%48 = call i32 @puts(i8* dereferenceable(1) %47)
br label %32
49: ; preds = %28
store i8 48, i8* %10
%50 = load i32, i32* %2
%51 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([101 x i8], [101 x i8]* @.str.8, i64 0, i64 0), i32 %50)
%52 = load i32, i32* %2
%53 = icmp sgt i32 %52, 0
br i1 %53, label %54, label %104
54: ; preds = %49, %84
%55 = phi i32 [ %85, %84 ], [ 0, %49 ]
%56 = phi i32 [ %87, %84 ], [ 0, %49 ]
%57 = phi i32 [ %86, %84 ], [ 0, %49 ]
%58 = call i32 (...) @rand()
%59 = srem i32 %58, 21
%60 = call i32 (...) @rand()
%61 = srem i32 %60, 21
%62 = add nsw i32 %61, %59
%63 = add nsw i32 %55, 1
%64 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i32 %63, i32 %59, i32 %61)
%65 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32* %3, i8* %10)
%66 = icmp ne i32 %65, 2
%67 = load i8, i8* %10
%68 = icmp ne i8 %67, 10
%69 = select i1 %66, i1 true, i1 %68
br i1 %69, label %70, label %75
70: ; preds = %54
%71 = call i64 (...) @clear_input_value()
%72 = icmp eq i64 %71, 0
br i1 %72, label %75, label %73
73: ; preds = %70
%74 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.20, i64 0, i64 0))
br label %84
75: ; preds = %54, %70
%76 = load i32, i32* %3
%77 = icmp eq i32 %76, %62
br i1 %77, label %78, label %81
78: ; preds = %75
%79 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.19, i64 0, i64 0))
%80 = add nsw i32 %57, 1
br label %84
81: ; preds = %75
%82 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.12, i64 0, i64 0), i32 %62)
%83 = add nsw i32 %56, 1
br label %84
84: ; preds = %78, %81, %73
%85 = phi i32 [ %63, %78 ], [ %63, %81 ], [ %55, %73 ]
%86 = phi i32 [ %80, %78 ], [ %57, %81 ], [ %57, %73 ]
%87 = phi i32 [ %56, %78 ], [ %83, %81 ], [ %56, %73 ]
%88 = load i32, i32* %2
%89 = icmp slt i32 %85, %88
br i1 %89, label %54, label %104
90: ; preds = %28
%91 = icmp eq i32 %16, 1
br i1 %91, label %92, label %96
92: ; preds = %90
%93 = load i32, i32* %2
%94 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @.str.13, i64 0, i64 0), i32 %93, i32 %93)
%95 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.14, i64 0, i64 0), i32 %14, i32 %15)
br label %104
96: ; preds = %90
%97 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.18, i64 0, i64 0))
br label %104
98: ; preds = %28
%99 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([226 x i8], [226 x i8]* @str, i64 0, i64 0))
br label %104
100: ; preds = %28
%101 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.24, i64 0, i64 0))
br label %104
102: ; preds = %42
%103 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str.22, i64 0, i64 0))
br label %104
104: ; preds = %84, %102, %49, %26, %92, %96, %100, %98
%105 = phi i32 [ %14, %26 ], [ %14, %100 ], [ %14, %98 ], [ %14, %92 ], [ %14, %96 ], [ 0, %49 ], [ %14, %102 ], [ %86, %84 ]
%106 = phi i32 [ %15, %26 ], [ %15, %100 ], [ %15, %98 ], [ %15, %92 ], [ %15, %96 ], [ 0, %49 ], [ %15, %102 ], [ %87, %84 ]
%107 = phi i32 [ %16, %26 ], [ %16, %100 ], [ %16, %98 ], [ 1, %92 ], [ 0, %96 ], [ 0, %49 ], [ %16, %102 ], [ 1, %84 ]
%108 = load i8, i8* %1
%109 = icmp eq i8 %108, 52
br i1 %109, label %112, label %110
110: ; preds = %104
%111 = load i32, i32* %2
br label %12
112: ; preds = %104
ret i32 0
}