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


x86 assembly (clang, -O0):
<nc1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %edi,-0x1c(%rbp)
cmpl   $0x2,-0x1c(%rbp)
jge    1161 <nc1+0x41>
mov    0x2e9a(%rip),%rax
mov    (%rax),%edi
lea    0xec1(%rip),%rsi
call   1030 <fprintf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1248 <nc1+0x128>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jne    1184 <nc1+0x64>
jp     1184 <nc1+0x64>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1248 <nc1+0x128>
movsd  -0x10(%rbp),%xmm0
call   1040 <_f@plt>
mov    %eax,-0x40(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <_f@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%eax
add    %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  0xe5a(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x18(%rbp),%xmm0
subsd  -0x10(%rbp),%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movl   $0x1,-0x3c(%rbp)
movsd  0xe22(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1239 <nc1+0x119>
movsd  -0x10(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <_f@plt>
cvtsi2sd %eax,%xmm0
addsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
movsd  0xdd6(%rip),%xmm0
addsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    11e3 <nc1+0xc3>
movsd  -0x38(%rbp),%xmm0
mulsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nc1>:
push   %rbp
push   %rbx
sub    $0x28,%rsp
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x10(%rsp)
cmp    $0x1,%edi
jg     1155 <nc1+0x35>
mov    0x2ea2(%rip),%rax
mov    (%rax),%edi
lea    0xec9(%rip),%rsi
call   1030 <fprintf@plt>
xorpd  %xmm0,%xmm0
jmp    120f <nc1+0xef>
xorpd  %xmm0,%xmm0
movsd  0x10(%rsp),%xmm1
ucomisd 0x8(%rsp),%xmm1
jne    116d <nc1+0x4d>
jnp    120f <nc1+0xef>
mov    %edi,%ebx
movsd  0x10(%rsp),%xmm0
call   1040 <_f@plt>
mov    %eax,%ebp
movsd  0x8(%rsp),%xmm0
call   1040 <_f@plt>
add    %ebp,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mulsd  0xe68(%rip),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
movsd  0x8(%rsp),%xmm2
subsd  0x10(%rsp),%xmm2
divsd  %xmm0,%xmm2
movsd  %xmm2,0x8(%rsp)
add    $0xffffffff,%ebx
movsd  0xe48(%rip),%xmm2
movsd  %xmm2,0x18(%rsp)
movsd  %xmm1,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
mulsd  %xmm2,%xmm0
addsd  0x10(%rsp),%xmm0
call   1040 <_f@plt>
movsd  0x18(%rsp),%xmm2
movsd  0x20(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  %xmm0,%xmm1
addsd  0xe08(%rip),%xmm2
add    $0xffffffff,%ebx
jne    11c0 <nc1+0xa0>
movsd  0x8(%rsp),%xmm0
mulsd  %xmm1,%xmm0
add    $0x28,%rsp
pop    %rbx
pop    %rbp
ret

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

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