#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 sqrt(int);
double p_to_b(double p, double rtt, double tzero, int psize, int bval) {
  double tmp1, tmp2, res;
  if (p < 0 || rtt < 0) {
    return 25000000.0;
  }
  res = rtt * sqrt(2 * bval * p / 3);
  tmp1 = 3 * sqrt(3 * bval * p / 8);
  if (tmp1 > 1.0)
    tmp1 = 1.0;
  tmp2 = tzero * p * (1 + 32 * p * p);
  res += tmp1 * tmp2;
  if (res < 0.0000001) {
    res = 25000000.0;
  } else {
    res = psize / res;
  }
  if (res > 25000000.0) {
    res = 25000000.0;
  }
  return res;
}


x86 assembly (clang, -O0):
<p_to_b>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  %xmm2,-0x20(%rbp)
mov    %edi,-0x24(%rbp)
mov    %esi,-0x28(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
ja     1149 <p_to_b+0x39>
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    115b <p_to_b+0x4b>
movsd  0xed7(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12a0 <p_to_b+0x190>
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
mov    -0x28(%rbp),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  0xe94(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sqrt@plt>
movsd  -0x48(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
imul   $0x3,-0x28(%rbp),%eax
cvtsi2sd %eax,%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  0xe58(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sqrt@plt>
imul   $0x3,%eax,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xe2a(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11ed <p_to_b+0xdd>
movsd  0xe18(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x20(%rbp),%xmm0
mulsd  -0x10(%rbp),%xmm0
movsd  0xe21(%rip),%xmm1
mulsd  -0x10(%rbp),%xmm1
movsd  -0x10(%rbp),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xdeb(%rip),%xmm2
addsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm2
movsd  -0x40(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xdd2(%rip),%xmm0
ucomisd -0x40(%rbp),%xmm0
jbe    1263 <p_to_b+0x153>
movsd  0xdcf(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    1272 <p_to_b+0x162>
cvtsi2sdl -0x24(%rbp),%xmm0
divsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  0xda9(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1296 <p_to_b+0x186>
movsd  0xd97(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<p_to_b>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
movapd %xmm0,%xmm3
xorpd  %xmm4,%xmm4
ucomisd %xmm0,%xmm4
movsd  0xed6(%rip),%xmm0
ja     1216 <p_to_b+0x106>
ucomisd %xmm1,%xmm4
ja     1216 <p_to_b+0x106>
mov    %esi,%ebx
mov    %edi,%ebp
lea    (%rbx,%rbx,1),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  %xmm3,%xmm0
divsd  0xeb4(%rip),%xmm0
cvttsd2si %xmm0,%edi
movsd  %xmm2,0x10(%rsp)
movsd  %xmm3,0x8(%rsp)
movsd  %xmm1,(%rsp)
call   1030 <sqrt@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
lea    (%rbx,%rbx,2),%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
mulsd  0x8(%rsp),%xmm0
mulsd  0xe79(%rip),%xmm0
cvttsd2si %xmm0,%edi
call   1030 <sqrt@plt>
lea    (%rax,%rax,2),%eax
test   %eax,%eax
mov    $0x1,%ecx
cmovle %eax,%ecx
xorps  %xmm0,%xmm0
cvtsi2sd %ecx,%xmm0
movsd  0xe5c(%rip),%xmm1
movsd  0x8(%rsp),%xmm2
mulsd  %xmm2,%xmm1
mulsd  %xmm2,%xmm1
movapd %xmm2,%xmm3
addsd  0xe4a(%rip),%xmm1
movsd  0x10(%rsp),%xmm2
mulsd  %xmm3,%xmm2
mulsd  %xmm2,%xmm1
mulsd  %xmm0,%xmm1
addsd  (%rsp),%xmm1
movsd  0xe0b(%rip),%xmm0
movsd  0xe2b(%rip),%xmm2
ucomisd %xmm1,%xmm2
movapd %xmm0,%xmm2
ja     1212 <p_to_b+0x102>
xorps  %xmm2,%xmm2
cvtsi2sd %ebp,%xmm2
divsd  %xmm1,%xmm2
minsd  %xmm2,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
define double @p_to_b(double %0, double %1, double %2, i32 %3, i32 %4) {
%6 = fcmp olt double %0, 0.000000e+00
%7 = fcmp olt double %1, 0.000000e+00
%8 = or i1 %6, %7
br i1 %8, label %41, label %9
9: ; preds = %5
%10 = shl nsw i32 %4, 1
%11 = sitofp i32 %10 to double
%12 = fmul double %11, %0
%13 = fdiv double %12, 3.000000e+00
%14 = fptosi double %13 to i32
%15 = tail call i32 @sqrt(i32 %14)
%16 = sitofp i32 %15 to double
%17 = fmul double %16, %1
%18 = mul nsw i32 %4, 3
%19 = sitofp i32 %18 to double
%20 = fmul double %19, %0
%21 = fmul double %20, 1.250000e-01
%22 = fptosi double %21 to i32
%23 = tail call i32 @sqrt(i32 %22)
%24 = mul nsw i32 %23, 3
%25 = icmp slt i32 %24, 1
%26 = select i1 %25, i32 %24, i32 1
%27 = sitofp i32 %26 to double
%28 = fmul double %0, %2
%29 = fmul double %0, 3.200000e+01
%30 = tail call double @llvm.fmuladd.f64(double %29, double %0, double 1.000000e+00)
%31 = fmul double %30, %28
%32 = tail call double @llvm.fmuladd.f64(double %27, double %31, double %17)
%33 = fcmp olt double %32, 0x3E7AD7F29ABCAF48
br i1 %33, label %37, label %34
34: ; preds = %9
%35 = sitofp i32 %3 to double
%36 = fdiv double %35, %32
br label %37
37: ; preds = %9, %34
%38 = phi double [ %36, %34 ], [ 2.500000e+07, %9 ]
%39 = fcmp ogt double %38, 2.500000e+07
%40 = select i1 %39, double 2.500000e+07, double %38
br label %41
41: ; preds = %5, %37
%42 = phi double [ %40, %37 ], [ 2.500000e+07, %5 ]
ret double %42
}