#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 */
typedef int uint16_t;
typedef int /*<<< orphan*/ ngrLookup;

/* Variables and functions */
int geoDistance(double, double, double, double, char);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
double ngrDistance(double lat, double lng, char *country1, char *country2,
                   char *ngr) {
  uint16_t i;
  static struct ngrLookupStruct {
    char ngr[5];
    char country1[18];
    char country2[10];
    double lat;
    double lon;
  } ngrLookup[] = {{"SV", "England", "", 50.246, -6.911},
                   {"SW", "England", "", 50.297, -5.511},
                   {"SX", "England", "", 50.330, -4.109},
                   {"SY", "England", "", 50.348, -2.704},
                   {"SZ", "England", "", 50.348, -1.3},
                   {"TV", "England", "", 50.331, 0.106},
                   {"SR", "Wales", "", 51.194388, -5.579542},
                   {"SS", "England", "Wales", 51.229421, -4.149717},
                   {"ST", "England", "Wales", 51.246969, -2.717735},
                   {"SU", "England", "", 51.246989, -1.285031},
                   {"TQ", "England", "", 51.229482, 0.146955},
                   {"TR", "England", "", 51.194489, 1.576786},
                   {"SM", "Wales", "", 52.091722, -5.651005},
                   {"SN", "Wales", "", 52.127894, -4.192711},
                   {"SO", "England", "Wales", 52.146013, -2.732105},
                   {"SP", "England", "", 52.146034, -1.270726},
                   {"TL", "England", "", 53.026267, 0.235122},
                   {"TM", "England", "", 52.091825, 1.648184},
                   {"SH", "Wales", "", 53.026202, -4.238019},
                   {"SJ", "England", "Wales", 53.044916, -2.747250},
                   {"SK", "England", "", 53.044937, -1.255651},
                   {"TF", "England", "", 53.026267, 0.235122},
                   {"TG", "England", "", 52.988951, 1.723418},
                   {"SC", "England", "", 53.924346, -4.285810},
                   {"SD", "England", "", 53.943679, -2.763226},
                   {"SE", "England", "", 53.943701, -1.239749},
                   {"TA", "England", "", 54.782439, -5.889575},
                   {"NW", "Northern_Ireland", "", 54.782439, -5.889575},
                   {"NX", "England", "Scotland", 54.822323, -4.336271},
                   {"NY", "England", "Scotland", 54.842304, -2.780095},
                   {"NZ", "England", "Scotland", 54.842327, -1.222957},
                   {"OV", "England", "", 54.822392, 0.333224},
                   {"NR", "Scotland", "", 55.678902, -5.978189},
                   {"NS", "Scotland", "", 55.720134, -4.389608},
                   {"NT", "Scotland", "", 55.740791, -2.797926},
                   {"NU", "Scotland", "", 55.740815, -1.205207},
                   {"NL", "Scotland", "", 56.511336, -7.692291},
                   {"NM", "Scotland", "", 56.575134, -6.071947},
                   {"NN", "Scotland", "", 56.617777, -4.446048},
                   {"NO", "Scotland", "", 56.639142, -2.816797},
                   {"NF", "Scotland", "", 57.405124, -7.830669},
                   {"NG", "Scotland", "", 57.471129, -6.171267},
                   {"NH", "Scotland", "", 57.515251, -4.505847},
                   {"NJ", "Scotland", "", 57.537358, -2.836792},
                   {"NK", "Scotland", "", 57.537383, -1.166519},
                   {"NA", "Scotland", "", 58.298558, -7.977409},
                   {"NB", "Scotland", "", 58.366878, -6.276616},
                   {"NC", "Scotland", "", 58.412554, -4.569285},
                   {"ND", "Scotland", "", 58.435441, -2.858005}};
  printf("The size of ngrLookup is %ld, lat %f, long %f \n",
         sizeof(ngrLookup) / sizeof(ngrLookup[0]), lat, lng);
  for (i = 0; i < sizeof(ngrLookup) / sizeof(ngrLookup[0]); i++) {
    if (geoDistance(lat, lng, ngrLookup[i].lat, ngrLookup[i].lon, 'K') < 60) {
      printf("You are located in square %s located in %s\n", ngrLookup[i].ngr,
             ngrLookup[i].country1);
      strcpy(ngr, ngrLookup[i].ngr);
      strcpy(country1, ngrLookup[i].country1);
      strcpy(country2, ngrLookup[i].country2);
      return 1;
    }
  }
  printf("Location not found\n");
  return 0;
}


