#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 /*<<< orphan*/ _integrate_bessel(double, double, double, double, double,
                                     int, double *, double *);
double _sum_bessel_orders(double radius, double alpha, double beta,
                          double q_sin_psi, double q_cos_psi) {
  double Sn, Cn, sum;
  sum = 0.0;
  for (int n = 3; n > 0; n--) {
    _integrate_bessel(radius, alpha, beta, q_sin_psi, q_cos_psi, n, &Sn, &Cn);
    sum += 2.0 * (Sn * Sn + Cn * Cn);
  }
  _integrate_bessel(radius, alpha, beta, q_sin_psi, q_cos_psi, 0, &Sn, &Cn);
  sum += Sn * Sn + Cn * Cn;
  return sum;
}


x86 assembly (clang, -O0):
<_sum_bessel_orders>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  %xmm4,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movl   $0x3,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jle    11af <_sum_bessel_orders+0x9f>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm3
movsd  -0x28(%rbp),%xmm4
mov    -0x44(%rbp),%edi
lea    -0x30(%rbp),%rsi
lea    -0x38(%rbp),%rdx
call   1030 <_integrate_bessel@plt>
movsd  -0x30(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x40(%rbp),%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
mov    -0x44(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x44(%rbp)
jmp    1140 <_sum_bessel_orders+0x30>
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  -0x18(%rbp),%xmm2
movsd  -0x20(%rbp),%xmm3
movsd  -0x28(%rbp),%xmm4
xor    %edi,%edi
lea    -0x30(%rbp),%rsi
lea    -0x38(%rbp),%rdx
call   1030 <_integrate_bessel@plt>
movsd  -0x30(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm2
movsd  -0x38(%rbp),%xmm1
mulsd  -0x38(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
addsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_sum_bessel_orders>:
push   %r14
push   %rbx
sub    $0x48,%rsp
movsd  %xmm4,0x40(%rsp)
movsd  %xmm3,0x38(%rsp)
movsd  %xmm2,0x30(%rsp)
movsd  %xmm1,0x28(%rsp)
movsd  %xmm0,0x20(%rsp)
lea    0x18(%rsp),%rbx
lea    0x10(%rsp),%r14
mov    $0x3,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <_integrate_bessel@plt>
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
addsd  %xmm0,%xmm0
xorpd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x20(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
movsd  0x30(%rsp),%xmm2
movsd  0x38(%rsp),%xmm3
movsd  0x40(%rsp),%xmm4
mov    $0x2,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <_integrate_bessel@plt>
movsd  0x18(%rsp),%xmm1
movsd  0x10(%rsp),%xmm0
mulsd  %xmm0,%xmm0
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
addsd  %xmm1,%xmm1
addsd  0x8(%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x20(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
movsd  0x30(%rsp),%xmm2
movsd  0x38(%rsp),%xmm3
movsd  0x40(%rsp),%xmm4
mov    $0x1,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <_integrate_bessel@plt>
movsd  0x18(%rsp),%xmm1
movsd  0x10(%rsp),%xmm0
mulsd  %xmm0,%xmm0
mulsd  %xmm1,%xmm1
addsd  %xmm0,%xmm1
addsd  %xmm1,%xmm1
addsd  0x8(%rsp),%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x20(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
movsd  0x30(%rsp),%xmm2
movsd  0x38(%rsp),%xmm3
movsd  0x40(%rsp),%xmm4
xor    %edi,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <_integrate_bessel@plt>
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
addsd  0x8(%rsp),%xmm0
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define double @_sum_bessel_orders(double %0, double %1, double %2, double %3, double %4) {
%6 = alloca double
%7 = alloca double
%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* %6
store double %1, double* %7
store double %2, double* %8
store double %3, double* %9
store double %4, double* %10
store double 0.000000e+00, double* %13
store i32 3, i32* %14
br label %15
15: ; preds = %34, %5
%16 = load i32, i32* %14
%17 = icmp sgt i32 %16, 0
br i1 %17, label %18, label %37
18: ; preds = %15
%19 = load double, double* %6
%20 = load double, double* %7
%21 = load double, double* %8
%22 = load double, double* %9
%23 = load double, double* %10
%24 = load i32, i32* %14
%25 = call i32 @_integrate_bessel(double %19, double %20, double %21, double %22, double %23, i32 %24, double* %11, double* %12)
%26 = load double, double* %11
%27 = load double, double* %11
%28 = load double, double* %12
%29 = load double, double* %12
%30 = fmul double %28, %29
%31 = call double @llvm.fmuladd.f64(double %26, double %27, double %30)
%32 = load double, double* %13
%33 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %31, double %32)
store double %33, double* %13
br label %34
34: ; preds = %18
%35 = load i32, i32* %14
%36 = add nsw i32 %35, -1
store i32 %36, i32* %14
br label %15
37: ; preds = %15
%38 = load double, double* %6
%39 = load double, double* %7
%40 = load double, double* %8
%41 = load double, double* %9
%42 = load double, double* %10
%43 = call i32 @_integrate_bessel(double %38, double %39, double %40, double %41, double %42, i32 0, double* %11, double* %12)
%44 = load double, double* %11
%45 = load double, double* %11
%46 = load double, double* %12
%47 = load double, double* %12
%48 = fmul double %46, %47
%49 = call double @llvm.fmuladd.f64(double %44, double %45, double %48)
%50 = load double, double* %13
%51 = fadd double %50, %49
store double %51, double* %13
%52 = load double, double* %13
ret double %52
}

LLVM IR (-O2):
define double @_sum_bessel_orders(double %0, double %1, double %2, double %3, double %4) {
%6 = alloca double
%7 = alloca double
%8 = bitcast double* %6 to i8*
%9 = bitcast double* %7 to i8*
%10 = call i32 @_integrate_bessel(double %0, double %1, double %2, double %3, double %4, i32 3, double* %6, double* %7)
%11 = load double, double* %6
%12 = load double, double* %7
%13 = fmul double %12, %12
%14 = call double @llvm.fmuladd.f64(double %11, double %11, double %13)
%15 = call double @llvm.fmuladd.f64(double %14, double 2.000000e+00, double 0.000000e+00)
%16 = call i32 @_integrate_bessel(double %0, double %1, double %2, double %3, double %4, i32 2, double* %6, double* %7)
%17 = load double, double* %6
%18 = load double, double* %7
%19 = fmul double %18, %18
%20 = call double @llvm.fmuladd.f64(double %17, double %17, double %19)
%21 = call double @llvm.fmuladd.f64(double %20, double 2.000000e+00, double %15)
%22 = call i32 @_integrate_bessel(double %0, double %1, double %2, double %3, double %4, i32 1, double* %6, double* %7)
%23 = load double, double* %6
%24 = load double, double* %7
%25 = fmul double %24, %24
%26 = call double @llvm.fmuladd.f64(double %23, double %23, double %25)
%27 = call double @llvm.fmuladd.f64(double %26, double 2.000000e+00, double %21)
%28 = call i32 @_integrate_bessel(double %0, double %1, double %2, double %3, double %4, i32 0, double* %6, double* %7)
%29 = load double, double* %6
%30 = load double, double* %7
%31 = fmul double %30, %30
%32 = call double @llvm.fmuladd.f64(double %29, double %29, double %31)
%33 = fadd double %27, %32
ret double %33
}