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


x86 assembly (clang, -O0):
<nc2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %edi,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jge    1161 <nc2+0x41>
mov    0x2e9a(%rip),%rax
mov    (%rax),%edi
lea    0xed1(%rip),%rsi
call   1030 <fprintf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12a1 <nc2+0x181>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jne    1184 <nc2+0x64>
jp     1184 <nc2+0x64>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12a1 <nc2+0x181>
movsd  -0x10(%rbp),%xmm0
call   1040 <_f@plt>
mov    %eax,-0x50(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <_f@plt>
mov    %eax,%ecx
mov    -0x50(%rbp),%eax
sub    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x40(%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  0xe38(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x4c(%rbp)
movsd  0xe18(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1286 <nc2+0x166>
movsd  -0x10(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
subsd  -0x30(%rbp),%xmm0
call   1040 <_f@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x48(%rbp),%xmm0
call   1040 <_f@plt>
movsd  -0x58(%rbp),%xmm0
cvtsi2sd %eax,%xmm2
movsd  0xdc0(%rip),%xmm1
mulsd  %xmm2,%xmm1
movsd  0xdc4(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
movsd  0xd89(%rip),%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11ed <nc2+0xcd>
movsd  -0x40(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  0xd78(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nc2>:
push   %rbp
push   %rbx
sub    $0x38,%rsp
movsd  %xmm1,(%rsp)
movsd  %xmm0,0x8(%rsp)
cmp    $0x1,%edi
jg     1154 <nc2+0x34>
mov    0x2ea3(%rip),%rax
mov    (%rax),%edi
lea    0xeda(%rip),%rsi
call   1030 <fprintf@plt>
xorpd  %xmm0,%xmm0
jmp    1267 <nc2+0x147>
xorpd  %xmm0,%xmm0
movsd  0x8(%rsp),%xmm1
ucomisd (%rsp),%xmm1
jne    116b <nc2+0x4b>
jnp    1267 <nc2+0x147>
mov    %edi,%ebx
movsd  0x8(%rsp),%xmm0
call   1040 <_f@plt>
mov    %eax,%ebp
movsd  (%rsp),%xmm0
call   1040 <_f@plt>
sub    %eax,%ebp
xorps  %xmm1,%xmm1
cvtsi2sd %ebp,%xmm1
movsd  (%rsp),%xmm2
subsd  0x8(%rsp),%xmm2
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
divsd  %xmm0,%xmm2
movsd  0xe55(%rip),%xmm0
movsd  %xmm2,(%rsp)
mulsd  %xmm2,%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0xe46(%rip),%xmm0
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsd  %xmm0,0x28(%rsp)
movsd  %xmm1,0x30(%rsp)
movsd  (%rsp),%xmm1
mulsd  %xmm0,%xmm1
addsd  0x8(%rsp),%xmm1
movsd  %xmm1,0x18(%rsp)
movapd %xmm1,%xmm0
subsd  0x10(%rsp),%xmm0
call   1040 <_f@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  0x18(%rsp),%xmm0
call   1040 <_f@plt>
movsd  0x30(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  %xmm0,%xmm0
movsd  0x20(%rsp),%xmm2
mulsd  0xdd9(%rip),%xmm2
addsd  %xmm0,%xmm2
movsd  0x28(%rsp),%xmm0
addsd  %xmm2,%xmm1
addsd  0xdbb(%rip),%xmm0
add    $0xffffffff,%ebx
jne    11d0 <nc2+0xb0>
movsd  (%rsp),%xmm0
mulsd  %xmm1,%xmm0
divsd  0xdb1(%rip),%xmm0
add    $0x38,%rsp
pop    %rbx
pop    %rbp
ret

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

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