#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ askQuestions(int, int, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  srand((time(NULL)));
  int level, problemType;
  printf("Enter the level of the student: ");
  scanf("%d", &level);
  int getOption = 1;
  while (getOption) {
    printf("\nProblem Options\n");
    printf("\n1: Addition Problems Only");
    printf("\n2: Subtraction Problems Only");
    printf("\n3: Multiplication Problems Only");
    printf("\n4: Division Problems Only");
    printf("\n5: Random mix of problems\n");
    printf("\nEnter your choice: ");
    scanf("%d", &problemType);
    if (problemType > 0 && problemType < 5) {
      getOption = 0;
    } else {
      printf("\n<< Illegal Option - try again! >>\n\n");
    }
  }
  askQuestions(10, level, problemType);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
lea    0xe8a(%rip),%rdi
call   1040 <printf@plt>
lea    0xe9f(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <scanf@plt>
movl   $0x1,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     1231 <main+0xe1>
lea    0xe81(%rip),%rdi
call   1040 <printf@plt>
lea    0xe87(%rip),%rdi
call   1040 <printf@plt>
lea    0xe96(%rip),%rdi
call   1040 <printf@plt>
lea    0xea8(%rip),%rdi
call   1040 <printf@plt>
lea    0xebd(%rip),%rdi
call   1040 <printf@plt>
lea    0xecc(%rip),%rdi
call   1040 <printf@plt>
lea    0xedc(%rip),%rdi
call   1040 <printf@plt>
lea    0xe2a(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1070 <scanf@plt>
cmpl   $0x0,-0xc(%rbp)
jle    1220 <main+0xd0>
cmpl   $0x5,-0xc(%rbp)
jge    1220 <main+0xd0>
movl   $0x0,-0x10(%rbp)
jmp    122c <main+0xdc>
lea    0xeb5(%rip),%rdi
call   1040 <printf@plt>
jmp    1192 <main+0x42>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    $0xa,%edi
call   1030 <askQuestions@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
lea    0xe80(%rip),%rdi
call   1050 <printf@plt>
lea    0xe95(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1080 <scanf@plt>
lea    0xec0(%rip),%rbx
lea    0xeda(%rip),%rbp
lea    0xf14(%rip),%r14
lea    0xee7(%rip),%r15
mov    %rsp,%r12
lea    0xf1e(%rip),%r13
nopl   0x0(%rax)
lea    0xee7(%rip),%rdi
call   1030 <puts@plt>
lea    0xe51(%rip),%rdi
call   1050 <printf@plt>
lea    0xe60(%rip),%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1050 <printf@plt>
mov    %rbp,%rdi
call   1050 <printf@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
mov    %r15,%rdi
call   1050 <printf@plt>
lea    0xe16(%rip),%rdi
mov    %r12,%rsi
call   1080 <scanf@plt>
mov    (%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x4,%eax
jb     1228 <main+0xc8>
mov    %r13,%rdi
call   1030 <puts@plt>
jmp    11c0 <main+0x60>
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
mov    $0xa,%edi
call   1040 <askQuestions@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Enter the level of the student: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [18 x i8] c"\0AProblem Options\0A\00"
@.str.3 = [27 x i8] c"\0A1: Addition Problems Only\00"
@.str.4 = [30 x i8] c"\0A2: Subtraction Problems Only\00"
@.str.5 = [33 x i8] c"\0A3: Multiplication Problems Only\00"
@.str.6 = [27 x i8] c"\0A4: Division Problems Only\00"
@.str.7 = [28 x i8] c"\0A5: Random mix of problems\0A\00"
@.str.8 = [21 x i8] c"\0AEnter your choice: \00"
@.str.9 = [37 x i8] c"\0A<< Illegal Option - try again! >>\0A\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 @time(i32* null)
%6 = call i32 @srand(i32 %5)
%7 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 1, i32* %4
br label %9
9: ; preds = %29, %0
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %30
12: ; preds = %9
%13 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%16 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
%17 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
%18 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0))
%19 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%21 = load i32, i32* %3
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %27
23: ; preds = %12
%24 = load i32, i32* %3
%25 = icmp slt i32 %24, 5
br i1 %25, label %26, label %27
26: ; preds = %23
store i32 0, i32* %4
br label %29
27: ; preds = %23, %12
%28 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.9, i64 0, i64 0))
br label %29
29: ; preds = %27, %26
br label %9
30: ; preds = %9
%31 = load i32, i32* %2
%32 = load i32, i32* %3
%33 = call i32 @askQuestions(i32 10, i32 %31, i32 %32)
ret i32 0
}

LLVM IR (-O2):
@.str = [33 x i8] c"Enter the level of the student: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [27 x i8] c"\0A1: Addition Problems Only\00"
@.str.4 = [30 x i8] c"\0A2: Subtraction Problems Only\00"
@.str.5 = [33 x i8] c"\0A3: Multiplication Problems Only\00"
@.str.6 = [27 x i8] c"\0A4: Division Problems Only\00"
@.str.8 = [21 x i8] c"\0AEnter your choice: \00"
@str = [17 x i8] c"\0AProblem Options\00"
@str.10 = [27 x i8] c"\0A5: Random mix of problems\00"
@str.11 = [36 x i8] c"\0A<< Illegal Option - try again! >>\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
br label %9
9: ; preds = %21, %0
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%11 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0))
%14 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.10, i64 0, i64 0))
%16 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%18 = load i32, i32* %2
%19 = add i32 %18, -1
%20 = icmp ult i32 %19, 4
br i1 %20, label %23, label %21
21: ; preds = %9
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str.11, i64 0, i64 0))
br label %9
23: ; preds = %9
%24 = load i32, i32* %1
%25 = load i32, i32* %2
%26 = call i32 @askQuestions(i32 10, i32 %24, i32 %25)
ret i32 0
}