#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 getRandomNum();
int /*<<< orphan*/ printf(char *, ...);
void askQuestions(int n) {
  int i, a, b;
  int wrong = 0;
  for (i = 0; i < n; i++) {
    a = getRandomNum();
    b = getRandomNum();
    wrong += answerTheQuestion(a, b);
  }
  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    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    118f <askQuestions+0x5f>
mov    $0x0,%al
call   1030 <getRandomNum@plt>
mov    %eax,-0xc(%rbp)
mov    $0x0,%al
call   1030 <getRandomNum@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1050 <answerTheQuestion@plt>
mov    %rax,%rcx
movslq -0x14(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1149 <askQuestions+0x19>
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  0xe74(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  0xe68(%rip),%xmm0
divsd  %xmm1,%xmm0
movsd  0xe54(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe2e(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1206 <askQuestions+0xd6>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe2c(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    121d <askQuestions+0xed>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe58(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<askQuestions>:
push   %rbp
push   %r14
push   %rbx
movsd  0xeb4(%rip),%xmm1
movapd %xmm1,%xmm0
test   %edi,%edi
jle    1199 <askQuestions+0x59>
mov    %edi,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <getRandomNum@plt>
mov    %eax,%r14d
xor    %eax,%eax
call   1040 <getRandomNum@plt>
mov    %r14d,%edi
mov    %eax,%esi
call   1060 <answerTheQuestion@plt>
add    %eax,%ebp
add    $0xffffffff,%ebx
jne    1160 <askQuestions+0x20>
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
addsd  0xe6f(%rip),%xmm0
movsd  0xe67(%rip),%xmm1
divsd  %xmm0,%xmm1
mulsd  0xe63(%rip),%xmm1
cvtsd2ss %xmm1,%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
movss  0xe58(%rip),%xmm2
ucomiss %xmm1,%xmm2
jbe    11db <askQuestions+0x9b>
lea    0xe50(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xea3(%rip),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <puts@plt>
lea    0xe5d(%rip),%rdi
mov    $0x1,%al
pop    %rbx
pop    %r14
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) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca float
store i32 %0, i32* %2
store i32 0, i32* %6
store i32 0, i32* %3
br label %8
8: ; preds = %22, %1
%9 = load i32, i32* %3
%10 = load i32, i32* %2
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %25
12: ; preds = %8
%13 = call i32 (...) @getRandomNum()
store i32 %13, i32* %4
%14 = call i32 (...) @getRandomNum()
store i32 %14, i32* %5
%15 = load i32, i32* %4
%16 = load i32, i32* %5
%17 = call i64 @answerTheQuestion(i32 %15, i32 %16)
%18 = load i32, i32* %6
%19 = sext i32 %18 to i64
%20 = add nsw i64 %19, %17
%21 = trunc i64 %20 to i32
store i32 %21, i32* %6
br label %22
22: ; preds = %12
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %8
25: ; preds = %8
%26 = load i32, i32* %6
%27 = sitofp i32 %26 to double
%28 = fadd double 1.000000e+01, %27
%29 = fdiv double 1.000000e+01, %28
%30 = fmul double %29, 1.000000e+02
%31 = fptrunc double %30 to float
store float %31, float* %7
%32 = load float, float* %7
%33 = fpext float %32 to double
%34 = fcmp olt double %33, 7.500000e+01
br i1 %34, label %35, label %40
35: ; preds = %25
%36 = load float, float* %7
%37 = fpext float %36 to double
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), double %37)
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
br label %44
40: ; preds = %25
%41 = load float, float* %7
%42 = fpext float %41 to double
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0), double %42)
br label %44
44: ; preds = %40, %35
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) {
%2 = icmp sgt i32 %0, 0
br i1 %2, label %3, label %16
3: ; preds = %1, %3
%4 = phi i32 [ %11, %3 ], [ 0, %1 ]
%5 = phi i32 [ %10, %3 ], [ 0, %1 ]
%6 = tail call i32 (...) @getRandomNum()
%7 = tail call i32 (...) @getRandomNum()
%8 = tail call i64 @answerTheQuestion(i32 %6, i32 %7)
%9 = trunc i64 %8 to i32
%10 = add i32 %5, %9
%11 = add nuw nsw i32 %4, 1
%12 = icmp eq i32 %11, %0
br i1 %12, label %13, label %3
13: ; preds = %3
%14 = sitofp i32 %10 to double
%15 = fadd double %14, 1.000000e+01
br label %16
16: ; preds = %13, %1
%17 = phi double [ 1.000000e+01, %1 ], [ %15, %13 ]
%18 = fdiv double 1.000000e+01, %17
%19 = fmul double %18, 1.000000e+02
%20 = fptrunc double %19 to float
%21 = fpext float %20 to double
%22 = fcmp olt float %20, 7.500000e+01
br i1 %22, label %23, label %26
23: ; preds = %16
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), double %21)
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @str, i64 0, i64 0))
br label %28
26: ; preds = %16
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @.str.2, i64 0, i64 0), double %21)
br label %28
28: ; preds = %26, %23
ret void
}