#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 const pow(double, double const);
double sqrt(double const);
double cos_theta_star(double cos_theta) {
  const double p[] = {0.102573, -0.068287, 0.958633, 0.0407253, 0.817285};
  const double cs2 =
      (cos_theta * cos_theta + p[0] * p[0] + p[1] * pow(cos_theta, p[2]) +
       p[3] * pow(cos_theta, p[4])) /
      (1. + p[0] * p[0] + p[1] + p[3]);
  return cs2 > 0. ? sqrt(cs2) : 0.;
}


x86 assembly (clang, -O0):
<cos_theta_star>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1030 <memset@plt>
movsd  0xed3(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xebe(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xea9(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe94(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe7f(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x8(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
call   1040 <pow@plt>
movsd  -0x58(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x50(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
call   1040 <pow@plt>
movsd  -0x48(%rbp),%xmm1
movaps %xmm0,%xmm2
movsd  -0x40(%rbp),%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  -0x30(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xdda(%rip),%xmm2
addsd  %xmm2,%xmm1
addsd  -0x28(%rbp),%xmm1
addsd  -0x18(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x38(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1263 <cos_theta_star+0x133>
movsd  -0x38(%rbp),%xmm0
call   1050 <sqrt@plt>
movsd  %xmm0,-0x60(%rbp)
jmp    1270 <cos_theta_star+0x140>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
jmp    1270 <cos_theta_star+0x140>
movsd  -0x60(%rbp),%xmm0
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cos_theta_star>:
sub    $0x18,%rsp
movsd  %xmm0,0x10(%rsp)
movapd %xmm0,%xmm1
mulsd  %xmm0,%xmm1
addsd  0xec6(%rip),%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0xec0(%rip),%xmm1
call   1030 <pow@plt>
mulsd  0xebb(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rsp)
movsd  0xeaf(%rip),%xmm1
movsd  0x10(%rsp),%xmm0
call   1030 <pow@plt>
mulsd  0xea4(%rip),%xmm0
addsd  0x8(%rsp),%xmm0
divsd  0xe9e(%rip),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11a5 <cos_theta_star+0x85>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11ae <cos_theta_star+0x8e>
xorps  %xmm1,%xmm1
sqrtsd %xmm0,%xmm1
movapd %xmm1,%xmm0
add    $0x18,%rsp
ret
add    $0x18,%rsp
jmp    1040 <sqrt@plt>

LLVM IR (-O0):
define double @cos_theta_star(double %0) {
%2 = alloca double
%3 = alloca [5 x double]
%4 = alloca double
store double %0, double* %2
%5 = bitcast [5 x double]* %3 to i8*
%6 = bitcast i8* %5 to [5 x double]*
%7 = getelementptr inbounds [5 x double], [5 x double]* %6, i32 0, i32 0
store double 1.025730e-01, double* %7
%8 = getelementptr inbounds [5 x double], [5 x double]* %6, i32 0, i32 1
store double -6.828700e-02, double* %8
%9 = getelementptr inbounds [5 x double], [5 x double]* %6, i32 0, i32 2
store double 0x3FEEAD1F1CFBB949, double* %9
%10 = getelementptr inbounds [5 x double], [5 x double]* %6, i32 0, i32 3
store double 4.072530e-02, double* %10
%11 = getelementptr inbounds [5 x double], [5 x double]* %6, i32 0, i32 4
store double 8.172850e-01, double* %11
%12 = load double, double* %2
%13 = load double, double* %2
%14 = getelementptr inbounds [5 x double], [5 x double]* %3, i64 0, i64 0
%15 = load double, double* %14
%16 = getelementptr inbounds [5 x double], [5 x double]* %3, i64 0, i64 0
%17 = load double, double* %16
%18 = fmul double %15, %17
%19 = call double @llvm.fmuladd.f64(double %12, double %13, double %18)
%20 = getelementptr inbounds [5 x double], [5 x double]* %3, i64 0, i64 1
%21 = load double, double* %20
%22 = load double, double* %2
%23 = getelementptr inbounds [5 x double], [5 x double]* %3, i64 0, i64 2
%24 = load double, double* %23
%25 = call double @pow(double %22, double %24)
%26 = call double @llvm.fmuladd.f64(double %21, double %25, double %19)
%27 = getelementptr inbounds [5 x double], [5 x double]* %3, i64 0, i64 3
%28 = load double, double* %27
%29 = load double, double* %2
%30 = getelementptr inbounds [5 x double], [5 x double]* %3, i64 0, i64 4
%31 = load double, double* %30
%32 = call double @pow(double %29, double %31)
%33 = call double @llvm.fmuladd.f64(double %28, double %32, double %26)
%34 = getelementptr inbounds [5 x double], [5 x double]* %3, i64 0, i64 0
%35 = load double, double* %34
%36 = getelementptr inbounds [5 x double], [5 x double]* %3, i64 0, i64 0
%37 = load double, double* %36
%38 = call double @llvm.fmuladd.f64(double %35, double %37, double 1.000000e+00)
%39 = getelementptr inbounds [5 x double], [5 x double]* %3, i64 0, i64 1
%40 = load double, double* %39
%41 = fadd double %38, %40
%42 = getelementptr inbounds [5 x double], [5 x double]* %3, i64 0, i64 3
%43 = load double, double* %42
%44 = fadd double %41, %43
%45 = fdiv double %33, %44
store double %45, double* %4
%46 = load double, double* %4
%47 = fcmp ogt double %46, 0.000000e+00
br i1 %47, label %48, label %51
48: ; preds = %1
%49 = load double, double* %4
%50 = call double @sqrt(double %49)
br label %52
51: ; preds = %1
br label %52
52: ; preds = %51, %48
%53 = phi double [ %50, %48 ], [ 0.000000e+00, %51 ]
ret double %53
}

LLVM IR (-O2):
define double @cos_theta_star(double %0) {
%2 = tail call double @llvm.fmuladd.f64(double %0, double %0, double 0x3F858C2649D107A4)
%3 = tail call double @pow(double %0, double 0x3FEEAD1F1CFBB949)
%4 = tail call double @llvm.fmuladd.f64(double %3, double -6.828700e-02, double %2)
%5 = tail call double @pow(double %0, double 8.172850e-01)
%6 = tail call double @llvm.fmuladd.f64(double %5, double 4.072530e-02, double %4)
%7 = fdiv double %6, 0x3FEF746786235B5B
%8 = fcmp ogt double %7, 0.000000e+00
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = tail call double @sqrt(double %7)
br label %11
11: ; preds = %1, %9
%12 = phi double [ %10, %9 ], [ 0.000000e+00, %1 ]
ret double %12
}