#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 nc4(double xmin, double xmax, int n) {
  double h, hh, h2, h3, hi, s, x;
  int i;
  if (n < 2) {
    fprintf(stderr, "Error : n < 2  in nc4()\n");
    return 0.;
  }
  if (xmin == xmax)
    return 0.;
  s = _f(xmin) - 7. * _f(xmax);
  h = (xmax - xmin) / (double)n;
  hh = h / 4.;
  h2 = h / 2.;
  h3 = h * .75;
  for (i = 0, hi = 1.; i < n; i++, hi += 1.) {
    x = xmin + h * hi;
    s += (14. * _f(x) + 32. * (_f(x - h3) + _f(x - hh)) + 12. * _f(x - h2));
  }
  return s * h / 90.;
}


x86 assembly (clang, -O0):
<nc4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %edi,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jge    1164 <nc4+0x44>
mov    0x2e97(%rip),%rax
mov    (%rax),%edi
lea    0xef6(%rip),%rsi
call   1030 <fprintf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1326 <nc4+0x206>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jne    1187 <nc4+0x67>
jp     1187 <nc4+0x67>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1326 <nc4+0x206>
movsd  -0x10(%rbp),%xmm0
call   1040 <_f@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <_f@plt>
movsd  -0x68(%rbp),%xmm1
cvtsi2sd %eax,%xmm0
movsd  0xe6b(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%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  0xe31(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe13(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xdfa(%rip),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x0,-0x5c(%rbp)
movsd  0xdd9(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x5c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    130b <nc4+0x1eb>
movsd  -0x10(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
call   1040 <_f@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  -0x58(%rbp),%xmm0
subsd  -0x40(%rbp),%xmm0
call   1040 <_f@plt>
mov    %eax,-0x74(%rbp)
movsd  -0x58(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
call   1040 <_f@plt>
movsd  -0x80(%rbp),%xmm0
mov    %eax,%ecx
mov    -0x74(%rbp),%eax
add    %ecx,%eax
cvtsi2sd %eax,%xmm2
movsd  0xda0(%rip),%xmm1
mulsd  %xmm2,%xmm1
movsd  0xd8c(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  -0x58(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
call   1040 <_f@plt>
movsd  -0x70(%rbp),%xmm1
cvtsi2sd %eax,%xmm0
movsd  0xd57(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
movsd  0xd04(%rip),%xmm0
addsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    122c <nc4+0x10c>
movsd  -0x50(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  0xd0b(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nc4>:
push   %rbp
push   %rbx
sub    $0x48,%rsp
movsd  %xmm1,(%rsp)
movsd  %xmm0,0x10(%rsp)
cmp    $0x1,%edi
jg     1154 <nc4+0x34>
mov    0x2ea3(%rip),%rax
mov    (%rax),%edi
lea    0xf02(%rip),%rsi
call   1030 <fprintf@plt>
xorpd  %xmm0,%xmm0
jmp    12d8 <nc4+0x1b8>
xorpd  %xmm0,%xmm0
movsd  0x10(%rsp),%xmm1
ucomisd (%rsp),%xmm1
jne    116b <nc4+0x4b>
jnp    12d8 <nc4+0x1b8>
mov    %edi,%ebx
movsd  0x10(%rsp),%xmm0
call   1040 <_f@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
call   1040 <_f@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mulsd  0xe62(%rip),%xmm1
addsd  0x8(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  (%rsp),%xmm2
subsd  0x10(%rsp),%xmm2
divsd  %xmm0,%xmm2
movsd  0xe46(%rip),%xmm0
mulsd  %xmm2,%xmm0
movsd  %xmm0,0x30(%rsp)
movsd  0xe3c(%rip),%xmm0
mulsd  %xmm2,%xmm0
movsd  %xmm0,0x28(%rsp)
movsd  0xe32(%rip),%xmm0
movsd  %xmm2,(%rsp)
mulsd  %xmm2,%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  0xe23(%rip),%xmm2
nopl   (%rax)
movsd  %xmm2,0x38(%rsp)
movsd  %xmm1,0x40(%rsp)
movsd  (%rsp),%xmm0
mulsd  %xmm2,%xmm0
addsd  0x10(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1040 <_f@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x18(%rsp)
movsd  0x8(%rsp),%xmm0
subsd  0x20(%rsp),%xmm0
call   1040 <_f@plt>
mov    %eax,%ebp
movsd  0x8(%rsp),%xmm0
subsd  0x30(%rsp),%xmm0
call   1040 <_f@plt>
add    %ebp,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xdc0(%rip),%xmm0
movsd  0x18(%rsp),%xmm1
mulsd  0xdba(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x18(%rsp)
movsd  0x8(%rsp),%xmm0
subsd  0x28(%rsp),%xmm0
call   1040 <_f@plt>
movsd  0x40(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xd92(%rip),%xmm0
addsd  0x18(%rsp),%xmm0
addsd  %xmm0,%xmm1
movsd  0x38(%rsp),%xmm2
addsd  0xd62(%rip),%xmm2
add    $0xffffffff,%ebx
jne    1200 <nc4+0xe0>
movsd  (%rsp),%xmm0
mulsd  %xmm1,%xmm0
divsd  0xd68(%rip),%xmm0
add    $0x48,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@stderr = global i32 0
@.str = [25 x i8] c"Error : n < 2 in nc4()\0A\00"
define double @nc4(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 ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
br label %48
8: ; preds = %3
%9 = fcmp oeq double %0, %1
br i1 %9, label %48, label %10
10: ; preds = %8
%11 = tail call i32 @_f(double %0)
%12 = sitofp i32 %11 to double
%13 = tail call i32 @_f(double %1)
%14 = sitofp i32 %13 to double
%15 = tail call double @llvm.fmuladd.f64(double %14, double -7.000000e+00, double %12)
%16 = fsub double %1, %0
%17 = sitofp i32 %2 to double
%18 = fdiv double %16, %17
%19 = fmul double %18, 2.500000e-01
%20 = fmul double %18, 5.000000e-01
%21 = fmul double %18, 7.500000e-01
br label %22
22: ; preds = %10, %22
%23 = phi i32 [ %42, %22 ], [ 0, %10 ]
%24 = phi double [ %41, %22 ], [ %15, %10 ]
%25 = phi double [ %43, %22 ], [ 1.000000e+00, %10 ]
%26 = tail call double @llvm.fmuladd.f64(double %18, double %25, double %0)
%27 = tail call i32 @_f(double %26)
%28 = sitofp i32 %27 to double
%29 = fsub double %26, %21
%30 = tail call i32 @_f(double %29)
%31 = fsub double %26, %19
%32 = tail call i32 @_f(double %31)
%33 = add nsw i32 %32, %30
%34 = sitofp i32 %33 to double
%35 = fmul double %34, 3.200000e+01
%36 = tail call double @llvm.fmuladd.f64(double %28, double 1.400000e+01, double %35)
%37 = fsub double %26, %20
%38 = tail call i32 @_f(double %37)
%39 = sitofp i32 %38 to double
%40 = tail call double @llvm.fmuladd.f64(double %39, double 1.200000e+01, double %36)
%41 = fadd double %24, %40
%42 = add nuw nsw i32 %23, 1
%43 = fadd double %25, 1.000000e+00
%44 = icmp eq i32 %42, %2
br i1 %44, label %45, label %22
45: ; preds = %22
%46 = fmul double %18, %41
%47 = fdiv double %46, 9.000000e+01
br label %48
48: ; preds = %8, %45, %5
%49 = phi double [ 0.000000e+00, %5 ], [ %47, %45 ], [ 0.000000e+00, %8 ]
ret double %49
}