#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ NextLine(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int rint(double);
int /*<<< orphan*/ sprintf(char *, char *, double, double);
int sscanf(char *, char *, ...);
scalar_t__ strcasecmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
void ReadLoc(int ind_i[], int ind_j[], char siten[1024][1024], int *nloc) {
  FILE *loc_file;
  int match;
  int lno = 0;
  char cmdstr[1024];
  char lon_char[1024], lat_char[1024];
  char siten_char[1024];
  int kloc;
  int exist;
  double lat, lon;
  loc_file = fopen("location.txt", "r");
  if (NULL == loc_file) {
    printf("ERROR: Cannot find the required location.txt file.\n");
    exit(EXIT_FAILURE);
  }
  NextLine(loc_file, cmdstr, &lno);
  match = sscanf(cmdstr, "%s %s %s", lat_char, lon_char, siten_char);
  if (match != 3 || strcasecmp(lat_char, "LATITUDE") != 0 ||
      strcasecmp(lon_char, "LONGITUDE") != 0 ||
      strcasecmp(siten_char, "NAME") != 0) {
    printf("Error reading the header line of location.txt at Line %d.\n", lno);
    exit(EXIT_FAILURE);
  }
  NextLine(loc_file, cmdstr, &lno);
  while (strcasecmp(cmdstr, "EOF") != 0) {
    match = sscanf(cmdstr, "%lf %lf %s", &lat, &lon, siten_char);
    if (match != 3 && match != 2) {
      printf("Error reading location.txt at Line %d.\n", lno);
      exit(EXIT_FAILURE);
    }
    lon -= (lon > 180.0) ? 360.0 : 0.0;
    if (match == 2) {
      sprintf(siten_char, "met%.4lfNx%.4lfW", lat, -lon);
    }
    if (lat < 25.0625 || lat > 52.9375) {
      printf("Error: latitude out of range (25.0625N ~ 52.9375N)\n");
      exit(EXIT_FAILURE);
    }
    if (lon < -124.9375 || lon > -67.0625) {
      printf("Error: longitude out of range (124.9375W ~ 67.0625W)\n");
      exit(EXIT_FAILURE);
    }
    exist = 0;
    if (*nloc > 0) {
      for (kloc = 0; kloc < *nloc; kloc++) {
        if (rint((lon - -124.9375) / 0.125) + 1 == ind_i[kloc] &&
            rint((lat - 25.0625) / 0.125) + 1 == ind_j[kloc]) {
          printf("Site %s and site %s are in the same NLDAS grid.\n"
                 "Forcing for Site %s will not be generated.\n",
                 siten_char, siten[kloc], siten_char);
          exist = 1;
          break;
        }
      }
    }
    if (!exist) {
      ind_i[*nloc] = rint((lon - -124.9375) / 0.125) + 1;
      ind_j[*nloc] = rint((lat - 25.0625) / 0.125) + 1;
      strcpy(siten[*nloc], siten_char);
      (*nloc)++;
    }
    NextLine(loc_file, cmdstr, &lno);
  }
}


