#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 sqrt(double);
unsigned int BitAllocation(double pe, int short_block) {
  double pew1;
  double pew2;
  double bit_allocation;
  if (short_block) {
    pew1 = 0.6;
    pew2 = 24.0;
  } else {
    pew1 = 0.3;
    pew2 = 6.0;
  }
  bit_allocation = pew1 * pe + pew2 * sqrt(pe);
  bit_allocation =
      ((((((0.0) > (bit_allocation)) ? (0.0) : (bit_allocation))) < (6144.0))
           ? ((((0.0) > (bit_allocation)) ? (0.0) : (bit_allocation)))
           : (6144.0));
  return (unsigned int)(bit_allocation + 0.5);
}


x86 assembly (clang, -O0):
<BitAllocation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     1149 <BitAllocation+0x39>
movsd  0xee6(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xed1(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
jmp    1163 <BitAllocation+0x53>
movsd  0xeb7(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xea2(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x8(%rbp),%xmm0
call   1030 <sqrt@plt>
movsd  -0x40(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm2
movaps %xmm0,%xmm3
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm3,%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    11c9 <BitAllocation+0xb9>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x48(%rbp)
jmp    11d3 <BitAllocation+0xc3>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm1
movsd  0xe40(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    121e <BitAllocation+0x10e>
xorps  %xmm0,%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    1205 <BitAllocation+0xf5>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x50(%rbp)
jmp    120f <BitAllocation+0xff>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    1230 <BitAllocation+0x120>
movsd  0xdfa(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
jmp    1230 <BitAllocation+0x120>
movsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  0xde1(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BitAllocation>:
sub    $0x18,%rsp
movapd %xmm0,%xmm1
xor    %eax,%eax
test   %edi,%edi
sete   %al
lea    0xeda(%rip),%rcx
movsd  (%rcx,%rax,8),%xmm3
lea    0xede(%rip),%rcx
movsd  (%rcx,%rax,8),%xmm4
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm0
jb     114a <BitAllocation+0x3a>
xorps  %xmm0,%xmm0
sqrtsd %xmm1,%xmm0
jmp    1179 <BitAllocation+0x69>
movapd %xmm1,%xmm0
movsd  %xmm1,0x10(%rsp)
movsd  %xmm3,0x8(%rsp)
movsd  %xmm4,(%rsp)
call   1030 <sqrt@plt>
movsd  (%rsp),%xmm4
movsd  0x8(%rsp),%xmm3
xorpd  %xmm2,%xmm2
movsd  0x10(%rsp),%xmm1
mulsd  %xmm0,%xmm3
mulsd  %xmm1,%xmm4
addsd  %xmm3,%xmm4
maxsd  %xmm4,%xmm2
minsd  0xe8f(%rip),%xmm2
addsd  0xe8f(%rip),%xmm2
cvttsd2si %xmm2,%rax
add    $0x18,%rsp
ret

LLVM IR (-O0):
define i32 @BitAllocation(double %0, i32 %1) {
%3 = alloca double
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
store double %0, double* %3
store i32 %1, i32* %4
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %2
store double 6.000000e-01, double* %5
store double 2.400000e+01, double* %6
br label %12
11: ; preds = %2
store double 3.000000e-01, double* %5
store double 6.000000e+00, double* %6
br label %12
12: ; preds = %11, %10
%13 = load double, double* %5
%14 = load double, double* %3
%15 = load double, double* %6
%16 = load double, double* %3
%17 = call double @sqrt(double %16)
%18 = fmul double %15, %17
%19 = call double @llvm.fmuladd.f64(double %13, double %14, double %18)
store double %19, double* %7
%20 = load double, double* %7
%21 = fcmp ogt double 0.000000e+00, %20
br i1 %21, label %22, label %23
22: ; preds = %12
br label %25
23: ; preds = %12
%24 = load double, double* %7
br label %25
25: ; preds = %23, %22
%26 = phi double [ 0.000000e+00, %22 ], [ %24, %23 ]
%27 = fcmp olt double %26, 6.144000e+03
br i1 %27, label %28, label %36
28: ; preds = %25
%29 = load double, double* %7
%30 = fcmp ogt double 0.000000e+00, %29
br i1 %30, label %31, label %32
31: ; preds = %28
br label %34
32: ; preds = %28
%33 = load double, double* %7
br label %34
34: ; preds = %32, %31
%35 = phi double [ 0.000000e+00, %31 ], [ %33, %32 ]
br label %37
36: ; preds = %25
br label %37
37: ; preds = %36, %34
%38 = phi double [ %35, %34 ], [ 6.144000e+03, %36 ]
store double %38, double* %7
%39 = load double, double* %7
%40 = fadd double %39, 5.000000e-01
%41 = fptoui double %40 to i32
ret i32 %41
}

LLVM IR (-O2):
define i32 @BitAllocation(double %0, i32 %1) {
%3 = icmp eq i32 %1, 0
%4 = select i1 %3, double 6.000000e+00, double 2.400000e+01
%5 = select i1 %3, double 3.000000e-01, double 6.000000e-01
%6 = tail call double @sqrt(double %0)
%7 = fmul double %4, %6
%8 = tail call double @llvm.fmuladd.f64(double %5, double %0, double %7)
%9 = fcmp olt double %8, 0.000000e+00
%10 = select i1 %9, double 0.000000e+00, double %8
%11 = fcmp olt double %10, 6.144000e+03
%12 = select i1 %11, double %10, double 6.144000e+03
%13 = fadd double %12, 5.000000e-01
%14 = fptoui double %13 to i32
ret i32 %14
}