int rfun(y, per)
double y;
int per;
{
  double x;
  x = y;
  if ((y > .666666) && (per == 1))
    x = 1. - y;
  if (x > .33333333333)
    return (0);
  return ((int)(3. * 255 * sqrt((.333334 - x) * (x + .33334))));
}


x86 assembly (clang, -O0):
<rfun>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
mov    %edi,-0x14(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xec9(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    115d <rfun+0x4d>
cmpl   $0x1,-0x14(%rbp)
jne    115d <rfun+0x4d>
movsd  0xeb5(%rip),%xmm0
subsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  0xea6(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1180 <rfun+0x70>
movl   $0x0,-0x4(%rbp)
jmp    11b9 <rfun+0xa9>
movsd  0xea0(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  0xe8b(%rip),%xmm1
addsd  -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm0
call   1030 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xe6a(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rfun>:
push   %rax
movapd %xmm0,%xmm1
movsd  0xeeb(%rip),%xmm0
cmpltsd %xmm1,%xmm0
cmp    $0x1,%edi
je     112d <rfun+0x1d>
movapd %xmm1,%xmm2
jmp    1139 <rfun+0x29>
movsd  0xecb(%rip),%xmm2
subsd  %xmm1,%xmm2
andpd  %xmm0,%xmm2
andnpd %xmm1,%xmm0
orpd   %xmm2,%xmm0
xor    %eax,%eax
ucomisd 0xec1(%rip),%xmm0
ja     118a <rfun+0x7a>
movsd  0xebf(%rip),%xmm1
subsd  %xmm0,%xmm1
addsd  0xebb(%rip),%xmm0
mulsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1179 <rfun+0x69>
sqrtsd %xmm0,%xmm0
jmp    117e <rfun+0x6e>
call   1030 <sqrt@plt>
mulsd  0xea2(%rip),%xmm0
cvttsd2si %xmm0,%eax
pop    %rcx
ret

LLVM IR (-O0):
define i32 @rfun(double %0, i32 %1) {
%3 = alloca i32
%4 = alloca double
%5 = alloca i32
%6 = alloca double
store double %0, double* %4
store i32 %1, i32* %5
%7 = load double, double* %4
store double %7, double* %6
%8 = load double, double* %4
%9 = fcmp ogt double %8, 0x3FE55553EF6B5D46
br i1 %9, label %10, label %16
10: ; preds = %2
%11 = load i32, i32* %5
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load double, double* %4
%15 = fsub double 1.000000e+00, %14
store double %15, double* %6
br label %16
16: ; preds = %13, %10, %2
%17 = load double, double* %6
%18 = fcmp ogt double %17, 0x3FD5555555546AC5
br i1 %18, label %19, label %20
19: ; preds = %16
store i32 0, i32* %3
br label %29
20: ; preds = %16
%21 = load double, double* %6
%22 = fsub double 3.333340e-01, %21
%23 = load double, double* %6
%24 = fadd double %23, 3.333400e-01
%25 = fmul double %22, %24
%26 = call double @sqrt(double %25)
%27 = fmul double 7.650000e+02, %26
%28 = fptosi double %27 to i32
store i32 %28, i32* %3
br label %29
29: ; preds = %20, %19
%30 = load i32, i32* %3
ret i32 %30
}

LLVM IR (-O2):
define i32 @rfun(double %0, i32 %1) {
%3 = fcmp ogt double %0, 0x3FE55553EF6B5D46
%4 = icmp eq i32 %1, 1
%5 = and i1 %3, %4
%6 = fsub double 1.000000e+00, %0
%7 = select i1 %5, double %6, double %0
%8 = fcmp ogt double %7, 0x3FD5555555546AC5
br i1 %8, label %16, label %9
9: ; preds = %2
%10 = fsub double 3.333340e-01, %7
%11 = fadd double %7, 3.333400e-01
%12 = fmul double %10, %11
%13 = tail call double @sqrt(double %12)
%14 = fmul double %13, 7.650000e+02
%15 = fptosi double %14 to i32
br label %16
16: ; preds = %2, %9
%17 = phi i32 [ %15, %9 ], [ 0, %2 ]
ret i32 %17
}