x86 assembly (clang, -O0):
<ReadLoc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1050,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x30(%rbp)
lea    0xe7f(%rip),%rdi
lea    0xe85(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
cmp    -0x28(%rbp),%rax
jne    11f1 <ReadLoc+0x61>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2df6(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x28(%rbp),%rdi
lea    -0x430(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1050 <NextLine@plt>
lea    -0x430(%rbp),%rdi
lea    -0xc30(%rbp),%rdx
lea    -0x830(%rbp),%rcx
lea    -0x1030(%rbp),%r8
lea    0xe53(%rip),%rsi
mov    $0x0,%al
call   1080 <sscanf@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x3,-0x2c(%rbp)
jne    1293 <ReadLoc+0x103>
lea    -0xc30(%rbp),%rdi
lea    0xe3a(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1293 <ReadLoc+0x103>
lea    -0x830(%rbp),%rdi
lea    0xe26(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1293 <ReadLoc+0x103>
lea    -0x1030(%rbp),%rdi
lea    0xe13(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     12b2 <ReadLoc+0x122>
mov    -0x30(%rbp),%esi
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2d35(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
mov    -0x28(%rbp),%rdi
lea    -0x430(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1050 <NextLine@plt>
lea    -0x430(%rbp),%rdi
lea    0xe03(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
je     1627 <ReadLoc+0x497>
lea    -0x430(%rbp),%rdi
lea    -0x1030(%rbp),%r8
lea    0xde3(%rip),%rsi
lea    -0x1040(%rbp),%rdx
lea    -0x1048(%rbp),%rcx
mov    $0x0,%al
call   1080 <sscanf@plt>
mov    %eax,-0x2c(%rbp)
cmpl   $0x3,-0x2c(%rbp)
je     1343 <ReadLoc+0x1b3>
cmpl   $0x2,-0x2c(%rbp)
je     1343 <ReadLoc+0x1b3>
mov    -0x30(%rbp),%esi
lea    0xdb8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2ca4(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
movsd  -0x1048(%rbp),%xmm0
ff
movsd  0xcad(%rip),%xmm3
xorps  %xmm2,%xmm2
movsd  0xcaa(%rip),%xmm1
cmpltsd %xmm0,%xmm1
movaps %xmm1,%xmm0
andpd  %xmm3,%xmm0
andnpd %xmm2,%xmm1
orpd   %xmm0,%xmm1
movsd  -0x1048(%rbp),%xmm0
ff
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x1048(%rbp)
ff
cmpl   $0x2,-0x2c(%rbp)
jne    13ca <ReadLoc+0x23a>
lea    -0x1030(%rbp),%rdi
movsd  -0x1040(%rbp),%xmm0
ff
movsd  -0x1048(%rbp),%xmm1
ff
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
lea    0xd49(%rip),%rsi
call   10a0 <sprintf@plt>
movsd  0xc3e(%rip),%xmm0
ucomisd -0x1040(%rbp),%xmm0
ff
ja     13fa <ReadLoc+0x26a>
movsd  -0x1040(%rbp),%xmm0
ff
movsd  0xc28(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1416 <ReadLoc+0x286>
lea    0xd1e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2bd1(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
movsd  0xc02(%rip),%xmm0
ucomisd -0x1048(%rbp),%xmm0
ff
ja     1446 <ReadLoc+0x2b6>
movsd  -0x1048(%rbp),%xmm0
ff
movsd  0xbec(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1462 <ReadLoc+0x2d2>
lea    0xd06(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    0x2b85(%rip),%rax
mov    (%rax),%edi
call   10b0 <exit@plt>
movl   $0x0,-0x1038(%rbp)
mov    -0x20(%rbp),%rax
cmpl   $0x0,(%rax)
jle    1568 <ReadLoc+0x3d8>
movl   $0x0,-0x1034(%rbp)
mov    -0x1034(%rbp),%eax
mov    -0x20(%rbp),%rcx
cmp    (%rcx),%eax
jge    1563 <ReadLoc+0x3d3>
movsd  -0x1048(%rbp),%xmm0
ff
movsd  0xb7b(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xb7f(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1070 <rint@plt>
add    $0x1,%eax
mov    -0x8(%rbp),%rcx
movslq -0x1034(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jne    154a <ReadLoc+0x3ba>
movsd  -0x1040(%rbp),%xmm0
ff
movsd  0xb2f(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xb43(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1070 <rint@plt>
add    $0x1,%eax
mov    -0x10(%rbp),%rcx
movslq -0x1034(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jne    154a <ReadLoc+0x3ba>
lea    -0x1030(%rbp),%rsi
mov    -0x18(%rbp),%rdx
movslq -0x1034(%rbp),%rax
shl    $0xa,%rax
add    %rax,%rdx
lea    -0x1030(%rbp),%rcx
lea    0xc55(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x1038(%rbp)
jmp    1563 <ReadLoc+0x3d3>
jmp    154f <ReadLoc+0x3bf>
mov    -0x1034(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1034(%rbp)
jmp    1483 <ReadLoc+0x2f3>
jmp    1568 <ReadLoc+0x3d8>
cmpl   $0x0,-0x1038(%rbp)
jne    160e <ReadLoc+0x47e>
movsd  -0x1048(%rbp),%xmm0
ff
movsd  0xa9b(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xa9f(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1070 <rint@plt>
mov    %eax,%edx
add    $0x1,%edx
mov    -0x8(%rbp),%rax
mov    -0x20(%rbp),%rcx
movslq (%rcx),%rcx
mov    %edx,(%rax,%rcx,4)
movsd  -0x1040(%rbp),%xmm0
ff
movsd  0xa53(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  0xa67(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1070 <rint@plt>
mov    %eax,%edx
add    $0x1,%edx
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movslq (%rcx),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rax
movslq (%rax),%rax
shl    $0xa,%rax
add    %rax,%rdi
lea    -0x1030(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rdi
lea    -0x430(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1050 <NextLine@plt>
jmp    12c6 <ReadLoc+0x136>
add    $0x1050,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReadLoc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1038,%rsp
mov    %rcx,%rbx
mov    %rdx,0x20(%rsp)
mov    %rsi,%r15
mov    %rdi,%r12
movl   $0x0,0xc(%rsp)
lea    0xe92(%rip),%rdi
lea    0xe98(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1514 <ReadLoc+0x374>
mov    %rax,%r13
lea    0x30(%rsp),%r14
lea    0xc(%rsp),%rdx
mov    %rax,%rdi
mov    %r14,%rsi
call   1060 <NextLine@plt>
lea    0xe6d(%rip),%rsi
lea    0x830(%rsp),%rdx
lea    0xc30(%rsp),%rcx
lea    0x430(%rsp),%r8
mov    %r14,%rdi
xor    %eax,%eax
call   1090 <sscanf@plt>
cmp    $0x3,%eax
jne    1507 <ReadLoc+0x367>
lea    0xe44(%rip),%rsi
lea    0x830(%rsp),%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
jne    1507 <ReadLoc+0x367>
lea    0xe30(%rip),%rsi
lea    0xc30(%rsp),%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
jne    1507 <ReadLoc+0x367>
lea    0xe1d(%rip),%rsi
lea    0x430(%rsp),%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
jne    1507 <ReadLoc+0x367>
lea    0x30(%rsp),%r14
lea    0xc(%rsp),%rdx
mov    %r13,%rdi
mov    %r14,%rsi
call   1060 <NextLine@plt>
lea    0xe2b(%rip),%rsi
mov    %r14,%rdi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     14be <ReadLoc+0x31e>
lea    0x30(%rsp),%rbp
lea    0x430(%rsp),%r14
mov    %r13,0x28(%rsp)
jmp    1361 <ReadLoc+0x1c1>
nopl   0x0(%rax,%rax,1)
addsd  0xd58(%rip),%xmm0
movsd  0xd58(%rip),%xmm1
mulsd  %xmm1,%xmm0
call   1080 <rint@plt>
add    $0x1,%eax
movslq (%rbx),%rcx
mov    %eax,(%r12,%rcx,4)
movsd  0x18(%rsp),%xmm0
addsd  0xd3f(%rip),%xmm0
mulsd  0xd2f(%rip),%xmm0
call   1080 <rint@plt>
add    $0x1,%eax
movslq (%rbx),%rcx
mov    %eax,(%r15,%rcx,4)
movslq (%rbx),%rdi
shl    $0xa,%rdi
add    0x20(%rsp),%rdi
mov    %rbp,%r14
mov    %rbp,%rsi
call   1040 <strcpy@plt>
addl   $0x1,(%rbx)
mov    0x28(%rsp),%rdi
lea    0x30(%rsp),%rbp
mov    %rbp,%rsi
lea    0xc(%rsp),%rdx
call   1060 <NextLine@plt>
mov    %rbp,%rdi
lea    0xd78(%rip),%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     14be <ReadLoc+0x31e>
mov    %rbp,%rdi
lea    0xd64(%rip),%rsi
lea    0x18(%rsp),%rdx
lea    0x10(%rsp),%rcx
mov    %r14,%r8
xor    %eax,%eax
call   1090 <sscanf@plt>
mov    %eax,%ecx
and    $0xfffffffe,%ecx
cmp    $0x2,%ecx
jne    14d0 <ReadLoc+0x330>
movsd  0x10(%rsp),%xmm1
movsd  0xc65(%rip),%xmm0
cmpltsd %xmm1,%xmm0
movsd  0xc60(%rip),%xmm2
andpd  %xmm2,%xmm0
subsd  %xmm0,%xmm1
movsd  %xmm1,0x10(%rsp)
cmp    $0x2,%eax
jne    13d8 <ReadLoc+0x238>
movsd  0x18(%rsp),%xmm0
xorpd  0xc87(%rip),%xmm1
mov    %r14,%rdi
lea    0xd2f(%rip),%rsi
call   10b0 <sprintf@plt>
movsd  0x18(%rsp),%xmm0
movsd  0xc2a(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     14e4 <ReadLoc+0x344>
ucomisd 0xc20(%rip),%xmm0
ja     14e4 <ReadLoc+0x344>
movsd  0x10(%rsp),%xmm0
movsd  0xc14(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     14ed <ReadLoc+0x34d>
ucomisd 0xc0a(%rip),%xmm0
ja     14ed <ReadLoc+0x34d>
mov    %r14,%rbp
cmpl   $0x0,(%rbx)
jle    12d0 <ReadLoc+0x130>
mov    0x20(%rsp),%r14
xor    %r13d,%r13d
jmp    145d <ReadLoc+0x2bd>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r13
movslq (%rbx),%rax
movsd  0x10(%rsp),%xmm0
add    $0x400,%r14
cmp    %rax,%r13
jge    12d0 <ReadLoc+0x130>
addsd  0xbcb(%rip),%xmm0
mulsd  0xbcb(%rip),%xmm0
call   1080 <rint@plt>
add    $0x1,%eax
cmp    (%r12,%r13,4),%eax
jne    1440 <ReadLoc+0x2a0>
movsd  0x18(%rsp),%xmm0
addsd  0xbb7(%rip),%xmm0
mulsd  0xba7(%rip),%xmm0
call   1080 <rint@plt>
add    $0x1,%eax
cmp    (%r15,%r13,4),%eax
jne    1440 <ReadLoc+0x2a0>
lea    0xc6d(%rip),%rdi
mov    %rbp,%rsi
mov    %r14,%rdx
mov    %rbp,%r14
mov    %rbp,%rcx
xor    %eax,%eax
call   1070 <printf@plt>
jmp    1332 <ReadLoc+0x192>
add    $0x1038,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0xc(%rsp),%esi
lea    0xbff(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    14f9 <ReadLoc+0x359>
lea    0xcb9(%rip),%rdi
jmp    14f4 <ReadLoc+0x354>
lea    0xc7b(%rip),%rdi
call   1050 <puts@plt>
mov    0x2ae0(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    0xc(%rsp),%esi
lea    0xb7e(%rip),%rdi
jmp    14db <ReadLoc+0x33b>
lea    0xcbc(%rip),%rdi
jmp    14f4 <ReadLoc+0x354>

LLVM IR (-O0):
@.str = [13 x i8] c"location.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [52 x i8] c"ERROR: Cannot find the required location.txt file.\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [9 x i8] c"%s %s %s\00"
@.str.4 = [9 x i8] c"LATITUDE\00"
@.str.5 = [10 x i8] c"LONGITUDE\00"
@.str.6 = [5 x i8] c"NAME\00"
@.str.7 = [59 x i8] c"Error reading the header line of location.txt at Line %d.\0A\00"
@.str.8 = [4 x i8] c"EOF\00"
@.str.9 = [11 x i8] c"%lf %lf %s\00"
@.str.10 = [40 x i8] c"Error reading location.txt at Line %d.\0A\00"
@.str.11 = [17 x i8] c"met%.4lfNx%.4lfW\00"
@.str.12 = [52 x i8] c"Error: latitude out of range (25.0625N ~ 52.9375N)\0A\00"
@.str.13 = [54 x i8] c"Error: longitude out of range (124.9375W ~ 67.0625W)\0A\00"
@.str.14 = [92 x i8] c"Site %s and site %s are in the same NLDAS grid.\0AForcing for Site %s will not be generated.\0A\00"
define void @ReadLoc(i32* %0, i32* %1, [1024 x i8]* %2, i32* %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca [1024 x i8]*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca [1024 x i8]
%13 = alloca [1024 x i8]
%14 = alloca [1024 x i8]
%15 = alloca [1024 x i8]
%16 = alloca i32
%17 = alloca i32
%18 = alloca double
%19 = alloca double
store i32* %0, i32** %5
store i32* %1, i32** %6
store [1024 x i8]* %2, [1024 x i8]** %7
store i32* %3, i32** %8
store i32 0, i32* %11
%20 = call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %9
%21 = load i32*, i32** %9
%22 = icmp eq i32* null, %21
br i1 %22, label %23, label %27
23: ; preds = %4
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0))
%25 = load i32, i32* @EXIT_FAILURE
%26 = call i32 @exit(i32 %25)
unreachable
27: ; preds = %4
%28 = load i32*, i32** %9
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%30 = call i32 @NextLine(i32* %28, i8* %29, i32* %11)
%31 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%32 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %15, i64 0, i64 0
%35 = call i32 (i8*, i8*, ...) @sscanf(i8* %31, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %32, i8* %33, i8* %34)
store i32 %35, i32* %10
%36 = load i32, i32* %10
%37 = icmp ne i32 %36, 3
br i1 %37, label %50, label %38
38: ; preds = %27
%39 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%40 = call i64 @strcasecmp(i8* %39, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%41 = icmp ne i64 %40, 0
br i1 %41, label %50, label %42
42: ; preds = %38
%43 = getelementptr inbounds [1024 x i8], [1024 x i8]* %13, i64 0, i64 0
%44 = call i64 @strcasecmp(i8* %43, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%45 = icmp ne i64 %44, 0
br i1 %45, label %50, label %46
46: ; preds = %42
%47 = getelementptr inbounds [1024 x i8], [1024 x i8]* %15, i64 0, i64 0
%48 = call i64 @strcasecmp(i8* %47, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%49 = icmp ne i64 %48, 0
br i1 %49, label %50, label %55
50: ; preds = %46, %42, %38, %27
%51 = load i32, i32* %11
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str.7, i64 0, i64 0), i32 %51)
%53 = load i32, i32* @EXIT_FAILURE
%54 = call i32 @exit(i32 %53)
unreachable
55: ; preds = %46
%56 = load i32*, i32** %9
%57 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%58 = call i32 @NextLine(i32* %56, i8* %57, i32* %11)
br label %59
59: ; preds = %195, %55
%60 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%61 = call i64 @strcasecmp(i8* %60, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%62 = icmp ne i64 %61, 0
br i1 %62, label %63, label %199
63: ; preds = %59
%64 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%65 = getelementptr inbounds [1024 x i8], [1024 x i8]* %15, i64 0, i64 0
%66 = call i32 (i8*, i8*, ...) @sscanf(i8* %64, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), double* %18, double* %19, i8* %65)
store i32 %66, i32* %10
%67 = load i32, i32* %10
%68 = icmp ne i32 %67, 3
br i1 %68, label %69, label %77
69: ; preds = %63
%70 = load i32, i32* %10
%71 = icmp ne i32 %70, 2
br i1 %71, label %72, label %77
72: ; preds = %69
%73 = load i32, i32* %11
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.10, i64 0, i64 0), i32 %73)
%75 = load i32, i32* @EXIT_FAILURE
%76 = call i32 @exit(i32 %75)
unreachable
77: ; preds = %69, %63
%78 = load double, double* %19
%79 = fcmp ogt double %78, 1.800000e+02
%80 = zext i1 %79 to i64
%81 = select i1 %79, double 3.600000e+02, double 0.000000e+00
%82 = load double, double* %19
%83 = fsub double %82, %81
store double %83, double* %19
%84 = load i32, i32* %10
%85 = icmp eq i32 %84, 2
br i1 %85, label %86, label %92
86: ; preds = %77
%87 = getelementptr inbounds [1024 x i8], [1024 x i8]* %15, i64 0, i64 0
%88 = load double, double* %18
%89 = load double, double* %19
%90 = fneg double %89
%91 = call i32 @sprintf(i8* %87, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), double %88, double %90)
br label %92
92: ; preds = %86, %77
%93 = load double, double* %18
%94 = fcmp olt double %93, 2.506250e+01
br i1 %94, label %98, label %95
95: ; preds = %92
%96 = load double, double* %18
%97 = fcmp ogt double %96, 5.293750e+01
br i1 %97, label %98, label %102
98: ; preds = %95, %92
%99 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.12, i64 0, i64 0))
%100 = load i32, i32* @EXIT_FAILURE
%101 = call i32 @exit(i32 %100)
unreachable
102: ; preds = %95
%103 = load double, double* %19
%104 = fcmp olt double %103, 0xC05F3C0000000000
br i1 %104, label %108, label %105
105: ; preds = %102
%106 = load double, double* %19
%107 = fcmp ogt double %106, -6.706250e+01
br i1 %107, label %108, label %112
108: ; preds = %105, %102
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.13, i64 0, i64 0))
%110 = load i32, i32* @EXIT_FAILURE
%111 = call i32 @exit(i32 %110)
unreachable
112: ; preds = %105
store i32 0, i32* %17
%113 = load i32*, i32** %8
%114 = load i32, i32* %113
%115 = icmp sgt i32 %114, 0
br i1 %115, label %116, label %160
116: ; preds = %112
store i32 0, i32* %16
br label %117
117: ; preds = %156, %116
%118 = load i32, i32* %16
%119 = load i32*, i32** %8
%120 = load i32, i32* %119
%121 = icmp slt i32 %118, %120
br i1 %121, label %122, label %159
122: ; preds = %117
%123 = load double, double* %19
%124 = fsub double %123, 0xC05F3C0000000000
%125 = fdiv double %124, 1.250000e-01
%126 = call i32 @rint(double %125)
%127 = add nsw i32 %126, 1
%128 = load i32*, i32** %5
%129 = load i32, i32* %16
%130 = sext i32 %129 to i64
%131 = getelementptr inbounds i32, i32* %128, i64 %130
%132 = load i32, i32* %131
%133 = icmp eq i32 %127, %132
br i1 %133, label %134, label %155
134: ; preds = %122
%135 = load double, double* %18
%136 = fsub double %135, 2.506250e+01
%137 = fdiv double %136, 1.250000e-01
%138 = call i32 @rint(double %137)
%139 = add nsw i32 %138, 1
%140 = load i32*, i32** %6
%141 = load i32, i32* %16
%142 = sext i32 %141 to i64
%143 = getelementptr inbounds i32, i32* %140, i64 %142
%144 = load i32, i32* %143
%145 = icmp eq i32 %139, %144
br i1 %145, label %146, label %155
146: ; preds = %134
%147 = getelementptr inbounds [1024 x i8], [1024 x i8]* %15, i64 0, i64 0
%148 = load [1024 x i8]*, [1024 x i8]** %7
%149 = load i32, i32* %16
%150 = sext i32 %149 to i64
%151 = getelementptr inbounds [1024 x i8], [1024 x i8]* %148, i64 %150
%152 = getelementptr inbounds [1024 x i8], [1024 x i8]* %151, i64 0, i64 0
%153 = getelementptr inbounds [1024 x i8], [1024 x i8]* %15, i64 0, i64 0
%154 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str.14, i64 0, i64 0), i8* %147, i8* %152, i8* %153)
store i32 1, i32* %17
br label %159
155: ; preds = %134, %122
br label %156
156: ; preds = %155
%157 = load i32, i32* %16
%158 = add nsw i32 %157, 1
store i32 %158, i32* %16
br label %117
159: ; preds = %146, %117
br label %160
160: ; preds = %159, %112
%161 = load i32, i32* %17
%162 = icmp ne i32 %161, 0
br i1 %162, label %195, label %163
163: ; preds = %160
%164 = load double, double* %19
%165 = fsub double %164, 0xC05F3C0000000000
%166 = fdiv double %165, 1.250000e-01
%167 = call i32 @rint(double %166)
%168 = add nsw i32 %167, 1
%169 = load i32*, i32** %5
%170 = load i32*, i32** %8
%171 = load i32, i32* %170
%172 = sext i32 %171 to i64
%173 = getelementptr inbounds i32, i32* %169, i64 %172
store i32 %168, i32* %173
%174 = load double, double* %18
%175 = fsub double %174, 2.506250e+01
%176 = fdiv double %175, 1.250000e-01
%177 = call i32 @rint(double %176)
%178 = add nsw i32 %177, 1
%179 = load i32*, i32** %6
%180 = load i32*, i32** %8
%181 = load i32, i32* %180
%182 = sext i32 %181 to i64
%183 = getelementptr inbounds i32, i32* %179, i64 %182
store i32 %178, i32* %183
%184 = load [1024 x i8]*, [1024 x i8]** %7
%185 = load i32*, i32** %8
%186 = load i32, i32* %185
%187 = sext i32 %186 to i64
%188 = getelementptr inbounds [1024 x i8], [1024 x i8]* %184, i64 %187
%189 = getelementptr inbounds [1024 x i8], [1024 x i8]* %188, i64 0, i64 0
%190 = getelementptr inbounds [1024 x i8], [1024 x i8]* %15, i64 0, i64 0
%191 = call i32 @strcpy(i8* %189, i8* %190)
%192 = load i32*, i32** %8
%193 = load i32, i32* %192
%194 = add nsw i32 %193, 1
store i32 %194, i32* %192
br label %195
195: ; preds = %163, %160
%196 = load i32*, i32** %9
%197 = getelementptr inbounds [1024 x i8], [1024 x i8]* %12, i64 0, i64 0
%198 = call i32 @NextLine(i32* %196, i8* %197, i32* %11)
br label %59
199: ; preds = %59
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"location.txt\00"
@.str.1 = [2 x i8] c"r\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [9 x i8] c"%s %s %s\00"
@.str.4 = [9 x i8] c"LATITUDE\00"
@.str.5 = [10 x i8] c"LONGITUDE\00"
@.str.6 = [5 x i8] c"NAME\00"
@.str.7 = [59 x i8] c"Error reading the header line of location.txt at Line %d.\0A\00"
@.str.8 = [4 x i8] c"EOF\00"
@.str.9 = [11 x i8] c"%lf %lf %s\00"
@.str.10 = [40 x i8] c"Error reading location.txt at Line %d.\0A\00"
@.str.11 = [17 x i8] c"met%.4lfNx%.4lfW\00"
@.str.14 = [92 x i8] c"Site %s and site %s are in the same NLDAS grid.\0AForcing for Site %s will not be generated.\0A\00"
@str = [53 x i8] c"Error: longitude out of range (124.9375W ~ 67.0625W)\00"
@str.15 = [51 x i8] c"Error: latitude out of range (25.0625N ~ 52.9375N)\00"
@str.16 = [51 x i8] c"ERROR: Cannot find the required location.txt file.\00"
define void @ReadLoc(i32* nocapture %0, i32* nocapture %1, [1024 x i8]* %2, i32* nocapture %3) {
%5 = alloca i32
%6 = alloca [1024 x i8]
%7 = alloca [1024 x i8]
%8 = alloca [1024 x i8]
%9 = alloca [1024 x i8]
%10 = alloca double
%11 = alloca double
%12 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%15 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%17 = bitcast double* %10 to i8*
%18 = bitcast double* %11 to i8*
%19 = tail call i32* @fopen(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %25
21: ; preds = %4
%22 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.16, i64 0, i64 0))
%23 = load i32, i32* @EXIT_FAILURE
%24 = tail call i32 @exit(i32 %23)
unreachable
25: ; preds = %4
%26 = call i32 @NextLine(i32* %19, i8* %13, i32* %5)
%27 = call i32 (i8*, i8*, ...) @sscanf(i8* %13, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0), i8* %15, i8* %14, i8* %16)
%28 = icmp eq i32 %27, 3
br i1 %28, label %29, label %38
29: ; preds = %25
%30 = call i64 @strcasecmp(i8* %15, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %38
32: ; preds = %29
%33 = call i64 @strcasecmp(i8* %14, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %32
%36 = call i64 @strcasecmp(i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.6, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %43, label %38
38: ; preds = %35, %32, %29, %25
%39 = load i32, i32* %5
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str.7, i64 0, i64 0), i32 %39)
%41 = load i32, i32* @EXIT_FAILURE
%42 = call i32 @exit(i32 %41)
unreachable
43: ; preds = %35
%44 = call i32 @NextLine(i32* %19, i8* %13, i32* %5)
%45 = call i64 @strcasecmp(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
br i1 %46, label %143, label %47
47: ; preds = %43, %139
%48 = call i32 (i8*, i8*, ...) @sscanf(i8* %13, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.9, i64 0, i64 0), double* %10, double* %11, i8* %16)
%49 = and i32 %48, -2
%50 = icmp eq i32 %49, 2
br i1 %50, label %56, label %51
51: ; preds = %47
%52 = load i32, i32* %5
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.10, i64 0, i64 0), i32 %52)
%54 = load i32, i32* @EXIT_FAILURE
%55 = call i32 @exit(i32 %54)
unreachable
56: ; preds = %47
%57 = load double, double* %11
%58 = fcmp ogt double %57, 1.800000e+02
%59 = select i1 %58, double 3.600000e+02, double 0.000000e+00
%60 = fsub double %57, %59
store double %60, double* %11
%61 = icmp eq i32 %48, 2
br i1 %61, label %62, label %66
62: ; preds = %56
%63 = load double, double* %10
%64 = fneg double %60
%65 = call i32 @sprintf(i8* %16, i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.11, i64 0, i64 0), double %63, double %64)
br label %66
66: ; preds = %62, %56
%67 = load double, double* %10
%68 = fcmp olt double %67, 2.506250e+01
%69 = fcmp ogt double %67, 5.293750e+01
%70 = or i1 %68, %69
br i1 %70, label %71, label %75
71: ; preds = %66
%72 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.15, i64 0, i64 0))
%73 = load i32, i32* @EXIT_FAILURE
%74 = call i32 @exit(i32 %73)
unreachable
75: ; preds = %66
%76 = load double, double* %11
%77 = fcmp olt double %76, 0xC05F3C0000000000
%78 = fcmp ogt double %76, -6.706250e+01
%79 = or i1 %77, %78
br i1 %79, label %80, label %84
80: ; preds = %75
%81 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str, i64 0, i64 0))
%82 = load i32, i32* @EXIT_FAILURE
%83 = call i32 @exit(i32 %82)
unreachable
84: ; preds = %75
%85 = load i32, i32* %3
%86 = icmp sgt i32 %85, 0
br i1 %86, label %87, label %116
87: ; preds = %84, %110
%88 = phi double [ %115, %110 ], [ %76, %84 ]
%89 = phi i64 [ %111, %110 ], [ 0, %84 ]
%90 = fadd double %88, 0x405F3C0000000000
%91 = fmul double %90, 8.000000e+00
%92 = call i32 @rint(double %91)
%93 = add nsw i32 %92, 1
%94 = getelementptr inbounds i32, i32* %0, i64 %89
%95 = load i32, i32* %94
%96 = icmp eq i32 %93, %95
br i1 %96, label %97, label %110
97: ; preds = %87
%98 = load double, double* %10
%99 = fadd double %98, -2.506250e+01
%100 = fmul double %99, 8.000000e+00
%101 = call i32 @rint(double %100)
%102 = add nsw i32 %101, 1
%103 = getelementptr inbounds i32, i32* %1, i64 %89
%104 = load i32, i32* %103
%105 = icmp eq i32 %102, %104
br i1 %105, label %106, label %110
106: ; preds = %97
%107 = and i64 %89, 4294967295
%108 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 %107, i64 0
%109 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([92 x i8], [92 x i8]* @.str.14, i64 0, i64 0), i8* %16, i8* %108, i8* %16)
br label %139
110: ; preds = %87, %97
%111 = add nuw nsw i64 %89, 1
%112 = load i32, i32* %3
%113 = sext i32 %112 to i64
%114 = icmp slt i64 %111, %113
%115 = load double, double* %11
br i1 %114, label %87, label %116
116: ; preds = %110, %84
%117 = phi double [ %76, %84 ], [ %115, %110 ]
%118 = fadd double %117, 0x405F3C0000000000
%119 = fmul double %118, 8.000000e+00
%120 = call i32 @rint(double %119)
%121 = add nsw i32 %120, 1
%122 = load i32, i32* %3
%123 = sext i32 %122 to i64
%124 = getelementptr inbounds i32, i32* %0, i64 %123
store i32 %121, i32* %124
%125 = load double, double* %10
%126 = fadd double %125, -2.506250e+01
%127 = fmul double %126, 8.000000e+00
%128 = call i32 @rint(double %127)
%129 = add nsw i32 %128, 1
%130 = load i32, i32* %3
%131 = sext i32 %130 to i64
%132 = getelementptr inbounds i32, i32* %1, i64 %131
store i32 %129, i32* %132
%133 = load i32, i32* %3
%134 = sext i32 %133 to i64
%135 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 %134, i64 0
%136 = call i32 @strcpy(i8* %135, i8* %16)
%137 = load i32, i32* %3
%138 = add nsw i32 %137, 1
store i32 %138, i32* %3
br label %139
139: ; preds = %106, %116
%140 = call i32 @NextLine(i32* %19, i8* %13, i32* %5)
%141 = call i64 @strcasecmp(i8* %13, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.8, i64 0, i64 0))
%142 = icmp eq i64 %141, 0
br i1 %142, label %143, label %47
143: ; preds = %139, %43
ret void
}