#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 */
float calcc1Spiral(float, float);
float sqrt(float);
float calcGtwistSpiral(float kr, float fr, float interleaves) {
  float gtwist;
  float c1 = calcc1Spiral(fr, interleaves);
  float c2 = 0.0f;
  gtwist = c1 * kr * kr - c2;
  gtwist = sqrt((gtwist > 0) ? gtwist : 0);
  return gtwist;
}


x86 assembly (clang, -O0):
<calcGtwistSpiral>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
movss  %xmm2,-0xc(%rbp)
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
call   1030 <calcc1Spiral@plt>
movss  %xmm0,-0x14(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
movss  -0x14(%rbp),%xmm0
mulss  -0x4(%rbp),%xmm0
movss  -0x4(%rbp),%xmm2
movss  -0x18(%rbp),%xmm1
movd   %xmm1,%eax
xor    $0x80000000,%eax
movd   %eax,%xmm1
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    11a1 <calcGtwistSpiral+0x81>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    11ae <calcGtwistSpiral+0x8e>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
jmp    11ae <calcGtwistSpiral+0x8e>
movss  -0x1c(%rbp),%xmm0
call   1040 <sqrt@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<calcGtwistSpiral>:
push   %rax
movss  %xmm0,0x4(%rsp)
movaps %xmm1,%xmm0
movaps %xmm2,%xmm1
call   1030 <calcc1Spiral@plt>
movss  0x4(%rsp),%xmm1
mulss  %xmm1,%xmm0
mulss  %xmm1,%xmm0
xorps  %xmm1,%xmm1
maxss  %xmm1,%xmm0
ucomiss %xmm1,%xmm0
jb     1152 <calcGtwistSpiral+0x32>
sqrtss %xmm0,%xmm0
pop    %rax
ret
pop    %rax
jmp    1040 <sqrt@plt>

LLVM IR (-O0):
define float @calcGtwistSpiral(float %0, float %1, float %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca float
%8 = alloca float
%9 = alloca float
store float %0, float* %4
store float %1, float* %5
store float %2, float* %6
%10 = load float, float* %5
%11 = load float, float* %6
%12 = call float @calcc1Spiral(float %10, float %11)
store float %12, float* %8
store float 0.000000e+00, float* %9
%13 = load float, float* %8
%14 = load float, float* %4
%15 = fmul float %13, %14
%16 = load float, float* %4
%17 = load float, float* %9
%18 = fneg float %17
%19 = call float @llvm.fmuladd.f32(float %15, float %16, float %18)
store float %19, float* %7
%20 = load float, float* %7
%21 = fcmp ogt float %20, 0.000000e+00
br i1 %21, label %22, label %24
22: ; preds = %3
%23 = load float, float* %7
br label %25
24: ; preds = %3
br label %25
25: ; preds = %24, %22
%26 = phi float [ %23, %22 ], [ 0.000000e+00, %24 ]
%27 = call float @sqrt(float %26)
store float %27, float* %7
%28 = load float, float* %7
ret float %28
}

LLVM IR (-O2):
define float @calcGtwistSpiral(float %0, float %1, float %2) {
%4 = tail call float @calcc1Spiral(float %1, float %2)
%5 = fmul float %4, %0
%6 = fmul float %5, %0
%7 = fcmp ogt float %6, 0.000000e+00
%8 = select i1 %7, float %6, float 0.000000e+00
%9 = tail call float @sqrt(float %8)
ret float %9
}