#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 fatorial(unsigned long);
double pow(int, int);
double calcError(int n, double a, double b) {
  double p1, p2;
  p1 = pow((b - a) / 2, n) / pow(2, n - 1);
  p2 = 1 / fatorial((unsigned long)n);
  return p1 * p2;
}


x86 assembly (clang, -O0):
<calcError>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  0xeb9(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
mov    -0x4(%rbp),%esi
call   1040 <pow@plt>
movsd  %xmm0,-0x30(%rbp)
mov    -0x4(%rbp),%esi
sub    $0x1,%esi
mov    $0x2,%edi
call   1040 <pow@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movslq -0x4(%rbp),%rdi
call   1030 <fatorial@plt>
mov    %eax,%ecx
mov    $0x1,%eax
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcError>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
subsd  %xmm0,%xmm1
mulsd  0xecd(%rip),%xmm1
cvttsd2si %xmm1,%edi
mov    %ebx,%esi
call   1040 <pow@plt>
movsd  %xmm0,0x8(%rsp)
lea    -0x1(%rbx),%esi
mov    $0x2,%edi
call   1040 <pow@plt>
movsd  0x8(%rsp),%xmm1
divsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movslq %ebx,%rdi
call   1030 <fatorial@plt>
lea    0x1(%rax),%ecx
xor    %edx,%edx
cmp    $0x3,%ecx
cmovb  %eax,%edx
xorps  %xmm0,%xmm0
cvtsi2sd %edx,%xmm0
mulsd  0x8(%rsp),%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @calcError(i32 %0, double %1, double %2) {
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
store i32 %0, i32* %4
store double %1, double* %5
store double %2, double* %6
%9 = load double, double* %6
%10 = load double, double* %5
%11 = fsub double %9, %10
%12 = fdiv double %11, 2.000000e+00
%13 = fptosi double %12 to i32
%14 = load i32, i32* %4
%15 = call double @pow(i32 %13, i32 %14)
%16 = load i32, i32* %4
%17 = sub nsw i32 %16, 1
%18 = call double @pow(i32 2, i32 %17)
%19 = fdiv double %15, %18
store double %19, double* %7
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = call i32 @fatorial(i64 %21)
%23 = sdiv i32 1, %22
%24 = sitofp i32 %23 to double
store double %24, double* %8
%25 = load double, double* %7
%26 = load double, double* %8
%27 = fmul double %25, %26
ret double %27
}

LLVM IR (-O2):
define double @calcError(i32 %0, double %1, double %2) {
%4 = fsub double %2, %1
%5 = fmul double %4, 5.000000e-01
%6 = fptosi double %5 to i32
%7 = tail call double @pow(i32 %6, i32 %0)
%8 = add nsw i32 %0, -1
%9 = tail call double @pow(i32 2, i32 %8)
%10 = fdiv double %7, %9
%11 = sext i32 %0 to i64
%12 = tail call i32 @fatorial(i64 %11)
%13 = add i32 %12, 1
%14 = icmp ult i32 %13, 3
%15 = select i1 %14, i32 %12, i32 0
%16 = sitofp i32 %15 to double
%17 = fmul double %10, %16
ret double %17
}