#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, double);
long reg_quadrant(double ang1) {
  double ang = ang1;
  long quad = 4;
  while (ang < 0.0)
    ang += 360.0;
  if (ang == 360.0)
    return quad;
  ang = fmod(ang, 360.0);
  quad = (ang / 90.0) + 1;
  return quad;
}


x86 assembly (clang, -O0):
<reg_quadrant>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movq   $0x4,-0x20(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1154 <reg_quadrant+0x44>
movsd  0xebb(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    112f <reg_quadrant+0x1f>
movsd  -0x18(%rbp),%xmm0
movsd  0xe9f(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    117e <reg_quadrant+0x6e>
jp     117e <reg_quadrant+0x6e>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11c3 <reg_quadrant+0xb3>
movsd  -0x18(%rbp),%xmm0
movsd  0xe75(%rip),%xmm1
call   1030 <fmod@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  0xe6e(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe5a(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reg_quadrant>:
push   %rax
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
jbe    113a <reg_quadrant+0x2a>
movsd  0xedd(%rip),%xmm2
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
addsd  %xmm2,%xmm0
ucomisd %xmm0,%xmm1
ja     1130 <reg_quadrant+0x20>
mov    $0x4,%eax
ucomisd 0xeb9(%rip),%xmm0
jne    114d <reg_quadrant+0x3d>
jp     114d <reg_quadrant+0x3d>
pop    %rcx
ret
movsd  0xeab(%rip),%xmm1
call   1030 <fmod@plt>
divsd  0xea6(%rip),%xmm0
addsd  0xea6(%rip),%xmm0
cvttsd2si %xmm0,%rax
pop    %rcx
ret

LLVM IR (-O0):
define i64 @reg_quadrant(double %0) {
%2 = alloca i64
%3 = alloca double
%4 = alloca double
%5 = alloca i64
store double %0, double* %3
%6 = load double, double* %3
store double %6, double* %4
store i64 4, i64* %5
br label %7
7: ; preds = %10, %1
%8 = load double, double* %4
%9 = fcmp olt double %8, 0.000000e+00
br i1 %9, label %10, label %13
10: ; preds = %7
%11 = load double, double* %4
%12 = fadd double %11, 3.600000e+02
store double %12, double* %4
br label %7
13: ; preds = %7
%14 = load double, double* %4
%15 = fcmp oeq double %14, 3.600000e+02
br i1 %15, label %16, label %18
16: ; preds = %13
%17 = load i64, i64* %5
store i64 %17, i64* %2
br label %26
18: ; preds = %13
%19 = load double, double* %4
%20 = call double @fmod(double %19, double 3.600000e+02)
store double %20, double* %4
%21 = load double, double* %4
%22 = fdiv double %21, 9.000000e+01
%23 = fadd double %22, 1.000000e+00
%24 = fptosi double %23 to i64
store i64 %24, i64* %5
%25 = load i64, i64* %5
store i64 %25, i64* %2
br label %26
26: ; preds = %18, %16
%27 = load i64, i64* %2
ret i64 %27
}

LLVM IR (-O2):
define i64 @reg_quadrant(double %0) {
%2 = fcmp olt double %0, 0.000000e+00
br i1 %2, label %3, label %7
3: ; preds = %1, %3
%4 = phi double [ %5, %3 ], [ %0, %1 ]
%5 = fadd double %4, 3.600000e+02
%6 = fcmp olt double %5, 0.000000e+00
br i1 %6, label %3, label %7
7: ; preds = %3, %1
%8 = phi double [ %0, %1 ], [ %5, %3 ]
%9 = fcmp oeq double %8, 3.600000e+02
br i1 %9, label %15, label %10
10: ; preds = %7
%11 = tail call double @fmod(double %8, double 3.600000e+02)
%12 = fdiv double %11, 9.000000e+01
%13 = fadd double %12, 1.000000e+00
%14 = fptosi double %13 to i64
br label %15
15: ; preds = %7, %10
%16 = phi i64 [ %14, %10 ], [ 4, %7 ]
ret i64 %16
}