#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 pow(double, double);
double sqrt(double);
int get_acq_thresh(double samp_rate) {
  double acq_thres_db = 35;
  double acq_thres_value = pow(10.0, acq_thres_db / 10.0);
  double acq_thres_ratio = sqrt(2.0 * acq_thres_value / 1000);
  int carrier_dco_levels[8] = {-1, 1, 2, 2, 1, -1, -2, -2};
  int i;
  double sigma_n;
  double sum_sq = 0, mean_sum_sq;
  double hack = 1;
  for (i = 0; i < 8; i++)
    sum_sq += (carrier_dco_levels[i] * carrier_dco_levels[i]);
  mean_sum_sq = sum_sq / 8;
  sigma_n =
      sqrt(2.0 *
           ((mean_sum_sq * 3.0 * 3.0) * 0.3 + (mean_sum_sq * 1.0 * 1.0) * 0.7) *
           samp_rate * hack * 0.001);
  return (int)(sigma_n * acq_thres_ratio + 0.5);
}


x86 assembly (clang, -O0):
<get_acq_thresh>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xeeb(%rip),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm1
movsd  0xed1(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  0xec5(%rip),%xmm0
call   1030 <pow@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  0xeab(%rip),%xmm0
mulsd  -0x18(%rbp),%xmm0
movsd  0xe96(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x20(%rbp)
mov    0xed9(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xed6(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xed3(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xed0(%rip),%rax
mov    %rax,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xe44(%rip),%xmm0
movsd  %xmm0,-0x68(%rbp)
movl   $0x0,-0x44(%rbp)
cmpl   $0x8,-0x44(%rbp)
jge    11ff <get_acq_thresh+0xdf>
movslq -0x44(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%eax
movslq -0x44(%rbp),%rcx
imul   -0x40(%rbp,%rcx,4),%eax
cvtsi2sd %eax,%xmm0
addsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11c8 <get_acq_thresh+0xa8>
movsd  -0x58(%rbp),%xmm0
movsd  0xe44(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  0xe2b(%rip),%xmm1
mulsd  -0x60(%rbp),%xmm1
movsd  0xe1e(%rip),%xmm0
mulsd  %xmm0,%xmm1
movsd  0xdca(%rip),%xmm0
mulsd  -0x60(%rbp),%xmm0
movsd  0xdbd(%rip),%xmm2
mulsd  %xmm2,%xmm0
movsd  0xdf1(%rip),%xmm2
mulsd  %xmm2,%xmm0
movsd  0xddd(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xda5(%rip),%xmm0
mulsd  %xmm1,%xmm0
mulsd  -0x8(%rbp),%xmm0
mulsd  -0x68(%rbp),%xmm0
movsd  0xdaf(%rip),%xmm1
mulsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm0
movsd  0xd83(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_acq_thresh>:
push   %rax
mulsd  0xee7(%rip),%xmm0
mulsd  0xee7(%rip),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1131 <get_acq_thresh+0x21>
sqrtsd %xmm0,%xmm0
jmp    1136 <get_acq_thresh+0x26>
call   1030 <sqrt@plt>
mulsd  0xed2(%rip),%xmm0
addsd  0xed2(%rip),%xmm0
cvttsd2si %xmm0,%eax
pop    %rcx
ret

LLVM IR (-O0):
@__const.get_acq_thresh.carrier_dco_levels = [8 x i32] [i32 -1, i32 1, i32 2, i32 2, i32 1, i32 -1, i32 -2, i32 -2]
define i32 @get_acq_thresh(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca [8 x i32]
%7 = alloca i32
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
store double %0, double* %2
store double 3.500000e+01, double* %3
%12 = load double, double* %3
%13 = fdiv double %12, 1.000000e+01
%14 = call double @pow(double 1.000000e+01, double %13)
store double %14, double* %4
%15 = load double, double* %4
%16 = fmul double 2.000000e+00, %15
%17 = fdiv double %16, 1.000000e+03
%18 = call double @sqrt(double %17)
store double %18, double* %5
%19 = bitcast [8 x i32]* %6 to i8*
store double 0.000000e+00, double* %9
store double 1.000000e+00, double* %11
store i32 0, i32* %7
br label %20
20: ; preds = %36, %1
%21 = load i32, i32* %7
%22 = icmp slt i32 %21, 8
br i1 %22, label %23, label %39
23: ; preds = %20
%24 = load i32, i32* %7
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 %25
%27 = load i32, i32* %26
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [8 x i32], [8 x i32]* %6, i64 0, i64 %29
%31 = load i32, i32* %30
%32 = mul nsw i32 %27, %31
%33 = sitofp i32 %32 to double
%34 = load double, double* %9
%35 = fadd double %34, %33
store double %35, double* %9
br label %36
36: ; preds = %23
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %20
39: ; preds = %20
%40 = load double, double* %9
%41 = fdiv double %40, 8.000000e+00
store double %41, double* %10
%42 = load double, double* %10
%43 = fmul double %42, 3.000000e+00
%44 = fmul double %43, 3.000000e+00
%45 = load double, double* %10
%46 = fmul double %45, 1.000000e+00
%47 = fmul double %46, 1.000000e+00
%48 = fmul double %47, 0x3FE6666666666666
%49 = call double @llvm.fmuladd.f64(double %44, double 3.000000e-01, double %48)
%50 = fmul double 2.000000e+00, %49
%51 = load double, double* %2
%52 = fmul double %50, %51
%53 = load double, double* %11
%54 = fmul double %52, %53
%55 = fmul double %54, 1.000000e-03
%56 = call double @sqrt(double %55)
store double %56, double* %8
%57 = load double, double* %8
%58 = load double, double* %5
%59 = call double @llvm.fmuladd.f64(double %57, double %58, double 5.000000e-01)
%60 = fptosi double %59 to i32
ret i32 %60
}

LLVM IR (-O2):
define i32 @get_acq_thresh(double %0) {
%2 = fmul double %0, 1.700000e+01
%3 = fmul double %2, 1.000000e-03
%4 = tail call double @sqrt(double %3)
%5 = tail call double @llvm.fmuladd.f64(double %4, double 0x40041E7284162A49, double 5.000000e-01)
%6 = fptosi double %5 to i32
ret i32 %6
}