#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, double, double, double,
                           double);
int /*<<< orphan*/ llh2xyz(double *, double *);
int /*<<< orphan*/ printf(char *);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
char *strtok(char *, char *);
int main(int argc, char *argv[]) {
  FILE *inp, *outp;
  char str[256];
  char *token;
  double llh[3], xyz[3], t = 0.0;
  char tmp[8];
  if (argc != 3) {
    printf("Usage: nmea2um <nmea_gga> <user_motion>\n");
    exit(1);
  }
  if ((inp = fopen(argv[1], "rt")) == NULL) {
    printf("Failed to open NMEA file.\n");
    exit(1);
  }
  if ((outp = fopen(argv[2], "wt")) == NULL) {
    printf("Failed to open user motion file.\n");
    exit(1);
  }
  while (1) {
    if (fgets(str, 256, inp) == 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, xyz);
      fprintf(outp, "%5.1f,%12.3f,%12.3f,%12.3f\n", t, xyz[0], xyz[1], xyz[2]);
      t += 0.1;
    }
  }
  fclose(inp);
  fclose(outp);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x180,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x168(%rbp)
ff
cmpl   $0x3,-0x8(%rbp)
je     11f4 <main+0x44>
lea    0xe3b(%rip),%rdi
call   1080 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe46(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    122c <main+0x7c>
lea    0xe2f(%rip),%rdi
call   1080 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe2c(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1264 <main+0xb4>
lea    0xe15(%rip),%rdi
call   1080 <printf@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>
jmp    1269 <main+0xb9>
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x100,%esi
call   1090 <fgets@plt>
cmp    $0x0,%rax
jne    128d <main+0xdd>
jmp    15b4 <main+0x404>
lea    -0x120(%rbp),%rdi
lea    0xdf1(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x128(%rbp)
mov    -0x128(%rbp),%rdi
add    $0x3,%rdi
lea    0xdd5(%rip),%rsi
mov    $0x3,%edx
call   1040 <strncmp@plt>
cmp    $0x0,%rax
jne    15af <main+0x3ff>
xor    %eax,%eax
mov    %eax,%edi
lea    0xdb4(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x128(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xd9d(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x128(%rbp)
lea    -0x170(%rbp),%rdi
mov    -0x128(%rbp),%rsi
mov    $0x2,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x16e(%rbp)
lea    -0x170(%rbp),%rdi
call   1060 <atof@plt>
movsd  %xmm0,-0x178(%rbp)
ff
mov    -0x128(%rbp),%rdi
add    $0x2,%rdi
call   1060 <atof@plt>
movaps %xmm0,%xmm1
movsd  -0x178(%rbp),%xmm0
ff
movsd  0xcaf(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x140(%rbp)
ff
xor    %eax,%eax
mov    %eax,%edi
lea    0xd20(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x128(%rbp)
mov    -0x128(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x53,%eax
jne    13a3 <main+0x1f3>
movsd  0xc75(%rip),%xmm0
mulsd  -0x140(%rbp),%xmm0
ff
movsd  %xmm0,-0x140(%rbp)
ff
movsd  -0x140(%rbp),%xmm0
ff
movsd  0xc5d(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x140(%rbp)
ff
xor    %eax,%eax
mov    %eax,%edi
lea    0xcc2(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x128(%rbp)
lea    -0x170(%rbp),%rdi
mov    -0x128(%rbp),%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
movb   $0x0,-0x16d(%rbp)
lea    -0x170(%rbp),%rdi
call   1060 <atof@plt>
movsd  %xmm0,-0x180(%rbp)
ff
mov    -0x128(%rbp),%rdi
add    $0x3,%rdi
call   1060 <atof@plt>
movaps %xmm0,%xmm1
movsd  -0x180(%rbp),%xmm0
ff
movsd  0xbd4(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x138(%rbp)
ff
xor    %eax,%eax
mov    %eax,%edi
lea    0xc45(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x128(%rbp)
mov    -0x128(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x57,%eax
jne    147e <main+0x2ce>
movsd  0xb9a(%rip),%xmm0
mulsd  -0x138(%rbp),%xmm0
ff
movsd  %xmm0,-0x138(%rbp)
ff
movsd  -0x138(%rbp),%xmm0
ff
movsd  0xb82(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x138(%rbp)
ff
xor    %eax,%eax
mov    %eax,%edi
lea    0xbe7(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x128(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xbd0(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x128(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xbb9(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x128(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xba2(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x128(%rbp)
mov    -0x128(%rbp),%rdi
call   1060 <atof@plt>
movsd  %xmm0,-0x130(%rbp)
ff
xor    %eax,%eax
mov    %eax,%edi
lea    0xb77(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x128(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xb60(%rip),%rsi
call   10c0 <strtok@plt>
mov    %rax,-0x128(%rbp)
mov    -0x128(%rbp),%rdi
call   1060 <atof@plt>
addsd  -0x130(%rbp),%xmm0
ff
movsd  %xmm0,-0x130(%rbp)
ff
lea    -0x140(%rbp),%rdi
lea    -0x160(%rbp),%rsi
call   1050 <llh2xyz@plt>
mov    -0x20(%rbp),%rdi
movsd  -0x168(%rbp),%xmm0
ff
movsd  -0x160(%rbp),%xmm1
ff
movsd  -0x158(%rbp),%xmm2
ff
movsd  -0x150(%rbp),%xmm3
ff
lea    0xb00(%rip),%rsi
call   10a0 <fprintf@plt>
movsd  0xa79(%rip),%xmm0
addsd  -0x168(%rbp),%xmm0
ff
movsd  %xmm0,-0x168(%rbp)
ff
jmp    1269 <main+0xb9>
mov    -0x18(%rbp),%rdi
call   1070 <fclose@plt>
mov    -0x20(%rbp),%rdi
call   1070 <fclose@plt>
xor    %eax,%eax
add    $0x180,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x168,%rsp
cmp    $0x3,%edi
jne    1466 <main+0x2b6>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe58(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     146f <main+0x2bf>
mov    %rax,%r15
mov    0x10(%rbx),%rdi
lea    0xe3f(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,0x30(%rsp)
test   %rax,%rax
je     1478 <main+0x2c8>
lea    0x60(%rsp),%rdi
mov    $0x100,%esi
mov    %r15,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     1440 <main+0x290>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
lea    0xe03(%rip),%rbx
lea    0x60(%rsp),%r12
lea    0xdf9(%rip),%rbp
lea    0x38(%rsp),%r13
jmp    1328 <main+0x178>
nopl   0x0(%rax)
lea    0xde1(%rip),%rbp
divsd  0xda9(%rip),%xmm0
movsd  %xmm0,0x18(%rsp)
xor    %edi,%edi
mov    %rbx,%rsi
call   10c0 <strtok@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   10c0 <strtok@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   10c0 <strtok@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   10c0 <strtok@plt>
mov    %rax,%rdi
call   1070 <atof@plt>
movsd  %xmm0,0x20(%rsp)
xor    %edi,%edi
mov    %rbx,%rsi
call   10c0 <strtok@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   10c0 <strtok@plt>
mov    %rax,%rdi
call   1070 <atof@plt>
addsd  0x20(%rsp),%xmm0
movsd  %xmm0,0x20(%rsp)
lea    0x10(%rsp),%rdi
lea    0x40(%rsp),%rsi
call   1050 <llh2xyz@plt>
movsd  0x40(%rsp),%xmm1
movsd  0x48(%rsp),%xmm2
movsd  0x50(%rsp),%xmm3
mov    0x30(%rsp),%rdi
lea    0xd4c(%rip),%rsi
movsd  0x8(%rsp),%xmm0
call   10a0 <fprintf@plt>
movsd  0x8(%rsp),%xmm0
addsd  0xd07(%rip),%xmm0
movsd  %xmm0,0x8(%rsp)
mov    %r12,%rdi
mov    $0x100,%esi
mov    %r15,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     1440 <main+0x290>
mov    %r12,%rdi
mov    %rbx,%rsi
call   10c0 <strtok@plt>
lea    0x3(%rax),%rdi
mov    %rbp,%rsi
mov    $0x3,%edx
call   1040 <strncmp@plt>
test   %rax,%rax
jne    130f <main+0x15f>
xor    %edi,%edi
mov    %rbx,%rsi
call   10c0 <strtok@plt>
xor    %edi,%edi
mov    %rbx,%rsi
call   10c0 <strtok@plt>
mov    %rax,%r14
mov    %r13,%rdi
mov    %rax,%rsi
mov    $0x2,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x3a(%rsp)
mov    %r13,%rdi
call   1070 <atof@plt>
movsd  %xmm0,(%rsp)
add    $0x2,%r14
mov    %r14,%rdi
call   1070 <atof@plt>
divsd  0xc6a(%rip),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,0x10(%rsp)
xor    %edi,%edi
mov    %rbx,%rsi
call   10c0 <strtok@plt>
cmpb   $0x53,(%rax)
movsd  0x10(%rsp),%xmm0
jne    13be <main+0x20e>
xorpd  0xc62(%rip),%xmm0
divsd  0xc42(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
xor    %edi,%edi
mov    %rbx,%rsi
call   10c0 <strtok@plt>
mov    %rax,%rbp
mov    %r13,%rdi
mov    %rax,%rsi
mov    $0x3,%edx
call   1030 <strncpy@plt>
movb   $0x0,0x3b(%rsp)
mov    %r13,%rdi
call   1070 <atof@plt>
movsd  %xmm0,(%rsp)
add    $0x3,%rbp
mov    %rbp,%rdi
call   1070 <atof@plt>
divsd  0xbf1(%rip),%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,0x18(%rsp)
xor    %edi,%edi
mov    %rbx,%rsi
call   10c0 <strtok@plt>
cmpb   $0x57,(%rax)
movsd  0x18(%rsp),%xmm0
jne    1250 <main+0xa0>
xorpd  0xbe5(%rip),%xmm0
jmp    1250 <main+0xa0>
mov    %r15,%rdi
call   1080 <fclose@plt>
mov    0x30(%rsp),%rdi
call   1080 <fclose@plt>
xor    %eax,%eax
add    $0x168,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xc26(%rip),%rdi
jmp    147f <main+0x2cf>
lea    0xc03(%rip),%rdi
jmp    147f <main+0x2cf>
lea    0xbd9(%rip),%rdi
call   1060 <puts@plt>
mov    $0x1,%edi
call   10d0 <exit@plt>

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

LLVM IR (-O2):
@.str.1 = [3 x i8] c"rt\00"
@.str.3 = [3 x i8] c"wt\00"
@.str.5 = [2 x i8] c",\00"
@.str.6 = [4 x i8] c"GGA\00"
@.str.7 = [28 x i8] c"%5.1f,%12.3f,%12.3f,%12.3f\0A\00"
@str = [33 x i8] c"Failed to open user motion file.\00"
@str.8 = [26 x i8] c"Failed to open NMEA file.\00"
@str.9 = [40 x i8] c"Usage: nmea2um <nmea_gga> <user_motion>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = alloca [3 x double]
%5 = alloca [3 x double]
%6 = alloca [8 x i8]
%7 = getelementptr inbounds [256 x i8], [256 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 = icmp eq i32 %0, 3
br i1 %11, label %15, label %12
12: ; preds = %2
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.9, i64 0, i64 0))
%14 = tail call i32 @exit(i32 1)
unreachable
15: ; preds = %2
%16 = getelementptr inbounds i8*, i8** %1, i64 1
%17 = load i8*, i8** %16
%18 = tail call i32* @fopen(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%19 = icmp eq i32* %18, null
br i1 %19, label %20, label %23
20: ; preds = %15
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.8, i64 0, i64 0))
%22 = tail call i32 @exit(i32 1)
unreachable
23: ; preds = %15
%24 = getelementptr inbounds i8*, i8** %1, i64 2
%25 = load i8*, i8** %24
%26 = tail call i32* @fopen(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%27 = icmp eq i32* %26, null
br i1 %27, label %40, label %28
28: ; preds = %23
%29 = call i32* @fgets(i8* %7, i32 256, i32* %18)
%30 = icmp eq i32* %29, null
br i1 %30, label %99, label %31
31: ; preds = %28
%32 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 2
%33 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
%34 = getelementptr inbounds [8 x i8], [8 x i8]* %6, i64 0, i64 3
%35 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 1
%36 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 2
%37 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
%38 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 1
%39 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 2
br label %43
40: ; preds = %23
%41 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @str, i64 0, i64 0))
%42 = tail call i32 @exit(i32 1)
unreachable
43: ; preds = %31, %95
%44 = phi double [ 0.000000e+00, %31 ], [ %96, %95 ]
%45 = call i8* @strtok(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%46 = getelementptr inbounds i8, i8* %45, i64 3
%47 = call i64 @strncmp(i8* %46, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 3)
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %95
49: ; preds = %43
%50 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%51 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%52 = call i32 @strncpy(i8* %10, i8* %51, i32 2)
store i8 0, i8* %32
%53 = call double @atof(i8* %10)
%54 = getelementptr inbounds i8, i8* %51, i64 2
%55 = call double @atof(i8* %54)
%56 = fdiv double %55, 6.000000e+01
%57 = fadd double %53, %56
store double %57, double* %33
%58 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%59 = load i8, i8* %58
%60 = icmp eq i8 %59, 83
%61 = load double, double* %33
%62 = fneg double %61
%63 = select i1 %60, double %62, double %61
%64 = fdiv double %63, 0x404CA5DC1A63CBB0
store double %64, double* %33
%65 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%66 = call i32 @strncpy(i8* %10, i8* %65, i32 3)
store i8 0, i8* %34
%67 = call double @atof(i8* %10)
%68 = getelementptr inbounds i8, i8* %65, i64 3
%69 = call double @atof(i8* %68)
%70 = fdiv double %69, 6.000000e+01
%71 = fadd double %67, %70
store double %71, double* %35
%72 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%73 = load i8, i8* %72
%74 = icmp eq i8 %73, 87
%75 = load double, double* %35
%76 = fneg double %75
%77 = select i1 %74, double %76, double %75
%78 = fdiv double %77, 0x404CA5DC1A63CBB0
store double %78, double* %35
%79 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%80 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%81 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%82 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%83 = call double @atof(i8* %82)
store double %83, double* %36
%84 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%85 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%86 = call double @atof(i8* %85)
%87 = load double, double* %36
%88 = fadd double %86, %87
store double %88, double* %36
%89 = call i32 @llh2xyz(double* %33, double* %37)
%90 = load double, double* %37
%91 = load double, double* %38
%92 = load double, double* %39
%93 = call i32 @fprintf(i32* %26, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), double %44, double %90, double %91, double %92)
%94 = fadd double %44, 1.000000e-01
br label %95
95: ; preds = %49, %43
%96 = phi double [ %94, %49 ], [ %44, %43 ]
%97 = call i32* @fgets(i8* %7, i32 256, i32* %18)
%98 = icmp eq i32* %97, null
br i1 %98, label %99, label %43
99: ; preds = %95, %28
%100 = call i32 @fclose(i32* %18)
%101 = call i32 @fclose(i32* %26)
ret i32 0
}