#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 floor(double);
double parangle(double phase, double b) {
  double x = phase - 0.5 * floor(2 * phase) - 0.25;
  x *= 16 * x;
  if (phase - floor(phase) < 0.5) {
    return x - 1;
  }
  return 1 - x;
}


x86 assembly (clang, -O0):
<parangle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xeec(%rip),%xmm0
mulsd  -0x10(%rbp),%xmm0
call   1030 <floor@plt>
movsd  -0x30(%rbp),%xmm1
movsd  0xecd(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  0xeb5(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe9c(%rip),%xmm0
mulsd  -0x20(%rbp),%xmm0
mulsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1030 <floor@plt>
movsd  -0x28(%rbp),%xmm1
subsd  %xmm0,%xmm1
movsd  0xe60(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11c5 <parangle+0xb5>
movsd  -0x20(%rbp),%xmm0
movsd  0xe71(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11d7 <parangle+0xc7>
movsd  0xe5b(%rip),%xmm0
subsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parangle>:
sub    $0x28,%rsp
movapd %xmm0,0x10(%rsp)
addsd  %xmm0,%xmm0
call   1030 <floor@plt>
mulsd  0xed5(%rip),%xmm0
movapd 0x10(%rsp),%xmm1
addsd  %xmm1,%xmm0
addsd  0xecb(%rip),%xmm0
movsd  0xecb(%rip),%xmm2
mulsd  %xmm0,%xmm2
mulsd  %xmm0,%xmm2
movsd  %xmm2,0x8(%rsp)
movapd %xmm1,%xmm0
call   1030 <floor@plt>
movapd 0x10(%rsp),%xmm2
subsd  %xmm0,%xmm2
movsd  0xeaa(%rip),%xmm0
movsd  0x8(%rsp),%xmm3
addsd  %xmm3,%xmm0
movsd  0xea0(%rip),%xmm1
cmpltsd 0xe9f(%rip),%xmm2
subsd  %xmm3,%xmm1
andpd  %xmm2,%xmm0
andnpd %xmm1,%xmm2
orpd   %xmm0,%xmm2
movapd %xmm2,%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
define double @parangle(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca double
%6 = alloca double
store double %0, double* %4
store double %1, double* %5
%7 = load double, double* %4
%8 = load double, double* %4
%9 = fmul double 2.000000e+00, %8
%10 = call double @llvm.floor.f64(double %9)
%11 = call double @llvm.fmuladd.f64(double -5.000000e-01, double %10, double %7)
%12 = fsub double %11, 2.500000e-01
store double %12, double* %6
%13 = load double, double* %6
%14 = fmul double 1.600000e+01, %13
%15 = load double, double* %6
%16 = fmul double %15, %14
store double %16, double* %6
%17 = load double, double* %4
%18 = load double, double* %4
%19 = call double @llvm.floor.f64(double %18)
%20 = fsub double %17, %19
%21 = fcmp olt double %20, 5.000000e-01
br i1 %21, label %22, label %25
22: ; preds = %2
%23 = load double, double* %6
%24 = fsub double %23, 1.000000e+00
store double %24, double* %3
br label %28
25: ; preds = %2
%26 = load double, double* %6
%27 = fsub double 1.000000e+00, %26
store double %27, double* %3
br label %28
28: ; preds = %25, %22
%29 = load double, double* %3
ret double %29
}

LLVM IR (-O2):
define double @parangle(double %0, double %1) {
%3 = fmul double %0, 2.000000e+00
%4 = tail call double @llvm.floor.f64(double %3)
%5 = tail call double @llvm.fmuladd.f64(double %4, double -5.000000e-01, double %0)
%6 = fadd double %5, -2.500000e-01
%7 = fmul double %6, 1.600000e+01
%8 = fmul double %6, %7
%9 = tail call double @llvm.floor.f64(double %0)
%10 = fsub double %0, %9
%11 = fcmp olt double %10, 5.000000e-01
%12 = fadd double %8, -1.000000e+00
%13 = fsub double 1.000000e+00, %8
%14 = select i1 %11, double %12, double %13
ret double %14
}