#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 fmod(double, int);
double tor(double torsion) {
  if (torsion >= -999999999.0 - 1 && torsion <= -999999999.0 + 1)
    return -999999999.0;
  if (torsion >= 360.)
    torsion = fmod(torsion, 360);
  if (torsion <= -360.)
    torsion = fmod(torsion, 360);
  if (torsion > 180.)
    torsion = -360.0 + torsion;
  if (torsion <= -180.0)
    torsion = 360.0 + torsion;
  return torsion;
}


x86 assembly (clang, -O0):
<tor>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xed6(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1159 <tor+0x49>
movsd  0xecc(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     1159 <tor+0x49>
movsd  0xee1(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1203 <tor+0xf3>
movsd  -0x10(%rbp),%xmm0
movsd  0xeaa(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1184 <tor+0x74>
movsd  -0x10(%rbp),%xmm0
mov    $0x168,%edi
call   1030 <fmod@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  0xe8c(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     11ab <tor+0x9b>
movsd  -0x10(%rbp),%xmm0
mov    $0x168,%edi
call   1030 <fmod@plt>
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe68(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11d4 <tor+0xc4>
movsd  0xe4e(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  0xe4c(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jb     11f9 <tor+0xe9>
movsd  0xe21(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tor>:
push   %rax
ucomisd 0xee7(%rip),%xmm0
jb     1133 <tor+0x23>
movsd  0xeed(%rip),%xmm1
ucomisd %xmm0,%xmm1
jb     1133 <tor+0x23>
movsd  0xed7(%rip),%xmm0
pop    %rax
ret
ucomisd 0xedd(%rip),%xmm0
jb     1147 <tor+0x37>
mov    $0x168,%edi
call   1030 <fmod@plt>
movsd  0xed1(%rip),%xmm1
ucomisd %xmm0,%xmm1
jb     115f <tor+0x4f>
mov    $0x168,%edi
call   1030 <fmod@plt>
movsd  0xeb9(%rip),%xmm1
addsd  %xmm0,%xmm1
movsd  0xeb5(%rip),%xmm2
cmpltsd %xmm0,%xmm2
andpd  %xmm2,%xmm1
andnpd %xmm0,%xmm2
orpd   %xmm1,%xmm2
movsd  0xe8c(%rip),%xmm1
movapd %xmm2,%xmm0
cmpnlesd 0xe97(%rip),%xmm0
addsd  %xmm2,%xmm1
movapd %xmm0,%xmm3
andpd  %xmm2,%xmm3
andnpd %xmm1,%xmm0
orpd   %xmm3,%xmm0
pop    %rax
ret

LLVM IR (-O0):
define double @tor(double %0) {
%2 = alloca double
%3 = alloca double
store double %0, double* %3
%4 = load double, double* %3
%5 = fcmp oge double %4, -1.000000e+09
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = load double, double* %3
%8 = fcmp ole double %7, 0xC1CDCD64FF000000
br i1 %8, label %9, label %10
9: ; preds = %6
store double 0xC1CDCD64FF800000, double* %2
br label %36
10: ; preds = %6, %1
%11 = load double, double* %3
%12 = fcmp oge double %11, 3.600000e+02
br i1 %12, label %13, label %16
13: ; preds = %10
%14 = load double, double* %3
%15 = call double @fmod(double %14, i32 360)
store double %15, double* %3
br label %16
16: ; preds = %13, %10
%17 = load double, double* %3
%18 = fcmp ole double %17, -3.600000e+02
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load double, double* %3
%21 = call double @fmod(double %20, i32 360)
store double %21, double* %3
br label %22
22: ; preds = %19, %16
%23 = load double, double* %3
%24 = fcmp ogt double %23, 1.800000e+02
br i1 %24, label %25, label %28
25: ; preds = %22
%26 = load double, double* %3
%27 = fadd double -3.600000e+02, %26
store double %27, double* %3
br label %28
28: ; preds = %25, %22
%29 = load double, double* %3
%30 = fcmp ole double %29, -1.800000e+02
br i1 %30, label %31, label %34
31: ; preds = %28
%32 = load double, double* %3
%33 = fadd double 3.600000e+02, %32
store double %33, double* %3
br label %34
34: ; preds = %31, %28
%35 = load double, double* %3
store double %35, double* %2
br label %36
36: ; preds = %34, %9
%37 = load double, double* %2
ret double %37
}

LLVM IR (-O2):
define double @tor(double %0) {
%2 = fcmp oge double %0, -1.000000e+09
%3 = fcmp ole double %0, 0xC1CDCD64FF000000
%4 = and i1 %2, %3
br i1 %4, label %22, label %5
5: ; preds = %1
%6 = fcmp ult double %0, 3.600000e+02
br i1 %6, label %9, label %7
7: ; preds = %5
%8 = tail call double @fmod(double %0, i32 360)
br label %9
9: ; preds = %7, %5
%10 = phi double [ %8, %7 ], [ %0, %5 ]
%11 = fcmp ugt double %10, -3.600000e+02
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = tail call double @fmod(double %10, i32 360)
br label %14
14: ; preds = %12, %9
%15 = phi double [ %13, %12 ], [ %10, %9 ]
%16 = fcmp ogt double %15, 1.800000e+02
%17 = fadd double %15, -3.600000e+02
%18 = select i1 %16, double %17, double %15
%19 = fcmp ugt double %18, -1.800000e+02
%20 = fadd double %18, 3.600000e+02
%21 = select i1 %19, double %18, double %20
br label %22
22: ; preds = %1, %14
%23 = phi double [ %21, %14 ], [ 0xC1CDCD64FF800000, %1 ]
ret double %23
}