#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 trunc(int);
void block_location(int bn, int ns, int sf, double *latN, double *lonW,
                    double *latSize, double *lonSize) {
  double raw_lat, raw_lon;
  double scale;
  if (sf == 1)
    scale = 5.0;
  else if (sf == 2)
    scale = 9.0;
  else
    scale = 1.0;
  if (bn >= 405000) {
    bn = bn & ~1;
  }
  raw_lat = (4.0 / 60.0) * trunc(bn / 450);
  raw_lon = (bn % 450) * (48.0 / 60.0);
  *lonSize = (bn >= 405000 ? (96.0 / 60.0) : (48.0 / 60.0)) * scale;
  *latSize = (4.0 / 60.0) * scale;
  *lonW = raw_lon;
  if (ns) {
    *latN = 0 - raw_lat;
  } else {
    *latN = raw_lat + (4.0 / 60.0);
  }
}


x86 assembly (clang, -O0):
<block_location>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
cmpl   $0x1,-0xc(%rbp)
jne    114d <block_location+0x3d>
movsd  0xecd(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    117b <block_location+0x6b>
cmpl   $0x2,-0xc(%rbp)
jne    1169 <block_location+0x59>
movsd  0xea9(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    1176 <block_location+0x66>
movsd  0xe8f(%rip),%xmm0
movsd  %xmm0,-0x40(%rbp)
jmp    117b <block_location+0x6b>
cmpl   $0x62e08,-0x4(%rbp)
jl     1191 <block_location+0x81>
mov    -0x4(%rbp),%eax
and    $0xfffffffe,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x1c2,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1030 <trunc@plt>
movaps %xmm0,%xmm1
movsd  0xe6a(%rip),%xmm0
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x1c2,%ecx
cltd
idiv   %ecx
cvtsi2sd %edx,%xmm0
movsd  0xe5a(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  %xmm0,-0x38(%rbp)
mov    -0x4(%rbp),%eax
movsd  0xe3e(%rip),%xmm0
movsd  0xe3e(%rip),%xmm1
movsd  %xmm1,-0x50(%rbp)
cmp    $0x62e08,%eax
movsd  %xmm0,-0x48(%rbp)
jge    1209 <block_location+0xf9>
movsd  -0x50(%rbp),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
mulsd  -0x40(%rbp),%xmm0
mov    0x10(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  0xdf5(%rip),%xmm0
mulsd  -0x40(%rbp),%xmm0
mov    -0x28(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x38(%rbp),%xmm0
mov    -0x20(%rbp),%rax
movsd  %xmm0,(%rax)
cmpl   $0x0,-0x8(%rbp)
je     125c <block_location+0x14c>
xorps  %xmm0,%xmm0
subsd  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1271 <block_location+0x161>
movsd  0xdb4(%rip),%xmm0
addsd  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<block_location>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,%r15
mov    %r8,%r12
mov    %rcx,0x10(%rsp)
mov    %esi,%ebp
xor    %eax,%eax
cmp    $0x2,%edx
sete   %cl
cmp    $0x1,%edx
je     1148 <block_location+0x38>
mov    %cl,%al
lea    0xebf(%rip),%rcx
movsd  (%rcx,%rax,8),%xmm0
jmp    1150 <block_location+0x40>
movsd  0xed0(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %edi,%eax
and    $0xfffffffe,%eax
cmp    $0x62e08,%edi
cmovl  %edi,%eax
xor    %r13d,%r13d
cmp    $0x62e08,%eax
setge  %r13b
movslq %eax,%r14
imul   $0xffffffff91a2b3c5,%r14,%rbx
shr    $0x20,%rbx
add    %r14d,%ebx
mov    %ebx,%eax
shr    $0x1f,%eax
sar    $0x8,%ebx
add    %eax,%ebx
mov    %ebx,%edi
call   1030 <trunc@plt>
movsd  0xe8e(%rip),%xmm1
mulsd  %xmm1,%xmm0
imul   $0x1c2,%ebx,%eax
sub    %eax,%r14d
cvtsi2sd %r14d,%xmm2
mulsd  0xe7c(%rip),%xmm2
lea    0xe55(%rip),%rax
movsd  (%rax,%r13,8),%xmm3
movsd  0x8(%rsp),%xmm4
mulsd  %xmm4,%xmm3
mov    0x50(%rsp),%rax
movsd  %xmm3,(%rax)
mulsd  %xmm1,%xmm4
movsd  %xmm4,(%r15)
movsd  %xmm2,(%r12)
test   %ebp,%ebp
je     11f5 <block_location+0xe5>
xorpd  %xmm1,%xmm1
subsd  %xmm0,%xmm1
movapd %xmm1,%xmm0
jmp    11f9 <block_location+0xe9>
addsd  %xmm1,%xmm0
mov    0x10(%rsp),%rax
movsd  %xmm0,(%rax)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @block_location(i32 %0, i32 %1, i32 %2, double* %3, double* %4, double* %5, double* %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca double
%16 = alloca double
%17 = alloca double
store i32 %0, i32* %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store double* %3, double** %11
store double* %4, double** %12
store double* %5, double** %13
store double* %6, double** %14
%18 = load i32, i32* %10
%19 = icmp eq i32 %18, 1
br i1 %19, label %20, label %21
20: ; preds = %7
store double 5.000000e+00, double* %17
br label %27
21: ; preds = %7
%22 = load i32, i32* %10
%23 = icmp eq i32 %22, 2
br i1 %23, label %24, label %25
24: ; preds = %21
store double 9.000000e+00, double* %17
br label %26
25: ; preds = %21
store double 1.000000e+00, double* %17
br label %26
26: ; preds = %25, %24
br label %27
27: ; preds = %26, %20
%28 = load i32, i32* %8
%29 = icmp sge i32 %28, 405000
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = load i32, i32* %8
%32 = and i32 %31, -2
store i32 %32, i32* %8
br label %33
33: ; preds = %30, %27
%34 = load i32, i32* %8
%35 = sdiv i32 %34, 450
%36 = call double @trunc(i32 %35)
%37 = fmul double 0x3FB1111111111111, %36
store double %37, double* %15
%38 = load i32, i32* %8
%39 = srem i32 %38, 450
%40 = sitofp i32 %39 to double
%41 = fmul double %40, 8.000000e-01
store double %41, double* %16
%42 = load i32, i32* %8
%43 = icmp sge i32 %42, 405000
%44 = zext i1 %43 to i64
%45 = select i1 %43, double 1.600000e+00, double 8.000000e-01
%46 = load double, double* %17
%47 = fmul double %45, %46
%48 = load double*, double** %14
store double %47, double* %48
%49 = load double, double* %17
%50 = fmul double 0x3FB1111111111111, %49
%51 = load double*, double** %13
store double %50, double* %51
%52 = load double, double* %16
%53 = load double*, double** %12
store double %52, double* %53
%54 = load i32, i32* %9
%55 = icmp ne i32 %54, 0
br i1 %55, label %56, label %60
56: ; preds = %33
%57 = load double, double* %15
%58 = fsub double 0.000000e+00, %57
%59 = load double*, double** %11
store double %58, double* %59
br label %64
60: ; preds = %33
%61 = load double, double* %15
%62 = fadd double %61, 0x3FB1111111111111
%63 = load double*, double** %11
store double %62, double* %63
br label %64
64: ; preds = %60, %56
ret void
}

LLVM IR (-O2):
define void @block_location(i32 %0, i32 %1, i32 %2, double* nocapture writeonly %3, double* nocapture writeonly %4, double* nocapture writeonly %5, double* nocapture writeonly %6) {
%8 = icmp eq i32 %2, 2
%9 = select i1 %8, double 9.000000e+00, double 1.000000e+00
%10 = icmp eq i32 %2, 1
%11 = select i1 %10, double 5.000000e+00, double %9
%12 = icmp sgt i32 %0, 404999
%13 = and i32 %0, -2
%14 = select i1 %12, i32 %13, i32 %0
%15 = sdiv i32 %14, 450
%16 = tail call double @trunc(i32 %15)
%17 = fmul double %16, 0x3FB1111111111111
%18 = srem i32 %14, 450
%19 = sitofp i32 %18 to double
%20 = fmul double %19, 8.000000e-01
%21 = icmp sgt i32 %14, 404999
%22 = select i1 %21, double 1.600000e+00, double 8.000000e-01
%23 = fmul double %22, %11
store double %23, double* %6
%24 = fmul double %11, 0x3FB1111111111111
store double %24, double* %5
store double %20, double* %4
%25 = icmp eq i32 %1, 0
%26 = fadd double %17, 0x3FB1111111111111
%27 = fsub double 0.000000e+00, %17
%28 = select i1 %25, double %26, double %27
store double %28, double* %3
ret void
}