main() {
  int answers[5] = {88, 228, 156, -4, 1};
  int option;
  int score = 0;
  int wrong = 0;
  int num_questions = 0;
  int i;
  int user_answer;
  int round = 1;
  printf("\t\t\t*** FUN MATHS QUIZ ***\t\t\t\n");
  printf("\n\t\t\tWelcome to your Maths Quiz!\t\t\t");
  printf("\n\tPlease select one of the following options from the Main Menu "
         "below...\t\n");
  do {
    printf("\n\t\t\t*** MAIN MENU ***\t\t\t\n");
    printf(">>> Select 1: to select the number of QUESTIONS you would like to "
           "answer.\n");
    printf(">>> Select 2: to START the quiz.\n");
    printf(">>> Select 3: to display your SCORE for the ROUND.\n");
    printf(">>> Select 4: to EXIT the quiz.\n");
    printf("\n>>> Please select a menu option: ");
    scanf("%d", &option);
    flushall();
    if (option != 1 && option != 2 && option != 3 && option != 4) {
      printf("\nThis is not a valid option.\n");
    } else if (option == 4) {
      printf("\nGoodbye");
      printf("\nPress 'enter' to exit.");
    }
    switch (option) {
    case 1: {
      do {
        printf("\n--- You selected Menu Option: %d", option);
        printf("\nThere are a maximum of %d questions per round.\n", 5);
        printf("Please enter number of questions for this round: ");
        scanf("%d", &num_questions);
        flushall();
        printf("--- You have selected to answer %d questions this round.\n",
               num_questions);
        if (num_questions > 5 || num_questions < 1) {
          printf("\n*** ERROR: Please select a number up to max of %d!\n", 5);
        }
      } while (num_questions > 5 || num_questions < 1);
      break;
    }
    case 2: {
      if (num_questions == 0) {
        printf("\n*** ERROR: Please select the number of questions first!\n");
        break;
      } else {
        score = 0;
        wrong = 0;
        i = 0;
        printf("\n--- You selected Menu Option: %d", option);
        printf("\n--- Let's begin...\n");
        printf("\n\t***** ROUND %d *****\n", round);
        do {
          printf("\nQuestion 1: >> (9 x 8) + 16 = _ \n");
          scanf("%d", &user_answer);
          flushall();
          if (user_answer == answers[i]) {
            printf("--- You entered: %d - Correct!!\n", user_answer);
            score++;
          } else {
            printf("--- You entered: %d - Wrong!! The correct answer: %d\n",
                   user_answer, answers[i]);
            wrong++;
          }
          i++;
          if (i < num_questions) {
            printf("\nQuestion 2: >> (121 - 83) x 6 = _ \n");
            scanf("%d", &user_answer);
            flushall();
            if (user_answer == answers[i]) {
              printf("--- You entered: %d - Correct!!\n", user_answer);
              score++;
            } else {
              printf("--- You entered: %d - Wrong!! The correct answer: %d\n",
                     user_answer, answers[i]);
              wrong++;
            }
            i++;
          }
          if (i < num_questions) {
            printf("\nQuestion 3: >> 12 x (143 / 11) = _ \n");
            scanf("%d", &user_answer);
            flushall();
            if (user_answer == answers[i]) {
              printf("--- You entered: %d - Correct!!\n", user_answer);
              score++;
            } else {
              printf("--- You entered: %d - Wrong!! The correct answer: %d\n",
                     user_answer, answers[i]);
              wrong++;
            }
            i++;
          }
          if (i < num_questions) {
            printf("\nQuestion 4: >> (56 x 3) - 172 = _ \n");
            scanf("%d", &user_answer);
            flushall();
            if (user_answer == answers[i]) {
              printf("--- You entered: %d - Correct!!\n", user_answer);
              score++;
            } else {
              printf("--- You entered: %d - Wrong!! The correct answer: %d\n",
                     user_answer, answers[i]);
              wrong++;
            }
            i++;
          }
          if (i < num_questions) {
            printf("\nQuestion 5: >> 216 / (18 x 12) = _ \n");
            scanf("%d", &user_answer);
            flushall();
            if (user_answer == answers[i]) {
              printf("--- You entered: %d - Correct!!\n", user_answer);
              score++;
            } else {
              printf("--- You entered: %d - Wrong!! The correct answer: %d\n",
                     user_answer, answers[i]);
              wrong++;
            }
          }
        } while (i < num_questions - 1);
        printf("\n>>> That is the end of Round %d.\n", round);
        round++;
        break;
      }
    }
    case 3: {
      if (num_questions == 0) {
        printf("\n*** ERROR: You must play the game first!\n");
      } else if (score == 0 && wrong == 0) {
        printf("\n*** ERROR: You must play the game first!\n");
      } else {
        printf("\nScore for Round %d: %d CORRECT, %d WRONG.\n", round - 1,
               score, wrong);
        printf(
            "\n>>> Would you like to play again? Press 1 (yes) / 4 (EXIT)\n");
        num_questions = 0;
        break;
      }
    }
    }
  } while (option != 4);
  getchar();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xeaa(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xea7(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xea5(%rip),%eax
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x1,-0x3c(%rbp)
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf2e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf68(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf7b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xfee(%rip),%rdi
lea    -0x24(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    $0x0,%al
call   1040 <flushall@plt>
cmpl   $0x1,-0x24(%rbp)
je     125c <main+0x11c>
cmpl   $0x2,-0x24(%rbp)
je     125c <main+0x11c>
cmpl   $0x3,-0x24(%rbp)
je     125c <main+0x11c>
cmpl   $0x4,-0x24(%rbp)
je     125c <main+0x11c>
lea    0xf4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1287 <main+0x147>
cmpl   $0x4,-0x24(%rbp)
jne    1282 <main+0x142>
lea    0xf50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf4b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1287 <main+0x147>
mov    -0x24(%rbp),%eax
mov    %eax,-0x40(%rbp)
sub    $0x1,%eax
je     12bd <main+0x17d>
jmp    129b <main+0x15b>
mov    -0x40(%rbp),%eax
sub    $0x2,%eax
je     1373 <main+0x233>
jmp    12ac <main+0x16c>
mov    -0x40(%rbp),%eax
sub    $0x3,%eax
je     16c0 <main+0x580>
jmp    1742 <main+0x602>
jmp    12c2 <main+0x182>
mov    -0x24(%rbp),%esi
lea    0xf12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf26(%rip),%rdi
mov    $0x5,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf44(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf02(%rip),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    $0x0,%al
call   1040 <flushall@plt>
mov    -0x30(%rbp),%esi
lea    0xf4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x5,-0x30(%rbp)
jg     1332 <main+0x1f2>
cmpl   $0x1,-0x30(%rbp)
jge    1345 <main+0x205>
lea    0xf64(%rip),%rdi
mov    $0x5,%esi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    134a <main+0x20a>
mov    $0x1,%al
cmpl   $0x5,-0x30(%rbp)
mov    %al,-0x41(%rbp)
jg     1363 <main+0x223>
cmpl   $0x1,-0x30(%rbp)
setl   %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
test   $0x1,%al
jne    12c2 <main+0x182>
jmp    1742 <main+0x602>
cmpl   $0x0,-0x30(%rbp)
jne    1390 <main+0x250>
lea    0xf4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1742 <main+0x602>
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x24(%rbp),%esi
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x3c(%rbp),%esi
lea    0xf53(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe13(%rip),%rdi
lea    -0x38(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    $0x0,%al
call   1040 <flushall@plt>
mov    -0x38(%rbp),%eax
movslq -0x34(%rbp),%rcx
cmp    -0x20(%rbp,%rcx,4),%eax
jne    142c <main+0x2ec>
mov    -0x38(%rbp),%esi
lea    0xf45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    144e <main+0x30e>
mov    -0x38(%rbp),%esi
movslq -0x34(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%edx
lea    0xf3f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    14e5 <main+0x3a5>
lea    0xf49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd85(%rip),%rdi
lea    -0x38(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    $0x0,%al
call   1040 <flushall@plt>
mov    -0x38(%rbp),%eax
movslq -0x34(%rbp),%rcx
cmp    -0x20(%rbp,%rcx,4),%eax
jne    14ba <main+0x37a>
mov    -0x38(%rbp),%esi
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    14dc <main+0x39c>
mov    -0x38(%rbp),%esi
movslq -0x34(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%edx
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    1573 <main+0x433>
lea    0xee0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xcf7(%rip),%rdi
lea    -0x38(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    $0x0,%al
call   1040 <flushall@plt>
mov    -0x38(%rbp),%eax
movslq -0x34(%rbp),%rcx
cmp    -0x20(%rbp,%rcx,4),%eax
jne    1548 <main+0x408>
mov    -0x38(%rbp),%esi
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    156a <main+0x42a>
mov    -0x38(%rbp),%esi
movslq -0x34(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%edx
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    1601 <main+0x4c1>
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xc69(%rip),%rdi
lea    -0x38(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    $0x0,%al
call   1040 <flushall@plt>
mov    -0x38(%rbp),%eax
movslq -0x34(%rbp),%rcx
cmp    -0x20(%rbp,%rcx,4),%eax
jne    15d6 <main+0x496>
mov    -0x38(%rbp),%esi
lea    0xd9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    15f8 <main+0x4b8>
mov    -0x38(%rbp),%esi
movslq -0x34(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%edx
lea    0xd95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x30(%rbp),%eax
jge    168b <main+0x54b>
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xbdb(%rip),%rdi
lea    -0x38(%rbp),%rsi
mov    $0x0,%al
call   1060 <scanf@plt>
mov    $0x0,%al
call   1040 <flushall@plt>
mov    -0x38(%rbp),%eax
movslq -0x34(%rbp),%rcx
cmp    -0x20(%rbp,%rcx,4),%eax
jne    1664 <main+0x524>
mov    -0x38(%rbp),%esi
lea    0xd0d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1686 <main+0x546>
mov    -0x38(%rbp),%esi
movslq -0x34(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%edx
lea    0xd07(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    168b <main+0x54b>
jmp    1690 <main+0x550>
mov    -0x34(%rbp),%eax
mov    -0x30(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jl     13d5 <main+0x295>
mov    -0x3c(%rbp),%esi
lea    0xd9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1742 <main+0x602>
cmpl   $0x0,-0x30(%rbp)
jne    16dd <main+0x59d>
lea    0xd9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    173d <main+0x5fd>
cmpl   $0x0,-0x28(%rbp)
jne    1704 <main+0x5c4>
cmpl   $0x0,-0x2c(%rbp)
jne    1704 <main+0x5c4>
lea    0xd74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1738 <main+0x5f8>
mov    -0x3c(%rbp),%esi
sub    $0x1,%esi
mov    -0x28(%rbp),%edx
mov    -0x2c(%rbp),%ecx
lea    0xd80(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x30(%rbp)
jmp    1742 <main+0x602>
jmp    173d <main+0x5fd>
jmp    1742 <main+0x602>
jmp    1747 <main+0x607>
cmpl   $0x4,-0x24(%rbp)
jne    11b4 <main+0x74>
mov    $0x0,%al
call   1050 <getchar@plt>
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
sub    $0x18,%rsp
movl   $0x0,0x4(%rsp)
lea    0x10c0(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x10c3(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%r12d
lea    0x10fb(%rip),%r13
lea    0xefa(%rip),%r15
lea    0x8(%rsp),%r14
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    11db <main+0x8b>
lea    0x102c(%rip),%rdi
mov    0x10(%rsp),%r12
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r12d
lea    0x10c8(%rip),%r13
nopl   0x0(%rax)
cmpl   $0x4,0xc(%rsp)
je     16d4 <main+0x584>
mov    %r13,%rdi
call   1030 <puts@plt>
lea    0x10c3(%rip),%rdi
call   1030 <puts@plt>
lea    0x1101(%rip),%rdi
call   1030 <puts@plt>
lea    0x1116(%rip),%rdi
call   1030 <puts@plt>
lea    0x113d(%rip),%rdi
call   1030 <puts@plt>
lea    0xe1d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
xor    %eax,%eax
call   1050 <flushall@plt>
mov    0xc(%rsp),%eax
lea    -0x5(%rax),%ecx
cmp    $0xfffffffb,%ecx
ja     1260 <main+0x110>
lea    0x1288(%rip),%rdi
call   1030 <puts@plt>
jmp    1281 <main+0x131>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmp    $0x4,%eax
jne    1285 <main+0x135>
lea    0xdee(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xde9(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%eax
cmp    $0x3,%eax
je     1660 <main+0x510>
cmp    $0x2,%eax
je     13b0 <main+0x260>
cmp    $0x1,%eax
jne    11d0 <main+0x80>
lea    0xdd4(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xde3(%rip),%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe01(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
xor    %eax,%eax
call   1050 <flushall@plt>
mov    0x4(%rsp),%esi
lea    0xe0b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%eax
add    $0xfffffffa,%eax
cmp    $0xfffffffa,%eax
ja     11d0 <main+0x80>
nopl   0x0(%rax)
lea    0xe23(%rip),%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%eax
add    $0xfffffffa,%eax
cmp    $0xfffffffa,%eax
ja     11d0 <main+0x80>
mov    0xc(%rsp),%esi
lea    0xd3d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd51(%rip),%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd6f(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
xor    %eax,%eax
call   1050 <flushall@plt>
mov    0x4(%rsp),%esi
lea    0xd79(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%eax
add    $0xfffffffa,%eax
cmp    $0xfffffffb,%eax
jb     1310 <main+0x1c0>
jmp    11d0 <main+0x80>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmpl   $0x0,0x4(%rsp)
je     1682 <main+0x532>
xor    %ebx,%ebx
lea    0xcb7(%rip),%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xffa(%rip),%rdi
call   1030 <puts@plt>
lea    0xd8c(%rip),%rdi
mov    %r12,0x10(%rsp)
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %ebp,%ebp
xor    %r13d,%r13d
jmp    1421 <main+0x2d1>
nopl   0x0(%rax)
lea    0xda1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    %eax,%r13d
jge    11ab <main+0x5b>
lea    0xfbd(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
xor    %eax,%eax
call   1050 <flushall@plt>
mov    0x8(%rsp),%esi
movslq %r13d,%rax
lea    0xbb1(%rip),%rcx
mov    (%rcx,%rax,4),%edx
cmp    %edx,%esi
jne    1470 <main+0x320>
lea    0xd2a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebx
jmp    1481 <main+0x331>
nopl   0x0(%rax)
lea    0xd31(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
lea    0x1(%r13),%r12d
mov    0x4(%rsp),%eax
cmp    %eax,%r12d
jl     14b0 <main+0x360>
cmp    %eax,%r12d
jl     1525 <main+0x3d5>
cmp    %eax,%r12d
jl     158e <main+0x43e>
jmp    15f9 <main+0x4a9>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xfbe(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
xor    %eax,%eax
call   1050 <flushall@plt>
mov    0x8(%rsp),%esi
movslq %r12d,%rax
lea    0xb22(%rip),%rcx
mov    (%rcx,%rax,4),%edx
cmp    %edx,%esi
jne    1500 <main+0x3b0>
lea    0xc9b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebx
jmp    1511 <main+0x3c1>
nopl   0x0(%rax,%rax,1)
lea    0xca1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
add    $0x2,%r13d
mov    0x4(%rsp),%eax
mov    %r13d,%r12d
cmp    %eax,%r12d
jge    1497 <main+0x347>
lea    0xf24(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
xor    %eax,%eax
call   1050 <flushall@plt>
mov    0x8(%rsp),%esi
movslq %r12d,%rax
lea    0xaad(%rip),%rcx
mov    (%rcx,%rax,4),%edx
cmp    %edx,%esi
jne    1570 <main+0x420>
lea    0xc26(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebx
jmp    1581 <main+0x431>
nopl   (%rax)
lea    0xc31(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
add    $0x1,%r12d
mov    0x4(%rsp),%eax
cmp    %eax,%r12d
jge    15f9 <main+0x4a9>
lea    0xe97(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
xor    %eax,%eax
call   1050 <flushall@plt>
mov    0x8(%rsp),%esi
movslq %r12d,%rax
lea    0xa44(%rip),%rcx
mov    (%rcx,%rax,4),%edx
cmp    %edx,%esi
jne    15e0 <main+0x490>
lea    0xbbd(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebx
jmp    15f1 <main+0x4a1>
cs nopw 0x0(%rax,%rax,1)
lea    0xbc1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebp
add    $0x1,%r12d
mov    0x4(%rsp),%eax
mov    %r12d,%r13d
cmp    %eax,%r12d
jge    1411 <main+0x2c1>
lea    0xdfb(%rip),%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
xor    %eax,%eax
call   1050 <flushall@plt>
mov    0x8(%rsp),%esi
movslq %r13d,%rax
lea    0x9cd(%rip),%rcx
mov    (%rcx,%rax,4),%edx
cmp    %edx,%esi
jne    1400 <main+0x2b0>
lea    0xb42(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%ebx
jmp    1411 <main+0x2c1>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmpl   $0x0,0x4(%rsp)
je     1693 <main+0x543>
mov    %ebx,%eax
or     %ebp,%eax
jne    16a4 <main+0x554>
lea    0xd33(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
xor    %ebp,%ebp
jmp    11d0 <main+0x80>
lea    0xe10(%rip),%rdi
call   1030 <puts@plt>
jmp    11d0 <main+0x80>
lea    0xd0d(%rip),%rdi
call   1030 <puts@plt>
jmp    11d0 <main+0x80>
lea    -0x1(%r12),%esi
lea    0xb51(%rip),%rdi
mov    %ebx,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xca9(%rip),%rdi
call   1030 <puts@plt>
movl   $0x0,0x4(%rsp)
jmp    11d0 <main+0x80>
xor    %eax,%eax
call   1060 <getchar@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.answers = [5 x i32] [i32 88, i32 228, i32 156, i32 -4, i32 1]
@.str = [30 x i8] c"\09\09\09*** FUN MATHS QUIZ ***\09\09\09\0A\00"
@.str.1 = [35 x i8] c"\0A\09\09\09Welcome to your Maths Quiz!\09\09\09\00"
@.str.2 = [75 x i8] c"\0A\09Please select one of the following options from the Main Menu below...\09\0A\00"
@.str.3 = [26 x i8] c"\0A\09\09\09*** MAIN MENU ***\09\09\09\0A\00"
@.str.4 = [75 x i8] c">>> Select 1: to select the number of QUESTIONS you would like to answer.\0A\00"
@.str.5 = [34 x i8] c">>> Select 2: to START the quiz.\0A\00"
@.str.6 = [52 x i8] c">>> Select 3: to display your SCORE for the ROUND.\0A\00"
@.str.7 = [33 x i8] c">>> Select 4: to EXIT the quiz.\0A\00"
@.str.8 = [35 x i8] c"\0A>>> Please select a menu option: \00"
@.str.9 = [3 x i8] c"%d\00"
@.str.10 = [30 x i8] c"\0AThis is not a valid option.\0A\00"
@.str.11 = [9 x i8] c"\0AGoodbye\00"
@.str.12 = [24 x i8] c"\0APress 'enter' to exit.\00"
@.str.13 = [34 x i8] c"\0A--- You selected Menu Option: %d\00"
@.str.14 = [49 x i8] c"\0AThere are a maximum of %d questions per round.\0A\00"
@.str.15 = [50 x i8] c"Please enter number of questions for this round: \00"
@.str.16 = [58 x i8] c"--- You have selected to answer %d questions this round.\0A\00"
@.str.17 = [53 x i8] c"\0A*** ERROR: Please select a number up to max of %d!\0A\00"
@.str.18 = [58 x i8] c"\0A*** ERROR: Please select the number of questions first!\0A\00"
@.str.19 = [21 x i8] c"\0A--- Let's begin...\0A\00"
@.str.20 = [24 x i8] c"\0A\09***** ROUND %d *****\0A\00"
@.str.21 = [35 x i8] c"\0AQuestion 1: >> (9 x 8) + 16 = _ \0A\00"
@.str.22 = [33 x i8] c"--- You entered: %d - Correct!!\0A\00"
@.str.23 = [54 x i8] c"--- You entered: %d - Wrong!! The correct answer: %d\0A\00"
@.str.24 = [37 x i8] c"\0AQuestion 2: >> (121 - 83) x 6 = _ \0A\00"
@.str.25 = [38 x i8] c"\0AQuestion 3: >> 12 x (143 / 11) = _ \0A\00"
@.str.26 = [37 x i8] c"\0AQuestion 4: >> (56 x 3) - 172 = _ \0A\00"
@.str.27 = [38 x i8] c"\0AQuestion 5: >> 216 / (18 x 12) = _ \0A\00"
@.str.28 = [35 x i8] c"\0A>>> That is the end of Round %d.\0A\00"
@.str.29 = [43 x i8] c"\0A*** ERROR: You must play the game first!\0A\00"
@.str.30 = [44 x i8] c"\0AScore for Round %d: %d CORRECT, %d WRONG.\0A\00"
@.str.31 = [61 x i8] c"\0A>>> Would you like to play again? Press 1 (yes) / 4 (EXIT)\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [5 x i32]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
%10 = bitcast [5 x i32]* %2 to i8*
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 1, i32* %9
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.2, i64 0, i64 0))
br label %14
14: ; preds = %265, %0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.4, i64 0, i64 0))
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.5, i64 0, i64 0))
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.6, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0))
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0))
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32* %3)
%22 = call i32 (...) @flushall()
%23 = load i32, i32* %3
%24 = icmp ne i32 %23, 1
br i1 %24, label %25, label %36
25: ; preds = %14
%26 = load i32, i32* %3
%27 = icmp ne i32 %26, 2
br i1 %27, label %28, label %36
28: ; preds = %25
%29 = load i32, i32* %3
%30 = icmp ne i32 %29, 3
br i1 %30, label %31, label %36
31: ; preds = %28
%32 = load i32, i32* %3
%33 = icmp ne i32 %32, 4
br i1 %33, label %34, label %36
34: ; preds = %31
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.10, i64 0, i64 0))
br label %43
36: ; preds = %31, %28, %25, %14
%37 = load i32, i32* %3
%38 = icmp eq i32 %37, 4
br i1 %38, label %39, label %42
39: ; preds = %36
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0))
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0))
br label %42
42: ; preds = %39, %36
br label %43
43: ; preds = %42, %34
%44 = load i32, i32* %3
switch i32 %44, label %264 [
i32 1, label %45
i32 2, label %72
i32 3, label %242
]
45: ; preds = %43
br label %46
46: ; preds = %69, %45
%47 = load i32, i32* %3
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.13, i64 0, i64 0), i32 %47)
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.14, i64 0, i64 0), i32 5)
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.15, i64 0, i64 0))
%51 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32* %6)
%52 = call i32 (...) @flushall()
%53 = load i32, i32* %6
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.16, i64 0, i64 0), i32 %53)
%55 = load i32, i32* %6
%56 = icmp sgt i32 %55, 5
br i1 %56, label %60, label %57
57: ; preds = %46
%58 = load i32, i32* %6
%59 = icmp slt i32 %58, 1
br i1 %59, label %60, label %62
60: ; preds = %57, %46
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.17, i64 0, i64 0), i32 5)
br label %62
62: ; preds = %60, %57
br label %63
63: ; preds = %62
%64 = load i32, i32* %6
%65 = icmp sgt i32 %64, 5
br i1 %65, label %69, label %66
66: ; preds = %63
%67 = load i32, i32* %6
%68 = icmp slt i32 %67, 1
br label %69
69: ; preds = %66, %63
%70 = phi i1 [ true, %63 ], [ %68, %66 ]
br i1 %70, label %46, label %71
71: ; preds = %69
br label %264
72: ; preds = %43
%73 = load i32, i32* %6
%74 = icmp eq i32 %73, 0
br i1 %74, label %75, label %77
75: ; preds = %72
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.18, i64 0, i64 0))
br label %264
77: ; preds = %72
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %7
%78 = load i32, i32* %3
%79 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.13, i64 0, i64 0), i32 %78)
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.19, i64 0, i64 0))
%81 = load i32, i32* %9
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.20, i64 0, i64 0), i32 %81)
br label %83
83: ; preds = %232, %77
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.21, i64 0, i64 0))
%85 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32* %8)
%86 = call i32 (...) @flushall()
%87 = load i32, i32* %8
%88 = load i32, i32* %7
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %89
%91 = load i32, i32* %90
%92 = icmp eq i32 %87, %91
br i1 %92, label %93, label %98
93: ; preds = %83
%94 = load i32, i32* %8
%95 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.22, i64 0, i64 0), i32 %94)
%96 = load i32, i32* %4
%97 = add nsw i32 %96, 1
store i32 %97, i32* %4
br label %107
98: ; preds = %83
%99 = load i32, i32* %8
%100 = load i32, i32* %7
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %101
%103 = load i32, i32* %102
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.23, i64 0, i64 0), i32 %99, i32 %103)
%105 = load i32, i32* %5
%106 = add nsw i32 %105, 1
store i32 %106, i32* %5
br label %107
107: ; preds = %98, %93
%108 = load i32, i32* %7
%109 = add nsw i32 %108, 1
store i32 %109, i32* %7
%110 = load i32, i32* %7
%111 = load i32, i32* %6
%112 = icmp slt i32 %110, %111
br i1 %112, label %113, label %140
113: ; preds = %107
%114 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.24, i64 0, i64 0))
%115 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32* %8)
%116 = call i32 (...) @flushall()
%117 = load i32, i32* %8
%118 = load i32, i32* %7
%119 = sext i32 %118 to i64
%120 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %119
%121 = load i32, i32* %120
%122 = icmp eq i32 %117, %121
br i1 %122, label %123, label %128
123: ; preds = %113
%124 = load i32, i32* %8
%125 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.22, i64 0, i64 0), i32 %124)
%126 = load i32, i32* %4
%127 = add nsw i32 %126, 1
store i32 %127, i32* %4
br label %137
128: ; preds = %113
%129 = load i32, i32* %8
%130 = load i32, i32* %7
%131 = sext i32 %130 to i64
%132 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %131
%133 = load i32, i32* %132
%134 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.23, i64 0, i64 0), i32 %129, i32 %133)
%135 = load i32, i32* %5
%136 = add nsw i32 %135, 1
store i32 %136, i32* %5
br label %137
137: ; preds = %128, %123
%138 = load i32, i32* %7
%139 = add nsw i32 %138, 1
store i32 %139, i32* %7
br label %140
140: ; preds = %137, %107
%141 = load i32, i32* %7
%142 = load i32, i32* %6
%143 = icmp slt i32 %141, %142
br i1 %143, label %144, label %171
144: ; preds = %140
%145 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.25, i64 0, i64 0))
%146 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32* %8)
%147 = call i32 (...) @flushall()
%148 = load i32, i32* %8
%149 = load i32, i32* %7
%150 = sext i32 %149 to i64
%151 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %150
%152 = load i32, i32* %151
%153 = icmp eq i32 %148, %152
br i1 %153, label %154, label %159
154: ; preds = %144
%155 = load i32, i32* %8
%156 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.22, i64 0, i64 0), i32 %155)
%157 = load i32, i32* %4
%158 = add nsw i32 %157, 1
store i32 %158, i32* %4
br label %168
159: ; preds = %144
%160 = load i32, i32* %8
%161 = load i32, i32* %7
%162 = sext i32 %161 to i64
%163 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %162
%164 = load i32, i32* %163
%165 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.23, i64 0, i64 0), i32 %160, i32 %164)
%166 = load i32, i32* %5
%167 = add nsw i32 %166, 1
store i32 %167, i32* %5
br label %168
168: ; preds = %159, %154
%169 = load i32, i32* %7
%170 = add nsw i32 %169, 1
store i32 %170, i32* %7
br label %171
171: ; preds = %168, %140
%172 = load i32, i32* %7
%173 = load i32, i32* %6
%174 = icmp slt i32 %172, %173
br i1 %174, label %175, label %202
175: ; preds = %171
%176 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.26, i64 0, i64 0))
%177 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32* %8)
%178 = call i32 (...) @flushall()
%179 = load i32, i32* %8
%180 = load i32, i32* %7
%181 = sext i32 %180 to i64
%182 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %181
%183 = load i32, i32* %182
%184 = icmp eq i32 %179, %183
br i1 %184, label %185, label %190
185: ; preds = %175
%186 = load i32, i32* %8
%187 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.22, i64 0, i64 0), i32 %186)
%188 = load i32, i32* %4
%189 = add nsw i32 %188, 1
store i32 %189, i32* %4
br label %199
190: ; preds = %175
%191 = load i32, i32* %8
%192 = load i32, i32* %7
%193 = sext i32 %192 to i64
%194 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %193
%195 = load i32, i32* %194
%196 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.23, i64 0, i64 0), i32 %191, i32 %195)
%197 = load i32, i32* %5
%198 = add nsw i32 %197, 1
store i32 %198, i32* %5
br label %199
199: ; preds = %190, %185
%200 = load i32, i32* %7
%201 = add nsw i32 %200, 1
store i32 %201, i32* %7
br label %202
202: ; preds = %199, %171
%203 = load i32, i32* %7
%204 = load i32, i32* %6
%205 = icmp slt i32 %203, %204
br i1 %205, label %206, label %231
206: ; preds = %202
%207 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.27, i64 0, i64 0))
%208 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32* %8)
%209 = call i32 (...) @flushall()
%210 = load i32, i32* %8
%211 = load i32, i32* %7
%212 = sext i32 %211 to i64
%213 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %212
%214 = load i32, i32* %213
%215 = icmp eq i32 %210, %214
br i1 %215, label %216, label %221
216: ; preds = %206
%217 = load i32, i32* %8
%218 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.22, i64 0, i64 0), i32 %217)
%219 = load i32, i32* %4
%220 = add nsw i32 %219, 1
store i32 %220, i32* %4
br label %230
221: ; preds = %206
%222 = load i32, i32* %8
%223 = load i32, i32* %7
%224 = sext i32 %223 to i64
%225 = getelementptr inbounds [5 x i32], [5 x i32]* %2, i64 0, i64 %224
%226 = load i32, i32* %225
%227 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.23, i64 0, i64 0), i32 %222, i32 %226)
%228 = load i32, i32* %5
%229 = add nsw i32 %228, 1
store i32 %229, i32* %5
br label %230
230: ; preds = %221, %216
br label %231
231: ; preds = %230, %202
br label %232
232: ; preds = %231
%233 = load i32, i32* %7
%234 = load i32, i32* %6
%235 = sub nsw i32 %234, 1
%236 = icmp slt i32 %233, %235
br i1 %236, label %83, label %237
237: ; preds = %232
%238 = load i32, i32* %9
%239 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.28, i64 0, i64 0), i32 %238)
%240 = load i32, i32* %9
%241 = add nsw i32 %240, 1
store i32 %241, i32* %9
br label %264
242: ; preds = %43
%243 = load i32, i32* %6
%244 = icmp eq i32 %243, 0
br i1 %244, label %245, label %247
245: ; preds = %242
%246 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.29, i64 0, i64 0))
br label %263
247: ; preds = %242
%248 = load i32, i32* %4
%249 = icmp eq i32 %248, 0
br i1 %249, label %250, label %255
250: ; preds = %247
%251 = load i32, i32* %5
%252 = icmp eq i32 %251, 0
br i1 %252, label %253, label %255
253: ; preds = %250
%254 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.29, i64 0, i64 0))
br label %262
255: ; preds = %250, %247
%256 = load i32, i32* %9
%257 = sub nsw i32 %256, 1
%258 = load i32, i32* %4
%259 = load i32, i32* %5
%260 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.30, i64 0, i64 0), i32 %257, i32 %258, i32 %259)
%261 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.31, i64 0, i64 0))
store i32 0, i32* %6
br label %264
262: ; preds = %253
br label %263
263: ; preds = %262, %245
br label %264
264: ; preds = %263, %43, %255, %237, %75, %71
br label %265
265: ; preds = %264
%266 = load i32, i32* %3
%267 = icmp ne i32 %266, 4
br i1 %267, label %14, label %268
268: ; preds = %265
%269 = call i32 (...) @getchar()
%270 = load i32, i32* %1
ret i32 %270
}

