#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 fmod(double, double);
double sqrt(double);
double circ(double x) {
  const double u = fmod(x, 6.28318530717958647693);
  const double temp0 =
      1.57079632679489661923 -
      ((u < 3.14159265358979323846) ? u : (u - 3.14159265358979323846));
  const double temp1 =
      sqrt(2.46740110027233965471 - temp0 * temp0) / 1.57079632679489661923;
  return (u < 3.14159265358979323846) ? temp1 : -temp1;
}


x86 assembly (clang, -O0):
<circ>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  0xece(%rip),%xmm1
call   1030 <fmod@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  0xeb4(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1166 <circ+0x46>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    117c <circ+0x5c>
movsd  -0x10(%rbp),%xmm0
movsd  0xe8d(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  0xe87(%rip),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm1,%xmm0
movsd  0xe59(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movsd  0xe40(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe1f(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11fb <circ+0xdb>
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
jmp    121c <circ+0xfc>
movsd  -0x20(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<circ>:
sub    $0x18,%rsp
movsd  0xed4(%rip),%xmm1
call   1030 <fmod@plt>
movsd  0xecf(%rip),%xmm1
movapd %xmm0,%xmm3
cmpltsd 0xeca(%rip),%xmm3
addsd  %xmm0,%xmm1
andpd  %xmm3,%xmm0
movapd %xmm3,%xmm2
andnpd %xmm1,%xmm2
orpd   %xmm0,%xmm2
movsd  0xeb6(%rip),%xmm1
subsd  %xmm2,%xmm1
mulsd  %xmm1,%xmm1
movsd  0xeae(%rip),%xmm0
subsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1186 <circ+0x66>
sqrtsd %xmm0,%xmm0
jmp    1195 <circ+0x75>
movapd %xmm3,(%rsp)
call   1040 <sqrt@plt>
movapd (%rsp),%xmm3
divsd  0xe7b(%rip),%xmm0
movapd 0xe8b(%rip),%xmm1
xorpd  %xmm0,%xmm1
andpd  %xmm3,%xmm0
andnpd %xmm1,%xmm3
orpd   %xmm0,%xmm3
movapd %xmm3,%xmm0
add    $0x18,%rsp
ret

LLVM IR (-O0):
define double @circ(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
%5 = alloca double
store double %0, double* %2
%6 = load double, double* %2
%7 = call double @fmod(double %6, double 0x401921FB54442D18)
store double %7, double* %3
%8 = load double, double* %3
%9 = fcmp olt double %8, 0x400921FB54442D18
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = load double, double* %3
br label %15
12: ; preds = %1
%13 = load double, double* %3
%14 = fsub double %13, 0x400921FB54442D18
br label %15
15: ; preds = %12, %10
%16 = phi double [ %11, %10 ], [ %14, %12 ]
%17 = fsub double 0x3FF921FB54442D18, %16
store double %17, double* %4
%18 = load double, double* %4
%19 = load double, double* %4
%20 = fneg double %18
%21 = call double @llvm.fmuladd.f64(double %20, double %19, double 0x4003BD3CC9BE45DE)
%22 = call double @sqrt(double %21)
%23 = fdiv double %22, 0x3FF921FB54442D18
store double %23, double* %5
%24 = load double, double* %3
%25 = fcmp olt double %24, 0x400921FB54442D18
br i1 %25, label %26, label %28
26: ; preds = %15
%27 = load double, double* %5
br label %31
28: ; preds = %15
%29 = load double, double* %5
%30 = fneg double %29
br label %31
31: ; preds = %28, %26
%32 = phi double [ %27, %26 ], [ %30, %28 ]
ret double %32
}

LLVM IR (-O2):
define double @circ(double %0) {
%2 = tail call double @fmod(double %0, double 0x401921FB54442D18)
%3 = fcmp olt double %2, 0x400921FB54442D18
%4 = fadd double %2, 0xC00921FB54442D18
%5 = select i1 %3, double %2, double %4
%6 = fsub double 0x3FF921FB54442D18, %5
%7 = fneg double %6
%8 = tail call double @llvm.fmuladd.f64(double %7, double %6, double 0x4003BD3CC9BE45DE)
%9 = tail call double @sqrt(double %8)
%10 = fdiv double %9, 0x3FF921FB54442D18
%11 = fneg double %10
%12 = select i1 %3, double %10, double %11
ret double %12
}