#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(double);
double derotate_180_double(double a) {
  int i;
  i = fabs(a) / 180.0;
  if (a > 0)
    a -= 180 * i;
  else
    a += 180 * i;
  if (a < 0)
    a += 180;
  return a;
}


x86 assembly (clang, -O0):
<derotate_180_double>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movaps 0xefb(%rip),%xmm1
pand   %xmm1,%xmm0
movsd  0xedf(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0xc(%rbp)
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    115c <derotate_180_double+0x5c>
imul   $0xb4,-0xc(%rbp),%eax
cvtsi2sd %eax,%xmm1
movsd  -0x8(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1171 <derotate_180_double+0x71>
imul   $0xb4,-0xc(%rbp),%eax
cvtsi2sd %eax,%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1191 <derotate_180_double+0x91>
movsd  0xe79(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
pop    %rbp
ret

x86 assembly (clang, -O2):
<derotate_180_double>:
movapd 0xef8(%rip),%xmm1
andpd  %xmm0,%xmm1
movsd  0xf0c(%rip),%xmm2
divsd  %xmm2,%xmm1
cvttsd2si %xmm1,%eax
imul   $0xb4,%eax,%eax
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
movapd 0xedf(%rip),%xmm3
xorpd  %xmm1,%xmm3
xorpd  %xmm4,%xmm4
xorpd  %xmm5,%xmm5
cmpltsd %xmm0,%xmm5
movapd %xmm5,%xmm6
andnpd %xmm1,%xmm6
andpd  %xmm3,%xmm5
orpd   %xmm6,%xmm5
addsd  %xmm0,%xmm5
addsd  %xmm5,%xmm2
movapd %xmm5,%xmm0
cmpltsd %xmm4,%xmm0
andpd  %xmm0,%xmm2
andnpd %xmm5,%xmm0
orpd   %xmm2,%xmm0
ret

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

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