#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 powl(int, int);
long double normalize_radians(long double rad) {
  if (rad >= 2 * ((long double)3.14159265358979323)) {
    while (rad > 2 * ((long double)3.14159265358979323))
      rad -= 2 * ((long double)3.14159265358979323);
  } else if (rad < 0) {
    while (rad < 0)
      rad += 2 * ((long double)3.14159265358979323);
  }
  if (rad < 0)
    rad = 0;
  else if (rad >= 2 * ((long double)3.14159265358979323))
    rad = (2 * ((long double)3.14159265358979323)) - powl(2, -11);
  return rad;
}


x86 assembly (clang, -O0):
<normalize_radians>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
fldt   0x10(%rbp)
fstpt  -0x10(%rbp)
fldt   -0x10(%rbp)
fldl   0xed9(%rip)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jb     116f <normalize_radians+0x5f>
jmp    1138 <normalize_radians+0x28>
jmp    113d <normalize_radians+0x2d>
fldt   -0x10(%rbp)
fldl   0xeba(%rip)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jbe    116a <normalize_radians+0x5a>
jmp    1157 <normalize_radians+0x47>
fldt   -0x10(%rbp)
fldl   0xea8(%rip)
faddp  %st,%st(1)
fstpt  -0x10(%rbp)
jmp    113d <normalize_radians+0x2d>
jmp    11b9 <normalize_radians+0xa9>
fldt   -0x10(%rbp)
fldz
fucomip %st(1),%st
fstp   %st(0)
jbe    11b4 <normalize_radians+0xa4>
jmp    1183 <normalize_radians+0x73>
jmp    1188 <normalize_radians+0x78>
fldt   -0x10(%rbp)
fldz
fucomip %st(1),%st
fstp   %st(0)
jbe    11af <normalize_radians+0x9f>
jmp    119c <normalize_radians+0x8c>
fldt   -0x10(%rbp)
fldl   0xe5b(%rip)
faddp  %st,%st(1)
fstpt  -0x10(%rbp)
jmp    1188 <normalize_radians+0x78>
jmp    11b4 <normalize_radians+0xa4>
jmp    11b9 <normalize_radians+0xa9>
fldt   -0x10(%rbp)
fldz
fucomip %st(1),%st
fstp   %st(0)
jbe    11d7 <normalize_radians+0xc7>
jmp    11cd <normalize_radians+0xbd>
fldz
fstpt  -0x10(%rbp)
jmp    1216 <normalize_radians+0x106>
fldt   -0x10(%rbp)
fldl   0xe20(%rip)
fxch   %st(1)
fucomip %st(1),%st
fstp   %st(0)
jb     1211 <normalize_radians+0x101>
jmp    11f1 <normalize_radians+0xe1>
mov    $0x2,%edi
mov    $0xfffffff5,%esi
call   1030 <powl@plt>
mov    %eax,-0x14(%rbp)
fildl  -0x14(%rbp)
fldl   0xdf4(%rip)
fsubp  %st,%st(1)
fstpt  -0x10(%rbp)
jmp    1216 <normalize_radians+0x106>
fldt   -0x10(%rbp)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<normalize_radians>:
sub    $0x18,%rsp
fldt   0x20(%rsp)
fldl   0xee2(%rip)
fxch   %st(1)
fucomi %st(1),%st
jae    1140 <normalize_radians+0x30>
fldz
fucomi %st(1),%st
jbe    1160 <normalize_radians+0x50>
nopw   0x0(%rax,%rax,1)
fxch   %st(1)
faddl  0xec8(%rip)
fxch   %st(1)
fucomi %st(1),%st
ja     1130 <normalize_radians+0x20>
jmp    1164 <normalize_radians+0x54>
jbe    1162 <normalize_radians+0x52>
fldz
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
fstp   %st(0)
faddl  0xeb0(%rip)
fucomi %st(1),%st
fldz
ja     1150 <normalize_radians+0x40>
jmp    1164 <normalize_radians+0x54>
fstp   %st(0)
fldz
fstp   %st(0)
fldz
fucomi %st(1),%st
ja     119f <normalize_radians+0x8f>
fstp   %st(0)
fucomi %st(1),%st
fldz
fxch   %st(1)
jb     119f <normalize_radians+0x8f>
fstp   %st(1)
fstp   %st(0)
mov    $0x2,%edi
mov    $0xfffffff5,%esi
fstpt  0xc(%rsp)
call   1030 <powl@plt>
mov    %eax,0x8(%rsp)
fldt   0xc(%rsp)
fisubl 0x8(%rsp)
fldz
fldz
fxch   %st(2)
fstp   %st(1)
fstp   %st(1)
add    $0x18,%rsp
ret

