#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;
double fmod(double const, int);
scalar_t__ isinf(double const);
double absAngle(const double angle) {
  if (isinf(angle))
    return (2 * M_PI);
  double absangle = fmod(angle, (2 * M_PI));
  if (absangle < 0)
    absangle += (2 * M_PI);
  return absangle;
}


x86 assembly (clang, -O0):
<absAngle>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <isinf@plt>
cmp    $0x0,%rax
je     115b <absAngle+0x3b>
mov    0x2ea0(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    11a8 <absAngle+0x88>
movsd  -0x10(%rbp),%xmm0
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
shl    $0x1,%edi
call   1030 <fmod@plt>
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    119e <absAngle+0x7e>
mov    0x2e5d(%rip),%rax
mov    (%rax),%eax
shl    $0x1,%eax
cvtsi2sd %eax,%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<absAngle>:
push   %rbx
sub    $0x10,%rsp
movsd  %xmm0,0x8(%rsp)
call   1040 <isinf@plt>
mov    0x2eb1(%rip),%rbx
mov    (%rbx),%edi
add    %edi,%edi
test   %rax,%rax
je     1149 <absAngle+0x29>
xorps  %xmm0,%xmm0
cvtsi2sd %edi,%xmm0
jmp    1185 <absAngle+0x65>
movsd  0x8(%rsp),%xmm0
call   1030 <fmod@plt>
mov    (%rbx),%eax
add    %eax,%eax
cvtsi2sd %eax,%xmm2
movapd %xmm0,%xmm1
xorpd  %xmm3,%xmm3
cmpltsd %xmm3,%xmm0
movsd  0xe8f(%rip),%xmm3
movapd %xmm0,%xmm4
andnpd %xmm3,%xmm4
andpd  %xmm2,%xmm0
orpd   %xmm4,%xmm0
addsd  %xmm1,%xmm0
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@M_PI = global i32 0
define double @absAngle(double %0) {
%2 = alloca double
%3 = alloca double
%4 = alloca double
store double %0, double* %3
%5 = load double, double* %3
%6 = call i64 @isinf(double %5)
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = load i32, i32* @M_PI
%10 = mul nsw i32 2, %9
%11 = sitofp i32 %10 to double
store double %11, double* %2
br label %27
12: ; preds = %1
%13 = load double, double* %3
%14 = load i32, i32* @M_PI
%15 = mul nsw i32 2, %14
%16 = call double @fmod(double %13, i32 %15)
store double %16, double* %4
%17 = load double, double* %4
%18 = fcmp olt double %17, 0.000000e+00
br i1 %18, label %19, label %25
19: ; preds = %12
%20 = load i32, i32* @M_PI
%21 = mul nsw i32 2, %20
%22 = sitofp i32 %21 to double
%23 = load double, double* %4
%24 = fadd double %23, %22
store double %24, double* %4
br label %25
25: ; preds = %19, %12
%26 = load double, double* %4
store double %26, double* %2
br label %27
27: ; preds = %25, %8
%28 = load double, double* %2
ret double %28
}

LLVM IR (-O2):
@M_PI = global i32 0
define double @absAngle(double %0) {
%2 = tail call i64 @isinf(double %0)
%3 = icmp eq i64 %2, 0
%4 = load i32, i32* @M_PI
%5 = shl nsw i32 %4, 1
br i1 %3, label %8, label %6
6: ; preds = %1
%7 = sitofp i32 %5 to double
br label %16
8: ; preds = %1
%9 = tail call double @fmod(double %0, i32 %5)
%10 = fcmp olt double %9, 0.000000e+00
%11 = load i32, i32* @M_PI
%12 = shl nsw i32 %11, 1
%13 = sitofp i32 %12 to double
%14 = select i1 %10, double %13, double -0.000000e+00
%15 = fadd double %9, %14
br label %16
16: ; preds = %8, %6
%17 = phi double [ %7, %6 ], [ %15, %8 ]
ret double %17
}