#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 derotate_deg(float a) {
  int i;
  i = fabs(a) / 360.0;
  if (a > 0)
    a -= 360 * i;
  else
    a += 360 * i;
  if (a < 0)
    a += 360;
  return a;
}


x86 assembly (clang, -O0):
<derotate_deg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
call   1030 <fabs@plt>
movsd  0xed1(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x8(%rbp)
movss  -0x4(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jbe    1169 <derotate_deg+0x59>
imul   $0x168,-0x8(%rbp),%eax
cvtsi2ss %eax,%xmm1
movss  -0x4(%rbp),%xmm0
subss  %xmm1,%xmm0
movss  %xmm0,-0x4(%rbp)
jmp    117e <derotate_deg+0x6e>
imul   $0x168,-0x8(%rbp),%eax
cvtsi2ss %eax,%xmm0
addss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
xorps  %xmm0,%xmm0
ucomiss -0x4(%rbp),%xmm0
jbe    119d <derotate_deg+0x8d>
movss  0xe75(%rip),%xmm0
addss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movss  -0x4(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<derotate_deg>:
push   %rax
movss  %xmm0,0x4(%rsp)
call   1030 <fabs@plt>
divsd  0xedc(%rip),%xmm0
cvttsd2si %xmm0,%eax
imul   $0x168,%eax,%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
movaps 0xed4(%rip),%xmm1
xorps  %xmm0,%xmm1
xorps  %xmm2,%xmm2
xorps  %xmm3,%xmm3
movss  0x4(%rsp),%xmm5
cmpltss %xmm5,%xmm3
movaps %xmm3,%xmm4
andnps %xmm0,%xmm4
andps  %xmm1,%xmm3
orps   %xmm4,%xmm3
addss  %xmm5,%xmm3
movss  0xeb8(%rip),%xmm1
addss  %xmm3,%xmm1
movaps %xmm3,%xmm0
cmpltss %xmm2,%xmm0
andps  %xmm0,%xmm1
andnps %xmm3,%xmm0
orps   %xmm1,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define float @derotate_deg(float %0) {
%2 = alloca float
%3 = alloca i32
store float %0, float* %2
%4 = load float, float* %2
%5 = call double @fabs(float %4)
%6 = fdiv double %5, 3.600000e+02
%7 = fptosi double %6 to i32
store i32 %7, i32* %3
%8 = load float, float* %2
%9 = fcmp ogt float %8, 0.000000e+00
br i1 %9, label %10, label %16
10: ; preds = %1
%11 = load i32, i32* %3
%12 = mul nsw i32 360, %11
%13 = sitofp i32 %12 to float
%14 = load float, float* %2
%15 = fsub float %14, %13
store float %15, float* %2
br label %22
16: ; preds = %1
%17 = load i32, i32* %3
%18 = mul nsw i32 360, %17
%19 = sitofp i32 %18 to float
%20 = load float, float* %2
%21 = fadd float %20, %19
store float %21, float* %2
br label %22
22: ; preds = %16, %10
%23 = load float, float* %2
%24 = fcmp olt float %23, 0.000000e+00
br i1 %24, label %25, label %28
25: ; preds = %22
%26 = load float, float* %2
%27 = fadd float %26, 3.600000e+02
store float %27, float* %2
br label %28
28: ; preds = %25, %22
%29 = load float, float* %2
ret float %29
}

LLVM IR (-O2):
define float @derotate_deg(float %0) {
%2 = tail call double @fabs(float %0)
%3 = fdiv double %2, 3.600000e+02
%4 = fptosi double %3 to i32
%5 = fcmp ogt float %0, 0.000000e+00
%6 = mul nsw i32 %4, 360
%7 = sitofp i32 %6 to float
%8 = fneg float %7
%9 = select i1 %5, float %8, float %7
%10 = fadd float %9, %0
%11 = fcmp olt float %10, 0.000000e+00
%12 = fadd float %10, 3.600000e+02
%13 = select i1 %11, float %12, float %10
ret float %13
}