#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 fabs(float);
float fmod(float, int);
float principal_angle(float angle) {
  float alpha;
  if (fabs(angle) < 3.14159265359) {
    return angle;
  } else {
    alpha = fmod(angle, 2 * 3.14159265359);
    if (alpha < -3.14159265359) {
      alpha += 2 * 3.14159265359;
    }
    if (alpha > 3.14159265359) {
      alpha -= 2 * 3.14159265359;
    }
    return alpha;
  }
}


x86 assembly (clang, -O0):
<principal_angle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
call   1040 <fabs@plt>
movaps %xmm0,%xmm1
movsd  0xebe(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    115b <principal_angle+0x3b>
movss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    11eb <principal_angle+0xcb>
movss  -0x8(%rbp),%xmm0
mov    $0x6,%edi
call   1030 <fmod@plt>
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm1
movsd  0xe88(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11a8 <principal_angle+0x88>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe75(%rip),%xmm1
addsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe47(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11e1 <principal_angle+0xc1>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe3c(%rip),%xmm1
subsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<principal_angle>:
push   %rax
movss  %xmm0,0x4(%rsp)
call   1040 <fabs@plt>
movsd  0xecc(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1142 <principal_angle+0x22>
movss  0x4(%rsp),%xmm0
pop    %rax
ret
movss  0x4(%rsp),%xmm0
mov    $0x6,%edi
call   1030 <fmod@plt>
cvtss2sd %xmm0,%xmm2
movsd  0xeaa(%rip),%xmm1
ucomisd %xmm2,%xmm1
jbe    1173 <principal_angle+0x53>
addsd  0xea4(%rip),%xmm2
xorps  %xmm0,%xmm0
cvtsd2ss %xmm2,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm0,%xmm1
ucomisd 0xe7e(%rip),%xmm1
jbe    1193 <principal_angle+0x73>
addsd  0xe8c(%rip),%xmm1
xorps  %xmm0,%xmm0
cvtsd2ss %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @principal_angle(float %0) {
%2 = alloca float
%3 = alloca float
%4 = alloca float
store float %0, float* %3
%5 = load float, float* %3
%6 = call double @fabs(float %5)
%7 = fcmp olt double %6, 0x400921FB54442EEA
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = load float, float* %3
store float %9, float* %2
br label %32
10: ; preds = %1
%11 = load float, float* %3
%12 = call float @fmod(float %11, i32 6)
store float %12, float* %4
%13 = load float, float* %4
%14 = fpext float %13 to double
%15 = fcmp olt double %14, 0xC00921FB54442EEA
br i1 %15, label %16, label %21
16: ; preds = %10
%17 = load float, float* %4
%18 = fpext float %17 to double
%19 = fadd double %18, 0x401921FB54442EEA
%20 = fptrunc double %19 to float
store float %20, float* %4
br label %21
21: ; preds = %16, %10
%22 = load float, float* %4
%23 = fpext float %22 to double
%24 = fcmp ogt double %23, 0x400921FB54442EEA
br i1 %24, label %25, label %30
25: ; preds = %21
%26 = load float, float* %4
%27 = fpext float %26 to double
%28 = fsub double %27, 0x401921FB54442EEA
%29 = fptrunc double %28 to float
store float %29, float* %4
br label %30
30: ; preds = %25, %21
%31 = load float, float* %4
store float %31, float* %2
br label %32
32: ; preds = %30, %8
%33 = load float, float* %2
ret float %33
}

LLVM IR (-O2):
define float @principal_angle(float %0) {
%2 = tail call double @fabs(float %0)
%3 = fcmp olt double %2, 0x400921FB54442EEA
br i1 %3, label %16, label %4
4: ; preds = %1
%5 = tail call float @fmod(float %0, i32 6)
%6 = fpext float %5 to double
%7 = fcmp olt double %6, 0xC00921FB54442EEA
%8 = fadd double %6, 0x401921FB54442EEA
%9 = fptrunc double %8 to float
%10 = select i1 %7, float %9, float %5
%11 = fpext float %10 to double
%12 = fcmp ogt double %11, 0x400921FB54442EEA
%13 = fadd double %11, 0xC01921FB54442EEA
%14 = fptrunc double %13 to float
%15 = select i1 %12, float %14, float %10
br label %16
16: ; preds = %1, %4
%17 = phi float [ %15, %4 ], [ %0, %1 ]
ret float %17
}