#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__ answerTheQuestion(int, int, int);
int getRandomNum(int);
scalar_t__ pow(int, int);
int /*<<< orphan*/ printf(char *, ...);
void askQuestions(int n, int level, int problemType) {
  int i, a, b;
  int right = 10;
  int wrong = 0;
  int max = (int)(pow(10, level) - 1);
  for (i = 0; i < n; i++) {
    a = getRandomNum(max);
    b = getRandomNum(max);
    wrong += answerTheQuestion(a, b, problemType);
  }
  float percentage = (10.0 / (10.0 + wrong)) * 100.0;
  if (percentage < 75.0) {
    printf("\nOnly %.2f%% of your guesses were correct\n", percentage);
    printf("Please ask your instructor for extra help\n");
  } else {
    printf("\nCongratulations %.2f%% of your guesses were correct\n",
           percentage);
  }
}


x86 assembly (clang, -O0):
<askQuestions>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movl   $0xa,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x8(%rbp),%esi
mov    $0xa,%edi
call   1060 <pow@plt>
sub    $0x1,%rax
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11c5 <askQuestions+0x85>
mov    -0x24(%rbp),%edi
call   1030 <getRandomNum@plt>
mov    %eax,-0x14(%rbp)
mov    -0x24(%rbp),%edi
call   1030 <getRandomNum@plt>
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1050 <answerTheQuestion@plt>
mov    %rax,%rcx
movslq -0x20(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    117a <askQuestions+0x3a>
cvtsi2sdl -0x20(%rbp),%xmm0
movsd  0xe3e(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  0xe32(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  0xe1e(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x28(%rbp)
movss  -0x28(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xdf8(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    123c <askQuestions+0xfc>
movss  -0x28(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdf6(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1253 <askQuestions+0x113>
movss  -0x28(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe22(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<askQuestions>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r14d
mov    %edi,%ebp
mov    $0xa,%edi
call   1070 <pow@plt>
movsd  0xe91(%rip),%xmm1
movapd %xmm1,%xmm0
test   %ebp,%ebp
jle    11be <askQuestions+0x6e>
mov    %rax,%r15
add    $0xffffffff,%r15d
xor    %ebx,%ebx
mov    %r15d,%edi
call   1040 <getRandomNum@plt>
mov    %eax,%r12d
mov    %r15d,%edi
call   1040 <getRandomNum@plt>
mov    %r12d,%edi
mov    %eax,%esi
mov    %r14d,%edx
call   1060 <answerTheQuestion@plt>
add    %eax,%ebx
add    $0xffffffff,%ebp
jne    1180 <askQuestions+0x30>
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
addsd  0xe4a(%rip),%xmm0
movsd  0xe42(%rip),%xmm1
divsd  %xmm0,%xmm1
mulsd  0xe3e(%rip),%xmm1
cvtsd2ss %xmm1,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
movss  0xe33(%rip),%xmm2
ucomiss %xmm1,%xmm2
jbe    1204 <askQuestions+0xb4>
lea    0xe2b(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xe7e(%rip),%rdi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <puts@plt>
lea    0xe34(%rip),%rdi
mov    $0x1,%al
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <printf@plt>

LLVM IR (-O0):
@.str = [43 x i8] c"\0AOnly %.2f%% of your guesses were correct\0A\00"
@.str.1 = [43 x i8] c"Please ask your instructor for extra help\0A\00"
@.str.2 = [54 x i8] c"\0ACongratulations %.2f%% of your guesses were correct\0A\00"
define void @askQuestions(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca float
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 10, i32* %10
store i32 0, i32* %11
%14 = load i32, i32* %5
%15 = call i64 @pow(i32 10, i32 %14)
%16 = sub nsw i64 %15, 1
%17 = trunc i64 %16 to i32
store i32 %17, i32* %12
store i32 0, i32* %7
br label %18
18: ; preds = %35, %3
%19 = load i32, i32* %7
%20 = load i32, i32* %4
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %38
22: ; preds = %18
%23 = load i32, i32* %12
%24 = call i32 @getRandomNum(i32 %23)
store i32 %24, i32* %8
%25 = load i32, i32* %12
%26 = call i32 @getRandomNum(i32 %25)
store i32 %26, i32* %9
%27 = load i32, i32* %8
%28 = load i32, i32* %9
%29 = load i32, i32* %6
%30 = call i64 @answerTheQuestion(i32 %27, i32 %28, i32 %29)
%31 = load i32, i32* %11
%32 = sext i32 %31 to i64
%33 = add nsw i64 %32, %30
%34 = trunc i64 %33 to i32
store i32 %34, i32* %11
br label %35
35: ; preds = %22
%36 = load i32, i32* %7
%37 = add nsw i32 %36, 1
store i32 %37, i32* %7
br label %18
38: ; preds = %18
%39 = load i32, i32* %11
%40 = sitofp i32 %39 to double
%41 = fadd double 1.000000e+01, %40
%42 = fdiv double 1.000000e+01, %41
%43 = fmul double %42, 1.000000e+02
%44 = fptrunc double %43 to float
store float %44, float* %13
%45 = load float, float* %13
%46 = fpext float %45 to double
%47 = fcmp olt double %46, 7.500000e+01
br i1 %47, label %48, label %53
48: ; preds = %38
%49 = load float, float* %13
%50 = fpext float %49 to double
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), double %50)
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
br label %57
53: ; preds = %38
%54 = load float, float* %13
%55 = fpext float %54 to double
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0), double %55)
br label %57
57: ; preds = %53, %48
ret void
}

LLVM IR (-O2):
@.str = [43 x i8] c"\0AOnly %.2f%% of your guesses were correct\0A\00"
@.str.2 = [54 x i8] c"\0ACongratulations %.2f%% of your guesses were correct\0A\00"
@str = [42 x i8] c"Please ask your instructor for extra help\00"
define void @askQuestions(i32 %0, i32 %1, i32 %2) {
%4 = tail call i64 @pow(i32 10, i32 %1)
%5 = trunc i64 %4 to i32
%6 = add i32 %5, -1
%7 = icmp sgt i32 %0, 0
br i1 %7, label %8, label %21
8: ; preds = %3, %8
%9 = phi i32 [ %16, %8 ], [ 0, %3 ]
%10 = phi i32 [ %15, %8 ], [ 0, %3 ]
%11 = tail call i32 @getRandomNum(i32 %6)
%12 = tail call i32 @getRandomNum(i32 %6)
%13 = tail call i64 @answerTheQuestion(i32 %11, i32 %12, i32 %2)
%14 = trunc i64 %13 to i32
%15 = add i32 %10, %14
%16 = add nuw nsw i32 %9, 1
%17 = icmp eq i32 %16, %0
br i1 %17, label %18, label %8
18: ; preds = %8
%19 = sitofp i32 %15 to double
%20 = fadd double %19, 1.000000e+01
br label %21
21: ; preds = %18, %3
%22 = phi double [ 1.000000e+01, %3 ], [ %20, %18 ]
%23 = fdiv double 1.000000e+01, %22
%24 = fmul double %23, 1.000000e+02
%25 = fptrunc double %24 to float
%26 = fpext float %25 to double
%27 = fcmp olt float %25, 7.500000e+01
br i1 %27, label %28, label %31
28: ; preds = %21
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), double %26)
%30 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
br label %33
31: ; preds = %21
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0), double %26)
br label %33
33: ; preds = %31, %28
ret void
}