#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*/ printf(char *, int);
double findAreaRight(int a, int b, int c, int in, int fin, int rect) {
  double x = 0.0;
  double count = (double)(fin - in) / rect;
  double area = 0.0;
  for (x = fin; x > in; x -= count) {
    area += (a * (x * x) + b * x + c) * count;
    printf("\nArea: %f", area);
    printf("\nValue of x: %f", x);
  }
  printf("\nValue of fin: %d", fin);
  printf("\nValue of in: %d", in);
  return area;
}


x86 assembly (clang, -O0):
<findAreaRight>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    %r8d,-0x14(%rbp)
mov    %r9d,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x14(%rbp),%eax
sub    -0x10(%rbp),%eax
cvtsi2sd %eax,%xmm0
cvtsi2sdl -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
cvtsi2sdl -0x10(%rbp),%xmm1
ucomisd %xmm1,%xmm0
jbe    11ed <findAreaRight+0xdd>
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm2
mulsd  -0x20(%rbp),%xmm2
cvtsi2sdl -0x8(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
addsd  %xmm1,%xmm0
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
cvttsd2si -0x30(%rbp),%esi
lea    0xe41(%rip),%rdi
call   1030 <printf@plt>
cvttsd2si -0x20(%rbp),%esi
lea    0xe3a(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x28(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    115e <findAreaRight+0x4e>
mov    -0x14(%rbp),%esi
lea    0xe23(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xe26(%rip),%rdi
call   1030 <printf@plt>
movsd  -0x30(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findAreaRight>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    %r8d,%r15d
mov    %ecx,%r14d
cvtsi2sd %r8d,%xmm1
cvtsi2sd %ecx,%xmm3
xorpd  %xmm2,%xmm2
ucomisd %xmm3,%xmm1
jbe    1200 <findAreaRight+0xf0>
mov    %r15d,%eax
sub    %r14d,%eax
xorps  %xmm2,%xmm2
cvtsi2sd %eax,%xmm2
cvtsi2sd %r9d,%xmm0
cvtsi2sd %edi,%xmm4
movsd  %xmm4,0x28(%rsp)
xorps  %xmm4,%xmm4
cvtsi2sd %esi,%xmm4
movsd  %xmm4,0x20(%rsp)
xorps  %xmm4,%xmm4
cvtsi2sd %edx,%xmm4
movsd  %xmm4,0x18(%rsp)
divsd  %xmm0,%xmm2
movsd  %xmm2,0x10(%rsp)
xorpd  %xmm2,%xmm2
lea    0xe7e(%rip),%rbx
lea    0xe81(%rip),%rbp
movsd  %xmm3,0x30(%rsp)
nop
movsd  %xmm1,0x8(%rsp)
movapd %xmm1,%xmm0
mulsd  %xmm1,%xmm0
mulsd  0x28(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mulsd  0x20(%rsp),%xmm1
addsd  %xmm0,%xmm1
addsd  0x18(%rsp),%xmm1
mulsd  0x10(%rsp),%xmm1
addsd  %xmm1,%xmm2
movsd  %xmm2,(%rsp)
cvttsd2si %xmm2,%esi
mov    %rbx,%rdi
call   1030 <printf@plt>
cvttsd2si 0x8(%rsp),%esi
mov    %rbp,%rdi
call   1030 <printf@plt>
movsd  0x30(%rsp),%xmm3
movsd  0x8(%rsp),%xmm1
movsd  (%rsp),%xmm2
subsd  0x10(%rsp),%xmm1
ucomisd %xmm3,%xmm1
ja     1190 <findAreaRight+0x80>
movsd  %xmm2,(%rsp)
lea    0xe0e(%rip),%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
lea    0xe11(%rip),%rdi
mov    %r14d,%esi
call   1030 <printf@plt>
movsd  (%rsp),%xmm0
add    $0x38,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"\0AArea: %f\00"
@.str.1 = [16 x i8] c"\0AValue of x: %f\00"
@.str.2 = [18 x i8] c"\0AValue of fin: %d\00"
@.str.3 = [17 x i8] c"\0AValue of in: %d\00"
define double @findAreaRight(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca double
%14 = alloca double
%15 = alloca double
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 %5, i32* %12
store double 0.000000e+00, double* %13
%16 = load i32, i32* %11
%17 = load i32, i32* %10
%18 = sub nsw i32 %16, %17
%19 = sitofp i32 %18 to double
%20 = load i32, i32* %12
%21 = sitofp i32 %20 to double
%22 = fdiv double %19, %21
store double %22, double* %14
store double 0.000000e+00, double* %15
%23 = load i32, i32* %11
%24 = sitofp i32 %23 to double
store double %24, double* %13
br label %25
25: ; preds = %53, %6
%26 = load double, double* %13
%27 = load i32, i32* %10
%28 = sitofp i32 %27 to double
%29 = fcmp ogt double %26, %28
br i1 %29, label %30, label %57
30: ; preds = %25
%31 = load i32, i32* %7
%32 = sitofp i32 %31 to double
%33 = load double, double* %13
%34 = load double, double* %13
%35 = fmul double %33, %34
%36 = load i32, i32* %8
%37 = sitofp i32 %36 to double
%38 = load double, double* %13
%39 = fmul double %37, %38
%40 = call double @llvm.fmuladd.f64(double %32, double %35, double %39)
%41 = load i32, i32* %9
%42 = sitofp i32 %41 to double
%43 = fadd double %40, %42
%44 = load double, double* %14
%45 = load double, double* %15
%46 = call double @llvm.fmuladd.f64(double %43, double %44, double %45)
store double %46, double* %15
%47 = load double, double* %15
%48 = fptosi double %47 to i32
%49 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %48)
%50 = load double, double* %13
%51 = fptosi double %50 to i32
%52 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %51)
br label %53
53: ; preds = %30
%54 = load double, double* %14
%55 = load double, double* %13
%56 = fsub double %55, %54
store double %56, double* %13
br label %25
57: ; preds = %25
%58 = load i32, i32* %11
%59 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %58)
%60 = load i32, i32* %10
%61 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %60)
%62 = load double, double* %15
ret double %62
}

LLVM IR (-O2):
@.str = [10 x i8] c"\0AArea: %f\00"
@.str.1 = [16 x i8] c"\0AValue of x: %f\00"
@.str.2 = [18 x i8] c"\0AValue of fin: %d\00"
@.str.3 = [17 x i8] c"\0AValue of in: %d\00"
define double @findAreaRight(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = sub nsw i32 %4, %3
%8 = sitofp i32 %7 to double
%9 = sitofp i32 %5 to double
%10 = fdiv double %8, %9
%11 = sitofp i32 %4 to double
%12 = sitofp i32 %3 to double
%13 = fcmp ogt double %11, %12
br i1 %13, label %14, label %32
14: ; preds = %6
%15 = sitofp i32 %0 to double
%16 = sitofp i32 %1 to double
%17 = sitofp i32 %2 to double
br label %18
18: ; preds = %14, %18
%19 = phi double [ 0.000000e+00, %14 ], [ %25, %18 ]
%20 = phi double [ %11, %14 ], [ %30, %18 ]
%21 = fmul double %20, %20
%22 = fmul double %20, %16
%23 = tail call double @llvm.fmuladd.f64(double %15, double %21, double %22)
%24 = fadd double %23, %17
%25 = tail call double @llvm.fmuladd.f64(double %24, double %10, double %19)
%26 = fptosi double %25 to i32
%27 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %26)
%28 = fptosi double %20 to i32
%29 = tail call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = fsub double %20, %10
%31 = fcmp ogt double %30, %12
br i1 %31, label %18, label %32
32: ; preds = %18, %6
%33 = phi double [ 0.000000e+00, %6 ], [ %25, %18 ]
%34 = tail call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %4)
%35 = tail call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %3)
ret double %33
}