#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 _f(double);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
double weddle(double xmin, double xmax, int n) {
  double h, hh, h2, h3, h4, h5, hi, s, x;
  int i;
  if (n < 2) {
    fprintf(stderr, "Error : n < 2  in weddle()\n");
    return 0.;
  }
  if (xmin == xmax)
    return 0.;
  s = _f(xmin) - _f(xmax);
  h = (xmax - xmin) / (double)n;
  hh = h / 6.;
  h2 = h / 3.;
  h3 = h / 2.;
  h4 = h / 1.5;
  h5 = h / 1.2;
  for (i = 0, hi = 1.; i < n; i++, hi += 1.) {
    x = xmin + h * hi;
    s += (2. * _f(x) + 5. * (_f(x - h5) + _f(x - hh)) + _f(x - h4) +
          _f(x - h2) + 6. * _f(x - h3));
  }
  return s * h / 20.;
}


x86 assembly (clang, -O0):
<weddle>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %edi,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jge    1164 <weddle+0x44>
mov    0x2e97(%rip),%rax
mov    (%rax),%edi
lea    0xeee(%rip),%rsi
call   1030 <fprintf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    138e <weddle+0x26e>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jne    1187 <weddle+0x67>
jp     1187 <weddle+0x67>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    138e <weddle+0x26e>
movsd  -0x10(%rbp),%xmm0
call   1040 <_f@plt>
mov    %eax,-0x70(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <_f@plt>
mov    %eax,%ecx
mov    -0x70(%rbp),%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe55(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe37(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe19(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xdfb(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xddd(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movl   $0x0,-0x6c(%rbp)
movsd  0xdbd(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x6c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1373 <weddle+0x253>
movsd  -0x10(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
call   1040 <_f@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x68(%rbp),%xmm0
subsd  -0x50(%rbp),%xmm0
call   1040 <_f@plt>
mov    %eax,-0x8c(%rbp)
movsd  -0x68(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
call   1040 <_f@plt>
movsd  -0x98(%rbp),%xmm0
ff
mov    %eax,%ecx
mov    -0x8c(%rbp),%eax
add    %ecx,%eax
cvtsi2sd %eax,%xmm2
movsd  0xd70(%rip),%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x88(%rbp)
ff
movsd  -0x68(%rbp),%xmm0
subsd  -0x48(%rbp),%xmm0
call   1040 <_f@plt>
movsd  -0x88(%rbp),%xmm0
ff
cvtsi2sd %eax,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x68(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
call   1040 <_f@plt>
movsd  -0x80(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  -0x68(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
call   1040 <_f@plt>
movsd  -0x78(%rbp),%xmm1
cvtsi2sd %eax,%xmm0
movsd  0xce7(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x60(%rbp),%xmm0
movsd  %xmm0,-0x60(%rbp)
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
movsd  0xc9c(%rip),%xmm0
addsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    1248 <weddle+0x128>
movsd  -0x60(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  0xcab(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<weddle>:
push   %rbp
push   %rbx
sub    $0x58,%rsp
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x18(%rsp)
cmp    $0x1,%edi
jg     1155 <weddle+0x35>
mov    0x2ea2(%rip),%rax
mov    (%rax),%edi
lea    0xef9(%rip),%rsi
call   1030 <fprintf@plt>
xorpd  %xmm0,%xmm0
jmp    1326 <weddle+0x206>
xorpd  %xmm0,%xmm0
movsd  0x18(%rsp),%xmm1
ucomisd 0x8(%rsp),%xmm1
jne    116d <weddle+0x4d>
jnp    1326 <weddle+0x206>
mov    %edi,%ebx
movsd  0x18(%rsp),%xmm0
call   1040 <_f@plt>
mov    %eax,%ebp
movsd  0x8(%rsp),%xmm0
call   1040 <_f@plt>
sub    %eax,%ebp
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  0x8(%rsp),%xmm3
subsd  0x18(%rsp),%xmm3
divsd  %xmm0,%xmm3
movapd %xmm3,%xmm0
divsd  0xe4d(%rip),%xmm0
movsd  %xmm0,0x40(%rsp)
movapd %xmm3,%xmm0
divsd  0xe43(%rip),%xmm0
movsd  %xmm0,0x38(%rsp)
movsd  0xe3d(%rip),%xmm0
movapd %xmm3,%xmm2
divsd  0xe39(%rip),%xmm2
movsd  %xmm2,0x28(%rsp)
movapd %xmm3,%xmm2
divsd  0xe2f(%rip),%xmm2
movsd  %xmm2,0x20(%rsp)
movsd  %xmm3,0x8(%rsp)
mulsd  %xmm3,%xmm0
movsd  %xmm0,0x30(%rsp)
movsd  0xe19(%rip),%xmm2
nop
movsd  %xmm2,0x48(%rsp)
movsd  %xmm1,0x50(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  %xmm2,%xmm0
addsd  0x18(%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
call   1040 <_f@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
subsd  0x20(%rsp),%xmm0
call   1040 <_f@plt>
mov    %eax,%ebp
movsd  0x10(%rsp),%xmm0
subsd  0x40(%rsp),%xmm0
call   1040 <_f@plt>
add    %ebp,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xdb8(%rip),%xmm0
movsd  (%rsp),%xmm1
addsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,(%rsp)
movsd  0x10(%rsp),%xmm0
subsd  0x28(%rsp),%xmm0
call   1040 <_f@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
subsd  0x38(%rsp),%xmm0
call   1040 <_f@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
movsd  0x10(%rsp),%xmm0
subsd  0x30(%rsp),%xmm0
call   1040 <_f@plt>
movsd  0x50(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xd0c(%rip),%xmm0
addsd  (%rsp),%xmm0
addsd  %xmm0,%xmm1
movsd  0x48(%rsp),%xmm2
addsd  0xd1d(%rip),%xmm2
add    $0xffffffff,%ebx
jne    1210 <weddle+0xf0>
movsd  0x8(%rsp),%xmm0
mulsd  %xmm1,%xmm0
divsd  0xd12(%rip),%xmm0
add    $0x58,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [28 x i8] c"Error : n < 2 in weddle()\0A\00"
define double @weddle(double %0, double %1, i32 %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
%17 = alloca i32
store double %0, double* %5
store double %1, double* %6
store i32 %2, i32* %7
%18 = load i32, i32* %7
%19 = icmp slt i32 %18, 2
br i1 %19, label %20, label %23
20: ; preds = %3
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
store double 0.000000e+00, double* %4
br label %105
23: ; preds = %3
%24 = load double, double* %5
%25 = load double, double* %6
%26 = fcmp oeq double %24, %25
br i1 %26, label %27, label %28
27: ; preds = %23
store double 0.000000e+00, double* %4
br label %105
28: ; preds = %23
%29 = load double, double* %5
%30 = call i32 @_f(double %29)
%31 = load double, double* %6
%32 = call i32 @_f(double %31)
%33 = sub nsw i32 %30, %32
%34 = sitofp i32 %33 to double
store double %34, double* %15
%35 = load double, double* %6
%36 = load double, double* %5
%37 = fsub double %35, %36
%38 = load i32, i32* %7
%39 = sitofp i32 %38 to double
%40 = fdiv double %37, %39
store double %40, double* %8
%41 = load double, double* %8
%42 = fdiv double %41, 6.000000e+00
store double %42, double* %9
%43 = load double, double* %8
%44 = fdiv double %43, 3.000000e+00
store double %44, double* %10
%45 = load double, double* %8
%46 = fdiv double %45, 2.000000e+00
store double %46, double* %11
%47 = load double, double* %8
%48 = fdiv double %47, 1.500000e+00
store double %48, double* %12
%49 = load double, double* %8
%50 = fdiv double %49, 1.200000e+00
store double %50, double* %13
store i32 0, i32* %17
store double 1.000000e+00, double* %14
br label %51
51: ; preds = %95, %28
%52 = load i32, i32* %17
%53 = load i32, i32* %7
%54 = icmp slt i32 %52, %53
br i1 %54, label %55, label %100
55: ; preds = %51
%56 = load double, double* %5
%57 = load double, double* %8
%58 = load double, double* %14
%59 = call double @llvm.fmuladd.f64(double %57, double %58, double %56)
store double %59, double* %16
%60 = load double, double* %16
%61 = call i32 @_f(double %60)
%62 = sitofp i32 %61 to double
%63 = load double, double* %16
%64 = load double, double* %13
%65 = fsub double %63, %64
%66 = call i32 @_f(double %65)
%67 = load double, double* %16
%68 = load double, double* %9
%69 = fsub double %67, %68
%70 = call i32 @_f(double %69)
%71 = add nsw i32 %66, %70
%72 = sitofp i32 %71 to double
%73 = fmul double 5.000000e+00, %72
%74 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %62, double %73)
%75 = load double, double* %16
%76 = load double, double* %12
%77 = fsub double %75, %76
%78 = call i32 @_f(double %77)
%79 = sitofp i32 %78 to double
%80 = fadd double %74, %79
%81 = load double, double* %16
%82 = load double, double* %10
%83 = fsub double %81, %82
%84 = call i32 @_f(double %83)
%85 = sitofp i32 %84 to double
%86 = fadd double %80, %85
%87 = load double, double* %16
%88 = load double, double* %11
%89 = fsub double %87, %88
%90 = call i32 @_f(double %89)
%91 = sitofp i32 %90 to double
%92 = call double @llvm.fmuladd.f64(double 6.000000e+00, double %91, double %86)
%93 = load double, double* %15
%94 = fadd double %93, %92
store double %94, double* %15
br label %95
95: ; preds = %55
%96 = load i32, i32* %17
%97 = add nsw i32 %96, 1
store i32 %97, i32* %17
%98 = load double, double* %14
%99 = fadd double %98, 1.000000e+00
store double %99, double* %14
br label %51
100: ; preds = %51
%101 = load double, double* %15
%102 = load double, double* %8
%103 = fmul double %101, %102
%104 = fdiv double %103, 2.000000e+01
store double %104, double* %4
br label %105
105: ; preds = %100, %27, %20
%106 = load double, double* %4
ret double %106
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [28 x i8] c"Error : n < 2 in weddle()\0A\00"
define double @weddle(double %0, double %1, i32 %2) {
%4 = icmp slt i32 %2, 2
br i1 %4, label %5, label %8
5: ; preds = %3
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %57
8: ; preds = %3
%9 = fcmp oeq double %0, %1
br i1 %9, label %57, label %10
10: ; preds = %8
%11 = tail call i32 @_f(double %0)
%12 = tail call i32 @_f(double %1)
%13 = sub nsw i32 %11, %12
%14 = sitofp i32 %13 to double
%15 = fsub double %1, %0
%16 = sitofp i32 %2 to double
%17 = fdiv double %15, %16
%18 = fdiv double %17, 6.000000e+00
%19 = fdiv double %17, 3.000000e+00
%20 = fmul double %17, 5.000000e-01
%21 = fdiv double %17, 1.500000e+00
%22 = fdiv double %17, 1.200000e+00
br label %23
23: ; preds = %10, %23
%24 = phi i32 [ %51, %23 ], [ 0, %10 ]
%25 = phi double [ %50, %23 ], [ %14, %10 ]
%26 = phi double [ %52, %23 ], [ 1.000000e+00, %10 ]
%27 = tail call double @llvm.fmuladd.f64(double %17, double %26, double %0)
%28 = tail call i32 @_f(double %27)
%29 = sitofp i32 %28 to double
%30 = fsub double %27, %22
%31 = tail call i32 @_f(double %30)
%32 = fsub double %27, %18
%33 = tail call i32 @_f(double %32)
%34 = add nsw i32 %33, %31
%35 = sitofp i32 %34 to double
%36 = fmul double %35, 5.000000e+00
%37 = tail call double @llvm.fmuladd.f64(double %29, double 2.000000e+00, double %36)
%38 = fsub double %27, %21
%39 = tail call i32 @_f(double %38)
%40 = sitofp i32 %39 to double
%41 = fadd double %37, %40
%42 = fsub double %27, %19
%43 = tail call i32 @_f(double %42)
%44 = sitofp i32 %43 to double
%45 = fadd double %41, %44
%46 = fsub double %27, %20
%47 = tail call i32 @_f(double %46)
%48 = sitofp i32 %47 to double
%49 = tail call double @llvm.fmuladd.f64(double %48, double 6.000000e+00, double %45)
%50 = fadd double %25, %49
%51 = add nuw nsw i32 %24, 1
%52 = fadd double %26, 1.000000e+00
%53 = icmp eq i32 %51, %2
br i1 %53, label %54, label %23
54: ; preds = %23
%55 = fmul double %17, %50
%56 = fdiv double %55, 2.000000e+01
br label %57
57: ; preds = %8, %54, %5
%58 = phi double [ 0.000000e+00, %5 ], [ %56, %54 ], [ 0.000000e+00, %8 ]
ret double %58
}