#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 */
double sin(double);
double tan(double);
double rho(double theta, double theta_2) {
  double a, b;
  double s_theta_m, s_theta_p;
  s_theta_m = sin(theta - theta_2);
  s_theta_p = sin(theta + theta_2);
  if (s_theta_m < -1.)
    s_theta_m = -1.;
  else if (s_theta_m > 1.)
    s_theta_m = 1.;
  if (s_theta_p < -1.)
    s_theta_p = -1.;
  else if (s_theta_p > 1.)
    s_theta_p = 1.;
  if (theta == 0.)
    return 0.0347806944734;
  else if (theta == 3.14159265359 / 2.)
    return 0.;
  else {
    a = (tan(theta - theta_2) / tan(theta + theta_2)) *
        (tan(theta - theta_2) / tan(theta + theta_2));
    b = (s_theta_m / s_theta_p) * (s_theta_m / s_theta_p);
    return 0.5 * (a + b);
  }
}


x86 assembly (clang, -O0):
<rho>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
call   1030 <sin@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  0xe9e(%rip),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    117f <rho+0x5f>
movsd  0xe8b(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    11a8 <rho+0x88>
movsd  -0x30(%rbp),%xmm0
movsd  0xe7c(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11a3 <rho+0x83>
movsd  0xe6a(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    11a8 <rho+0x88>
movsd  0xe50(%rip),%xmm0
ucomisd -0x38(%rbp),%xmm0
jbe    11cd <rho+0xad>
movsd  0xe3d(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11f6 <rho+0xd6>
movsd  -0x38(%rbp),%xmm0
movsd  0xe2e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11f1 <rho+0xd1>
movsd  0xe1c(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
jmp    11f6 <rho+0xd6>
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1220 <rho+0x100>
jp     1220 <rho+0x100>
movsd  0xe0a(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12f3 <rho+0x1d3>
movsd  -0x10(%rbp),%xmm0
movsd  0xde3(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    124a <rho+0x12a>
jp     124a <rho+0x12a>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12f3 <rho+0x1d3>
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
call   1040 <tan@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
call   1040 <tan@plt>
movaps %xmm0,%xmm1
movsd  -0x50(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x10(%rbp),%xmm0
subsd  -0x18(%rbp),%xmm0
call   1040 <tan@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x10(%rbp),%xmm0
addsd  -0x18(%rbp),%xmm0
call   1040 <tan@plt>
movsd  -0x48(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x40(%rbp),%xmm0
divsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x30(%rbp),%xmm0
divsd  -0x38(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
divsd  -0x38(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x20(%rbp),%xmm1
addsd  -0x28(%rbp),%xmm1
movsd  0xd2e(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rho>:
sub    $0x68,%rsp
movsd  %xmm1,0x8(%rsp)
movsd  %xmm0,0x20(%rsp)
subsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%rsp)
call   1030 <sin@plt>
movsd  %xmm0,0x30(%rsp)
movsd  0x8(%rsp),%xmm0
addsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
call   1030 <sin@plt>
movsd  0x30(%rsp),%xmm3
movsd  0xe96(%rip),%xmm2
ucomisd %xmm3,%xmm2
movapd %xmm2,%xmm1
ja     118a <rho+0x6a>
ucomisd 0xe8c(%rip),%xmm3
movapd %xmm3,%xmm1
jbe    118a <rho+0x6a>
movsd  0xe7e(%rip),%xmm1
ucomisd %xmm0,%xmm2
ja     11a6 <rho+0x86>
ucomisd 0xe70(%rip),%xmm0
movapd %xmm0,%xmm2
jbe    11a6 <rho+0x86>
movsd  0xe62(%rip),%xmm2
xorpd  %xmm0,%xmm0
movsd  0x20(%rsp),%xmm3
ucomisd %xmm0,%xmm3
jne    11c5 <rho+0xa5>
jp     11c5 <rho+0xa5>
movsd  0xe50(%rip),%xmm0
add    $0x68,%rsp
ret
ucomisd 0xe4b(%rip),%xmm3
jne    11d6 <rho+0xb6>
jp     11d6 <rho+0xb6>
add    $0x68,%rsp
ret
movsd  0x10(%rsp),%xmm0
movapd %xmm1,0x30(%rsp)
movapd %xmm2,0x20(%rsp)
call   1040 <tan@plt>
movaps %xmm0,0x50(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <tan@plt>
movaps %xmm0,0x40(%rsp)
movsd  0x10(%rsp),%xmm0
call   1040 <tan@plt>
movaps %xmm0,0x10(%rsp)
movsd  0x8(%rsp),%xmm0
call   1040 <tan@plt>
movapd 0x10(%rsp),%xmm2
divsd  %xmm0,%xmm2
movapd 0x30(%rsp),%xmm0
unpcklpd 0x50(%rsp),%xmm0
movapd 0x20(%rsp),%xmm1
unpcklpd 0x40(%rsp),%xmm1
divpd  %xmm1,%xmm0
movapd %xmm0,%xmm1
unpcklpd %xmm2,%xmm1
mulpd  %xmm0,%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
mulsd  0xdbd(%rip),%xmm0
add    $0x68,%rsp
ret

LLVM IR (-O0):
define double @rho(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
store double %0, double* %4
store double %1, double* %5
%10 = load double, double* %4
%11 = load double, double* %5
%12 = fsub double %10, %11
%13 = call double @sin(double %12)
store double %13, double* %8
%14 = load double, double* %4
%15 = load double, double* %5
%16 = fadd double %14, %15
%17 = call double @sin(double %16)
store double %17, double* %9
%18 = load double, double* %8
%19 = fcmp olt double %18, -1.000000e+00
br i1 %19, label %20, label %21
20: ; preds = %2
store double -1.000000e+00, double* %8
br label %26
21: ; preds = %2
%22 = load double, double* %8
%23 = fcmp ogt double %22, 1.000000e+00
br i1 %23, label %24, label %25
24: ; preds = %21
store double 1.000000e+00, double* %8
br label %25
25: ; preds = %24, %21
br label %26
26: ; preds = %25, %20
%27 = load double, double* %9
%28 = fcmp olt double %27, -1.000000e+00
br i1 %28, label %29, label %30
29: ; preds = %26
store double -1.000000e+00, double* %9
br label %35
30: ; preds = %26
%31 = load double, double* %9
%32 = fcmp ogt double %31, 1.000000e+00
br i1 %32, label %33, label %34
33: ; preds = %30
store double 1.000000e+00, double* %9
br label %34
34: ; preds = %33, %30
br label %35
35: ; preds = %34, %29
%36 = load double, double* %4
%37 = fcmp oeq double %36, 0.000000e+00
br i1 %37, label %38, label %39
38: ; preds = %35
store double 0x3FA1CEC67297416A, double* %3
br label %74
39: ; preds = %35
%40 = load double, double* %4
%41 = fcmp oeq double %40, 0x3FF921FB54442EEA
br i1 %41, label %42, label %43
42: ; preds = %39
store double 0.000000e+00, double* %3
br label %74
43: ; preds = %39
%44 = load double, double* %4
%45 = load double, double* %5
%46 = fsub double %44, %45
%47 = call double @tan(double %46)
%48 = load double, double* %4
%49 = load double, double* %5
%50 = fadd double %48, %49
%51 = call double @tan(double %50)
%52 = fdiv double %47, %51
%53 = load double, double* %4
%54 = load double, double* %5
%55 = fsub double %53, %54
%56 = call double @tan(double %55)
%57 = load double, double* %4
%58 = load double, double* %5
%59 = fadd double %57, %58
%60 = call double @tan(double %59)
%61 = fdiv double %56, %60
%62 = fmul double %52, %61
store double %62, double* %6
%63 = load double, double* %8
%64 = load double, double* %9
%65 = fdiv double %63, %64
%66 = load double, double* %8
%67 = load double, double* %9
%68 = fdiv double %66, %67
%69 = fmul double %65, %68
store double %69, double* %7
%70 = load double, double* %6
%71 = load double, double* %7
%72 = fadd double %70, %71
%73 = fmul double 5.000000e-01, %72
store double %73, double* %3
br label %74
74: ; preds = %43, %42, %38
%75 = load double, double* %3
ret double %75
}

LLVM IR (-O2):
define double @rho(double %0, double %1) {
%3 = fsub double %0, %1
%4 = tail call double @sin(double %3)
%5 = fadd double %0, %1
%6 = tail call double @sin(double %5)
%7 = fcmp olt double %4, -1.000000e+00
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = fcmp ogt double %4, 1.000000e+00
br i1 %9, label %10, label %11
10: ; preds = %8
br label %11
11: ; preds = %2, %8, %10
%12 = phi double [ 1.000000e+00, %10 ], [ %4, %8 ], [ -1.000000e+00, %2 ]
%13 = fcmp olt double %6, -1.000000e+00
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = fcmp ogt double %6, 1.000000e+00
br i1 %15, label %16, label %17
16: ; preds = %14
br label %17
17: ; preds = %11, %14, %16
%18 = phi double [ 1.000000e+00, %16 ], [ %6, %14 ], [ -1.000000e+00, %11 ]
%19 = fcmp oeq double %0, 0.000000e+00
br i1 %19, label %39, label %20
20: ; preds = %17
%21 = fcmp oeq double %0, 0x3FF921FB54442EEA
br i1 %21, label %39, label %22
22: ; preds = %20
%23 = tail call double @tan(double %3)
%24 = tail call double @tan(double %5)
%25 = tail call double @tan(double %3)
%26 = tail call double @tan(double %5)
%27 = fdiv double %25, %26
%28 = insertelement <2 x double> poison, double %12, i64 0
%29 = insertelement <2 x double> %28, double %23, i64 1
%30 = insertelement <2 x double> poison, double %18, i64 0
%31 = insertelement <2 x double> %30, double %24, i64 1
%32 = fdiv <2 x double> %29, %31
%33 = insertelement <2 x double> %32, double %27, i64 1
%34 = fmul <2 x double> %32, %33
%35 = shufflevector <2 x double> %34, <2 x double> poison, <2 x i32> <i32 1, i32 undef>
%36 = fadd <2 x double> %34, %35
%37 = extractelement <2 x double> %36, i64 0
%38 = fmul double %37, 5.000000e-01
br label %39
39: ; preds = %20, %17, %22
%40 = phi double [ %38, %22 ], [ 0x3FA1CEC67297416A, %17 ], [ 0.000000e+00, %20 ]
ret double %40
}