#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);
void hsc_getface(double lon, double lat, int *face) {
  double londiff;
  lon = fmod(6.283185307179586 + lon, 6.283185307179586);
  if (lat > 0.7297276562269663) {
    *face = 0;
  } else if (lat < (-1 * 0.7297276562269663)) {
    *face = 5;
  } else {
    londiff = fmod(6.283185307179586 + lon - 0.0 + 0.7853981633974483,
                   6.283185307179586);
    if (londiff <= 1.5707963267948966) {
      *face = 1;
    } else if (londiff <= 3.141592653589793) {
      *face = 2;
    } else if (londiff <= 4.7123889803846897) {
      *face = 3;
    } else {
      *face = 4;
    }
  }
}


x86 assembly (clang, -O0):
<hsc_getface>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
movsd  0xeda(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
movsd  0xecd(%rip),%xmm1
call   1030 <fmod@plt>
movsd  %xmm0,-0x8(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xeae(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    116b <hsc_getface+0x5b>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
jmp    1243 <hsc_getface+0x133>
movsd  0xe9d(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    118d <hsc_getface+0x7d>
mov    -0x18(%rbp),%rax
movl   $0x5,(%rax)
jmp    123e <hsc_getface+0x12e>
movsd  0xe73(%rip),%xmm0
addsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
subsd  %xmm1,%xmm0
movsd  0xe77(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  0xe53(%rip),%xmm1
call   1030 <fmod@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  0xe51(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     11e1 <hsc_getface+0xd1>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
jmp    1239 <hsc_getface+0x129>
movsd  0xe3f(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     1203 <hsc_getface+0xf3>
mov    -0x18(%rbp),%rax
movl   $0x2,(%rax)
jmp    1234 <hsc_getface+0x124>
movsd  0xe25(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jb     1225 <hsc_getface+0x115>
mov    -0x18(%rbp),%rax
movl   $0x3,(%rax)
jmp    122f <hsc_getface+0x11f>
mov    -0x18(%rbp),%rax
movl   $0x4,(%rax)
jmp    1234 <hsc_getface+0x124>
jmp    1239 <hsc_getface+0x129>
jmp    123e <hsc_getface+0x12e>
jmp    1243 <hsc_getface+0x133>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hsc_getface>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
movsd  %xmm1,0x8(%rsp)
movsd  0xeda(%rip),%xmm1
addsd  %xmm1,%xmm0
call   1030 <fmod@plt>
movsd  0x8(%rsp),%xmm2
xor    %eax,%eax
ucomisd 0xec9(%rip),%xmm2
ja     11a7 <hsc_getface+0x97>
mov    $0x5,%eax
movsd  0xec2(%rip),%xmm1
ucomisd %xmm2,%xmm1
ja     11a7 <hsc_getface+0x97>
movsd  0xea4(%rip),%xmm1
addsd  %xmm1,%xmm0
addsd  0xeb0(%rip),%xmm0
call   1030 <fmod@plt>
mov    $0x1,%eax
movsd  0xea6(%rip),%xmm1
ucomisd %xmm0,%xmm1
jae    11a7 <hsc_getface+0x97>
mov    $0x2,%eax
movsd  0xe9b(%rip),%xmm1
ucomisd %xmm0,%xmm1
jae    11a7 <hsc_getface+0x97>
movsd  0xe95(%rip),%xmm1
ucomisd %xmm0,%xmm1
mov    $0x3,%eax
adc    $0x0,%eax
mov    %eax,(%rbx)
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @hsc_getface(double %0, double %1, i32* %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca i32*
%7 = alloca double
store double %0, double* %4
store double %1, double* %5
store i32* %2, i32** %6
%8 = load double, double* %4
%9 = fadd double 0x401921FB54442D18, %8
%10 = call double @fmod(double %9, double 0x401921FB54442D18)
store double %10, double* %4
%11 = load double, double* %5
%12 = fcmp ogt double %11, 0x3FE759EDD04F68DE
br i1 %12, label %13, label %15
13: ; preds = %3
%14 = load i32*, i32** %6
store i32 0, i32* %14
br label %46
15: ; preds = %3
%16 = load double, double* %5
%17 = fcmp olt double %16, 0xBFE759EDD04F68DE
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = load i32*, i32** %6
store i32 5, i32* %19
br label %45
20: ; preds = %15
%21 = load double, double* %4
%22 = fadd double 0x401921FB54442D18, %21
%23 = fsub double %22, 0.000000e+00
%24 = fadd double %23, 0x3FE921FB54442D18
%25 = call double @fmod(double %24, double 0x401921FB54442D18)
store double %25, double* %7
%26 = load double, double* %7
%27 = fcmp ole double %26, 0x3FF921FB54442D18
br i1 %27, label %28, label %30
28: ; preds = %20
%29 = load i32*, i32** %6
store i32 1, i32* %29
br label %44
30: ; preds = %20
%31 = load double, double* %7
%32 = fcmp ole double %31, 0x400921FB54442D18
br i1 %32, label %33, label %35
33: ; preds = %30
%34 = load i32*, i32** %6
store i32 2, i32* %34
br label %43
35: ; preds = %30
%36 = load double, double* %7
%37 = fcmp ole double %36, 0x4012D97C7F3321D2
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = load i32*, i32** %6
store i32 3, i32* %39
br label %42
40: ; preds = %35
%41 = load i32*, i32** %6
store i32 4, i32* %41
br label %42
42: ; preds = %40, %38
br label %43
43: ; preds = %42, %33
br label %44
44: ; preds = %43, %28
br label %45
45: ; preds = %44, %18
br label %46
46: ; preds = %45, %13
ret void
}

LLVM IR (-O2):
define void @hsc_getface(double %0, double %1, i32* nocapture writeonly %2) {
%4 = fadd double %0, 0x401921FB54442D18
%5 = tail call double @fmod(double %4, double 0x401921FB54442D18)
%6 = fcmp ogt double %1, 0x3FE759EDD04F68DE
br i1 %6, label %19, label %7
7: ; preds = %3
%8 = fcmp olt double %1, 0xBFE759EDD04F68DE
br i1 %8, label %19, label %9
9: ; preds = %7
%10 = fadd double %5, 0x401921FB54442D18
%11 = fadd double %10, 0x3FE921FB54442D18
%12 = tail call double @fmod(double %11, double 0x401921FB54442D18)
%13 = fcmp ugt double %12, 0x3FF921FB54442D18
br i1 %13, label %14, label %19
14: ; preds = %9
%15 = fcmp ugt double %12, 0x400921FB54442D18
br i1 %15, label %16, label %19
16: ; preds = %14
%17 = fcmp ugt double %12, 0x4012D97C7F3321D2
%18 = select i1 %17, i32 4, i32 3
br label %19
19: ; preds = %16, %14, %9, %7, %3
%20 = phi i32 [ 0, %3 ], [ 5, %7 ], [ 1, %9 ], [ 2, %14 ], [ %18, %16 ]
store i32 %20, i32* %2
ret void
}