#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 */
double fabs(double);
char getchar();
int /*<<< orphan*/ printf(char *, double, double);
int rand();
int /*<<< orphan*/ scanf(char *, double *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int question(int numof_question) {
  int i_question, numof_correct_answers = 0;
  double computer_add1, computer_add2, player_input = 0;
  srand(time(NULL));
  for (i_question = 0; i_question < numof_question; i_question++) {
    computer_add1 = rand() % 49 + 1;
    computer_add2 = rand() % 49 + 1;
    computer_add1 /= 10;
    computer_add2 /= 10;
    printf("%.1lf+%.1lf=", computer_add1, computer_add2);
    scanf("%3lf", &player_input);
    while (getchar() != '\n') {
    }
    if (fabs((computer_add1 + computer_add2) - player_input) < 0.00000000000001)
      numof_correct_answers++;
  }
  return numof_correct_answers;
}


x86 assembly (clang, -O0):
<question>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1285 <question+0x125>
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x31,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
cvtsi2sd %edx,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    $0x0,%al
call   1080 <rand@plt>
mov    $0x31,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
cvtsi2sd %edx,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe20(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xe0a(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
lea    0xe10(%rip),%rdi
call   1030 <printf@plt>
lea    0xe11(%rip),%rdi
lea    -0x28(%rbp),%rsi
call   1070 <scanf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     123d <question+0xdd>
jmp    1225 <question+0xc5>
movsd  -0x18(%rbp),%xmm1
addsd  -0x20(%rbp),%xmm1
subsd  -0x28(%rbp),%xmm1
movaps 0xdbd(%rip),%xmm0
pand   %xmm0,%xmm1
movsd  0xda9(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1272 <question+0x112>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1277 <question+0x117>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1191 <question+0x31>
mov    -0xc(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<question>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edi,%r13d
movq   $0x0,0x8(%rsp)
xor    %ebx,%ebx
xor    %edi,%edi
call   1060 <time@plt>
mov    %eax,%edi
call   1040 <srand@plt>
test   %r13d,%r13d
jle    1294 <question+0x134>
lea    0xe86(%rip),%r14
lea    0xe8c(%rip),%r15
lea    0x8(%rsp),%r12
xor    %ebx,%ebx
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x5397829d,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x24,%rcx
add    %edx,%ecx
imul   $0x31,%ecx,%ecx
neg    %ecx
add    %ecx,%eax
add    $0x1,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movapd %xmm0,0x10(%rsp)
xor    %eax,%eax
call   1080 <rand@plt>
cltq
imul   $0x5397829d,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x24,%rcx
add    %edx,%ecx
imul   $0x31,%ecx,%ecx
neg    %ecx
add    %ecx,%eax
add    $0x1,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movsd  0xde6(%rip),%xmm2
movapd 0x10(%rsp),%xmm0
divsd  %xmm2,%xmm0
divsd  %xmm2,%xmm1
mov    %r14,%rdi
movapd %xmm0,0x10(%rsp)
movsd  %xmm1,0x20(%rsp)
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1070 <scanf@plt>
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1050 <getchar@plt>
cmp    $0xa,%al
jne    1250 <question+0xf0>
movapd 0x10(%rsp),%xmm1
addsd  0x20(%rsp),%xmm1
subsd  0x8(%rsp),%xmm1
andpd  0xd9b(%rip),%xmm1
xor    %eax,%eax
movsd  0xd89(%rip),%xmm0
ucomisd %xmm1,%xmm0
seta   %al
add    %eax,%ebx
add    $0x1,%ebp
cmp    %r13d,%ebp
jne    11b0 <question+0x50>
mov    %ebx,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"%.1lf+%.1lf=\00"
@.str.1 = [5 x i8] c"%3lf\00"
define i32 @question(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
store i32 %0, i32* %2
store i32 0, i32* %4
store double 0.000000e+00, double* %7
%8 = call i32 @time(i32* null)
%9 = call i32 @srand(i32 %8)
store i32 0, i32* %3
br label %10
10: ; preds = %48, %1
%11 = load i32, i32* %3
%12 = load i32, i32* %2
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %51
14: ; preds = %10
%15 = call i32 (...) @rand()
%16 = srem i32 %15, 49
%17 = add nsw i32 %16, 1
%18 = sitofp i32 %17 to double
store double %18, double* %5
%19 = call i32 (...) @rand()
%20 = srem i32 %19, 49
%21 = add nsw i32 %20, 1
%22 = sitofp i32 %21 to double
store double %22, double* %6
%23 = load double, double* %5
%24 = fdiv double %23, 1.000000e+01
store double %24, double* %5
%25 = load double, double* %6
%26 = fdiv double %25, 1.000000e+01
store double %26, double* %6
%27 = load double, double* %5
%28 = load double, double* %6
%29 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), double %27, double %28)
%30 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double* %7)
br label %31
31: ; preds = %35, %14
%32 = call signext i8 (...) @getchar()
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %33, 10
br i1 %34, label %35, label %36
35: ; preds = %31
br label %31
36: ; preds = %31
%37 = load double, double* %5
%38 = load double, double* %6
%39 = fadd double %37, %38
%40 = load double, double* %7
%41 = fsub double %39, %40
%42 = call double @llvm.fabs.f64(double %41)
%43 = fcmp olt double %42, 0x3D06849B86A12B9B
br i1 %43, label %44, label %47
44: ; preds = %36
%45 = load i32, i32* %4
%46 = add nsw i32 %45, 1
store i32 %46, i32* %4
br label %47
47: ; preds = %44, %36
br label %48
48: ; preds = %47
%49 = load i32, i32* %3
%50 = add nsw i32 %49, 1
store i32 %50, i32* %3
br label %10
51: ; preds = %10
%52 = load i32, i32* %4
ret i32 %52
}

LLVM IR (-O2):
@.str = [13 x i8] c"%.1lf+%.1lf=\00"
@.str.1 = [5 x i8] c"%3lf\00"
define i32 @question(i32 %0) {
%2 = alloca double
%3 = bitcast double* %2 to i8*
store double 0.000000e+00, double* %2
%4 = tail call i32 @time(i32* null)
%5 = tail call i32 @srand(i32 %4)
%6 = icmp sgt i32 %0, 0
br i1 %6, label %7, label %35
7: ; preds = %1, %25
%8 = phi i32 [ %32, %25 ], [ 0, %1 ]
%9 = phi i32 [ %33, %25 ], [ 0, %1 ]
%10 = call i32 (...) @rand()
%11 = srem i32 %10, 49
%12 = add nsw i32 %11, 1
%13 = sitofp i32 %12 to double
%14 = call i32 (...) @rand()
%15 = srem i32 %14, 49
%16 = add nsw i32 %15, 1
%17 = sitofp i32 %16 to double
%18 = fdiv double %13, 1.000000e+01
%19 = fdiv double %17, 1.000000e+01
%20 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), double %18, double %19)
%21 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double* %2)
br label %22
22: ; preds = %22, %7
%23 = call signext i8 (...) @getchar()
%24 = icmp eq i8 %23, 10
br i1 %24, label %25, label %22
25: ; preds = %22
%26 = fadd double %18, %19
%27 = load double, double* %2
%28 = fsub double %26, %27
%29 = call double @llvm.fabs.f64(double %28)
%30 = fcmp olt double %29, 0x3D06849B86A12B9B
%31 = zext i1 %30 to i32
%32 = add nuw nsw i32 %8, %31
%33 = add nuw nsw i32 %9, 1
%34 = icmp eq i32 %33, %0
br i1 %34, label %35, label %7
35: ; preds = %25, %1
%36 = phi i32 [ 0, %1 ], [ %32, %25 ]
ret i32 %36
}