#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 */
double atof(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ llh2xyz(double *, double *);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strtok(char *, char *);
int readNmeaGGA(double xyz[(3000)][3], const char *filename) {
  FILE *fp;
  int numd = 0;
  char str[(100)];
  char *token;
  double llh[3], pos[3];
  char tmp[8];
  if (NULL == (fp = fopen(filename, "rt")))
    return (-1);
  while (1) {
    if (fgets(str, (100), fp) == NULL)
      break;
    token = strtok(str, ",");
    if (strncmp(token + 3, "GGA", 3) == 0) {
      token = strtok(NULL, ",");
      token = strtok(NULL, ",");
      strncpy(tmp, token, 2);
      tmp[2] = 0;
      llh[0] = atof(tmp) + atof(token + 2) / 60.0;
      token = strtok(NULL, ",");
      if (token[0] == 'S')
        llh[0] *= -1.0;
      llh[0] /= 57.2957795131;
      token = strtok(NULL, ",");
      strncpy(tmp, token, 3);
      tmp[3] = 0;
      llh[1] = atof(tmp) + atof(token + 3) / 60.0;
      token = strtok(NULL, ",");
      if (token[0] == 'W')
        llh[1] *= -1.0;
      llh[1] /= 57.2957795131;
      token = strtok(NULL, ",");
      token = strtok(NULL, ",");
      token = strtok(NULL, ",");
      token = strtok(NULL, ",");
      llh[2] = atof(token);
      token = strtok(NULL, ",");
      token = strtok(NULL, ",");
      llh[2] += atof(token);
      llh2xyz(llh, pos);
      xyz[numd][0] = pos[0];
      xyz[numd][1] = pos[1];
      xyz[numd][2] = pos[2];
      numd++;
      if (numd >= (3000))
        break;
    }
  }
  fclose(fp);
  return (numd);
}


x86 assembly (clang, -O0):
<readNmeaGGA>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe73(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%rcx
mov    %rcx,-0x20(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    11c8 <readNmeaGGA+0x48>
movl   $0xffffffff,-0x4(%rbp)
jmp    1552 <readNmeaGGA+0x3d2>
jmp    11cd <readNmeaGGA+0x4d>
lea    -0x90(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x64,%esi
call   1080 <fgets@plt>
cmp    $0x0,%rax
jne    11f1 <readNmeaGGA+0x71>
jmp    1543 <readNmeaGGA+0x3c3>
lea    -0x90(%rbp),%rdi
lea    0xe1c(%rip),%rsi
call   10a0 <strtok@plt>
mov    %rax,-0x98(%rbp)
mov    -0x98(%rbp),%rdi
add    $0x3,%rdi
lea    0xe00(%rip),%rsi
mov    $0x3,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    153e <readNmeaGGA+0x3be>
xor    %eax,%eax
mov    %eax,%edi
lea    0xddf(%rip),%rsi
call   10a0 <strtok@plt>
mov    %rax,-0x98(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xdc8(%rip),%rsi
call   10a0 <strtok@plt>
mov    %rax,-0x98(%rbp)
lea    -0xd8(%rbp),%rdi
mov    -0x98(%rbp),%rsi
mov    $0x2,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0xd6(%rbp)
lea    -0xd8(%rbp),%rdi
call   1060 <atof@plt>
movsd  %xmm0,-0xe0(%rbp)
ff
mov    -0x98(%rbp),%rdi
add    $0x2,%rdi
call   1060 <atof@plt>
movaps %xmm0,%xmm1
movsd  -0xe0(%rbp),%xmm0
ff
movsd  0xd4b(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
xor    %eax,%eax
mov    %eax,%edi
lea    0xd4b(%rip),%rsi
call   10a0 <strtok@plt>
mov    %rax,-0x98(%rbp)
mov    -0x98(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x53,%eax
jne    1307 <readNmeaGGA+0x187>
movsd  0xd11(%rip),%xmm0
mulsd  -0xb0(%rbp),%xmm0
ff
movsd  %xmm0,-0xb0(%rbp)
ff
movsd  -0xb0(%rbp),%xmm0
ff
movsd  0xcf9(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xb0(%rbp)
ff
xor    %eax,%eax
mov    %eax,%edi
lea    0xced(%rip),%rsi
call   10a0 <strtok@plt>
mov    %rax,-0x98(%rbp)
lea    -0xd8(%rbp),%rdi
mov    -0x98(%rbp),%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0xd5(%rbp)
lea    -0xd8(%rbp),%rdi
call   1060 <atof@plt>
movsd  %xmm0,-0xe8(%rbp)
ff
mov    -0x98(%rbp),%rdi
add    $0x3,%rdi
call   1060 <atof@plt>
movaps %xmm0,%xmm1
movsd  -0xe8(%rbp),%xmm0
ff
movsd  0xc70(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
xor    %eax,%eax
mov    %eax,%edi
lea    0xc70(%rip),%rsi
call   10a0 <strtok@plt>
mov    %rax,-0x98(%rbp)
mov    -0x98(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x57,%eax
jne    13e2 <readNmeaGGA+0x262>
movsd  0xc36(%rip),%xmm0
mulsd  -0xa8(%rbp),%xmm0
ff
movsd  %xmm0,-0xa8(%rbp)
ff
movsd  -0xa8(%rbp),%xmm0
ff
movsd  0xc1e(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0xa8(%rbp)
ff
xor    %eax,%eax
mov    %eax,%edi
lea    0xc12(%rip),%rsi
call   10a0 <strtok@plt>
mov    %rax,-0x98(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xbfb(%rip),%rsi
call   10a0 <strtok@plt>
mov    %rax,-0x98(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xbe4(%rip),%rsi
call   10a0 <strtok@plt>
mov    %rax,-0x98(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xbcd(%rip),%rsi
call   10a0 <strtok@plt>
mov    %rax,-0x98(%rbp)
mov    -0x98(%rbp),%rdi
call   1060 <atof@plt>
movsd  %xmm0,-0xa0(%rbp)
ff
xor    %eax,%eax
mov    %eax,%edi
lea    0xba2(%rip),%rsi
call   10a0 <strtok@plt>
mov    %rax,-0x98(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xb8b(%rip),%rsi
call   10a0 <strtok@plt>
mov    %rax,-0x98(%rbp)
mov    -0x98(%rbp),%rdi
call   1060 <atof@plt>
addsd  -0xa0(%rbp),%xmm0
ff
movsd  %xmm0,-0xa0(%rbp)
ff
lea    -0xb0(%rbp),%rdi
lea    -0xd0(%rbp),%rsi
call   1050 <llh2xyz@plt>
movsd  -0xd0(%rbp),%xmm0
ff
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  %xmm0,(%rax)
movsd  -0xc8(%rbp),%xmm0
ff
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  %xmm0,0x8(%rax)
movsd  -0xc0(%rbp),%xmm0
ff
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
imul   $0x18,%rcx,%rcx
add    %rcx,%rax
movsd  %xmm0,0x10(%rax)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
cmpl   $0xbb8,-0x24(%rbp)
jl     1539 <readNmeaGGA+0x3b9>
jmp    1543 <readNmeaGGA+0x3c3>
jmp    153e <readNmeaGGA+0x3be>
jmp    11cd <readNmeaGGA+0x4d>
mov    -0x20(%rbp),%rdi
call   1070 <fclose@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readNmeaGGA>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xb8,%rsp
mov    %rsi,%rax
mov    %rdi,0x28(%rsp)
lea    0xe80(%rip),%rsi
mov    %rax,%rdi
call   1090 <fopen@plt>
test   %rax,%rax
je     13e2 <readNmeaGGA+0x262>
mov    %rax,%r15
lea    0x50(%rsp),%rdi
mov    $0x64,%esi
mov    %rax,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     13ea <readNmeaGGA+0x26a>
lea    0xe4d(%rip),%r12
lea    0x50(%rsp),%rbx
lea    0xe43(%rip),%rbp
xor    %r13d,%r13d
jmp    12c0 <readNmeaGGA+0x140>
nopw   0x0(%rax,%rax,1)
lea    0xe2e(%rip),%rbp
lea    0x50(%rsp),%rbx
divsd  0xe04(%rip),%xmm0
movsd  %xmm0,0x18(%rsp)
xor    %edi,%edi
mov    %r12,%rsi
call   10a0 <strtok@plt>
xor    %edi,%edi
mov    %r12,%rsi
call   10a0 <strtok@plt>
xor    %edi,%edi
mov    %r12,%rsi
call   10a0 <strtok@plt>
xor    %edi,%edi
mov    %r12,%rsi
call   10a0 <strtok@plt>
mov    %rax,%rdi
call   1060 <atof@plt>
movsd  %xmm0,0x20(%rsp)
xor    %edi,%edi
mov    %r12,%rsi
call   10a0 <strtok@plt>
xor    %edi,%edi
mov    %r12,%rsi
call   10a0 <strtok@plt>
mov    %rax,%rdi
call   1060 <atof@plt>
addsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x20(%rsp)
lea    0x10(%rsp),%rdi
lea    0x30(%rsp),%rsi
call   1050 <llh2xyz@plt>
movslq %r13d,%rax
lea    (%rax,%rax,2),%rcx
movaps 0x30(%rsp),%xmm0
mov    0x28(%rsp),%rdx
movups %xmm0,(%rdx,%rcx,8)
movsd  0x40(%rsp),%xmm0
movsd  %xmm0,0x10(%rdx,%rcx,8)
lea    0x1(%rax),%r13d
cmp    $0xbb6,%eax
jg     13ed <readNmeaGGA+0x26d>
mov    %rbx,%rdi
mov    $0x64,%esi
mov    %r15,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     13ed <readNmeaGGA+0x26d>
mov    %rbx,%rdi
mov    %r12,%rsi
call   10a0 <strtok@plt>
lea    0x3(%rax),%rdi
mov    %rbp,%rsi
mov    $0x3,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
jne    12a7 <readNmeaGGA+0x127>
xor    %edi,%edi
mov    %r12,%rsi
call   10a0 <strtok@plt>
xor    %edi,%edi
mov    %r12,%rsi
call   10a0 <strtok@plt>
mov    %rax,%r14
lea    0x8(%rsp),%rbp
mov    %rbp,%rdi
mov    %rax,%rsi
mov    $0x2,%edx
call   1030 <strncpy@plt>
movb   $0x0,0xa(%rsp)
mov    %rbp,%rdi
call   1060 <atof@plt>
movsd  %xmm0,(%rsp)
add    $0x2,%r14
mov    %r14,%rdi
call   1060 <atof@plt>
divsd  0xccd(%rip),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
xor    %edi,%edi
mov    %r12,%rsi
call   10a0 <strtok@plt>
cmpb   $0x53,(%rax)
movsd  0x10(%rsp),%xmm0
jne    135b <readNmeaGGA+0x1db>
xorpd  0xcb5(%rip),%xmm0
divsd  0xca5(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
xor    %edi,%edi
mov    %r12,%rsi
call   10a0 <strtok@plt>
mov    %rax,%rbp
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    %rax,%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
movb   $0x0,0xb(%rsp)
mov    %rbx,%rdi
call   1060 <atof@plt>
movsd  %xmm0,(%rsp)
add    $0x3,%rbp
mov    %rbp,%rdi
call   1060 <atof@plt>
divsd  0xc4f(%rip),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
xor    %edi,%edi
mov    %r12,%rsi
call   10a0 <strtok@plt>
cmpb   $0x57,(%rax)
movsd  0x18(%rsp),%xmm0
jne    11f0 <readNmeaGGA+0x70>
xorpd  0xc33(%rip),%xmm0
jmp    11f0 <readNmeaGGA+0x70>
mov    $0xffffffff,%r13d
jmp    13f5 <readNmeaGGA+0x275>
xor    %r13d,%r13d
mov    %r15,%rdi
call   1070 <fclose@plt>
mov    %r13d,%eax
add    $0xb8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rt\00"
@.str.1 = [2 x i8] c",\00"
@.str.2 = [4 x i8] c"GGA\00"
define i32 @readNmeaGGA([3 x double]* %0, i8* %1) {
%3 = alloca i32
%4 = alloca [3 x double]*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca [100 x i8]
%9 = alloca i8*
%10 = alloca [3 x double]
%11 = alloca [3 x double]
%12 = alloca [8 x i8]
store [3 x double]* %0, [3 x double]** %4
store i8* %1, i8** %5
store i32 0, i32* %7
%13 = load i8*, i8** %5
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %6
%15 = icmp eq i32* null, %14
br i1 %15, label %16, label %17
16: ; preds = %2
store i32 -1, i32* %3
br label %136
17: ; preds = %2
br label %18
18: ; preds = %17, %131
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%20 = load i32*, i32** %6
%21 = call i32* @fgets(i8* %19, i32 100, i32* %20)
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %24
23: ; preds = %18
br label %132
24: ; preds = %18
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%26 = call i8* @strtok(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %26, i8** %9
%27 = load i8*, i8** %9
%28 = getelementptr inbounds i8, i8* %27, i64 3
%29 = call i64 @strncmp(i8* %28, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %131
31: ; preds = %24
%32 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %32, i8** %9
%33 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %33, i8** %9
%34 = getelementptr inbounds [8 x i8], [8 x i8]* %12, i64 0, i64 0
%35 = load i8*, i8** %9
%36 = call i32 @strncpy(i8* %34, i8* %35, i32 2)
%37 = getelementptr inbounds [8 x i8], [8 x i8]* %12, i64 0, i64 2
store i8 0, i8* %37
%38 = getelementptr inbounds [8 x i8], [8 x i8]* %12, i64 0, i64 0
%39 = call double @atof(i8* %38)
%40 = load i8*, i8** %9
%41 = getelementptr inbounds i8, i8* %40, i64 2
%42 = call double @atof(i8* %41)
%43 = fdiv double %42, 6.000000e+01
%44 = fadd double %39, %43
%45 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 0
store double %44, double* %45
%46 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %46, i8** %9
%47 = load i8*, i8** %9
%48 = getelementptr inbounds i8, i8* %47, i64 0
%49 = load i8, i8* %48
%50 = sext i8 %49 to i32
%51 = icmp eq i32 %50, 83
br i1 %51, label %52, label %56
52: ; preds = %31
%53 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 0
%54 = load double, double* %53
%55 = fmul double %54, -1.000000e+00
store double %55, double* %53
br label %56
56: ; preds = %52, %31
%57 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 0
%58 = load double, double* %57
%59 = fdiv double %58, 0x404CA5DC1A63CBB0
store double %59, double* %57
%60 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %60, i8** %9
%61 = getelementptr inbounds [8 x i8], [8 x i8]* %12, i64 0, i64 0
%62 = load i8*, i8** %9
%63 = call i32 @strncpy(i8* %61, i8* %62, i32 3)
%64 = getelementptr inbounds [8 x i8], [8 x i8]* %12, i64 0, i64 3
store i8 0, i8* %64
%65 = getelementptr inbounds [8 x i8], [8 x i8]* %12, i64 0, i64 0
%66 = call double @atof(i8* %65)
%67 = load i8*, i8** %9
%68 = getelementptr inbounds i8, i8* %67, i64 3
%69 = call double @atof(i8* %68)
%70 = fdiv double %69, 6.000000e+01
%71 = fadd double %66, %70
%72 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 1
store double %71, double* %72
%73 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %73, i8** %9
%74 = load i8*, i8** %9
%75 = getelementptr inbounds i8, i8* %74, i64 0
%76 = load i8, i8* %75
%77 = sext i8 %76 to i32
%78 = icmp eq i32 %77, 87
br i1 %78, label %79, label %83
79: ; preds = %56
%80 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 1
%81 = load double, double* %80
%82 = fmul double %81, -1.000000e+00
store double %82, double* %80
br label %83
83: ; preds = %79, %56
%84 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 1
%85 = load double, double* %84
%86 = fdiv double %85, 0x404CA5DC1A63CBB0
store double %86, double* %84
%87 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %87, i8** %9
%88 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %88, i8** %9
%89 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %89, i8** %9
%90 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %90, i8** %9
%91 = load i8*, i8** %9
%92 = call double @atof(i8* %91)
%93 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 2
store double %92, double* %93
%94 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %94, i8** %9
%95 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %95, i8** %9
%96 = load i8*, i8** %9
%97 = call double @atof(i8* %96)
%98 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 2
%99 = load double, double* %98
%100 = fadd double %99, %97
store double %100, double* %98
%101 = getelementptr inbounds [3 x double], [3 x double]* %10, i64 0, i64 0
%102 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%103 = call i32 @llh2xyz(double* %101, double* %102)
%104 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%105 = load double, double* %104
%106 = load [3 x double]*, [3 x double]** %4
%107 = load i32, i32* %7
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds [3 x double], [3 x double]* %106, i64 %108
%110 = getelementptr inbounds [3 x double], [3 x double]* %109, i64 0, i64 0
store double %105, double* %110
%111 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 1
%112 = load double, double* %111
%113 = load [3 x double]*, [3 x double]** %4
%114 = load i32, i32* %7
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds [3 x double], [3 x double]* %113, i64 %115
%117 = getelementptr inbounds [3 x double], [3 x double]* %116, i64 0, i64 1
store double %112, double* %117
%118 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 2
%119 = load double, double* %118
%120 = load [3 x double]*, [3 x double]** %4
%121 = load i32, i32* %7
%122 = sext i32 %121 to i64
%123 = getelementptr inbounds [3 x double], [3 x double]* %120, i64 %122
%124 = getelementptr inbounds [3 x double], [3 x double]* %123, i64 0, i64 2
store double %119, double* %124
%125 = load i32, i32* %7
%126 = add nsw i32 %125, 1
store i32 %126, i32* %7
%127 = load i32, i32* %7
%128 = icmp sge i32 %127, 3000
br i1 %128, label %129, label %130
129: ; preds = %83
br label %132
130: ; preds = %83
br label %131
131: ; preds = %130, %24
br label %18
132: ; preds = %129, %23
%133 = load i32*, i32** %6
%134 = call i32 @fclose(i32* %133)
%135 = load i32, i32* %7
store i32 %135, i32* %3
br label %136
136: ; preds = %132, %16
%137 = load i32, i32* %3
ret i32 %137
}

LLVM IR (-O2):
@.str = [3 x i8] c"rt\00"
@.str.1 = [2 x i8] c",\00"
@.str.2 = [4 x i8] c"GGA\00"
define i32 @readNmeaGGA([3 x double]* nocapture writeonly %0, i8* nocapture %1) {
%3 = alloca [100 x i8]
%4 = alloca [3 x double]
%5 = alloca [3 x double]
%6 = alloca [8 x i8]
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%8 = bitcast [3 x double]* %4 to i8*
%9 = bitcast [3 x double]* %5 to i8*
%10 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 0
%11 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %87, label %13
13: ; preds = %2
%14 = call i32* @fgets(i8* %7, i32 100, i32* %11)
%15 = icmp eq i32* %14, null
br i1 %15, label %84, label %16
16: ; preds = %13
%17 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 2
%18 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
%19 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 3
%20 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 1
%21 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 2
%22 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%23 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 2
%24 = bitcast [3 x double]* %5 to <2 x double>*
br label %25
25: ; preds = %16, %80
%26 = phi i32 [ 0, %16 ], [ %81, %80 ]
%27 = call i8* @strtok(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%28 = getelementptr inbounds i8, i8* %27, i64 3
%29 = call i64 @strncmp(i8* %28, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %80
31: ; preds = %25
%32 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%33 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%34 = call i32 @strncpy(i8* %10, i8* %33, i32 2)
store i8 0, i8* %17
%35 = call double @atof(i8* %10)
%36 = getelementptr inbounds i8, i8* %33, i64 2
%37 = call double @atof(i8* %36)
%38 = fdiv double %37, 6.000000e+01
%39 = fadd double %35, %38
store double %39, double* %18
%40 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%41 = load i8, i8* %40
%42 = icmp eq i8 %41, 83
%43 = load double, double* %18
%44 = fneg double %43
%45 = select i1 %42, double %44, double %43
%46 = fdiv double %45, 0x404CA5DC1A63CBB0
store double %46, double* %18
%47 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%48 = call i32 @strncpy(i8* %10, i8* %47, i32 3)
store i8 0, i8* %19
%49 = call double @atof(i8* %10)
%50 = getelementptr inbounds i8, i8* %47, i64 3
%51 = call double @atof(i8* %50)
%52 = fdiv double %51, 6.000000e+01
%53 = fadd double %49, %52
store double %53, double* %20
%54 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%55 = load i8, i8* %54
%56 = icmp eq i8 %55, 87
%57 = load double, double* %20
%58 = fneg double %57
%59 = select i1 %56, double %58, double %57
%60 = fdiv double %59, 0x404CA5DC1A63CBB0
store double %60, double* %20
%61 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%62 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%63 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%64 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%65 = call double @atof(i8* %64)
store double %65, double* %21
%66 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%67 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%68 = call double @atof(i8* %67)
%69 = load double, double* %21
%70 = fadd double %68, %69
store double %70, double* %21
%71 = call i32 @llh2xyz(double* %18, double* %22)
%72 = sext i32 %26 to i64
%73 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 %72, i64 0
%74 = load <2 x double>, <2 x double>* %24
%75 = bitcast double* %73 to <2 x double>*
store <2 x double> %74, <2 x double>* %75
%76 = load double, double* %23
%77 = getelementptr inbounds [3 x double], [3 x double]* %0, i64 %72, i64 2
store double %76, double* %77
%78 = add nsw i32 %26, 1
%79 = icmp sgt i32 %26, 2998
br i1 %79, label %84, label %80
80: ; preds = %31, %25
%81 = phi i32 [ %78, %31 ], [ %26, %25 ]
%82 = call i32* @fgets(i8* %7, i32 100, i32* %11)
%83 = icmp eq i32* %82, null
br i1 %83, label %84, label %25
84: ; preds = %80, %31, %13
%85 = phi i32 [ 0, %13 ], [ %78, %31 ], [ %81, %80 ]
%86 = call i32 @fclose(i32* %11)
br label %87
87: ; preds = %2, %84
%88 = phi i32 [ %85, %84 ], [ -1, %2 ]
ret i32 %88
}