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


x86 assembly (clang, -O0):
<nc3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %edi,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jge    1161 <nc3+0x41>
mov    0x2e9a(%rip),%rax
mov    (%rax),%edi
lea    0xed9(%rip),%rsi
call   1030 <fprintf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12d0 <nc3+0x1b0>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jne    1184 <nc3+0x64>
jp     1184 <nc3+0x64>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12d0 <nc3+0x1b0>
movsd  -0x10(%rbp),%xmm0
call   1040 <_f@plt>
mov    %eax,-0x58(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <_f@plt>
mov    %eax,%ecx
mov    -0x58(%rbp),%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x48(%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  0xe40(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xe22(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movl   $0x0,-0x54(%rbp)
movsd  0xe02(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    12b5 <nc3+0x195>
movsd  -0x10(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
movsd  -0x40(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
subsd  -0x38(%rbp),%xmm0
call   1040 <_f@plt>
mov    %eax,-0x64(%rbp)
movsd  -0x50(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
call   1040 <_f@plt>
mov    %eax,%ecx
mov    -0x64(%rbp),%eax
add    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x50(%rbp),%xmm0
call   1040 <_f@plt>
movsd  -0x60(%rbp),%xmm0
cvtsi2sd %eax,%xmm2
movsd  0xda9(%rip),%xmm1
mulsd  %xmm2,%xmm1
movsd  0xd8d(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
movsd  0xd5a(%rip),%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    1203 <nc3+0xe3>
movsd  -0x48(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  0xd51(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nc3>:
push   %rbp
push   %rbx
sub    $0x48,%rsp
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
cmp    $0x1,%edi
jg     1155 <nc3+0x35>
mov    0x2ea2(%rip),%rax
mov    (%rax),%edi
lea    0xed9(%rip),%rsi
call   1030 <fprintf@plt>
xorpd  %xmm0,%xmm0
jmp    128e <nc3+0x16e>
xorpd  %xmm0,%xmm0
movsd  0x10(%rsp),%xmm1
ucomisd 0x8(%rsp),%xmm1
jne    116d <nc3+0x4d>
jnp    128e <nc3+0x16e>
mov    %edi,%ebx
movsd  0x10(%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),%xmm2
subsd  0x10(%rsp),%xmm2
divsd  %xmm0,%xmm2
movapd %xmm2,%xmm0
divsd  0xe4d(%rip),%xmm0
movsd  %xmm0,0x28(%rsp)
movsd  %xmm2,0x8(%rsp)
movapd %xmm2,%xmm0
divsd  0xe3d(%rip),%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  0xe37(%rip),%xmm0
nopl   0x0(%rax)
movsd  %xmm0,0x38(%rsp)
movsd  %xmm1,0x40(%rsp)
movsd  0x8(%rsp),%xmm1
mulsd  %xmm0,%xmm1
addsd  0x10(%rsp),%xmm1
movsd  %xmm1,0x18(%rsp)
movapd %xmm1,%xmm0
subsd  0x20(%rsp),%xmm0
call   1040 <_f@plt>
mov    %eax,%ebp
movsd  0x18(%rsp),%xmm0
subsd  0x28(%rsp),%xmm0
call   1040 <_f@plt>
add    %ebp,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x30(%rsp)
movsd  0x18(%rsp),%xmm0
call   1040 <_f@plt>
movsd  0x40(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  %xmm0,%xmm0
movsd  0x30(%rsp),%xmm2
mulsd  0xda3(%rip),%xmm2
addsd  %xmm0,%xmm2
movsd  0x38(%rsp),%xmm0
addsd  %xmm2,%xmm1
addsd  0xd9d(%rip),%xmm0
add    $0xffffffff,%ebx
jne    11e0 <nc3+0xc0>
movsd  0x8(%rsp),%xmm0
mulsd  %xmm1,%xmm0
mulsd  0xd8a(%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 nc3()\0A\00"
define double @nc3(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 i32
store double %0, double* %5
store double %1, double* %6
store i32 %2, i32* %7
%15 = load i32, i32* %7
%16 = icmp slt i32 %15, 2
br i1 %16, label %17, label %20
17: ; preds = %3
%18 = load i32, i32* @stderr
%19 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
store double 0.000000e+00, double* %4
br label %78
20: ; preds = %3
%21 = load double, double* %5
%22 = load double, double* %6
%23 = fcmp oeq double %21, %22
br i1 %23, label %24, label %25
24: ; preds = %20
store double 0.000000e+00, double* %4
br label %78
25: ; preds = %20
%26 = load double, double* %5
%27 = call i32 @_f(double %26)
%28 = load double, double* %6
%29 = call i32 @_f(double %28)
%30 = sub nsw i32 %27, %29
%31 = sitofp i32 %30 to double
store double %31, double* %12
%32 = load double, double* %6
%33 = load double, double* %5
%34 = fsub double %32, %33
%35 = load i32, i32* %7
%36 = sitofp i32 %35 to double
%37 = fdiv double %34, %36
store double %37, double* %8
%38 = load double, double* %8
%39 = fdiv double %38, 3.000000e+00
store double %39, double* %9
%40 = load double, double* %8
%41 = fdiv double %40, 1.500000e+00
store double %41, double* %10
store i32 0, i32* %14
store double 1.000000e+00, double* %11
br label %42
42: ; preds = %68, %25
%43 = load i32, i32* %14
%44 = load i32, i32* %7
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %73
46: ; preds = %42
%47 = load double, double* %5
%48 = load double, double* %8
%49 = load double, double* %11
%50 = call double @llvm.fmuladd.f64(double %48, double %49, double %47)
store double %50, double* %13
%51 = load double, double* %13
%52 = load double, double* %10
%53 = fsub double %51, %52
%54 = call i32 @_f(double %53)
%55 = load double, double* %13
%56 = load double, double* %9
%57 = fsub double %55, %56
%58 = call i32 @_f(double %57)
%59 = add nsw i32 %54, %58
%60 = sitofp i32 %59 to double
%61 = load double, double* %13
%62 = call i32 @_f(double %61)
%63 = sitofp i32 %62 to double
%64 = fmul double 2.000000e+00, %63
%65 = call double @llvm.fmuladd.f64(double 3.000000e+00, double %60, double %64)
%66 = load double, double* %12
%67 = fadd double %66, %65
store double %67, double* %12
br label %68
68: ; preds = %46
%69 = load i32, i32* %14
%70 = add nsw i32 %69, 1
store i32 %70, i32* %14
%71 = load double, double* %11
%72 = fadd double %71, 1.000000e+00
store double %72, double* %11
br label %42
73: ; preds = %42
%74 = load double, double* %12
%75 = load double, double* %8
%76 = fmul double %74, %75
%77 = fdiv double %76, 8.000000e+00
store double %77, double* %4
br label %78
78: ; preds = %73, %24, %17
%79 = load double, double* %4
ret double %79
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [25 x i8] c"Error : n < 2 in nc3()\0A\00"
define double @nc3(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 %42
8: ; preds = %3
%9 = fcmp oeq double %0, %1
br i1 %9, label %42, 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, 3.000000e+00
%19 = fdiv double %17, 1.500000e+00
br label %20
20: ; preds = %10, %20
%21 = phi i32 [ %36, %20 ], [ 0, %10 ]
%22 = phi double [ %35, %20 ], [ %14, %10 ]
%23 = phi double [ %37, %20 ], [ 1.000000e+00, %10 ]
%24 = tail call double @llvm.fmuladd.f64(double %17, double %23, double %0)
%25 = fsub double %24, %19
%26 = tail call i32 @_f(double %25)
%27 = fsub double %24, %18
%28 = tail call i32 @_f(double %27)
%29 = add nsw i32 %28, %26
%30 = sitofp i32 %29 to double
%31 = tail call i32 @_f(double %24)
%32 = sitofp i32 %31 to double
%33 = fmul double %32, 2.000000e+00
%34 = tail call double @llvm.fmuladd.f64(double %30, double 3.000000e+00, double %33)
%35 = fadd double %22, %34
%36 = add nuw nsw i32 %21, 1
%37 = fadd double %23, 1.000000e+00
%38 = icmp eq i32 %36, %2
br i1 %38, label %39, label %20
39: ; preds = %20
%40 = fmul double %17, %35
%41 = fmul double %40, 1.250000e-01
br label %42
42: ; preds = %8, %39, %5
%43 = phi double [ 0.000000e+00, %5 ], [ %41, %39 ], [ 0.000000e+00, %8 ]
ret double %43
}