char grid_byte(double lat, double lon) {
  char c = 0x00;
  if ((lon >= 0.0) && (lon < 90.0)) {
    if (lat >= 0.0) {
      c = 0x00;
    } else {
      c = 0x04;
    }
  } else if (lon >= 90.0) {
    if (lat >= 0.0) {
      c = 0x01;
    } else {
      c = 0x05;
    }
  } else if ((lon < 0.0) && (lon >= -90.0)) {
    if (lat >= 0.0) {
      c = 0x02;
    } else {
      c = 0x06;
    }
  } else if (lon < -90.0) {
    if (lat >= 0.0) {
      c = 0x03;
    } else {
      c = 0x07;
    }
  }
  return (c);
}


x86 assembly (clang, -O0):
<grid_byte>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
movb   $0x0,-0x11(%rbp)
movsd  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     115b <grid_byte+0x5b>
movsd  0xed4(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    115b <grid_byte+0x5b>
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     1152 <grid_byte+0x52>
movb   $0x0,-0x11(%rbp)
jmp    1156 <grid_byte+0x56>
movb   $0x4,-0x11(%rbp)
jmp    1225 <grid_byte+0x125>
movsd  -0x10(%rbp),%xmm0
movsd  0xe98(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1196 <grid_byte+0x96>
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     118d <grid_byte+0x8d>
movb   $0x1,-0x11(%rbp)
jmp    1191 <grid_byte+0x91>
movb   $0x5,-0x11(%rbp)
jmp    1220 <grid_byte+0x120>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11df <grid_byte+0xdf>
movsd  -0x10(%rbp),%xmm0
movsd  0xe57(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11df <grid_byte+0xdf>
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11d6 <grid_byte+0xd6>
movb   $0x2,-0x11(%rbp)
jmp    11da <grid_byte+0xda>
movb   $0x6,-0x11(%rbp)
jmp    121b <grid_byte+0x11b>
movsd  0xe21(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1216 <grid_byte+0x116>
movsd  -0x8(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     120d <grid_byte+0x10d>
movb   $0x3,-0x11(%rbp)
jmp    1211 <grid_byte+0x111>
movb   $0x7,-0x11(%rbp)
jmp    1216 <grid_byte+0x116>
jmp    121b <grid_byte+0x11b>
jmp    1220 <grid_byte+0x120>
jmp    1225 <grid_byte+0x125>
movsbl -0x11(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<grid_byte>:
xorpd  %xmm2,%xmm2
ucomisd %xmm2,%xmm1
jb     1127 <grid_byte+0x27>
movsd  0xeee(%rip),%xmm2
ucomisd %xmm1,%xmm2
jbe    1127 <grid_byte+0x27>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
setb   %al
shl    $0x2,%al
ret
ucomisd 0xed1(%rip),%xmm1
jae    1156 <grid_byte+0x56>
xorpd  %xmm2,%xmm2
ucomisd %xmm1,%xmm2
jbe    1167 <grid_byte+0x67>
ucomisd 0xec5(%rip),%xmm1
jb     1167 <grid_byte+0x67>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
setb   %al
shl    $0x2,%al
or     $0x2,%al
ret
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
setb   %al
shl    $0x2,%al
or     $0x1,%al
ret
movsd  0xe99(%rip),%xmm2
ucomisd %xmm1,%xmm2
jbe    1186 <grid_byte+0x86>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
setb   %al
shl    $0x2,%al
or     $0x3,%al
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
define signext i8 @grid_byte(double %0, double %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca i8
store double %0, double* %3
store double %1, double* %4
store i8 0, i8* %5
%6 = load double, double* %4
%7 = fcmp oge double %6, 0.000000e+00
br i1 %7, label %8, label %17
8: ; preds = %2
%9 = load double, double* %4
%10 = fcmp olt double %9, 9.000000e+01
br i1 %10, label %11, label %17
11: ; preds = %8
%12 = load double, double* %3
%13 = fcmp oge double %12, 0.000000e+00
br i1 %13, label %14, label %15
14: ; preds = %11
store i8 0, i8* %5
br label %16
15: ; preds = %11
store i8 4, i8* %5
br label %16
16: ; preds = %15, %14
br label %50
17: ; preds = %8, %2
%18 = load double, double* %4
%19 = fcmp oge double %18, 9.000000e+01
br i1 %19, label %20, label %26
20: ; preds = %17
%21 = load double, double* %3
%22 = fcmp oge double %21, 0.000000e+00
br i1 %22, label %23, label %24
23: ; preds = %20
store i8 1, i8* %5
br label %25
24: ; preds = %20
store i8 5, i8* %5
br label %25
25: ; preds = %24, %23
br label %49
26: ; preds = %17
%27 = load double, double* %4
%28 = fcmp olt double %27, 0.000000e+00
br i1 %28, label %29, label %38
29: ; preds = %26
%30 = load double, double* %4
%31 = fcmp oge double %30, -9.000000e+01
br i1 %31, label %32, label %38
32: ; preds = %29
%33 = load double, double* %3
%34 = fcmp oge double %33, 0.000000e+00
br i1 %34, label %35, label %36
35: ; preds = %32
store i8 2, i8* %5
br label %37
36: ; preds = %32
store i8 6, i8* %5
br label %37
37: ; preds = %36, %35
br label %48
38: ; preds = %29, %26
%39 = load double, double* %4
%40 = fcmp olt double %39, -9.000000e+01
br i1 %40, label %41, label %47
41: ; preds = %38
%42 = load double, double* %3
%43 = fcmp oge double %42, 0.000000e+00
br i1 %43, label %44, label %45
44: ; preds = %41
store i8 3, i8* %5
br label %46
45: ; preds = %41
store i8 7, i8* %5
br label %46
46: ; preds = %45, %44
br label %47
47: ; preds = %46, %38
br label %48
48: ; preds = %47, %37
br label %49
49: ; preds = %48, %25
br label %50
50: ; preds = %49, %16
%51 = load i8, i8* %5
ret i8 %51
}

LLVM IR (-O2):
define signext i8 @grid_byte(double %0, double %1) {
%3 = fcmp oge double %1, 0.000000e+00
%4 = fcmp olt double %1, 9.000000e+01
%5 = and i1 %3, %4
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = fcmp ult double %0, 0.000000e+00
%8 = select i1 %7, i8 4, i8 0
br label %26
9: ; preds = %2
%10 = fcmp ult double %1, 9.000000e+01
br i1 %10, label %14, label %11
11: ; preds = %9
%12 = fcmp ult double %0, 0.000000e+00
%13 = select i1 %12, i8 5, i8 1
br label %26
14: ; preds = %9
%15 = fcmp olt double %1, 0.000000e+00
%16 = fcmp oge double %1, -9.000000e+01
%17 = and i1 %15, %16
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = fcmp ult double %0, 0.000000e+00
%20 = select i1 %19, i8 6, i8 2
br label %26
21: ; preds = %14
%22 = fcmp olt double %1, -9.000000e+01
br i1 %22, label %23, label %26
23: ; preds = %21
%24 = fcmp ult double %0, 0.000000e+00
%25 = select i1 %24, i8 7, i8 3
br label %26
26: ; preds = %23, %18, %11, %6, %21
%27 = phi i8 [ 0, %21 ], [ %8, %6 ], [ %13, %11 ], [ %20, %18 ], [ %25, %23 ]
ret i8 %27
}