#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 M_PI;
double log(double);
double sqrt(int);
double intensity(double r, double u1, double u2, double u3, double u4,
                 double u5, double u6) {
  if (r > 0.99995)
    r = 0.99995;
  double mu = sqrt(1. - r * r);
  double norm = 2. * M_PI *
                (-u1 / 6. - u2 * u3 / 2. + u2 / 4. + 0.5 +
                 u2 * u3 * u3 * log(1. + 1. / u3) / 2.);
  return (1. - u1 * (1. - mu) - u2 * log((mu + u3) / (1. + u3))) / norm;
}


x86 assembly (clang, -O0):
<intensity>:
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  %xmm4,-0x28(%rbp)
movsd  %xmm5,-0x30(%rbp)
movsd  %xmm6,-0x38(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xea8(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    116f <intensity+0x4f>
movsd  0xe96(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe6c(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movsd  %xmm0,-0x40(%rbp)
mov    0x2e33(%rip),%rax
cvtsi2sdl (%rax),%xmm1
movsd  0xe4f(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  -0x10(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xe3a(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  -0x18(%rbp),%xmm1
mulsd  -0x20(%rbp),%xmm1
movsd  0xe0c(%rip),%xmm2
divsd  %xmm2,%xmm1
subsd  %xmm1,%xmm0
movsd  -0x18(%rbp),%xmm1
movsd  0xe07(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  0xdef(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x68(%rbp)
movsd  -0x18(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  0xdba(%rip),%xmm1
divsd  -0x20(%rbp),%xmm1
movsd  0xdad(%rip),%xmm0
addsd  %xmm1,%xmm0
call   1030 <log@plt>
movsd  -0x70(%rbp),%xmm2
movsd  -0x68(%rbp),%xmm1
movaps %xmm0,%xmm3
movsd  -0x60(%rbp),%xmm0
mulsd  %xmm3,%xmm2
movsd  0xd8e(%rip),%xmm3
divsd  %xmm3,%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xd68(%rip),%xmm1
subsd  -0x40(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xd40(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x40(%rbp),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  0xd1b(%rip),%xmm1
addsd  -0x20(%rbp),%xmm1
divsd  %xmm1,%xmm0
call   1030 <log@plt>
movsd  -0x58(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x50(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
divsd  -0x48(%rbp),%xmm0
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<intensity>:
sub    $0x38,%rsp
movsd  %xmm3,0x10(%rsp)
movsd  %xmm2,0x18(%rsp)
movsd  %xmm1,(%rsp)
movsd  0xec3(%rip),%xmm1
minsd  %xmm0,%xmm1
mulsd  %xmm1,%xmm1
movsd  0xebb(%rip),%xmm0
subsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1040 <sqrt@plt>
movsd  %xmm0,0x30(%rsp)
mov    0x2e81(%rip),%rax
xorps  %xmm1,%xmm1
cvtsi2sdl (%rax),%xmm1
movsd  (%rsp),%xmm0
divsd  0xe95(%rip),%xmm0
addsd  %xmm1,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x18(%rsp),%xmm2
movapd %xmm2,%xmm5
movsd  0x10(%rsp),%xmm3
mulsd  %xmm3,%xmm5
movsd  0xe77(%rip),%xmm4
movapd %xmm5,%xmm1
mulsd  %xmm4,%xmm1
subsd  %xmm1,%xmm0
movsd  0xe6b(%rip),%xmm1
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
addsd  %xmm4,%xmm1
movsd  %xmm1,0x28(%rsp)
movapd %xmm3,%xmm1
mulsd  %xmm3,%xmm5
movsd  %xmm5,0x20(%rsp)
movsd  0xe2b(%rip),%xmm2
movapd %xmm2,%xmm0
divsd  %xmm1,%xmm0
addsd  %xmm2,%xmm0
call   1030 <log@plt>
mulsd  0x20(%rsp),%xmm0
mulsd  0xe1c(%rip),%xmm0
addsd  0x28(%rsp),%xmm0
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0xdf2(%rip),%xmm2
movapd %xmm2,%xmm0
movsd  0x30(%rsp),%xmm3
subsd  %xmm3,%xmm0
mulsd  (%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
addsd  %xmm1,%xmm3
addsd  %xmm2,%xmm1
subsd  %xmm0,%xmm2
movsd  %xmm2,(%rsp)
divsd  %xmm1,%xmm3
movapd %xmm3,%xmm0
call   1030 <log@plt>
mulsd  0x18(%rsp),%xmm0
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
divsd  0x8(%rsp),%xmm1
movapd %xmm1,%xmm0
add    $0x38,%rsp
ret

LLVM IR (-O0):
@M_PI = global i32 0
define double @intensity(double %0, double %1, double %2, double %3, double %4, double %5, double %6) {
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
%15 = alloca double
%16 = alloca double
store double %0, double* %8
store double %1, double* %9
store double %2, double* %10
store double %3, double* %11
store double %4, double* %12
store double %5, double* %13
store double %6, double* %14
%17 = load double, double* %8
%18 = fcmp ogt double %17, 9.999500e-01
br i1 %18, label %19, label %20
19: ; preds = %7
store double 9.999500e-01, double* %8
br label %20
20: ; preds = %19, %7
%21 = load double, double* %8
%22 = load double, double* %8
%23 = fneg double %21
%24 = call double @llvm.fmuladd.f64(double %23, double %22, double 1.000000e+00)
%25 = fptosi double %24 to i32
%26 = call double @sqrt(i32 %25)
store double %26, double* %15
%27 = load i32, i32* @M_PI
%28 = sitofp i32 %27 to double
%29 = fmul double 2.000000e+00, %28
%30 = load double, double* %9
%31 = fneg double %30
%32 = fdiv double %31, 6.000000e+00
%33 = load double, double* %10
%34 = load double, double* %11
%35 = fmul double %33, %34
%36 = fdiv double %35, 2.000000e+00
%37 = fsub double %32, %36
%38 = load double, double* %10
%39 = fdiv double %38, 4.000000e+00
%40 = fadd double %37, %39
%41 = fadd double %40, 5.000000e-01
%42 = load double, double* %10
%43 = load double, double* %11
%44 = fmul double %42, %43
%45 = load double, double* %11
%46 = fmul double %44, %45
%47 = load double, double* %11
%48 = fdiv double 1.000000e+00, %47
%49 = fadd double 1.000000e+00, %48
%50 = call double @log(double %49)
%51 = fmul double %46, %50
%52 = fdiv double %51, 2.000000e+00
%53 = fadd double %41, %52
%54 = fmul double %29, %53
store double %54, double* %16
%55 = load double, double* %9
%56 = load double, double* %15
%57 = fsub double 1.000000e+00, %56
%58 = fneg double %55
%59 = call double @llvm.fmuladd.f64(double %58, double %57, double 1.000000e+00)
%60 = load double, double* %10
%61 = load double, double* %15
%62 = load double, double* %11
%63 = fadd double %61, %62
%64 = load double, double* %11
%65 = fadd double 1.000000e+00, %64
%66 = fdiv double %63, %65
%67 = call double @log(double %66)
%68 = fneg double %60
%69 = call double @llvm.fmuladd.f64(double %68, double %67, double %59)
%70 = load double, double* %16
%71 = fdiv double %69, %70
ret double %71
}

LLVM IR (-O2):
@M_PI = global i32 0
define double @intensity(double %0, double %1, double %2, double %3, double %4, double %5, double %6) {
%8 = fcmp ogt double %0, 9.999500e-01
%9 = select i1 %8, double 9.999500e-01, double %0
%10 = fneg double %9
%11 = tail call double @llvm.fmuladd.f64(double %10, double %9, double 1.000000e+00)
%12 = fptosi double %11 to i32
%13 = tail call double @sqrt(i32 %12)
%14 = load i32, i32* @M_PI
%15 = sitofp i32 %14 to double
%16 = fmul double %15, 2.000000e+00
%17 = fneg double %1
%18 = fdiv double %1, -6.000000e+00
%19 = fmul double %2, %3
%20 = fmul double %19, 5.000000e-01
%21 = fsub double %18, %20
%22 = fmul double %2, 2.500000e-01
%23 = fadd double %22, %21
%24 = fadd double %23, 5.000000e-01
%25 = fmul double %19, %3
%26 = fdiv double 1.000000e+00, %3
%27 = fadd double %26, 1.000000e+00
%28 = tail call double @log(double %27)
%29 = fmul double %25, %28
%30 = fmul double %29, 5.000000e-01
%31 = fadd double %24, %30
%32 = fmul double %16, %31
%33 = fsub double 1.000000e+00, %13
%34 = tail call double @llvm.fmuladd.f64(double %17, double %33, double 1.000000e+00)
%35 = fadd double %13, %3
%36 = fadd double %3, 1.000000e+00
%37 = fdiv double %35, %36
%38 = tail call double @log(double %37)
%39 = fneg double %2
%40 = tail call double @llvm.fmuladd.f64(double %39, double %38, double %34)
%41 = fdiv double %40, %32
ret double %41
}