LLVM IR (-O0):
define x86_fp80 @normalize_radians(x86_fp80 %0) {
%2 = alloca x86_fp80
store x86_fp80 %0, x86_fp80* %2
%3 = load x86_fp80, x86_fp80* %2
%4 = fcmp oge x86_fp80 %3, 0xK4001C90FDAA22168C000
br i1 %4, label %5, label %13
5: ; preds = %1
br label %6
6: ; preds = %9, %5
%7 = load x86_fp80, x86_fp80* %2
%8 = fcmp ogt x86_fp80 %7, 0xK4001C90FDAA22168C000
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = load x86_fp80, x86_fp80* %2
%11 = fsub x86_fp80 %10, 0xK4001C90FDAA22168C000
store x86_fp80 %11, x86_fp80* %2
br label %6
12: ; preds = %6
br label %25
13: ; preds = %1
%14 = load x86_fp80, x86_fp80* %2
%15 = fcmp olt x86_fp80 %14, 0xK00000000000000000000
br i1 %15, label %16, label %24
16: ; preds = %13
br label %17
17: ; preds = %20, %16
%18 = load x86_fp80, x86_fp80* %2
%19 = fcmp olt x86_fp80 %18, 0xK00000000000000000000
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load x86_fp80, x86_fp80* %2
%22 = fadd x86_fp80 %21, 0xK4001C90FDAA22168C000
store x86_fp80 %22, x86_fp80* %2
br label %17
23: ; preds = %17
br label %24
24: ; preds = %23, %13
br label %25
25: ; preds = %24, %12
%26 = load x86_fp80, x86_fp80* %2
%27 = fcmp olt x86_fp80 %26, 0xK00000000000000000000
br i1 %27, label %28, label %29
28: ; preds = %25
store x86_fp80 0xK00000000000000000000, x86_fp80* %2
br label %37
29: ; preds = %25
%30 = load x86_fp80, x86_fp80* %2
%31 = fcmp oge x86_fp80 %30, 0xK4001C90FDAA22168C000
br i1 %31, label %32, label %36
32: ; preds = %29
%33 = call i32 @powl(i32 2, i32 -11)
%34 = sitofp i32 %33 to x86_fp80
%35 = fsub x86_fp80 0xK4001C90FDAA22168C000, %34
store x86_fp80 %35, x86_fp80* %2
br label %36
36: ; preds = %32, %29
br label %37
37: ; preds = %36, %28
%38 = load x86_fp80, x86_fp80* %2
ret x86_fp80 %38
}

LLVM IR (-O2):
define x86_fp80 @normalize_radians(x86_fp80 %0) {
%2 = fcmp ult x86_fp80 %0, 0xK4001C90FDAA22168C000
br i1 %2, label %9, label %3
3: ; preds = %1
%4 = fcmp ogt x86_fp80 %0, 0xK4001C90FDAA22168C000
br i1 %4, label %5, label %15
5: ; preds = %3, %5
%6 = phi x86_fp80 [ %7, %5 ], [ %0, %3 ]
%7 = fadd x86_fp80 %6, 0xKC001C90FDAA22168C000
%8 = fcmp ogt x86_fp80 %7, 0xK4001C90FDAA22168C000
br i1 %8, label %5, label %15
9: ; preds = %1
%10 = fcmp olt x86_fp80 %0, 0xK00000000000000000000
br i1 %10, label %11, label %15
11: ; preds = %9, %11
%12 = phi x86_fp80 [ %13, %11 ], [ %0, %9 ]
%13 = fadd x86_fp80 %12, 0xK4001C90FDAA22168C000
%14 = fcmp olt x86_fp80 %13, 0xK00000000000000000000
br i1 %14, label %11, label %15
15: ; preds = %5, %11, %3, %9
%16 = phi x86_fp80 [ %0, %9 ], [ %0, %3 ], [ %13, %11 ], [ %7, %5 ]
%17 = fcmp olt x86_fp80 %16, 0xK00000000000000000000
br i1 %17, label %24, label %18
18: ; preds = %15
%19 = fcmp ult x86_fp80 %16, 0xK4001C90FDAA22168C000
br i1 %19, label %24, label %20
20: ; preds = %18
%21 = tail call i32 @powl(i32 2, i32 -11)
%22 = sitofp i32 %21 to x86_fp80
%23 = fsub x86_fp80 0xK4001C90FDAA22168C000, %22
br label %24
24: ; preds = %15, %18, %20
%25 = phi x86_fp80 [ %23, %20 ], [ %16, %18 ], [ 0xK00000000000000000000, %15 ]
ret x86_fp80 %25
}