x86 assembly (clang, -O0):
<ngrDistance>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x10(%rbp)
movsd  %xmm1,-0x18(%rbp)
mov    %rdi,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
mov    %rdx,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    0xea9(%rip),%rdi
mov    $0x31,%esi
mov    $0x2,%al
call   1040 <printf@plt>
movl   $0x0,-0x34(%rbp)
movslq -0x34(%rbp),%rax
cmp    $0x31,%rax
jae    127f <ngrDistance+0x14f>
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movslq -0x34(%rbp),%rcx
lea    0x2eab(%rip),%rax
imul   $0x38,%rcx,%rcx
add    %rcx,%rax
movsd  0x28(%rax),%xmm2
movslq -0x34(%rbp),%rcx
lea    0x2e94(%rip),%rax
imul   $0x38,%rcx,%rcx
add    %rcx,%rax
movsd  0x30(%rax),%xmm3
mov    $0x4b,%edi
call   1050 <geoDistance@plt>
cmp    $0x3c,%eax
jge    126c <ngrDistance+0x13c>
movslq -0x34(%rbp),%rax
lea    0x2e6a(%rip),%rsi
imul   $0x38,%rax,%rax
add    %rax,%rsi
movslq -0x34(%rbp),%rax
lea    0x2e58(%rip),%rdx
imul   $0x38,%rax,%rax
add    %rax,%rdx
add    $0x5,%rdx
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rdi
movslq -0x34(%rbp),%rax
lea    0x2e30(%rip),%rsi
imul   $0x38,%rax,%rax
add    %rax,%rsi
call   1030 <strcpy@plt>
mov    -0x20(%rbp),%rdi
movslq -0x34(%rbp),%rax
lea    0x2e15(%rip),%rsi
imul   $0x38,%rax,%rax
add    %rax,%rsi
add    $0x5,%rsi
call   1030 <strcpy@plt>
mov    -0x28(%rbp),%rdi
movslq -0x34(%rbp),%rax
lea    0x2df6(%rip),%rsi
imul   $0x38,%rax,%rax
add    %rax,%rsi
add    $0x17,%rsi
call   1030 <strcpy@plt>
movsd  0xd9e(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
jmp    1295 <ngrDistance+0x165>
jmp    1271 <ngrDistance+0x141>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1172 <ngrDistance+0x42>
lea    0xdde(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ngrDistance>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r12
mov    %rsi,%r13
mov    %rdi,%r15
lea    0xeaa(%rip),%rdi
mov    $0x31,%esi
movsd  %xmm0,0x8(%rsp)
movsd  %xmm1,0x10(%rsp)
mov    $0x2,%al
call   1050 <printf@plt>
mov    $0x30,%ebp
xor    %ebx,%ebx
lea    0x2ecc(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  -0x8(%rbp,%r14,1),%xmm2
movsd  0x0(%rbp,%r14,1),%xmm3
movsd  0x8(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
mov    $0x4b,%edi
call   1060 <geoDistance@plt>
cmp    $0x3b,%eax
jle    11db <ngrDistance+0x9b>
add    $0xffffffffffffffc8,%rbx
add    $0x38,%rbp
cmp    $0xae8,%rbp
jne    1190 <ngrDistance+0x50>
lea    0xe93(%rip),%rdi
call   1040 <puts@plt>
xorps  %xmm0,%xmm0
jmp    1226 <ngrDistance+0xe6>
sub    %rbx,%r14
mov    %r13,%rbx
lea    0x5(%r14),%r13
lea    0xe4c(%rip),%rdi
mov    %r14,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
mov    %r15,%rdi
mov    %r13,%rsi
call   1030 <strcpy@plt>
add    $0x17,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
movsd  0xdda(%rip),%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.ngrLookupStruct = type { [5 x i8], [18 x i8], [10 x i8], double, double }
@ngrDistance.ngrLookup = internal global [49 x %struct.ngrLookupStruct] [%struct.ngrLookupStruct { [5 x i8] c"SV\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 5.024600e+01, double -6.911000e+00 }, %struct.ngrLookupStruct { [5 x i8] c"SW\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 5.029700e+01, double -5.511000e+00 }, %struct.ngrLookupStruct { [5 x i8] c"SX\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 5.033000e+01, double -4.109000e+00 }, %struct.ngrLookupStruct { [5 x i8] c"SY\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 5.034800e+01, double -2.704000e+00 }, %struct.ngrLookupStruct { [5 x i8] c"SZ\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 5.034800e+01, double -1.300000e+00 }, %struct.ngrLookupStruct { [5 x i8] c"TV\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 5.033100e+01, double 1.060000e-01 }, %struct.ngrLookupStruct { [5 x i8] c"SR\00\00\00", [18 x i8] c"Wales\00\00\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404998E1B4BB5E0F, double 0xC01651737542A23C }, %struct.ngrLookupStruct { [5 x i8] c"SS\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] c"Wales\00\00\00\00\00", double 0x40499D5DAAD60200, double 0xC010994F69CA9EF5 }, %struct.ngrLookupStruct { [5 x i8] c"ST\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] c"Wales\00\00\00\00\00", double 0x40499F9CAE21101B, double 0xC005BDEBD9018E75 }, %struct.ngrLookupStruct { [5 x i8] c"SU\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x40499F9D55E6BC62, double 0xBFF48F7CAA7589F0 }, %struct.ngrLookupStruct { [5 x i8] c"TQ\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x40499D5FAA8A82A5, double 1.469550e-01 }, %struct.ngrLookupStruct { [5 x i8] c"TR\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404998E503FB3743, double 0x3FF93A83F4ECA687 }, %struct.ngrLookupStruct { [5 x i8] c"SM\00\00\00", [18 x i8] c"Wales\00\00\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404A0BBD8BE7296F, double 0xC0169AA10E022142 }, %struct.ngrLookupStruct { [5 x i8] c"SN\00\00\00", [18 x i8] c"Wales\00\00\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404A105ED4A1AD64, double 0xC010C556084A515D }, %struct.ngrLookupStruct { [5 x i8] c"SO\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] c"Wales\00\00\00\00\00", double 0x404A12B08DD1E53B, double 0xC005DB59DDC1E796 }, %struct.ngrLookupStruct { [5 x i8] c"SP\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404A12B13DFB0D52, double 0xBFF454E4C942D491 }, %struct.ngrLookupStruct { [5 x i8] c"TL\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404A835CB790FB65, double 2.351220e-01 }, %struct.ngrLookupStruct { [5 x i8] c"TM\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404A0BC0EBEDFA44, double 0x3FFA5EF62F9CA5BE }, %struct.ngrLookupStruct { [5 x i8] c"SH\00\00\00", [18 x i8] c"Wales\00\00\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404A835A964E8B7E, double 0xC010F3BB40B34E77 }, %struct.ngrLookupStruct { [5 x i8] c"SJ\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] c"Wales\00\00\00\00\00", double 0x404A85BFCEB78898, double -2.747250e+00 }, %struct.ngrLookupStruct { [5 x i8] c"SK\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404A85C07EE0B0AF, double 0xBFF4172580C308FF }, %struct.ngrLookupStruct { [5 x i8] c"TF\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404A835CB790FB65, double 2.351220e-01 }, %struct.ngrLookupStruct { [5 x i8] c"TG\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404A7E95F2452C5A, double 0x3FFB931EC0B56755 }, %struct.ngrLookupStruct { [5 x i8] c"SC\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404AF650F840181E, double -4.285810e+00 }, %struct.ngrLookupStruct { [5 x i8] c"SD\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404AF8CA79357604, double 0xC0061B163BABA7B9 }, %struct.ngrLookupStruct { [5 x i8] c"SE\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404AF8CB31C219EB, double 0xBFF3D6030C23FAB1 }, %struct.ngrLookupStruct { [5 x i8] c"TA\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404B6426F60E0EB6, double 0xC0178EECBFB15B57 }, %struct.ngrLookupStruct { [5 x i8] c"NW\00\00\00", [18 x i8] c"Northern_Ireland\00\00", [10 x i8] zeroinitializer, double 0x404B6426F60E0EB6, double 0xC0178EECBFB15B57 }, %struct.ngrLookupStruct { [5 x i8] c"NX\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] c"Scotland\00\00", double 0x404B6941E14BDFD2, double 0xC01158576CCE5F74 }, %struct.ngrLookupStruct { [5 x i8] c"NY\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] c"Scotland\00\00", double 0x404B6BD09E12A51E, double 0xC0063DA272862F5A }, %struct.ngrLookupStruct { [5 x i8] c"NZ\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] c"Scotland\00\00", double 0x404B6BD15F02C4D6, double 0xBFF3913B5BF6A0DC }, %struct.ngrLookupStruct { [5 x i8] c"OV\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404B6944241C3EFB, double 3.332240e-01 }, %struct.ngrLookupStruct { [5 x i8] c"NR\00\00\00", [18 x i8] c"Scotland\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404BD6E642BF9831, double 0xC017E9AA60913A50 }, %struct.ngrLookupStruct { [5 x i8] c"NS\00\00\00", [18 x i8] c"Scotland\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404BDC2D59D55E6C, double 0xC0118EF566490A35 }, %struct.ngrLookupStruct { [5 x i8] c"NT\00\00\00", [18 x i8] c"Scotland\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404BDED23D4F15E8, double 0xC006622706D50657 }, %struct.ngrLookupStruct { [5 x i8] c"NU\00\00\00", [18 x i8] c"Scotland\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404BDED306A2B170, double 0xBFF34887229E9079 }, %struct.ngrLookupStruct { [5 x i8] c"NL\00\00\00", [18 x i8] c"Scotland\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404C41737542A23C, double 0xC01EC4E7EE9142B3 }, %struct.ngrLookupStruct { [5 x i8] c"NM\00\00\00", [18 x i8] c"Scotland\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404C499DFDAC68A9, double 0xC01849AC79702E66 }, %struct.ngrLookupStruct { [5 x i8] c"NN\00\00\00", [18 x i8] c"Scotland\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404C4F1351159C49, double 0xC011C8C0CE91C8EB }, %struct.ngrLookupStruct { [5 x i8] c"NO\00\00\00", [18 x i8] c"Scotland\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404C51CF67B1C001, double 0xC00688CCDD93C46E }, %struct.ngrLookupStruct { [5 x i8] c"NF\00\00\00", [18 x i8] c"Scotland\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404CB3DB1A6D6990, double 0xC01F529AE4F33440 }, %struct.ngrLookupStruct { [5 x i8] c"NG\00\00\00", [18 x i8] c"Scotland\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404CBC4DF47F993D, double 0xC018AF609DCF8940 }, %struct.ngrLookupStruct { [5 x i8] c"NH\00\00\00", [18 x i8] c"Scotland\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404CC1F3BEA91D9B, double 0xC01205FCC1871E6D }, %struct.ngrLookupStruct { [5 x i8] c"NJ\00\00\00", [18 x i8] c"Scotland\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404CC4C8259E1F3A, double 0xC006B1C0010C6F7A }, %struct.ngrLookupStruct { [5 x i8] c"NK\00\00\00", [18 x i8] c"Scotland\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404CC4C8F7553693, double 0xBFF2AA0FD3B29A1C }, %struct.ngrLookupStruct { [5 x i8] c"NA\00\00\00", [18 x i8] c"Scotland\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404D26372606FAC6, double 0xC01FE8DDE7A743A6 }, %struct.ngrLookupStruct { [5 x i8] c"NB\00\00\00", [18 x i8] c"Scotland\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404D2EF5DBB9CF9A, double 0xC0191B413986338B }, %struct.ngrLookupStruct { [5 x i8] c"NC\00\00\00", [18 x i8] c"Scotland\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404D34CE91C8EAC0, double 0xC01246F2A5A469D7 }, %struct.ngrLookupStruct { [5 x i8] c"ND\00\00\00", [18 x i8] c"Scotland\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404D37BC87DB2B34, double 0xC006DD31B9B66F93 }]
@.str = [48 x i8] c"The size of ngrLookup is %ld, lat %f, long %f \0A\00"
@.str.1 = [44 x i8] c"You are located in square %s located in %s\0A\00"
@.str.2 = [20 x i8] c"Location not found\0A\00"
define double @ngrDistance(double %0, double %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
store double %0, double* %7
store double %1, double* %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i8* %4, i8** %11
%13 = load double, double* %7
%14 = load double, double* %8
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i64 49, double %13, double %14)
store i32 0, i32* %12
br label %16
16: ; preds = %69, %5
%17 = load i32, i32* %12
%18 = sext i32 %17 to i64
%19 = icmp ult i64 %18, 49
br i1 %19, label %20, label %72
20: ; preds = %16
%21 = load double, double* %7
%22 = load double, double* %8
%23 = load i32, i32* %12
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [49 x %struct.ngrLookupStruct], [49 x %struct.ngrLookupStruct]* @ngrDistance.ngrLookup, i64 0, i64 %24
%26 = getelementptr inbounds %struct.ngrLookupStruct, %struct.ngrLookupStruct* %25, i32 0, i32 3
%27 = load double, double* %26
%28 = load i32, i32* %12
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [49 x %struct.ngrLookupStruct], [49 x %struct.ngrLookupStruct]* @ngrDistance.ngrLookup, i64 0, i64 %29
%31 = getelementptr inbounds %struct.ngrLookupStruct, %struct.ngrLookupStruct* %30, i32 0, i32 4
%32 = load double, double* %31
%33 = call i32 @geoDistance(double %21, double %22, double %27, double %32, i8 signext 75)
%34 = icmp slt i32 %33, 60
br i1 %34, label %35, label %68
35: ; preds = %20
%36 = load i32, i32* %12
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [49 x %struct.ngrLookupStruct], [49 x %struct.ngrLookupStruct]* @ngrDistance.ngrLookup, i64 0, i64 %37
%39 = getelementptr inbounds %struct.ngrLookupStruct, %struct.ngrLookupStruct* %38, i32 0, i32 0
%40 = getelementptr inbounds [5 x i8], [5 x i8]* %39, i64 0, i64 0
%41 = load i32, i32* %12
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [49 x %struct.ngrLookupStruct], [49 x %struct.ngrLookupStruct]* @ngrDistance.ngrLookup, i64 0, i64 %42
%44 = getelementptr inbounds %struct.ngrLookupStruct, %struct.ngrLookupStruct* %43, i32 0, i32 1
%45 = getelementptr inbounds [18 x i8], [18 x i8]* %44, i64 0, i64 0
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i8* %40, i8* %45)
%47 = load i8*, i8** %11
%48 = load i32, i32* %12
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds [49 x %struct.ngrLookupStruct], [49 x %struct.ngrLookupStruct]* @ngrDistance.ngrLookup, i64 0, i64 %49
%51 = getelementptr inbounds %struct.ngrLookupStruct, %struct.ngrLookupStruct* %50, i32 0, i32 0
%52 = getelementptr inbounds [5 x i8], [5 x i8]* %51, i64 0, i64 0
%53 = call i32 @strcpy(i8* %47, i8* %52)
%54 = load i8*, i8** %9
%55 = load i32, i32* %12
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [49 x %struct.ngrLookupStruct], [49 x %struct.ngrLookupStruct]* @ngrDistance.ngrLookup, i64 0, i64 %56
%58 = getelementptr inbounds %struct.ngrLookupStruct, %struct.ngrLookupStruct* %57, i32 0, i32 1
%59 = getelementptr inbounds [18 x i8], [18 x i8]* %58, i64 0, i64 0
%60 = call i32 @strcpy(i8* %54, i8* %59)
%61 = load i8*, i8** %10
%62 = load i32, i32* %12
%63 = sext i32 %62 to i64
%64 = getelementptr inbounds [49 x %struct.ngrLookupStruct], [49 x %struct.ngrLookupStruct]* @ngrDistance.ngrLookup, i64 0, i64 %63
%65 = getelementptr inbounds %struct.ngrLookupStruct, %struct.ngrLookupStruct* %64, i32 0, i32 2
%66 = getelementptr inbounds [10 x i8], [10 x i8]* %65, i64 0, i64 0
%67 = call i32 @strcpy(i8* %61, i8* %66)
store double 1.000000e+00, double* %6
br label %74
68: ; preds = %20
br label %69
69: ; preds = %68
%70 = load i32, i32* %12
%71 = add nsw i32 %70, 1
store i32 %71, i32* %12
br label %16
72: ; preds = %16
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
store double 0.000000e+00, double* %6
br label %74
74: ; preds = %72, %35
%75 = load double, double* %6
ret double %75
}

