#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 M_PI;
int cos(double);
double fabs(double);
double sqrt(double);
double root_raised_cosine_freq(double freq, double alpha) {
  freq = fabs(freq);
  freq -= 0.5 * (1 - alpha);
  if (freq <= 0)
    return 1;
  if (freq >= alpha)
    return 0;
  freq /= alpha;
  freq *= M_PI;
  return sqrt(0.5 * (1 + cos(freq)));
}


x86 assembly (clang, -O0):
<root_raised_cosine_freq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movaps 0xee2(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xeb9(%rip),%xmm0
subsd  -0x18(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm1
movsd  0xe9f(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     118e <root_raised_cosine_freq+0x6e>
movsd  0xe84(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11fa <root_raised_cosine_freq+0xda>
movsd  -0x10(%rbp),%xmm0
ucomisd -0x18(%rbp),%xmm0
jb     11ab <root_raised_cosine_freq+0x8b>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11fa <root_raised_cosine_freq+0xda>
movsd  -0x18(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm0
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    0x2e23(%rip),%rax
movsd  (%rax),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <cos@plt>
add    $0x1,%eax
cvtsi2sd %eax,%xmm1
movsd  0xe24(%rip),%xmm0
mulsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<root_raised_cosine_freq>:
push   %rax
movapd %xmm0,%xmm3
andpd  0xed3(%rip),%xmm3
movsd  0xedb(%rip),%xmm2
movapd %xmm2,%xmm0
subsd  %xmm1,%xmm0
mulsd  0xed3(%rip),%xmm0
addsd  %xmm3,%xmm0
xorpd  %xmm3,%xmm3
ucomisd %xmm0,%xmm3
jae    1194 <root_raised_cosine_freq+0x74>
ucomisd %xmm1,%xmm0
xorpd  %xmm2,%xmm2
jae    1194 <root_raised_cosine_freq+0x74>
divsd  %xmm1,%xmm0
mov    0x2e80(%rip),%rax
mulsd  (%rax),%xmm0
call   1030 <cos@plt>
add    $0x1,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0xe9d(%rip),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     119a <root_raised_cosine_freq+0x7a>
xorps  %xmm2,%xmm2
sqrtsd %xmm0,%xmm2
movapd %xmm2,%xmm0
pop    %rax
ret
pop    %rax
jmp    1040 <sqrt@plt>

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define double @root_raised_cosine_freq(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double %0, double* %4
store double %1, double* %5
%6 = load double, double* %4
%7 = call double @llvm.fabs.f64(double %6)
store double %7, double* %4
%8 = load double, double* %5
%9 = fsub double 1.000000e+00, %8
%10 = load double, double* %4
%11 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %9, double %10)
store double %11, double* %4
%12 = load double, double* %4
%13 = fcmp ole double %12, 0.000000e+00
br i1 %13, label %14, label %15
14: ; preds = %2
store double 1.000000e+00, double* %3
br label %33
15: ; preds = %2
%16 = load double, double* %4
%17 = load double, double* %5
%18 = fcmp oge double %16, %17
br i1 %18, label %19, label %20
19: ; preds = %15
store double 0.000000e+00, double* %3
br label %33
20: ; preds = %15
%21 = load double, double* %5
%22 = load double, double* %4
%23 = fdiv double %22, %21
store double %23, double* %4
%24 = load double, double* @M_PI
%25 = load double, double* %4
%26 = fmul double %25, %24
store double %26, double* %4
%27 = load double, double* %4
%28 = call i32 @cos(double %27)
%29 = add nsw i32 1, %28
%30 = sitofp i32 %29 to double
%31 = fmul double 5.000000e-01, %30
%32 = call double @sqrt(double %31)
store double %32, double* %3
br label %33
33: ; preds = %20, %19, %14
%34 = load double, double* %3
ret double %34
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define double @root_raised_cosine_freq(double %0, double %1) {
%3 = tail call double @llvm.fabs.f64(double %0)
%4 = fsub double 1.000000e+00, %1
%5 = tail call double @llvm.fmuladd.f64(double %4, double -5.000000e-01, double %3)
%6 = fcmp ugt double %5, 0.000000e+00
br i1 %6, label %7, label %18
7: ; preds = %2
%8 = fcmp ult double %5, %1
br i1 %8, label %9, label %18
9: ; preds = %7
%10 = fdiv double %5, %1
%11 = load double, double* @M_PI
%12 = fmul double %10, %11
%13 = tail call i32 @cos(double %12)
%14 = add nsw i32 %13, 1
%15 = sitofp i32 %14 to double
%16 = fmul double %15, 5.000000e-01
%17 = tail call double @sqrt(double %16)
br label %18
18: ; preds = %7, %2, %9
%19 = phi double [ %17, %9 ], [ 1.000000e+00, %2 ], [ 0.000000e+00, %7 ]
ret double %19
}