double Iq(double q, double radius, double fractal_dim_mass,
          double cutoff_length) {
  const double pq = square(sas_3j1x_x(q * radius));
  double sq;
  if (q > 0. && fractal_dim_mass > 1.) {
    const double Dm1 = fractal_dim_mass - 1.0;
    const double t1 = sas_gamma(Dm1) * sin(Dm1 * atan(q * cutoff_length));
    const double t2 = pow(cutoff_length, Dm1);
    const double t3 = pow(1.0 + square(q * cutoff_length), -0.5 * Dm1);
    sq = t1 * t2 * t3 / q;
  } else if (q > 0.) {
    sq = atan(q * cutoff_length) / q;
  } else if (fractal_dim_mass > 1.) {
    const double D = fractal_dim_mass;
    sq = pow(cutoff_length, D) * sas_gamma(D);
  } else {
    sq = cutoff_length;
  }
  return pq * sq;
}


x86 assembly (clang, -O0):
<Iq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movsd  %xmm2,-0x18(%rbp)
movsd  %xmm3,-0x20(%rbp)
movsd  -0x8(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
mov    $0x1,%al
call   1080 <sas_3j1x_x@plt>
mov    %eax,%edi
mov    $0x0,%al
call   1030 <square@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1298 <Iq+0x138>
movsd  -0x18(%rbp),%xmm0
movsd  0xe42(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1298 <Iq+0x138>
movsd  -0x18(%rbp),%xmm0
movsd  0xe2b(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
mov    $0x1,%al
call   1060 <sas_gamma@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x38(%rbp),%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x8(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1050 <atan@plt>
movaps %xmm0,%xmm1
movsd  -0x68(%rbp),%xmm0
mulsd  %xmm1,%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
call   1070 <pow@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x8(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
mov    $0x1,%al
call   1030 <square@plt>
cvtsi2sd %eax,%xmm1
movsd  0xda1(%rip),%xmm0
addsd  %xmm1,%xmm0
movsd  0xd9d(%rip),%xmm1
mulsd  -0x38(%rbp),%xmm1
call   1070 <pow@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x40(%rbp),%xmm0
mulsd  -0x48(%rbp),%xmm0
mulsd  -0x50(%rbp),%xmm0
divsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    1334 <Iq+0x1d4>
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    12c8 <Iq+0x168>
movsd  -0x8(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
call   1050 <atan@plt>
divsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    132f <Iq+0x1cf>
movsd  -0x18(%rbp),%xmm0
movsd  0xd2b(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1320 <Iq+0x1c0>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  -0x58(%rbp),%xmm1
call   1070 <pow@plt>
movsd  %xmm0,-0x70(%rbp)
movsd  -0x58(%rbp),%xmm0
mov    $0x1,%al
call   1060 <sas_gamma@plt>
movsd  -0x70(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    132a <Iq+0x1ca>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    132f <Iq+0x1cf>
jmp    1334 <Iq+0x1d4>
movsd  -0x28(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Iq>:
push   %rbx
sub    $0x30,%rsp
movsd  %xmm3,0x8(%rsp)
movsd  %xmm2,0x10(%rsp)
movsd  %xmm0,0x18(%rsp)
mulsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
mov    $0x1,%al
call   1080 <sas_3j1x_x@plt>
mov    %eax,%edi
xor    %eax,%eax
call   1030 <square@plt>
movsd  0x10(%rsp),%xmm2
movsd  0x18(%rsp),%xmm1
mov    %eax,%ebx
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm1
jbe    126b <Iq+0x10b>
ucomisd 0xe4d(%rip),%xmm2
jbe    126b <Iq+0x10b>
addsd  0xe47(%rip),%xmm2
movsd  %xmm2,0x10(%rsp)
movapd %xmm2,%xmm0
mov    $0x1,%al
call   1060 <sas_gamma@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  0x18(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x28(%rsp)
call   1050 <atan@plt>
mulsd  0x10(%rsp),%xmm0
call   1040 <sin@plt>
mulsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x20(%rsp)
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
call   1070 <pow@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x28(%rsp),%xmm0
mov    $0x1,%al
call   1030 <square@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
addsd  0xdc0(%rip),%xmm0
movsd  0x10(%rsp),%xmm1
mulsd  0xdc2(%rip),%xmm1
call   1070 <pow@plt>
movsd  0x8(%rsp),%xmm1
mulsd  0x20(%rsp),%xmm1
mulsd  %xmm0,%xmm1
divsd  0x18(%rsp),%xmm1
jmp    12c9 <Iq+0x169>
ucomisd %xmm0,%xmm1
jbe    128c <Iq+0x12c>
movsd  0x8(%rsp),%xmm0
mulsd  %xmm1,%xmm0
call   1050 <atan@plt>
movapd %xmm0,%xmm1
divsd  0x18(%rsp),%xmm1
jmp    12c9 <Iq+0x169>
ucomisd 0xd6c(%rip),%xmm2
movsd  0x8(%rsp),%xmm1
jbe    12c9 <Iq+0x169>
movapd %xmm1,%xmm0
movapd %xmm2,%xmm1
call   1070 <pow@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
mov    $0x1,%al
call   1060 <sas_gamma@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
mulsd  0x8(%rsp),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sd %ebx,%xmm0
mulsd  %xmm1,%xmm0
add    $0x30,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define double @Iq(double %0, double %1, double %2, double %3) {
%5 = alloca double
%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 double
%15 = alloca double
store double %0, double* %5
store double %1, double* %6
store double %2, double* %7
store double %3, double* %8
%16 = load double, double* %5
%17 = load double, double* %6
%18 = fmul double %16, %17
%19 = call i32 (double, ...) bitcast (i32 (...)* @sas_3j1x_x to i32 (double, ...)*)(double %18)
%20 = call i32 (i32, ...) bitcast (i32 (...)* @square to i32 (i32, ...)*)(i32 %19)
%21 = sitofp i32 %20 to double
store double %21, double* %9
%22 = load double, double* %5
%23 = fcmp ogt double %22, 0.000000e+00
br i1 %23, label %24, label %60
24: ; preds = %4
%25 = load double, double* %7
%26 = fcmp ogt double %25, 1.000000e+00
br i1 %26, label %27, label %60
27: ; preds = %24
%28 = load double, double* %7
%29 = fsub double %28, 1.000000e+00
store double %29, double* %11
%30 = load double, double* %11
%31 = call i32 (double, ...) bitcast (i32 (...)* @sas_gamma to i32 (double, ...)*)(double %30)
%32 = sitofp i32 %31 to double
%33 = load double, double* %11
%34 = load double, double* %5
%35 = load double, double* %8
%36 = fmul double %34, %35
%37 = call double @atan(double %36)
%38 = fmul double %33, %37
%39 = call double @sin(double %38)
%40 = fmul double %32, %39
store double %40, double* %12
%41 = load double, double* %8
%42 = load double, double* %11
%43 = call double @pow(double %41, double %42)
store double %43, double* %13
%44 = load double, double* %5
%45 = load double, double* %8
%46 = fmul double %44, %45
%47 = call i32 (double, ...) bitcast (i32 (...)* @square to i32 (double, ...)*)(double %46)
%48 = sitofp i32 %47 to double
%49 = fadd double 1.000000e+00, %48
%50 = load double, double* %11
%51 = fmul double -5.000000e-01, %50
%52 = call double @pow(double %49, double %51)
store double %52, double* %14
%53 = load double, double* %12
%54 = load double, double* %13
%55 = fmul double %53, %54
%56 = load double, double* %14
%57 = fmul double %55, %56
%58 = load double, double* %5
%59 = fdiv double %57, %58
store double %59, double* %10
br label %86
60: ; preds = %24, %4
%61 = load double, double* %5
%62 = fcmp ogt double %61, 0.000000e+00
br i1 %62, label %63, label %70
63: ; preds = %60
%64 = load double, double* %5
%65 = load double, double* %8
%66 = fmul double %64, %65
%67 = call double @atan(double %66)
%68 = load double, double* %5
%69 = fdiv double %67, %68
store double %69, double* %10
br label %85
70: ; preds = %60
%71 = load double, double* %7
%72 = fcmp ogt double %71, 1.000000e+00
br i1 %72, label %73, label %82
73: ; preds = %70
%74 = load double, double* %7
store double %74, double* %15
%75 = load double, double* %8
%76 = load double, double* %15
%77 = call double @pow(double %75, double %76)
%78 = load double, double* %15
%79 = call i32 (double, ...) bitcast (i32 (...)* @sas_gamma to i32 (double, ...)*)(double %78)
%80 = sitofp i32 %79 to double
%81 = fmul double %77, %80
store double %81, double* %10
br label %84
82: ; preds = %70
%83 = load double, double* %8
store double %83, double* %10
br label %84
84: ; preds = %82, %73
br label %85
85: ; preds = %84, %63
br label %86
86: ; preds = %85, %27
%87 = load double, double* %9
%88 = load double, double* %10
%89 = fmul double %87, %88
ret double %89
}

LLVM IR (-O2):
define double @Iq(double %0, double %1, double %2, double %3) {
%5 = fmul double %0, %1
%6 = tail call i32 (double, ...) bitcast (i32 (...)* @sas_3j1x_x to i32 (double, ...)*)(double %5)
%7 = tail call i32 (i32, ...) bitcast (i32 (...)* @square to i32 (i32, ...)*)(i32 %6)
%8 = fcmp ogt double %0, 0.000000e+00
%9 = fcmp ogt double %2, 1.000000e+00
%10 = and i1 %8, %9
br i1 %10, label %11, label %29
11: ; preds = %4
%12 = fadd double %2, -1.000000e+00
%13 = tail call i32 (double, ...) bitcast (i32 (...)* @sas_gamma to i32 (double, ...)*)(double %12)
%14 = sitofp i32 %13 to double
%15 = fmul double %0, %3
%16 = tail call double @atan(double %15)
%17 = fmul double %12, %16
%18 = tail call double @sin(double %17)
%19 = fmul double %18, %14
%20 = tail call double @pow(double %3, double %12)
%21 = tail call i32 (double, ...) bitcast (i32 (...)* @square to i32 (double, ...)*)(double %15)
%22 = sitofp i32 %21 to double
%23 = fadd double %22, 1.000000e+00
%24 = fmul double %12, -5.000000e-01
%25 = tail call double @pow(double %23, double %24)
%26 = fmul double %19, %20
%27 = fmul double %26, %25
%28 = fdiv double %27, %0
br label %40
29: ; preds = %4
br i1 %8, label %30, label %34
30: ; preds = %29
%31 = fmul double %0, %3
%32 = tail call double @atan(double %31)
%33 = fdiv double %32, %0
br label %40
34: ; preds = %29
br i1 %9, label %35, label %40
35: ; preds = %34
%36 = tail call double @pow(double %3, double %2)
%37 = tail call i32 (double, ...) bitcast (i32 (...)* @sas_gamma to i32 (double, ...)*)(double %2)
%38 = sitofp i32 %37 to double
%39 = fmul double %36, %38
br label %40
40: ; preds = %34, %30, %35, %11
%41 = phi double [ %28, %11 ], [ %33, %30 ], [ %39, %35 ], [ %3, %34 ]
%42 = sitofp i32 %7 to double
%43 = fmul double %41, %42
ret double %43
}