LLVM IR (-O2):
%struct.ngrLookupStruct = type { [5 x i8], [18 x i8], [10 x i8], double, double }
@ngrDistance.ngrLookup = internal global [49 x %struct.ngrLookupStruct] [%struct.ngrLookupStruct { [5 x i8] c"SV\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 5.024600e+01, double -6.911000e+00 }, %struct.ngrLookupStruct { [5 x i8] c"SW\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 5.029700e+01, double -5.511000e+00 }, %struct.ngrLookupStruct { [5 x i8] c"SX\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 5.033000e+01, double -4.109000e+00 }, %struct.ngrLookupStruct { [5 x i8] c"SY\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 5.034800e+01, double -2.704000e+00 }, %struct.ngrLookupStruct { [5 x i8] c"SZ\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 5.034800e+01, double -1.300000e+00 }, %struct.ngrLookupStruct { [5 x i8] c"TV\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 5.033100e+01, double 1.060000e-01 }, %struct.ngrLookupStruct { [5 x i8] c"SR\00\00\00", [18 x i8] c"Wales\00\00\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404998E1B4BB5E0F, double 0xC01651737542A23C }, %struct.ngrLookupStruct { [5 x i8] c"SS\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] c"Wales\00\00\00\00\00", double 0x40499D5DAAD60200, double 0xC010994F69CA9EF5 }, %struct.ngrLookupStruct { [5 x i8] c"ST\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] c"Wales\00\00\00\00\00", double 0x40499F9CAE21101B, double 0xC005BDEBD9018E75 }, %struct.ngrLookupStruct { [5 x i8] c"SU\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x40499F9D55E6BC62, double 0xBFF48F7CAA7589F0 }, %struct.ngrLookupStruct { [5 x i8] c"TQ\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x40499D5FAA8A82A5, double 1.469550e-01 }, %struct.ngrLookupStruct { [5 x i8] c"TR\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404998E503FB3743, double 0x3FF93A83F4ECA687 }, %struct.ngrLookupStruct { [5 x i8] c"SM\00\00\00", [18 x i8] c"Wales\00\00\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404A0BBD8BE7296F, double 0xC0169AA10E022142 }, %struct.ngrLookupStruct { [5 x i8] c"SN\00\00\00", [18 x i8] c"Wales\00\00\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404A105ED4A1AD64, double 0xC010C556084A515D }, %struct.ngrLookupStruct { [5 x i8] c"SO\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] c"Wales\00\00\00\00\00", double 0x404A12B08DD1E53B, double 0xC005DB59DDC1E796 }, %struct.ngrLookupStruct { [5 x i8] c"SP\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404A12B13DFB0D52, double 0xBFF454E4C942D491 }, %struct.ngrLookupStruct { [5 x i8] c"TL\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404A835CB790FB65, double 2.351220e-01 }, %struct.ngrLookupStruct { [5 x i8] c"TM\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404A0BC0EBEDFA44, double 0x3FFA5EF62F9CA5BE }, %struct.ngrLookupStruct { [5 x i8] c"SH\00\00\00", [18 x i8] c"Wales\00\00\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404A835A964E8B7E, double 0xC010F3BB40B34E77 }, %struct.ngrLookupStruct { [5 x i8] c"SJ\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] c"Wales\00\00\00\00\00", double 0x404A85BFCEB78898, double -2.747250e+00 }, %struct.ngrLookupStruct { [5 x i8] c"SK\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404A85C07EE0B0AF, double 0xBFF4172580C308FF }, %struct.ngrLookupStruct { [5 x i8] c"TF\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404A835CB790FB65, double 2.351220e-01 }, %struct.ngrLookupStruct { [5 x i8] c"TG\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404A7E95F2452C5A, double 0x3FFB931EC0B56755 }, %struct.ngrLookupStruct { [5 x i8] c"SC\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404AF650F840181E, double -4.285810e+00 }, %struct.ngrLookupStruct { [5 x i8] c"SD\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404AF8CA79357604, double 0xC0061B163BABA7B9 }, %struct.ngrLookupStruct { [5 x i8] c"SE\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404AF8CB31C219EB, double 0xBFF3D6030C23FAB1 }, %struct.ngrLookupStruct { [5 x i8] c"TA\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404B6426F60E0EB6, double 0xC0178EECBFB15B57 }, %struct.ngrLookupStruct { [5 x i8] c"NW\00\00\00", [18 x i8] c"Northern_Ireland\00\00", [10 x i8] zeroinitializer, double 0x404B6426F60E0EB6, double 0xC0178EECBFB15B57 }, %struct.ngrLookupStruct { [5 x i8] c"NX\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] c"Scotland\00\00", double 0x404B6941E14BDFD2, double 0xC01158576CCE5F74 }, %struct.ngrLookupStruct { [5 x i8] c"NY\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] c"Scotland\00\00", double 0x404B6BD09E12A51E, double 0xC0063DA272862F5A }, %struct.ngrLookupStruct { [5 x i8] c"NZ\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] c"Scotland\00\00", double 0x404B6BD15F02C4D6, double 0xBFF3913B5BF6A0DC }, %struct.ngrLookupStruct { [5 x i8] c"OV\00\00\00", [18 x i8] c"England\00\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404B6944241C3EFB, double 3.332240e-01 }, %struct.ngrLookupStruct { [5 x i8] c"NR\00\00\00", [18 x i8] c"Scotland\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404BD6E642BF9831, double 0xC017E9AA60913A50 }, %struct.ngrLookupStruct { [5 x i8] c"NS\00\00\00", [18 x i8] c"Scotland\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404BDC2D59D55E6C, double 0xC0118EF566490A35 }, %struct.ngrLookupStruct { [5 x i8] c"NT\00\00\00", [18 x i8] c"Scotland\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404BDED23D4F15E8, double 0xC006622706D50657 }, %struct.ngrLookupStruct { [5 x i8] c"NU\00\00\00", [18 x i8] c"Scotland\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404BDED306A2B170, double 0xBFF34887229E9079 }, %struct.ngrLookupStruct { [5 x i8] c"NL\00\00\00", [18 x i8] c"Scotland\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404C41737542A23C, double 0xC01EC4E7EE9142B3 }, %struct.ngrLookupStruct { [5 x i8] c"NM\00\00\00", [18 x i8] c"Scotland\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404C499DFDAC68A9, double 0xC01849AC79702E66 }, %struct.ngrLookupStruct { [5 x i8] c"NN\00\00\00", [18 x i8] c"Scotland\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404C4F1351159C49, double 0xC011C8C0CE91C8EB }, %struct.ngrLookupStruct { [5 x i8] c"NO\00\00\00", [18 x i8] c"Scotland\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404C51CF67B1C001, double 0xC00688CCDD93C46E }, %struct.ngrLookupStruct { [5 x i8] c"NF\00\00\00", [18 x i8] c"Scotland\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404CB3DB1A6D6990, double 0xC01F529AE4F33440 }, %struct.ngrLookupStruct { [5 x i8] c"NG\00\00\00", [18 x i8] c"Scotland\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404CBC4DF47F993D, double 0xC018AF609DCF8940 }, %struct.ngrLookupStruct { [5 x i8] c"NH\00\00\00", [18 x i8] c"Scotland\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404CC1F3BEA91D9B, double 0xC01205FCC1871E6D }, %struct.ngrLookupStruct { [5 x i8] c"NJ\00\00\00", [18 x i8] c"Scotland\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404CC4C8259E1F3A, double 0xC006B1C0010C6F7A }, %struct.ngrLookupStruct { [5 x i8] c"NK\00\00\00", [18 x i8] c"Scotland\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404CC4C8F7553693, double 0xBFF2AA0FD3B29A1C }, %struct.ngrLookupStruct { [5 x i8] c"NA\00\00\00", [18 x i8] c"Scotland\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404D26372606FAC6, double 0xC01FE8DDE7A743A6 }, %struct.ngrLookupStruct { [5 x i8] c"NB\00\00\00", [18 x i8] c"Scotland\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404D2EF5DBB9CF9A, double 0xC0191B413986338B }, %struct.ngrLookupStruct { [5 x i8] c"NC\00\00\00", [18 x i8] c"Scotland\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404D34CE91C8EAC0, double 0xC01246F2A5A469D7 }, %struct.ngrLookupStruct { [5 x i8] c"ND\00\00\00", [18 x i8] c"Scotland\00\00\00\00\00\00\00\00\00\00", [10 x i8] zeroinitializer, double 0x404D37BC87DB2B34, double 0xC006DD31B9B66F93 }]
@.str = [48 x i8] c"The size of ngrLookup is %ld, lat %f, long %f \0A\00"
@.str.1 = [44 x i8] c"You are located in square %s located in %s\0A\00"
@str = [19 x i8] c"Location not found\00"
define double @ngrDistance(double %0, double %1, i8* %2, i8* %3, i8* %4) {
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0), i64 49, double %0, double %1)
br label %7
7: ; preds = %5, %24
%8 = phi i64 [ 0, %5 ], [ %25, %24 ]
%9 = getelementptr inbounds [49 x %struct.ngrLookupStruct], [49 x %struct.ngrLookupStruct]* @ngrDistance.ngrLookup, i64 0, i64 %8, i32 3
%10 = load double, double* %9
%11 = getelementptr inbounds [49 x %struct.ngrLookupStruct], [49 x %struct.ngrLookupStruct]* @ngrDistance.ngrLookup, i64 0, i64 %8, i32 4
%12 = load double, double* %11
%13 = tail call i32 @geoDistance(double %0, double %1, double %10, double %12, i8 signext 75)
%14 = icmp slt i32 %13, 60
br i1 %14, label %15, label %24
15: ; preds = %7
%16 = and i64 %8, 4294967295
%17 = getelementptr inbounds [49 x %struct.ngrLookupStruct], [49 x %struct.ngrLookupStruct]* @ngrDistance.ngrLookup, i64 0, i64 %16, i32 0, i64 0
%18 = getelementptr inbounds [49 x %struct.ngrLookupStruct], [49 x %struct.ngrLookupStruct]* @ngrDistance.ngrLookup, i64 0, i64 %16, i32 1, i64 0
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i8* %17, i8* %18)
%20 = tail call i32 @strcpy(i8* %4, i8* %17)
%21 = tail call i32 @strcpy(i8* %2, i8* %18)
%22 = getelementptr inbounds [49 x %struct.ngrLookupStruct], [49 x %struct.ngrLookupStruct]* @ngrDistance.ngrLookup, i64 0, i64 %16, i32 2, i64 0
%23 = tail call i32 @strcpy(i8* %3, i8* %22)
br label %29
24: ; preds = %7
%25 = add nuw nsw i64 %8, 1
%26 = icmp eq i64 %25, 49
br i1 %26, label %27, label %7
27: ; preds = %24
%28 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %29
29: ; preds = %27, %15
%30 = phi double [ 1.000000e+00, %15 ], [ 0.000000e+00, %27 ]
ret double %30
}