#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 */
int M_PI;
long double fmodl(long double, int);
double _mod_unit_circle_radians(double radians) {
  long double x;
  if (radians > 2 * M_PI || radians < -2 * M_PI) {
    x = fmodl((long double)radians, 2 * M_PI);
  } else {
    x = radians;
  }
  return (double)x;
}


x86 assembly (clang, -O0):
<_mod_unit_circle_radians>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
mov    0x2ebf(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm1
ucomisd %xmm1,%xmm0
ja     115c <_mod_unit_circle_radians+0x4c>
movsd  -0x8(%rbp),%xmm1
mov    0x2ea0(%rip),%rax
imul   $0xfffffffe,(%rax),%eax
cvtsi2sd %eax,%xmm0
ucomisd %xmm1,%xmm0
jbe    117c <_mod_unit_circle_radians+0x6c>
fldl   -0x8(%rbp)
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
add    %edi,%edi
mov    %rsp,%rax
fstpt  (%rax)
call   1030 <fmodl@plt>
fstpt  -0x20(%rbp)
jmp    1182 <_mod_unit_circle_radians+0x72>
fldl   -0x8(%rbp)
fstpt  -0x20(%rbp)
fldt   -0x20(%rbp)
fstpl  -0x28(%rbp)
movsd  -0x28(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_mod_unit_circle_radians>:
sub    $0x28,%rsp
mov    0x2ecd(%rip),%rax
mov    (%rax),%edi
add    %edi,%edi
cvtsi2sd %edi,%xmm1
ucomisd %xmm1,%xmm0
ja     113a <_mod_unit_circle_radians+0x2a>
mov    %edi,%eax
neg    %eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
ucomisd %xmm0,%xmm1
jbe    114e <_mod_unit_circle_radians+0x3e>
movsd  %xmm0,0x18(%rsp)
fldl   0x18(%rsp)
fstpt  (%rsp)
call   1030 <fmodl@plt>
jmp    1158 <_mod_unit_circle_radians+0x48>
movsd  %xmm0,0x20(%rsp)
fldl   0x20(%rsp)
fstpl  0x10(%rsp)
movsd  0x10(%rsp),%xmm0
add    $0x28,%rsp
ret

LLVM IR (-O0):
@M_PI = global i32 0
define double @_mod_unit_circle_radians(double %0) {
%2 = alloca double
%3 = alloca x86_fp80
store double %0, double* %2
%4 = load double, double* %2
%5 = load i32, i32* @M_PI
%6 = mul nsw i32 2, %5
%7 = sitofp i32 %6 to double
%8 = fcmp ogt double %4, %7
br i1 %8, label %15, label %9
9: ; preds = %1
%10 = load double, double* %2
%11 = load i32, i32* @M_PI
%12 = mul nsw i32 -2, %11
%13 = sitofp i32 %12 to double
%14 = fcmp olt double %10, %13
br i1 %14, label %15, label %21
15: ; preds = %9, %1
%16 = load double, double* %2
%17 = fpext double %16 to x86_fp80
%18 = load i32, i32* @M_PI
%19 = mul nsw i32 2, %18
%20 = call x86_fp80 @fmodl(x86_fp80 %17, i32 %19)
store x86_fp80 %20, x86_fp80* %3
br label %24
21: ; preds = %9
%22 = load double, double* %2
%23 = fpext double %22 to x86_fp80
store x86_fp80 %23, x86_fp80* %3
br label %24
24: ; preds = %21, %15
%25 = load x86_fp80, x86_fp80* %3
%26 = fptrunc x86_fp80 %25 to double
ret double %26
}

LLVM IR (-O2):
@M_PI = global i32 0
define double @_mod_unit_circle_radians(double %0) {
%2 = load i32, i32* @M_PI
%3 = shl nsw i32 %2, 1
%4 = sitofp i32 %3 to double
%5 = fcmp olt double %4, %0
br i1 %5, label %10, label %6
6: ; preds = %1
%7 = mul nsw i32 %2, -2
%8 = sitofp i32 %7 to double
%9 = fcmp ogt double %8, %0
br i1 %9, label %10, label %13
10: ; preds = %6, %1
%11 = fpext double %0 to x86_fp80
%12 = tail call x86_fp80 @fmodl(x86_fp80 %11, i32 %3)
br label %15
13: ; preds = %6
%14 = fpext double %0 to x86_fp80
br label %15
15: ; preds = %13, %10
%16 = phi x86_fp80 [ %12, %10 ], [ %14, %13 ]
%17 = fptrunc x86_fp80 %16 to double
ret double %17
}