LLVM IR (-O2):
@__const.main.answers = [5 x i32] [i32 88, i32 228, i32 156, i32 -4, i32 1]
@.str.1 = [35 x i8] c"\0A\09\09\09Welcome to your Maths Quiz!\09\09\09\00"
@.str.8 = [35 x i8] c"\0A>>> Please select a menu option: \00"
@.str.9 = [3 x i8] c"%d\00"
@.str.11 = [9 x i8] c"\0AGoodbye\00"
@.str.12 = [24 x i8] c"\0APress 'enter' to exit.\00"
@.str.13 = [34 x i8] c"\0A--- You selected Menu Option: %d\00"
@.str.14 = [49 x i8] c"\0AThere are a maximum of %d questions per round.\0A\00"
@.str.15 = [50 x i8] c"Please enter number of questions for this round: \00"
@.str.16 = [58 x i8] c"--- You have selected to answer %d questions this round.\0A\00"
@.str.17 = [53 x i8] c"\0A*** ERROR: Please select a number up to max of %d!\0A\00"
@.str.20 = [24 x i8] c"\0A\09***** ROUND %d *****\0A\00"
@.str.22 = [33 x i8] c"--- You entered: %d - Correct!!\0A\00"
@.str.23 = [54 x i8] c"--- You entered: %d - Wrong!! The correct answer: %d\0A\00"
@.str.28 = [35 x i8] c"\0A>>> That is the end of Round %d.\0A\00"
@.str.30 = [44 x i8] c"\0AScore for Round %d: %d CORRECT, %d WRONG.\0A\00"
@str = [29 x i8] c"\09\09\09*** FUN MATHS QUIZ ***\09\09\09\00"
@str.32 = [74 x i8] c"\0A\09Please select one of the following options from the Main Menu below...\09\00"
@str.33 = [25 x i8] c"\0A\09\09\09*** MAIN MENU ***\09\09\09\00"
@str.34 = [74 x i8] c">>> Select 1: to select the number of QUESTIONS you would like to answer.\00"
@str.35 = [33 x i8] c">>> Select 2: to START the quiz.\00"
@str.36 = [51 x i8] c">>> Select 3: to display your SCORE for the ROUND.\00"
@str.37 = [32 x i8] c">>> Select 4: to EXIT the quiz.\00"
@str.38 = [60 x i8] c"\0A>>> Would you like to play again? Press 1 (yes) / 4 (EXIT)\00"
@str.40 = [42 x i8] c"\0A*** ERROR: You must play the game first!\00"
@str.41 = [20 x i8] c"\0A--- Let's begin...\00"
@str.42 = [34 x i8] c"\0AQuestion 1: >> (9 x 8) + 16 = _ \00"
@str.43 = [37 x i8] c"\0AQuestion 5: >> 216 / (18 x 12) = _ \00"
@str.44 = [36 x i8] c"\0AQuestion 4: >> (56 x 3) - 172 = _ \00"
@str.45 = [37 x i8] c"\0AQuestion 3: >> 12 x (143 / 11) = _ \00"
@str.46 = [36 x i8] c"\0AQuestion 2: >> (121 - 83) x 6 = _ \00"
@str.47 = [57 x i8] c"\0A*** ERROR: Please select the number of questions first!\00"
@str.48 = [29 x i8] c"\0AThis is not a valid option.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%6 = bitcast i32* %3 to i8*
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @str.32, i64 0, i64 0))
br label %10
10: ; preds = %214, %0
%11 = phi i32 [ 0, %0 ], [ %215, %214 ]
%12 = phi i32 [ 0, %0 ], [ %216, %214 ]
%13 = phi i32 [ 1, %0 ], [ %217, %214 ]
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.33, i64 0, i64 0))
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @str.34, i64 0, i64 0))
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str.35, i64 0, i64 0))
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.36, i64 0, i64 0))
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.37, i64 0, i64 0))
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0))
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32* %1)
%21 = call i32 (...) @flushall()
%22 = load i32, i32* %1
%23 = add i32 %22, -5
%24 = icmp ult i32 %23, -4
br i1 %24, label %25, label %27
25: ; preds = %10
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.48, i64 0, i64 0))
br label %32
27: ; preds = %10
%28 = icmp eq i32 %22, 4
br i1 %28, label %29, label %34
29: ; preds = %27
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.11, i64 0, i64 0))
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.12, i64 0, i64 0))
br label %32
32: ; preds = %25, %29
%33 = load i32, i32* %1
br label %34
34: ; preds = %32, %27
%35 = phi i32 [ %33, %32 ], [ %22, %27 ]
switch i32 %35, label %214 [
i32 1, label %36
i32 2, label %64
i32 3, label %199
]
36: ; preds = %34
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.13, i64 0, i64 0), i32 1)
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.14, i64 0, i64 0), i32 5)
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.15, i64 0, i64 0))
%40 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32* %2)
%41 = call i32 (...) @flushall()
%42 = load i32, i32* %2
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.16, i64 0, i64 0), i32 %42)
%44 = load i32, i32* %2
%45 = add i32 %44, -6
%46 = icmp ult i32 %45, -5
br i1 %46, label %47, label %214
47: ; preds = %36, %52
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.17, i64 0, i64 0), i32 5)
%49 = load i32, i32* %2
%50 = add i32 %49, -6
%51 = icmp ult i32 %50, -5
br i1 %51, label %52, label %214
52: ; preds = %47
%53 = load i32, i32* %1
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.13, i64 0, i64 0), i32 %53)
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.14, i64 0, i64 0), i32 5)
%56 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.15, i64 0, i64 0))
%57 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32* %2)
%58 = call i32 (...) @flushall()
%59 = load i32, i32* %2
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.16, i64 0, i64 0), i32 %59)
%61 = load i32, i32* %2
%62 = add i32 %61, -6
%63 = icmp ult i32 %62, -5
br i1 %63, label %47, label %214
64: ; preds = %34
%65 = load i32, i32* %2
%66 = icmp eq i32 %65, 0
br i1 %66, label %67, label %69
67: ; preds = %64
%68 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([57 x i8], [57 x i8]* @str.47, i64 0, i64 0))
br label %214
69: ; preds = %64
%70 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.13, i64 0, i64 0), i32 2)
%71 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.41, i64 0, i64 0))
%72 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.20, i64 0, i64 0), i32 %13)
br label %73
73: ; preds = %190, %69
%74 = phi i32 [ 0, %69 ], [ %191, %190 ]
%75 = phi i32 [ 0, %69 ], [ %192, %190 ]
%76 = phi i32 [ 0, %69 ], [ %173, %190 ]
%77 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str.42, i64 0, i64 0))
%78 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32* %3)
%79 = call i32 (...) @flushall()
%80 = load i32, i32* %3
%81 = sext i32 %76 to i64
%82 = getelementptr inbounds [5 x i32], [5 x i32]* @__const.main.answers, i64 0, i64 %81
%83 = load i32, i32* %82
%84 = icmp eq i32 %80, %83
br i1 %84, label %85, label %88
85: ; preds = %73
%86 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.22, i64 0, i64 0), i32 %80)
%87 = add nsw i32 %74, 1
br label %91
88: ; preds = %73
%89 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.23, i64 0, i64 0), i32 %80, i32 %83)
%90 = add nsw i32 %75, 1
br label %91
91: ; preds = %88, %85
%92 = phi i32 [ %87, %85 ], [ %74, %88 ]
%93 = phi i32 [ %75, %85 ], [ %90, %88 ]
%94 = add nsw i32 %76, 1
%95 = load i32, i32* %2
%96 = icmp slt i32 %94, %95
br i1 %96, label %97, label %117
97: ; preds = %91
%98 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.46, i64 0, i64 0))
%99 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32* %3)
%100 = call i32 (...) @flushall()
%101 = load i32, i32* %3
%102 = sext i32 %94 to i64
%103 = getelementptr inbounds [5 x i32], [5 x i32]* @__const.main.answers, i64 0, i64 %102
%104 = load i32, i32* %103
%105 = icmp eq i32 %101, %104
br i1 %105, label %106, label %109
106: ; preds = %97
%107 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.22, i64 0, i64 0), i32 %101)
%108 = add nsw i32 %92, 1
br label %112
109: ; preds = %97
%110 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.23, i64 0, i64 0), i32 %101, i32 %104)
%111 = add nsw i32 %93, 1
br label %112
112: ; preds = %109, %106
%113 = phi i32 [ %108, %106 ], [ %92, %109 ]
%114 = phi i32 [ %93, %106 ], [ %111, %109 ]
%115 = add nsw i32 %76, 2
%116 = load i32, i32* %2
br label %117
117: ; preds = %112, %91
%118 = phi i32 [ %116, %112 ], [ %95, %91 ]
%119 = phi i32 [ %113, %112 ], [ %92, %91 ]
%120 = phi i32 [ %114, %112 ], [ %93, %91 ]
%121 = phi i32 [ %115, %112 ], [ %94, %91 ]
%122 = icmp slt i32 %121, %118
br i1 %122, label %123, label %143
123: ; preds = %117
%124 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.45, i64 0, i64 0))
%125 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32* %3)
%126 = call i32 (...) @flushall()
%127 = load i32, i32* %3
%128 = sext i32 %121 to i64
%129 = getelementptr inbounds [5 x i32], [5 x i32]* @__const.main.answers, i64 0, i64 %128
%130 = load i32, i32* %129
%131 = icmp eq i32 %127, %130
br i1 %131, label %132, label %135
132: ; preds = %123
%133 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.22, i64 0, i64 0), i32 %127)
%134 = add nsw i32 %119, 1
br label %138
135: ; preds = %123
%136 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.23, i64 0, i64 0), i32 %127, i32 %130)
%137 = add nsw i32 %120, 1
br label %138
138: ; preds = %135, %132
%139 = phi i32 [ %134, %132 ], [ %119, %135 ]
%140 = phi i32 [ %120, %132 ], [ %137, %135 ]
%141 = add nsw i32 %121, 1
%142 = load i32, i32* %2
br label %143
143: ; preds = %138, %117
%144 = phi i32 [ %142, %138 ], [ %118, %117 ]
%145 = phi i32 [ %139, %138 ], [ %119, %117 ]
%146 = phi i32 [ %140, %138 ], [ %120, %117 ]
%147 = phi i32 [ %141, %138 ], [ %121, %117 ]
%148 = icmp slt i32 %147, %144
br i1 %148, label %149, label %169
149: ; preds = %143
%150 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.44, i64 0, i64 0))
%151 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32* %3)
%152 = call i32 (...) @flushall()
%153 = load i32, i32* %3
%154 = sext i32 %147 to i64
%155 = getelementptr inbounds [5 x i32], [5 x i32]* @__const.main.answers, i64 0, i64 %154
%156 = load i32, i32* %155
%157 = icmp eq i32 %153, %156
br i1 %157, label %158, label %161
158: ; preds = %149
%159 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.22, i64 0, i64 0), i32 %153)
%160 = add nsw i32 %145, 1
br label %164
161: ; preds = %149
%162 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.23, i64 0, i64 0), i32 %153, i32 %156)
%163 = add nsw i32 %146, 1
br label %164
164: ; preds = %161, %158
%165 = phi i32 [ %160, %158 ], [ %145, %161 ]
%166 = phi i32 [ %146, %158 ], [ %163, %161 ]
%167 = add nsw i32 %147, 1
%168 = load i32, i32* %2
br label %169
169: ; preds = %164, %143
%170 = phi i32 [ %168, %164 ], [ %144, %143 ]
%171 = phi i32 [ %165, %164 ], [ %145, %143 ]
%172 = phi i32 [ %166, %164 ], [ %146, %143 ]
%173 = phi i32 [ %167, %164 ], [ %147, %143 ]
%174 = icmp slt i32 %173, %170
br i1 %174, label %175, label %190
175: ; preds = %169
%176 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str.43, i64 0, i64 0))
%177 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32* %3)
%178 = call i32 (...) @flushall()
%179 = load i32, i32* %3
%180 = sext i32 %173 to i64
%181 = getelementptr inbounds [5 x i32], [5 x i32]* @__const.main.answers, i64 0, i64 %180
%182 = load i32, i32* %181
%183 = icmp eq i32 %179, %182
br i1 %183, label %184, label %187
184: ; preds = %175
%185 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.22, i64 0, i64 0), i32 %179)
%186 = add nsw i32 %171, 1
br label %190
187: ; preds = %175
%188 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.23, i64 0, i64 0), i32 %179, i32 %182)
%189 = add nsw i32 %172, 1
br label %190
190: ; preds = %169, %187, %184
%191 = phi i32 [ %186, %184 ], [ %171, %187 ], [ %171, %169 ]
%192 = phi i32 [ %172, %184 ], [ %189, %187 ], [ %172, %169 ]
%193 = load i32, i32* %2
%194 = add nsw i32 %193, -1
%195 = icmp slt i32 %173, %194
br i1 %195, label %73, label %196
196: ; preds = %190
%197 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.28, i64 0, i64 0), i32 %13)
%198 = add nsw i32 %13, 1
br label %214
199: ; preds = %34
%200 = load i32, i32* %2
%201 = icmp eq i32 %200, 0
br i1 %201, label %202, label %204
202: ; preds = %199
%203 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.40, i64 0, i64 0))
br label %214
204: ; preds = %199
%205 = icmp eq i32 %11, 0
%206 = icmp eq i32 %12, 0
%207 = select i1 %205, i1 %206, i1 false
br i1 %207, label %208, label %210
208: ; preds = %204
%209 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str.40, i64 0, i64 0))
br label %214
210: ; preds = %204
%211 = add nsw i32 %13, -1
%212 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.30, i64 0, i64 0), i32 %211, i32 %11, i32 %12)
%213 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @str.38, i64 0, i64 0))
store i32 0, i32* %2
br label %214
214: ; preds = %47, %52, %36, %67, %196, %210, %34, %208, %202
%215 = phi i32 [ %11, %34 ], [ %11, %202 ], [ 0, %208 ], [ %11, %210 ], [ %11, %67 ], [ %191, %196 ], [ %11, %36 ], [ %11, %52 ], [ %11, %47 ]
%216 = phi i32 [ %12, %34 ], [ %12, %202 ], [ 0, %208 ], [ %12, %210 ], [ %12, %67 ], [ %192, %196 ], [ %12, %36 ], [ %12, %52 ], [ %12, %47 ]
%217 = phi i32 [ %13, %34 ], [ %13, %202 ], [ %13, %208 ], [ %13, %210 ], [ %13, %67 ], [ %198, %196 ], [ %13, %36 ], [ %13, %52 ], [ %13, %47 ]
%218 = load i32, i32* %1
%219 = icmp eq i32 %218, 4
br i1 %219, label %220, label %10
220: ; preds = %214
%221 = call i32 (...) @getchar()
ret i32 0
}