#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 simpson1D(double, int, double (*)(double, double, void *),
              double (*)(double, void *), double (*)(double, void *), void *);
double simpson2D(double a, double b, int sdiv, int sdiv2,
                 double (*f)(double, double, void *),
                 double (*c)(double, void *), double (*d)(double, void *),
                 void *info) {
  double h, sum1 = 0, sum2 = 0;
  int i;
  h = ((double)b - a) / ((double)2 * sdiv);
  for (i = 1; i < sdiv; i++) {
    sum1 += simpson1D((a + h * 2 * (i)), sdiv2, f, c, d, info);
    sum2 += simpson1D((a + h * (2 * i - 1)), sdiv2, f, c, d, info);
  }
  sum2 += simpson1D((a + h * (2 * i - 1)), sdiv2, f, c, d, info);
  return ((double)(h / 3) *
          (simpson1D(a, sdiv2, f, c, d, info) +
           simpson1D(b, sdiv2, f, c, d, info) + 2 * sum1 + 4 * sum2));
}


x86 assembly (clang, -O0):
<simpson2D>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
mov    %esi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x8(%rbp),%xmm0
cvtsi2sdl -0x14(%rbp),%xmm2
movsd  0xea1(%rip),%xmm1
mulsd  %xmm2,%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x1,-0x54(%rbp)
mov    -0x54(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1217 <simpson2D+0x107>
movsd  -0x8(%rbp),%xmm1
movsd  0xe74(%rip),%xmm0
mulsd  -0x40(%rbp),%xmm0
cvtsi2sdl -0x54(%rbp),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%r8
call   1030 <simpson1D@plt>
cvtsi2sd %eax,%xmm0
addsd  -0x48(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x8(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
mov    -0x54(%rbp),%eax
shl    $0x1,%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%r8
call   1030 <simpson1D@plt>
cvtsi2sd %eax,%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1173 <simpson2D+0x63>
movsd  -0x8(%rbp),%xmm1
movsd  -0x40(%rbp),%xmm0
mov    -0x54(%rbp),%eax
shl    $0x1,%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x18(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%r8
call   1030 <simpson1D@plt>
cvtsi2sd %eax,%xmm0
addsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  0xda7(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    -0x18(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%r8
call   1030 <simpson1D@plt>
mov    %eax,-0x58(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    -0x18(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%r8
call   1030 <simpson1D@plt>
movsd  -0x60(%rbp),%xmm0
mov    %eax,%ecx
mov    -0x58(%rbp),%eax
add    %ecx,%eax
cvtsi2sd %eax,%xmm1
movsd  -0x48(%rbp),%xmm2
addsd  %xmm2,%xmm2
addsd  %xmm1,%xmm2
movsd  -0x50(%rbp),%xmm1
movsd  0xd2f(%rip),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<simpson2D>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %r9,%r14
mov    %r8,%r12
mov    %rcx,%rbx
mov    %rdx,%r15
mov    %esi,%ebp
movapd %xmm0,%xmm3
movsd  %xmm1,0x60(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %edi,%xmm0
subsd  %xmm3,%xmm1
addsd  %xmm0,%xmm0
divsd  %xmm0,%xmm1
cmp    $0x2,%edi
movsd  %xmm3,0x28(%rsp)
movsd  %xmm1,0x10(%rsp)
jl     12a8 <simpson2D+0x198>
movapd %xmm1,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,0x68(%rsp)
mov    %rdi,%rax
mov    %rdi,0x58(%rsp)
lea    -0x1(%rdi),%eax
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0xe77(%rip),%xmm2
mov    %r12,0x48(%rsp)
mov    %rbx,0x40(%rsp)
mov    %r15,0x50(%rsp)
mov    %ebp,0x1c(%rsp)
mov    %r14,0x38(%rsp)
mov    $0x1,%r14d
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x20(%rsp)
mov    0x1c(%rsp),%r15d
mov    0x50(%rsp),%r12
mov    0x40(%rsp),%rbp
mov    0x48(%rsp),%rbx
mov    0x38(%rsp),%r13
nopw   0x0(%rax,%rax,1)
movsd  %xmm2,0x70(%rsp)
mov    %eax,0x34(%rsp)
movsd  0x68(%rsp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm3,%xmm0
mov    %r15d,%edi
mov    %r12,%rsi
mov    %rbp,%rdx
mov    %rbx,%rcx
mov    %r13,%r8
call   1030 <simpson1D@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x20(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x20(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
mulsd  0x10(%rsp),%xmm0
addsd  0x28(%rsp),%xmm0
mov    %r15d,%edi
mov    %r12,%rsi
mov    %rbp,%rdx
mov    %rbx,%rcx
mov    %r13,%r8
call   1030 <simpson1D@plt>
movsd  0x70(%rsp),%xmm2
movsd  0x28(%rsp),%xmm3
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mov    0x34(%rsp),%eax
movsd  0x8(%rsp),%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
addsd  0xd96(%rip),%xmm2
add    $0x2,%r14d
add    $0xffffffff,%eax
jne    11d0 <simpson2D+0xc0>
mov    0x58(%rsp),%rax
add    %eax,%eax
add    $0xffffffff,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x10(%rsp),%xmm1
mov    0x38(%rsp),%r14
mov    0x48(%rsp),%r12
mov    0x40(%rsp),%rbx
mov    0x50(%rsp),%r15
mov    0x1c(%rsp),%ebp
jmp    12c4 <simpson2D+0x1b4>
movsd  0xd50(%rip),%xmm0
xorpd  %xmm2,%xmm2
movsd  %xmm2,0x20(%rsp)
xorpd  %xmm2,%xmm2
movsd  %xmm2,0x8(%rsp)
mulsd  %xmm1,%xmm0
addsd  %xmm3,%xmm0
mov    %ebp,%edi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
mov    %r14,%r8
call   1030 <simpson1D@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
divsd  0xd08(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
movsd  0x28(%rsp),%xmm0
mov    %ebp,%edi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
mov    %r14,%r8
call   1030 <simpson1D@plt>
mov    %eax,%r13d
movsd  0x60(%rsp),%xmm0
mov    %ebp,%edi
mov    %r15,%rsi
mov    %rbx,%rdx
mov    %r12,%rcx
mov    %r14,%r8
call   1030 <simpson1D@plt>
add    %r13d,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  0x20(%rsp),%xmm1
addsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm0
mulsd  0xcaf(%rip),%xmm0
addsd  %xmm1,%xmm0
mulsd  0x10(%rsp),%xmm0
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define double @simpson2D(double %0, double %1, i32 %2, i32 %3, double (double, double, i8*)* %4, double (double, i8*)* %5, double (double, i8*)* %6, i8* %7) {
%9 = fsub double %1, %0
%10 = sitofp i32 %2 to double
%11 = fmul double %10, 2.000000e+00
%12 = fdiv double %9, %11
%13 = icmp sgt i32 %2, 1
br i1 %13, label %14, label %38
14: ; preds = %8
%15 = fmul double %12, 2.000000e+00
br label %16
16: ; preds = %14, %16
%17 = phi i32 [ 1, %14 ], [ %32, %16 ]
%18 = phi double [ 0.000000e+00, %14 ], [ %31, %16 ]
%19 = phi double [ 0.000000e+00, %14 ], [ %24, %16 ]
%20 = sitofp i32 %17 to double
%21 = tail call double @llvm.fmuladd.f64(double %15, double %20, double %0)
%22 = tail call i32 @simpson1D(double %21, i32 %3, double (double, double, i8*)* %4, double (double, i8*)* %5, double (double, i8*)* %6, i8* %7)
%23 = sitofp i32 %22 to double
%24 = fadd double %19, %23
%25 = shl nuw nsw i32 %17, 1
%26 = add nsw i32 %25, -1
%27 = sitofp i32 %26 to double
%28 = tail call double @llvm.fmuladd.f64(double %12, double %27, double %0)
%29 = tail call i32 @simpson1D(double %28, i32 %3, double (double, double, i8*)* %4, double (double, i8*)* %5, double (double, i8*)* %6, i8* %7)
%30 = sitofp i32 %29 to double
%31 = fadd double %18, %30
%32 = add nuw nsw i32 %17, 1
%33 = icmp eq i32 %32, %2
br i1 %33, label %34, label %16
34: ; preds = %16
%35 = shl i32 %2, 1
%36 = add i32 %35, -1
%37 = sitofp i32 %36 to double
br label %38
38: ; preds = %34, %8
%39 = phi double [ 0.000000e+00, %8 ], [ %24, %34 ]
%40 = phi double [ 0.000000e+00, %8 ], [ %31, %34 ]
%41 = phi double [ 1.000000e+00, %8 ], [ %37, %34 ]
%42 = tail call double @llvm.fmuladd.f64(double %12, double %41, double %0)
%43 = tail call i32 @simpson1D(double %42, i32 %3, double (double, double, i8*)* %4, double (double, i8*)* %5, double (double, i8*)* %6, i8* %7)
%44 = sitofp i32 %43 to double
%45 = fadd double %40, %44
%46 = fdiv double %12, 3.000000e+00
%47 = tail call i32 @simpson1D(double %0, i32 %3, double (double, double, i8*)* %4, double (double, i8*)* %5, double (double, i8*)* %6, i8* %7)
%48 = tail call i32 @simpson1D(double %1, i32 %3, double (double, double, i8*)* %4, double (double, i8*)* %5, double (double, i8*)* %6, i8* %7)
%49 = add nsw i32 %48, %47
%50 = sitofp i32 %49 to double
%51 = tail call double @llvm.fmuladd.f64(double %39, double 2.000000e+00, double %50)
%52 = tail call double @llvm.fmuladd.f64(double %45, double 4.000000e+00, double %51)
%53 = fmul double %46, %52
ret double %53
}