#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_elevation(float latitude, float longitude, float **elevations) {
  float delta = 0.01666666667;
  float long_min = -130.350000000000023;
  float long_max = -59.0666666666666487;
  float lat_min = 21.899999999999995;
  float lat_max = 50.9833333333333272;
  int N_lat = 1746;
  int N_long = 4278;
  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 elevations[lat_idx][long_idx];
}


x86 assembly (clang, -O0):
<get_elevation>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movss  %xmm0,-0x4(%rbp)
movss  %xmm1,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
movss  0xee2(%rip),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xed1(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  0xec0(%rip),%xmm0
movss  %xmm0,-0x1c(%rbp)
movss  0xeaf(%rip),%xmm0
movss  %xmm0,-0x20(%rbp)
movss  0xe9e(%rip),%xmm0
movss  %xmm0,-0x24(%rbp)
movl   $0x6d2,-0x28(%rbp)
movl   $0x10b6,-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     11bc <get_elevation+0xac>
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     11e4 <get_elevation+0xd4>
mov    -0x34(%rbp),%eax
cmp    -0x2c(%rbp),%eax
setl   %al
mov    %al,-0x36(%rbp)
mov    -0x36(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movslq -0x34(%rbp),%rcx
movss  (%rax,%rcx,4),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_elevation>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
unpcklps %xmm0,%xmm1
addps  0xee0(%rip),%xmm1
mov    %rdi,%rbx
divps  0xee6(%rip),%xmm1
cvttps2dq %xmm1,%xmm1
movdqa %xmm1,(%rsp)
movdqa 0xee5(%rip),%xmm0
pxor   %xmm1,%xmm0
movdqa 0xee9(%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
movss  (%rax,%rcx,4),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define float @get_elevation(float %0, float %1, float** %2) {
%4 = alloca float
%5 = alloca float
%6 = alloca float**
%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 float** %2, float*** %6
store float 0x3F91111120000000, float* %7
store float 0xC0604B3340000000, float* %8
store float 0xC04D888880000000, float* %9
store float 0x4035E66660000000, float* %10
store float 0x40497DDDE0000000, float* %11
store i32 1746, i32* %12
store i32 4278, 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 float**, float*** %6
%49 = load i32, i32* %14
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds float*, float** %48, i64 %50
%52 = load float*, float** %51
%53 = load i32, i32* %15
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds float, float* %52, i64 %54
%56 = load float, float* %55
ret float %56
}

LLVM IR (-O2):
define float @get_elevation(float %0, float %1, float** nocapture %2) {
%4 = insertelement <2 x float> poison, float %1, i64 0
%5 = insertelement <2 x float> %4, float %0, i64 1
%6 = fadd <2 x float> %5, <float 0x40604B3340000000, float 0xC035E66660000000>
%7 = fdiv <2 x float> %6, <float 0x3F91111120000000, float 0x3F91111120000000>
%8 = fptosi <2 x float> %7 to <2 x i32>
%9 = icmp ult <2 x i32> %8, <i32 4278, i32 1746>
%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 float*, float** %2, i64 %17
%19 = load float*, float** %18
%20 = extractelement <2 x i32> %8, i64 0
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds float, float* %19, i64 %21
%23 = load float, float* %22
ret float %23
}