#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);
double PeriSmallCalcSide(int h, int a, int b, int c) {
  double addarray[8] = {0.0,  0.25,      0.0,       2.0 / 9.0,
                        0.25, 2.0 / 9.0, 2.0 / 9.0, 0.0};
  double l;
  l = sqrt(addarray[(((a) >= (h) ? 1 : 0) << 2) + (((b) >= (h) ? 1 : 0) << 1) +
                    ((c) >= (h) ? 1 : 0)]);
  if (c > h) {
    if (b < h) {
      if (a < h) {
        return (l + 1.0);
      } else if (a > h) {
        return (l + sqrt(2.0) * 2.0 / 3.0);
      }
    } else if (b > h) {
      if (a == h) {
        return (l - 1.0);
      } else if (a > h) {
        return (l - sqrt(2.0));
      }
    }
  }
  return (l);
}


x86 assembly (clang, -O0):
<PeriSmallCalcSide>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1030 <memset@plt>
movsd  0xeb9(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xea4(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xe9f(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  0xe8a(%rip),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  0xe7d(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x10(%rbp),%edx
mov    -0xc(%rbp),%esi
xor    %eax,%eax
mov    $0x1,%ecx
cmp    %esi,%edx
cmovge %ecx,%eax
shl    $0x2,%eax
mov    -0x14(%rbp),%esi
mov    -0xc(%rbp),%edi
xor    %ecx,%ecx
mov    $0x1,%edx
cmp    %edi,%esi
cmovge %edx,%ecx
shl    $0x1,%ecx
add    %ecx,%eax
mov    -0x18(%rbp),%esi
mov    -0xc(%rbp),%edi
xor    %ecx,%ecx
mov    $0x1,%edx
cmp    %edi,%esi
cmovge %edx,%ecx
add    %ecx,%eax
cltq
movsd  -0x60(%rbp,%rax,8),%xmm0
call   1040 <sqrt@plt>
movsd  %xmm0,-0x68(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    12f0 <PeriSmallCalcSide+0x1d0>
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1270 <PeriSmallCalcSide+0x150>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1215 <PeriSmallCalcSide+0xf5>
movsd  0xe12(%rip),%xmm0
addsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12fa <PeriSmallCalcSide+0x1da>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    1266 <PeriSmallCalcSide+0x146>
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x70(%rbp)
movsd  0xddd(%rip),%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x70(%rbp),%xmm0
movsd  0xdc8(%rip),%xmm2
mulsd  %xmm2,%xmm1
movsd  0xdcc(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12fa <PeriSmallCalcSide+0x1da>
jmp    126b <PeriSmallCalcSide+0x14b>
jmp    12eb <PeriSmallCalcSide+0x1cb>
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    12e6 <PeriSmallCalcSide+0x1c6>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    12a3 <PeriSmallCalcSide+0x183>
movsd  -0x68(%rbp),%xmm0
movsd  0xd83(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12fa <PeriSmallCalcSide+0x1da>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    12dc <PeriSmallCalcSide+0x1bc>
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x78(%rbp)
movsd  0xd4f(%rip),%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  -0x78(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    12fa <PeriSmallCalcSide+0x1da>
jmp    12e1 <PeriSmallCalcSide+0x1c1>
jmp    12e6 <PeriSmallCalcSide+0x1c6>
jmp    12eb <PeriSmallCalcSide+0x1cb>
jmp    12f0 <PeriSmallCalcSide+0x1d0>
movsd  -0x68(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PeriSmallCalcSide>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %ecx,%ebx
mov    %edx,%r15d
mov    %esi,%r14d
mov    %edi,%ebp
xor    %eax,%eax
cmp    %edi,%edx
setge  %al
xor    %ecx,%ecx
cmp    %edi,%esi
setge  %cl
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,0x30(%rsp)
movabs $0x3fd0000000000000,%rdx
mov    %rdx,0x8(%rsp)
movaps 0xea2(%rip),%xmm0
movups %xmm0,0x18(%rsp)
movaps 0xea6(%rip),%xmm0
movups %xmm0,0x28(%rsp)
shl    $0x2,%rcx
lea    (%rcx,%rax,2),%rax
xor    %ecx,%ecx
cmp    %edi,%ebx
setge  %cl
or     %rax,%rcx
movsd  (%rsp,%rcx,8),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     119a <PeriSmallCalcSide+0x8a>
sqrtsd %xmm0,%xmm0
cmp    %ebp,%ebx
jg     11a3 <PeriSmallCalcSide+0x93>
jmp    11de <PeriSmallCalcSide+0xce>
call   1030 <sqrt@plt>
cmp    %ebp,%ebx
jle    11de <PeriSmallCalcSide+0xce>
cmp    %ebp,%r15d
jge    11b7 <PeriSmallCalcSide+0xa7>
cmp    %ebp,%r14d
jge    11c8 <PeriSmallCalcSide+0xb8>
addsd  0xe83(%rip),%xmm0
jmp    11de <PeriSmallCalcSide+0xce>
jle    11de <PeriSmallCalcSide+0xce>
cmp    %ebp,%r14d
jne    11d4 <PeriSmallCalcSide+0xc4>
addsd  0xe62(%rip),%xmm0
jmp    11de <PeriSmallCalcSide+0xce>
jle    11de <PeriSmallCalcSide+0xce>
addsd  0xe5e(%rip),%xmm0
jmp    11de <PeriSmallCalcSide+0xce>
jle    11de <PeriSmallCalcSide+0xce>
addsd  0xe42(%rip),%xmm0
add    $0x48,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define double @PeriSmallCalcSide(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca double
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca [8 x double]
%11 = alloca double
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%12 = bitcast [8 x double]* %10 to i8*
%13 = bitcast i8* %12 to [8 x double]*
%14 = getelementptr inbounds [8 x double], [8 x double]* %13, i32 0, i32 1
store double 2.500000e-01, double* %14
%15 = getelementptr inbounds [8 x double], [8 x double]* %13, i32 0, i32 3
store double 0x3FCC71C71C71C71C, double* %15
%16 = getelementptr inbounds [8 x double], [8 x double]* %13, i32 0, i32 4
store double 2.500000e-01, double* %16
%17 = getelementptr inbounds [8 x double], [8 x double]* %13, i32 0, i32 5
store double 0x3FCC71C71C71C71C, double* %17
%18 = getelementptr inbounds [8 x double], [8 x double]* %13, i32 0, i32 6
store double 0x3FCC71C71C71C71C, double* %18
%19 = load i32, i32* %7
%20 = load i32, i32* %6
%21 = icmp sge i32 %19, %20
%22 = zext i1 %21 to i64
%23 = select i1 %21, i32 1, i32 0
%24 = shl i32 %23, 2
%25 = load i32, i32* %8
%26 = load i32, i32* %6
%27 = icmp sge i32 %25, %26
%28 = zext i1 %27 to i64
%29 = select i1 %27, i32 1, i32 0
%30 = shl i32 %29, 1
%31 = add nsw i32 %24, %30
%32 = load i32, i32* %9
%33 = load i32, i32* %6
%34 = icmp sge i32 %32, %33
%35 = zext i1 %34 to i64
%36 = select i1 %34, i32 1, i32 0
%37 = add nsw i32 %31, %36
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [8 x double], [8 x double]* %10, i64 0, i64 %38
%40 = load double, double* %39
%41 = call double @sqrt(double %40)
store double %41, double* %11
%42 = load i32, i32* %9
%43 = load i32, i32* %6
%44 = icmp sgt i32 %42, %43
br i1 %44, label %45, label %91
45: ; preds = %4
%46 = load i32, i32* %8
%47 = load i32, i32* %6
%48 = icmp slt i32 %46, %47
br i1 %48, label %49, label %68
49: ; preds = %45
%50 = load i32, i32* %7
%51 = load i32, i32* %6
%52 = icmp slt i32 %50, %51
br i1 %52, label %53, label %56
53: ; preds = %49
%54 = load double, double* %11
%55 = fadd double %54, 1.000000e+00
store double %55, double* %5
br label %93
56: ; preds = %49
%57 = load i32, i32* %7
%58 = load i32, i32* %6
%59 = icmp sgt i32 %57, %58
br i1 %59, label %60, label %66
60: ; preds = %56
%61 = load double, double* %11
%62 = call double @sqrt(double 2.000000e+00)
%63 = fmul double %62, 2.000000e+00
%64 = fdiv double %63, 3.000000e+00
%65 = fadd double %61, %64
store double %65, double* %5
br label %93
66: ; preds = %56
br label %67
67: ; preds = %66
br label %90
68: ; preds = %45
%69 = load i32, i32* %8
%70 = load i32, i32* %6
%71 = icmp sgt i32 %69, %70
br i1 %71, label %72, label %89
72: ; preds = %68
%73 = load i32, i32* %7
%74 = load i32, i32* %6
%75 = icmp eq i32 %73, %74
br i1 %75, label %76, label %79
76: ; preds = %72
%77 = load double, double* %11
%78 = fsub double %77, 1.000000e+00
store double %78, double* %5
br label %93
79: ; preds = %72
%80 = load i32, i32* %7
%81 = load i32, i32* %6
%82 = icmp sgt i32 %80, %81
br i1 %82, label %83, label %87
83: ; preds = %79
%84 = load double, double* %11
%85 = call double @sqrt(double 2.000000e+00)
%86 = fsub double %84, %85
store double %86, double* %5
br label %93
87: ; preds = %79
br label %88
88: ; preds = %87
br label %89
89: ; preds = %88, %68
br label %90
90: ; preds = %89, %67
br label %91
91: ; preds = %90, %4
%92 = load double, double* %11
store double %92, double* %5
br label %93
93: ; preds = %91, %83, %76, %60, %53
%94 = load double, double* %5
ret double %94
}

LLVM IR (-O2):
define double @PeriSmallCalcSide(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca [8 x double]
%6 = bitcast [8 x double]* %5 to i8*
%7 = getelementptr inbounds [8 x double], [8 x double]* %5, i64 0, i64 1
store double 2.500000e-01, double* %7
%8 = getelementptr inbounds [8 x double], [8 x double]* %5, i64 0, i64 3
%9 = bitcast double* %8 to <2 x double>*
store <2 x double> <double 0x3FCC71C71C71C71C, double 2.500000e-01>, <2 x double>* %9
%10 = getelementptr inbounds [8 x double], [8 x double]* %5, i64 0, i64 5
%11 = bitcast double* %10 to <2 x double>*
store <2 x double> <double 0x3FCC71C71C71C71C, double 0x3FCC71C71C71C71C>, <2 x double>* %11
%12 = icmp slt i32 %1, %0
%13 = select i1 %12, i64 0, i64 4
%14 = icmp slt i32 %2, %0
%15 = select i1 %14, i64 0, i64 2
%16 = or i64 %15, %13
%17 = icmp sge i32 %3, %0
%18 = zext i1 %17 to i64
%19 = or i64 %16, %18
%20 = getelementptr inbounds [8 x double], [8 x double]* %5, i64 0, i64 %19
%21 = load double, double* %20
%22 = tail call double @sqrt(double %21)
%23 = icmp sgt i32 %3, %0
br i1 %23, label %24, label %42
24: ; preds = %4
br i1 %14, label %25, label %32
25: ; preds = %24
br i1 %12, label %26, label %28
26: ; preds = %25
%27 = fadd double %22, 1.000000e+00
br label %42
28: ; preds = %25
%29 = icmp sgt i32 %1, %0
%30 = fadd double %22, 0x3FEE2B7DDDFEFA67
%31 = select i1 %29, double %30, double %22
br label %42
32: ; preds = %24
%33 = icmp sgt i32 %2, %0
br i1 %33, label %34, label %42
34: ; preds = %32
%35 = icmp eq i32 %1, %0
br i1 %35, label %36, label %38
36: ; preds = %34
%37 = fadd double %22, -1.000000e+00
br label %42
38: ; preds = %34
%39 = icmp sgt i32 %1, %0
%40 = fadd double %22, 0xBFF6A09E667F3BCD
%41 = select i1 %39, double %40, double %22
br label %42
42: ; preds = %38, %28, %4, %32, %36, %26
%43 = phi double [ %27, %26 ], [ %37, %36 ], [ %22, %32 ], [ %22, %4 ], [ %31, %28 ], [ %41, %38 ]
ret double %43
}