#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 M_PI;
double normalize_radian(double theta) {
  int multiplier;
  if (theta >= -M_PI && theta < M_PI)
    return theta;
  multiplier = (int)(theta / (2 * M_PI));
  theta = theta - multiplier * 2 * M_PI;
  if (theta >= M_PI)
    theta -= 2 * M_PI;
  if (theta < -M_PI)
    theta += 2 * M_PI;
  return theta;
}


x86 assembly (clang, -O0):
<normalize_radian>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    0x2ed3(%rip),%rax
movsd  (%rax),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
ucomisd %xmm1,%xmm0
jb     1163 <normalize_radian+0x63>
movsd  -0x10(%rbp),%xmm1
mov    0x2ea2(%rip),%rax
movsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
jbe    1163 <normalize_radian+0x63>
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    124f <normalize_radian+0x14f>
movsd  -0x10(%rbp),%xmm0
movsd  0xe90(%rip),%xmm1
mov    0x2e71(%rip),%rax
mulsd  (%rax),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x14(%rbp)
movsd  -0x10(%rbp),%xmm1
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
mov    0x2e4c(%rip),%rax
movsd  (%rax),%xmm2
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    0x2e18(%rip),%rax
ucomisd (%rax),%xmm0
jb     11f7 <normalize_radian+0xf7>
mov    0x2e07(%rip),%rax
movsd  (%rax),%xmm1
movsd  -0x10(%rbp),%xmm0
addsd  %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm1
mov    0x2de5(%rip),%rax
movsd  (%rax),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
ucomisd %xmm1,%xmm0
jbe    1245 <normalize_radian+0x145>
mov    0x2db9(%rip),%rax
movsd  (%rax),%xmm0
movsd  -0x10(%rbp),%xmm1
addsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<normalize_radian>:
mov    0x2ee1(%rip),%rax
movsd  (%rax),%xmm1
movapd 0xeed(%rip),%xmm2
xorpd  %xmm1,%xmm2
ucomisd %xmm2,%xmm0
jb     1124 <normalize_radian+0x24>
ucomisd %xmm0,%xmm1
jbe    1124 <normalize_radian+0x24>
ret
movapd %xmm1,%xmm3
addsd  %xmm1,%xmm3
movapd %xmm0,%xmm4
divsd  %xmm3,%xmm4
cvttsd2si %xmm4,%eax
add    %eax,%eax
xorps  %xmm4,%xmm4
cvtsi2sd %eax,%xmm4
mulsd  %xmm1,%xmm4
subsd  %xmm4,%xmm0
movapd %xmm0,%xmm4
subsd  %xmm3,%xmm4
cmpnlesd %xmm0,%xmm1
andpd  %xmm1,%xmm0
andnpd %xmm4,%xmm1
orpd   %xmm0,%xmm1
addsd  %xmm1,%xmm3
movapd %xmm1,%xmm0
cmpltsd %xmm2,%xmm0
andpd  %xmm0,%xmm3
andnpd %xmm1,%xmm0
orpd   %xmm3,%xmm0
ret

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
define double @normalize_radian(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca i32
store double %0, double* %3
%5 = load double, double* %3
%6 = load double, double* @M_PI
%7 = fneg double %6
%8 = fcmp oge double %5, %7
br i1 %8, label %9, label %15
9: ; preds = %1
%10 = load double, double* %3
%11 = load double, double* @M_PI
%12 = fcmp olt double %10, %11
br i1 %12, label %13, label %15
13: ; preds = %9
%14 = load double, double* %3
store double %14, double* %2
br label %46
15: ; preds = %9, %1
%16 = load double, double* %3
%17 = load double, double* @M_PI
%18 = fmul double 2.000000e+00, %17
%19 = fdiv double %16, %18
%20 = fptosi double %19 to i32
store i32 %20, i32* %4
%21 = load double, double* %3
%22 = load i32, i32* %4
%23 = mul nsw i32 %22, 2
%24 = sitofp i32 %23 to double
%25 = load double, double* @M_PI
%26 = fneg double %24
%27 = call double @llvm.fmuladd.f64(double %26, double %25, double %21)
store double %27, double* %3
%28 = load double, double* %3
%29 = load double, double* @M_PI
%30 = fcmp oge double %28, %29
br i1 %30, label %31, label %35
31: ; preds = %15
%32 = load double, double* @M_PI
%33 = load double, double* %3
%34 = call double @llvm.fmuladd.f64(double -2.000000e+00, double %32, double %33)
store double %34, double* %3
br label %35
35: ; preds = %31, %15
%36 = load double, double* %3
%37 = load double, double* @M_PI
%38 = fneg double %37
%39 = fcmp olt double %36, %38
br i1 %39, label %40, label %44
40: ; preds = %35
%41 = load double, double* @M_PI
%42 = load double, double* %3
%43 = call double @llvm.fmuladd.f64(double 2.000000e+00, double %41, double %42)
store double %43, double* %3
br label %44
44: ; preds = %40, %35
%45 = load double, double* %3
store double %45, double* %2
br label %46
46: ; preds = %44, %13
%47 = load double, double* %2
ret double %47
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
define double @normalize_radian(double %0) {
%2 = load double, double* @M_PI
%3 = fneg double %2
%4 = fcmp ole double %3, %0
%5 = fcmp ogt double %2, %0
%6 = and i1 %4, %5
br i1 %6, label %21, label %7
7: ; preds = %1
%8 = fmul double %2, 2.000000e+00
%9 = fdiv double %0, %8
%10 = fptosi double %9 to i32
%11 = shl nsw i32 %10, 1
%12 = sitofp i32 %11 to double
%13 = fneg double %12
%14 = tail call double @llvm.fmuladd.f64(double %13, double %2, double %0)
%15 = fcmp ult double %14, %2
%16 = tail call double @llvm.fmuladd.f64(double %2, double -2.000000e+00, double %14)
%17 = select i1 %15, double %14, double %16
%18 = fcmp olt double %17, %3
%19 = tail call double @llvm.fmuladd.f64(double %2, double 2.000000e+00, double %17)
%20 = select i1 %18, double %19, double %17
br label %21
21: ; preds = %1, %7
%22 = phi double [ %20, %7 ], [ %0, %1 ]
ret double %22
}