#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 */
int /*<<< orphan*/ assert(int);
float get_land_type(float latitude, float longitude, short **land_types) {
  float delta = 0.0041666667;
  float long_min = -180;
  float long_max = -0;
  float lat_min = 0;
  float lat_max = 90;
  ;
  int N_lat = 21600;
  int N_long = 43200;
  int lat_idx = (latitude - lat_min) / delta;
  int long_idx = (longitude - long_min) / delta;
  assert(lat_idx >= 0 && lat_idx < N_lat);
  assert(long_idx >= 0 && long_idx < N_long);
  return land_types[lat_idx][long_idx];
}


x86 assembly (clang, -O0):
<get_land_type>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
movss  0xeda(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xec9(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
movss  0xea8(%rip),%xmm0
movss  %xmm0,-0x24(%rbp)
movl   $0x5460,-0x28(%rbp)
movl   $0xa8c0,-0x2c(%rbp)
movss  -0x4(%rbp),%xmm0
subss  -0x20(%rbp),%xmm0
divss  -0x14(%rbp),%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x30(%rbp)
movss  -0x8(%rbp),%xmm0
subss  -0x18(%rbp),%xmm0
divss  -0x14(%rbp),%xmm0
cvttss2si %xmm0,%eax
mov    %eax,-0x34(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x30(%rbp)
mov    %al,-0x35(%rbp)
jl     11b2 <get_land_type+0xa2>
mov    -0x30(%rbp),%eax
cmp    -0x28(%rbp),%eax
setl   %al
mov    %al,-0x35(%rbp)
mov    -0x35(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
xor    %eax,%eax
cmpl   $0x0,-0x34(%rbp)
mov    %al,-0x36(%rbp)
jl     11da <get_land_type+0xca>
mov    -0x34(%rbp),%eax
cmp    -0x2c(%rbp),%eax
setl   %al
mov    %al,-0x36(%rbp)
mov    -0x36(%rbp),%al
movzbl %al,%edi
and    $0x1,%edi
call   1030 <assert@plt>
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x34(%rbp),%rcx
movswl (%rax,%rcx,2),%eax
cvtsi2ss %eax,%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_land_type>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
addss  0xedf(%rip),%xmm1
unpcklps %xmm0,%xmm1
divps  0xee5(%rip),%xmm1
cvttps2dq %xmm1,%xmm1
movdqa %xmm1,(%rsp)
movdqa 0xee4(%rip),%xmm0
pxor   %xmm1,%xmm0
movdqa 0xee8(%rip),%xmm1
pcmpgtd %xmm0,%xmm1
pshufd $0x50,%xmm1,%xmm0
movmskpd %xmm0,%ebp
mov    %ebp,%eax
shr    %al
movzbl %al,%edi
call   1030 <assert@plt>
and    $0x1,%ebp
mov    %ebp,%edi
call   1030 <assert@plt>
movdqa (%rsp),%xmm1
pshufd $0x55,%xmm1,%xmm0
movd   %xmm0,%eax
cltq
mov    (%rbx,%rax,8),%rax
movd   %xmm1,%ecx
movslq %ecx,%rcx
movswl (%rax,%rcx,2),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define float @get_land_type(float %0, float %1, i16** %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca i16**
%7 = alloca float
%8 = alloca float
%9 = alloca float
%10 = alloca float
%11 = alloca float
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
store float %0, float* %4
store float %1, float* %5
store i16** %2, i16*** %6
store float 0x3F71111120000000, float* %7
store float -1.800000e+02, float* %8
store float 0.000000e+00, float* %9
store float 0.000000e+00, float* %10
store float 9.000000e+01, float* %11
store i32 21600, i32* %12
store i32 43200, i32* %13
%16 = load float, float* %4
%17 = load float, float* %10
%18 = fsub float %16, %17
%19 = load float, float* %7
%20 = fdiv float %18, %19
%21 = fptosi float %20 to i32
store i32 %21, i32* %14
%22 = load float, float* %5
%23 = load float, float* %8
%24 = fsub float %22, %23
%25 = load float, float* %7
%26 = fdiv float %24, %25
%27 = fptosi float %26 to i32
store i32 %27, i32* %15
%28 = load i32, i32* %14
%29 = icmp sge i32 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %3
%31 = load i32, i32* %14
%32 = load i32, i32* %12
%33 = icmp slt i32 %31, %32
br label %34
34: ; preds = %30, %3
%35 = phi i1 [ false, %3 ], [ %33, %30 ]
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
%38 = load i32, i32* %15
%39 = icmp sge i32 %38, 0
br i1 %39, label %40, label %44
40: ; preds = %34
%41 = load i32, i32* %15
%42 = load i32, i32* %13
%43 = icmp slt i32 %41, %42
br label %44
44: ; preds = %40, %34
%45 = phi i1 [ false, %34 ], [ %43, %40 ]
%46 = zext i1 %45 to i32
%47 = call i32 @assert(i32 %46)
%48 = load i16**, i16*** %6
%49 = load i32, i32* %14
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i16*, i16** %48, i64 %50
%52 = load i16*, i16** %51
%53 = load i32, i32* %15
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i16, i16* %52, i64 %54
%56 = load i16, i16* %55
%57 = sitofp i16 %56 to float
ret float %57
}

LLVM IR (-O2):
define float @get_land_type(float %0, float %1, i16** nocapture %2) {
%4 = fadd float %1, 1.800000e+02
%5 = insertelement <2 x float> poison, float %0, i64 1
%6 = insertelement <2 x float> %5, float %4, i64 0
%7 = fdiv <2 x float> %6, <float 0x3F71111120000000, float 0x3F71111120000000>
%8 = fptosi <2 x float> %7 to <2 x i32>
%9 = icmp ult <2 x i32> %8, <i32 43200, i32 21600>
%10 = extractelement <2 x i1> %9, i64 1
%11 = zext i1 %10 to i32
%12 = tail call i32 @assert(i32 %11)
%13 = extractelement <2 x i1> %9, i64 0
%14 = zext i1 %13 to i32
%15 = tail call i32 @assert(i32 %14)
%16 = extractelement <2 x i32> %8, i64 1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i16*, i16** %2, i64 %17
%19 = load i16*, i16** %18
%20 = extractelement <2 x i32> %8, i64 0
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i16, i16* %19, i64 %21
%23 = load i16, i16* %22
%24 = sitofp i16 %23 to float
ret float %24
}