#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 calculate_answer_precise(int, int, int, int, int, char, char, char);
int calculate_terms(char, char);
int /*<<< orphan*/ printf(char *, double);
int determine_answer(double entered_answer, int term1, int term2, int term3,
                     int term4, char operand1, char operand2, char operand3) {
  int valid_answer = 0, terms = 0;
  double answer = 0.0;
  terms = calculate_terms(operand2, operand3);
  answer = calculate_answer_precise(terms, term1, term2, term3, term4, operand1,
                                    operand2, operand3);
  printf("Correct Answer: %.0lf\n", answer);
  if (answer == entered_answer) {
    valid_answer = 1;
  }
  return valid_answer;
}


x86 assembly (clang, -O0):
<determine_answer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %r8d,-0x40(%rbp)
mov    %ecx,%eax
mov    -0x40(%rbp),%ecx
mov    %eax,-0x3c(%rbp)
mov    %edx,%eax
mov    -0x3c(%rbp),%edx
mov    %eax,-0x38(%rbp)
mov    %esi,%eax
mov    -0x38(%rbp),%esi
mov    %eax,-0x34(%rbp)
mov    %edi,%r8d
mov    -0x34(%rbp),%edi
mov    %r9b,%al
mov    0x10(%rbp),%r9b
movsd  %xmm0,-0x8(%rbp)
mov    %r8d,-0xc(%rbp)
mov    %edi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %cl,-0x19(%rbp)
mov    %al,-0x1a(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x1a(%rbp),%al
movsbl %al,%edi
movsbl 0x10(%rbp),%esi
call   1040 <calculate_terms@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x19(%rbp),%r9b
mov    -0x1a(%rbp),%al
movsbl %r9b,%r9d
movsbl %al,%eax
mov    %eax,(%rsp)
movsbl 0x10(%rbp),%eax
mov    %eax,0x8(%rsp)
call   1050 <calculate_answer_precise@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
lea    0xe20(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x8(%rbp),%xmm0
jne    1202 <determine_answer+0xd2>
jp     1202 <determine_answer+0xd2>
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<determine_answer>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9d,%ebx
mov    %r8d,0x8(%rsp)
mov    %ecx,%r15d
mov    %edx,%r12d
mov    %esi,%r13d
mov    %edi,%ebp
movsd  %xmm0,0x10(%rsp)
movsbl 0x50(%rsp),%r14d
mov    %r9d,%edi
mov    %r14d,%esi
call   1040 <calculate_terms@plt>
mov    %eax,%edi
mov    %ebp,%esi
mov    %r13d,%edx
mov    %r12d,%ecx
mov    %r15d,%r8d
mov    0x8(%rsp),%r9d
push   %r14
push   %rbx
call   1050 <calculate_answer_precise@plt>
add    $0x10,%rsp
movsd  %xmm0,0x8(%rsp)
lea    0xe6d(%rip),%rdi
call   1030 <printf@plt>
movsd  0x10(%rsp),%xmm0
cmpeqsd 0x8(%rsp),%xmm0
movq   %xmm0,%rax
and    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Correct Answer: %.0lf\0A\00"
define i32 @determine_answer(double %0, i32 %1, i32 %2, i32 %3, i32 %4, i8 signext %5, i8 signext %6, i8 signext %7) {
%9 = alloca double
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8
%15 = alloca i8
%16 = alloca i8
%17 = alloca i32
%18 = alloca i32
%19 = alloca double
store double %0, double* %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store i32 %3, i32* %12
store i32 %4, i32* %13
store i8 %5, i8* %14
store i8 %6, i8* %15
store i8 %7, i8* %16
store i32 0, i32* %17
store i32 0, i32* %18
store double 0.000000e+00, double* %19
%20 = load i8, i8* %15
%21 = load i8, i8* %16
%22 = call i32 @calculate_terms(i8 signext %20, i8 signext %21)
store i32 %22, i32* %18
%23 = load i32, i32* %18
%24 = load i32, i32* %10
%25 = load i32, i32* %11
%26 = load i32, i32* %12
%27 = load i32, i32* %13
%28 = load i8, i8* %14
%29 = load i8, i8* %15
%30 = load i8, i8* %16
%31 = call double @calculate_answer_precise(i32 %23, i32 %24, i32 %25, i32 %26, i32 %27, i8 signext %28, i8 signext %29, i8 signext %30)
store double %31, double* %19
%32 = load double, double* %19
%33 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), double %32)
%34 = load double, double* %19
%35 = load double, double* %9
%36 = fcmp oeq double %34, %35
br i1 %36, label %37, label %38
37: ; preds = %8
store i32 1, i32* %17
br label %38
38: ; preds = %37, %8
%39 = load i32, i32* %17
ret i32 %39
}

LLVM IR (-O2):
@.str = [23 x i8] c"Correct Answer: %.0lf\0A\00"
define i32 @determine_answer(double %0, i32 %1, i32 %2, i32 %3, i32 %4, i8 signext %5, i8 signext %6, i8 signext %7) {
%9 = tail call i32 @calculate_terms(i8 signext %6, i8 signext %7)
%10 = tail call double @calculate_answer_precise(i32 %9, i32 %1, i32 %2, i32 %3, i32 %4, i8 signext %5, i8 signext %6, i8 signext %7)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), double %10)
%12 = fcmp oeq double %10, %0
%13 = zext i1 %12 to i32
ret i32 %13
}