#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 EOF;
int EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ SEEK_CUR;
int /*<<< orphan*/ SEEK_END;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, long, int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
int main(int argc, char *argv[]) {
  FILE *in, *out;
  int current_timestamp = 0;
  int timestamp_bytes[4] = {0, 0, 0, 0};
  int temp = 0;
  int read = 0;
  int length = 0;
  int nbmsg = 0;
  int nberr = 0;
  char err = 0;
  char nomsg = 0;
  if (argc != 3) {
    puts("wrong number of parameters!\n"
         "usage is openlog2tlm <inuptfile> <outputfile>");
    return EXIT_FAILURE;
  }
  if ((in = fopen(argv[1], "rb")) == NULL) {
    puts("openlog2tlm wasn't able to open the inputfile\n");
    return EXIT_FAILURE;
  }
  fseek(in, 0L, SEEK_END);
  int inlength = ftell(in);
  fseek(in, 0L, SEEK_SET);
  if ((out = fopen(argv[2], "w+")) == NULL) {
    puts("openlog2tlm wasn't able to open the outputfile\n");
    return EXIT_FAILURE;
  }
  printf("now converting %s to %s\n", argv[1], argv[2]);
  temp = fgetc(in);
  if (temp != 0x99) {
    while (temp != 0x99) {
      temp = fgetc(in);
      if (temp == EOF) {
        nomsg = 1;
        break;
      }
    }
  }
  fseek(in, -1L, SEEK_CUR);
  while (!feof(in)) {
    if (temp == 0x99) {
      nbmsg++;
      length = fgetc(in);
      int message[length - 2];
      int i;
      for (i = 0; i < (length - 2); i++) {
        message[i] = fgetc(in);
      }
      read = fgetc(in);
      if (read != 0x99) {
        nberr++;
        while (fgetc(in) != 0x99) {
          if (inlength <= ftell(in))
            break;
        }
        err = 1;
        if (inlength <= ftell(in))
          break;
      }
      fseek(in, -1L, SEEK_CUR);
      temp = fgetc(in);
      if (err != 1) {
        if (message[1] == 129) {
          current_timestamp = message[2] + (message[3] << 8) +
                              (message[4] << 16) + (message[5] << 24);
          current_timestamp = current_timestamp * 10;
          timestamp_bytes[0] = current_timestamp & 0xff;
          timestamp_bytes[1] = (current_timestamp >> 8) & 0xff;
          timestamp_bytes[2] = (current_timestamp >> 16) & 0xff;
          timestamp_bytes[3] = (current_timestamp >> 24) & 0xff;
        }
        fputc(0x99, out);
        fputc(length - 4, out);
        fputc(0, out);
        fputc(timestamp_bytes[0], out);
        fputc(timestamp_bytes[1], out);
        fputc(timestamp_bytes[2], out);
        fputc(timestamp_bytes[3], out);
        int checksum = length - 4 + timestamp_bytes[0] + timestamp_bytes[1] +
                       timestamp_bytes[2] + timestamp_bytes[3];
        for (i = 0; i < (length - 4); i++) {
          fputc(message[i], out);
          checksum += message[i];
        }
        fputc(checksum, out);
      } else {
        err = 0;
      }
    }
    if (inlength < ftell(in) + 2)
      break;
  }
  fseek(out, 0L, SEEK_END);
  int end = ftell(out);
  int temp2 = fgetc(out);
  while (temp2 != 0x99 && nomsg == 0) {
    fseek(out, -2L, SEEK_CUR);
    temp2 = fgetc(out);
  }
  fseek(out, -1L, SEEK_CUR);
  while (ftell(out) != end) {
    fputc(0x0, out);
  }
  if (length == 0) {
    printf("\nThere have been no messages at all. Perhaps you misconfigured "
           "your Openlog, so it uses the wrong baudrate, or you aren't using "
           "the transparent telemetry, or this even wasn't a Paparazzi-log. "
           "For debugging you can open the logfile using a hexeditor and check "
           "there is a more or less periodic occurance of the Paparazzi STX "
           "(0x99)\n Also check your wiring and the configfile of the openlog. "
           "It should be named CONFIG.TXT and contain 57600,26,3,0 if your "
           "baudrate is 57600.\n\n ");
    return EXIT_FAILURE;
  } else if (current_timestamp == 0) {
    printf("There have been messages but openlog2tlm didn't find the "
           "TIMESTAMP-Message. Check the messages-tool if there is a message "
           "called \"TIMESTAMP\". Make sure the Openlog-Module was loaded and "
           "check the messages.xml, the Timestamp was really %i\n",
           129);
    return EXIT_FAILURE;
  } else {
    printf("The conversion from the logfile from the SD to TLM seems to be "
           "successful, %i have been converted, %i packages have been broken\n",
           nbmsg, nberr);
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1050 <memset@plt>
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
movb   $0x0,-0x55(%rbp)
movb   $0x0,-0x56(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     1212 <main+0x82>
lea    0xe04(%rip),%rdi
call   1030 <puts@plt>
mov    0x2db8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    17c1 <main+0x631>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe29(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1251 <main+0xc1>
lea    0xe12(%rip),%rdi
call   1030 <puts@plt>
mov    0x2d79(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    17c1 <main+0x631>
mov    -0x18(%rbp),%rdi
mov    0x2d8c(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   10a0 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   1080 <ftell@plt>
mov    %eax,-0x5c(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2d4a(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   10a0 <fseek@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xde4(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    12c8 <main+0x138>
lea    0xdcd(%rip),%rdi
call   1030 <puts@plt>
mov    0x2d02(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    17c1 <main+0x631>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xdd0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x99,-0x44(%rbp)
je     1342 <main+0x1b2>
jmp    1304 <main+0x174>
cmpl   $0x99,-0x44(%rbp)
je     133d <main+0x1ad>
mov    -0x18(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    0x2cb1(%rip),%rcx
cmp    (%rcx),%eax
jne    1338 <main+0x1a8>
movb   $0x1,-0x56(%rbp)
jmp    133d <main+0x1ad>
jmp    1304 <main+0x174>
jmp    1342 <main+0x1b2>
mov    -0x18(%rbp),%rdi
mov    0x2c93(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffffffffffff,%rsi
call   10a0 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1379 <main+0x1e9>
jmp    1671 <main+0x4e1>
cmpl   $0x99,-0x44(%rbp)
jne    1642 <main+0x4b2>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
add    $0xfffffffe,%eax
mov    %rsp,%rcx
mov    %rcx,-0x68(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x90(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x70(%rbp)
movl   $0x0,-0x74(%rbp)
mov    -0x74(%rbp),%eax
mov    -0x4c(%rbp),%ecx
sub    $0x2,%ecx
cmp    %ecx,%eax
jge    1407 <main+0x277>
mov    -0x18(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %eax,%edx
mov    -0x90(%rbp),%rax
movslq -0x74(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    13cf <main+0x23f>
mov    -0x18(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %eax,-0x48(%rbp)
cmpl   $0x99,-0x48(%rbp)
je     14a0 <main+0x310>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <fgetc@plt>
cmp    $0x99,%eax
je     1469 <main+0x2d9>
mov    -0x5c(%rbp),%eax
mov    %eax,-0x94(%rbp)
mov    -0x18(%rbp),%rdi
call   1080 <ftell@plt>
mov    %eax,%ecx
mov    -0x94(%rbp),%eax
cmp    %ecx,%eax
jg     1464 <main+0x2d4>
jmp    1469 <main+0x2d9>
jmp    1429 <main+0x299>
movb   $0x1,-0x55(%rbp)
mov    -0x5c(%rbp),%eax
mov    %eax,-0x98(%rbp)
mov    -0x18(%rbp),%rdi
call   1080 <ftell@plt>
mov    %eax,%ecx
mov    -0x98(%rbp),%eax
cmp    %ecx,%eax
jg     149b <main+0x30b>
movl   $0x5,-0x78(%rbp)
jmp    1621 <main+0x491>
jmp    14a0 <main+0x310>
mov    -0x18(%rbp),%rdi
mov    0x2b35(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffffffffffff,%rsi
call   10a0 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %eax,-0x44(%rbp)
movsbl -0x55(%rbp),%eax
cmp    $0x1,%eax
je     1616 <main+0x486>
mov    -0x90(%rbp),%rax
cmpl   $0x81,0x4(%rax)
jne    1547 <main+0x3b7>
mov    -0x90(%rbp),%rcx
mov    0x8(%rcx),%eax
mov    0xc(%rcx),%edx
shl    $0x8,%edx
add    %edx,%eax
mov    0x10(%rcx),%edx
shl    $0x10,%edx
add    %edx,%eax
mov    0x14(%rcx),%ecx
shl    $0x18,%ecx
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
imul   $0xa,-0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x40(%rbp)
mov    -0x24(%rbp),%eax
sar    $0x8,%eax
and    $0xff,%eax
mov    %eax,-0x3c(%rbp)
mov    -0x24(%rbp),%eax
sar    $0x10,%eax
and    $0xff,%eax
mov    %eax,-0x38(%rbp)
mov    -0x24(%rbp),%eax
sar    $0x18,%eax
and    $0xff,%eax
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%rsi
mov    $0x99,%edi
call   1070 <fputc@plt>
mov    -0x4c(%rbp),%edi
sub    $0x4,%edi
mov    -0x20(%rbp),%rsi
call   1070 <fputc@plt>
mov    -0x20(%rbp),%rsi
xor    %edi,%edi
call   1070 <fputc@plt>
mov    -0x40(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1070 <fputc@plt>
mov    -0x3c(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1070 <fputc@plt>
mov    -0x38(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1070 <fputc@plt>
mov    -0x34(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1070 <fputc@plt>
mov    -0x4c(%rbp),%eax
sub    $0x4,%eax
add    -0x40(%rbp),%eax
add    -0x3c(%rbp),%eax
add    -0x38(%rbp),%eax
add    -0x34(%rbp),%eax
mov    %eax,-0x7c(%rbp)
movl   $0x0,-0x74(%rbp)
mov    -0x74(%rbp),%eax
mov    -0x4c(%rbp),%ecx
sub    $0x4,%ecx
cmp    %ecx,%eax
jge    1605 <main+0x475>
mov    -0x90(%rbp),%rax
movslq -0x74(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x20(%rbp),%rsi
call   1070 <fputc@plt>
mov    -0x90(%rbp),%rax
movslq -0x74(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
add    -0x7c(%rbp),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x74(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x74(%rbp)
jmp    15bb <main+0x42b>
mov    -0x7c(%rbp),%edi
mov    -0x20(%rbp),%rsi
call   1070 <fputc@plt>
jmp    161a <main+0x48a>
movb   $0x0,-0x55(%rbp)
movl   $0x0,-0x78(%rbp)
mov    -0x68(%rbp),%rax
mov    %rax,%rsp
mov    -0x78(%rbp),%eax
test   %eax,%eax
je     163d <main+0x4ad>
jmp    1638 <main+0x4a8>
jmp    1671 <main+0x4e1>
jmp    1642 <main+0x4b2>
mov    -0x5c(%rbp),%eax
mov    %eax,-0x9c(%rbp)
mov    -0x18(%rbp),%rdi
call   1080 <ftell@plt>
mov    %eax,%ecx
mov    -0x9c(%rbp),%eax
add    $0x2,%ecx
cmp    %ecx,%eax
jge    166c <main+0x4dc>
jmp    1671 <main+0x4e1>
jmp    135b <main+0x1cb>
mov    -0x20(%rbp),%rdi
mov    0x296c(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%esi
call   10a0 <fseek@plt>
mov    -0x20(%rbp),%rdi
call   1080 <ftell@plt>
mov    %eax,-0x80(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %eax,-0x84(%rbp)
xor    %eax,%eax
cmpl   $0x99,-0x84(%rbp)
mov    %al,-0x9d(%rbp)
je     16ca <main+0x53a>
movsbl -0x56(%rbp),%eax
cmp    $0x0,%eax
sete   %al
mov    %al,-0x9d(%rbp)
mov    -0x9d(%rbp),%al
test   $0x1,%al
jne    16dd <main+0x54d>
jmp    170a <main+0x57a>
mov    -0x20(%rbp),%rdi
mov    0x28f8(%rip),%rax
mov    (%rax),%edx
mov    $0xfffffffffffffffe,%rsi
call   10a0 <fseek@plt>
mov    -0x20(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %eax,-0x84(%rbp)
jmp    16a2 <main+0x512>
mov    -0x20(%rbp),%rdi
mov    0x28cb(%rip),%rax
mov    (%rax),%edx
mov    $0xffffffffffffffff,%rsi
call   10a0 <fseek@plt>
mov    -0x20(%rbp),%rdi
call   1080 <ftell@plt>
cmp    -0x80(%rbp),%eax
je     1745 <main+0x5b5>
mov    -0x20(%rbp),%rsi
xor    %edi,%edi
call   1070 <fputc@plt>
jmp    1723 <main+0x593>
cmpl   $0x0,-0x4c(%rbp)
jne    176e <main+0x5de>
lea    0x972(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x285c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    17c1 <main+0x631>
cmpl   $0x0,-0x24(%rbp)
jne    179c <main+0x60c>
lea    0xb23(%rip),%rdi
mov    $0x81,%esi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x282e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    17c1 <main+0x631>
mov    -0x50(%rbp),%esi
mov    -0x54(%rbp),%edx
lea    0xbe8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    17b5 <main+0x625>
mov    0x27fc(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
cmp    $0x3,%edi
jne    1239 <main+0xb9>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
lea    0xea2(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     1242 <main+0xc2>
mov    %rax,%rbx
mov    0x2e28(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %rbx,%rdi
call   1070 <ftell@plt>
mov    %eax,%r13d
mov    0x2dea(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    0x10(%r14),%rdi
lea    0xe87(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     124b <main+0xcb>
mov    %rax,%r15
mov    0x8(%r14),%rsi
mov    0x10(%r14),%rdx
lea    0xe9e(%rip),%rdi
xor    %eax,%eax
mov    %rax,-0x70(%rbp)
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1050 <fgetc@plt>
cmp    $0x99,%eax
jne    126f <main+0xef>
movb   $0x1,-0x29(%rbp)
mov    $0x99,%r12d
jmp    12a3 <main+0x123>
lea    0xdc0(%rip),%rdi
jmp    1252 <main+0xd2>
lea    0xe04(%rip),%rdi
jmp    1252 <main+0xd2>
lea    0xe2d(%rip),%rdi
call   1030 <puts@plt>
mov    0x2d62(%rip),%rax
mov    (%rax),%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d62(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1050 <fgetc@plt>
mov    %eax,%r12d
mov    (%r14),%eax
cmp    %eax,%r12d
je     129c <main+0x11c>
cmp    $0x99,%r12d
jne    1280 <main+0x100>
cmp    %eax,%r12d
setne  -0x29(%rbp)
mov    0x2d36(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0xffffffffffffffff,%rsi
call   1090 <fseek@plt>
movl   $0x0,-0x4c(%rbp)
xor    %eax,%eax
mov    %rax,-0x58(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x44(%rbp)
xor    %r14d,%r14d
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x40(%rbp)
mov    %rbx,-0x80(%rbp)
mov    %r13d,-0x34(%rbp)
jmp    1322 <main+0x1a2>
nopl   0x0(%rax,%rax,1)
xor    %r14d,%r14d
mov    -0x50(%rbp),%r12d
mov    -0x60(%rbp),%rax
mov    %rax,%rsp
mov    %rbx,%rdi
call   1070 <ftell@plt>
add    $0x2,%eax
cmp    %eax,%r13d
jl     1564 <main+0x3e4>
mov    %rbx,%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    1564 <main+0x3e4>
cmp    $0x99,%r12d
jne    130e <main+0x18e>
mov    %r14d,-0x3c(%rbp)
mov    %rbx,%rdi
call   1050 <fgetc@plt>
mov    %rsp,-0x60(%rbp)
mov    %rbx,%r13
lea    -0x2(%rax),%r14d
mov    %rsp,%r12
lea    0xf(,%r14,4),%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%r12
mov    %r12,%rsp
mov    %rax,-0x58(%rbp)
cmp    $0x3,%eax
jl     1395 <main+0x215>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r13,%rdi
call   1050 <fgetc@plt>
mov    %eax,(%r12,%rbx,4)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    1380 <main+0x200>
mov    %r12,-0x78(%rbp)
mov    -0x38(%rbp),%r14d
add    $0x1,%r14d
mov    %r13,%rdi
call   1050 <fgetc@plt>
cmp    $0x99,%eax
mov    %r13,%rbx
mov    %r14d,-0x38(%rbp)
jne    13d0 <main+0x250>
mov    -0x34(%rbp),%r13d
mov    -0x3c(%rbp),%r12d
jmp    1410 <main+0x290>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
addl   $0x1,-0x44(%rbp)
mov    -0x34(%rbp),%r13d
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1050 <fgetc@plt>
cmp    $0x99,%eax
je     13fc <main+0x27c>
mov    %rbx,%rdi
call   1070 <ftell@plt>
cmp    %eax,%r13d
jg     13e0 <main+0x260>
mov    %rbx,%rdi
call   1070 <ftell@plt>
mov    $0x1,%r12b
cmp    %eax,%r13d
jle    1560 <main+0x3e0>
mov    0x2bc9(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0xffffffffffffffff,%rsi
call   1090 <fseek@plt>
mov    %rbx,%rdi
call   1050 <fgetc@plt>
mov    %eax,-0x50(%rbp)
cmp    $0x1,%r12b
je     1300 <main+0x180>
mov    %r12d,-0x3c(%rbp)
mov    -0x78(%rbp),%rdx
cmpl   $0x81,0x4(%rdx)
jne    148d <main+0x30d>
mov    0xc(%rdx),%eax
mov    0x10(%rdx),%ecx
shl    $0x8,%eax
add    0x8(%rdx),%eax
shl    $0x10,%ecx
add    %eax,%ecx
mov    0x14(%rdx),%eax
shl    $0x18,%eax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%ecx
movzbl %cl,%eax
mov    %eax,-0x30(%rbp)
movzbl %ch,%eax
mov    %eax,-0x48(%rbp)
mov    %ecx,%eax
shr    $0x10,%eax
movzbl %al,%eax
mov    %rax,-0x70(%rbp)
mov    %ecx,-0x40(%rbp)
shr    $0x18,%ecx
mov    %ecx,-0x4c(%rbp)
mov    $0x99,%edi
mov    %r15,%rsi
call   1060 <fputc@plt>
mov    -0x58(%rbp),%rax
lea    -0x4(%rax),%edi
mov    %rax,%r13
mov    %edi,-0x68(%rbp)
mov    %r15,%rsi
call   1060 <fputc@plt>
xor    %edi,%edi
mov    %r15,%rsi
call   1060 <fputc@plt>
mov    -0x30(%rbp),%edi
mov    %r15,%rsi
call   1060 <fputc@plt>
mov    -0x48(%rbp),%r14d
mov    %r14d,%edi
mov    %r15,%rsi
call   1060 <fputc@plt>
mov    -0x70(%rbp),%rbx
mov    %ebx,%edi
mov    %r15,%rsi
call   1060 <fputc@plt>
mov    -0x4c(%rbp),%r12d
mov    %r12d,%edi
mov    %r15,%rsi
call   1060 <fputc@plt>
mov    %r13,%rax
add    %ebx,%r13d
add    $0xfffffffc,%r13d
add    %r12d,%r13d
add    %r14d,%r13d
add    -0x30(%rbp),%r13d
cmp    $0x5,%eax
jl     153e <main+0x3be>
mov    -0x68(%rbp),%eax
mov    %rax,-0x68(%rbp)
xor    %r14d,%r14d
mov    %r15,%rbx
mov    -0x78(%rbp),%r12
nopw   0x0(%rax,%rax,1)
mov    (%r12,%r14,4),%r15d
mov    %r15d,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
add    %r15d,%r13d
add    $0x1,%r14
cmp    %r14,-0x68(%rbp)
jne    1520 <main+0x3a0>
jmp    1541 <main+0x3c1>
mov    %r15,%rbx
mov    %r13d,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
mov    %rbx,%r15
mov    -0x80(%rbp),%rbx
mov    -0x34(%rbp),%r13d
mov    -0x3c(%rbp),%r14d
jmp    1303 <main+0x183>
mov    -0x60(%rbp),%rsp
mov    0x2a7d(%rip),%rax
mov    (%rax),%edx
mov    %r15,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %r15,%rdi
call   1070 <ftell@plt>
mov    %eax,%ebx
mov    %r15,%rdi
call   1050 <fgetc@plt>
cmp    $0x99,%eax
sete   %al
mov    -0x29(%rbp),%cl
xor    $0x1,%cl
or     %al,%cl
mov    0x2a40(%rip),%r14
jne    15d1 <main+0x451>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r14),%edx
mov    %r15,%rdi
mov    $0xfffffffffffffffe,%rsi
call   1090 <fseek@plt>
mov    %r15,%rdi
call   1050 <fgetc@plt>
cmp    $0x99,%eax
jne    15b0 <main+0x430>
mov    (%r14),%edx
mov    %r15,%rdi
mov    $0xffffffffffffffff,%rsi
call   1090 <fseek@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r15,%rdi
call   1070 <ftell@plt>
cmp    %ebx,%eax
je     1608 <main+0x488>
xor    %edi,%edi
mov    %r15,%rsi
call   1060 <fputc@plt>
jmp    15f0 <main+0x470>
cmpl   $0x0,-0x58(%rbp)
mov    -0x38(%rbp),%esi
je     1634 <main+0x4b4>
cmpl   $0x0,-0x40(%rbp)
je     1647 <main+0x4c7>
lea    0xd73(%rip),%rdi
mov    -0x44(%rbp),%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2989(%rip),%rax
jmp    125e <main+0xde>
lea    0xa8d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1257 <main+0xd7>
lea    0xc54(%rip),%rdi
mov    $0x81,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1257 <main+0xd7>

LLVM IR (-O0):
@.str = [74 x i8] c"wrong number of parameters!\0Ausage is openlog2tlm <inuptfile> <outputfile>\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [47 x i8] c"openlog2tlm wasn't able to open the inputfile\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.3 = [3 x i8] c"w+\00"
@.str.4 = [48 x i8] c"openlog2tlm wasn't able to open the outputfile\0A\00"
@.str.5 = [25 x i8] c"now converting %s to %s\0A\00"
@EOF = global i32 0
@SEEK_CUR = global i32 0
@.str.6 = [474 x i8] c"\0AThere have been no messages at all. Perhaps you misconfigured your Openlog, so it uses the wrong baudrate, or you aren't using the transparent telemetry, or this even wasn't a Paparazzi-log. For debugging you can open the logfile using a hexeditor and check there is a more or less periodic occurance of the Paparazzi STX (0x99)\0A Also check your wiring and the configfile of the openlog. It should be named CONFIG.TXT and contain 57600,26,3,0 if your baudrate is 57600.\0A\0A \00"
@.str.7 = [239 x i8] c"There have been messages but openlog2tlm didn't find the TIMESTAMP-Message. Check the messages-tool if there is a message called \22TIMESTAMP\22. Make sure the Openlog-Module was loaded and check the messages.xml, the Timestamp was really %i\0A\00"
@.str.8 = [129 x i8] c"The conversion from the logfile from the SD to TLM seems to be successful, %i have been converted, %i packages have been broken\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca [4 x i32]
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8
%16 = alloca i8
%17 = alloca i32
%18 = alloca i8*
%19 = alloca i64
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
%25 = bitcast [4 x i32]* %9 to i8*
store i32 0, i32* %10
store i32 0, i32* %11
store i32 0, i32* %12
store i32 0, i32* %13
store i32 0, i32* %14
store i8 0, i8* %15
store i8 0, i8* %16
%26 = load i32, i32* %4
%27 = icmp ne i32 %26, 3
br i1 %27, label %28, label %31
28: ; preds = %2
%29 = call i32 @puts(i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str, i64 0, i64 0))
%30 = load i32, i32* @EXIT_FAILURE
store i32 %30, i32* %3
br label %321
31: ; preds = %2
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 1
%34 = load i8*, i8** %33
%35 = call i32* @fopen(i8* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %35, i32** %6
%36 = icmp eq i32* %35, null
br i1 %36, label %37, label %40
37: ; preds = %31
%38 = call i32 @puts(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
%39 = load i32, i32* @EXIT_FAILURE
store i32 %39, i32* %3
br label %321
40: ; preds = %31
%41 = load i32*, i32** %6
%42 = load i32, i32* @SEEK_END
%43 = call i32 @fseek(i32* %41, i64 0, i32 %42)
%44 = load i32*, i32** %6
%45 = call i32 @ftell(i32* %44)
store i32 %45, i32* %17
%46 = load i32*, i32** %6
%47 = load i32, i32* @SEEK_SET
%48 = call i32 @fseek(i32* %46, i64 0, i32 %47)
%49 = load i8**, i8*** %5
%50 = getelementptr inbounds i8*, i8** %49, i64 2
%51 = load i8*, i8** %50
%52 = call i32* @fopen(i8* %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %52, i32** %7
%53 = icmp eq i32* %52, null
br i1 %53, label %54, label %57
54: ; preds = %40
%55 = call i32 @puts(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0))
%56 = load i32, i32* @EXIT_FAILURE
store i32 %56, i32* %3
br label %321
57: ; preds = %40
%58 = load i8**, i8*** %5
%59 = getelementptr inbounds i8*, i8** %58, i64 1
%60 = load i8*, i8** %59
%61 = load i8**, i8*** %5
%62 = getelementptr inbounds i8*, i8** %61, i64 2
%63 = load i8*, i8** %62
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %60, i8* %63)
%65 = load i32*, i32** %6
%66 = call i32 @fgetc(i32* %65)
store i32 %66, i32* %10
%67 = load i32, i32* %10
%68 = icmp ne i32 %67, 153
br i1 %68, label %69, label %82
69: ; preds = %57
br label %70
70: ; preds = %80, %69
%71 = load i32, i32* %10
%72 = icmp ne i32 %71, 153
br i1 %72, label %73, label %81
73: ; preds = %70
%74 = load i32*, i32** %6
%75 = call i32 @fgetc(i32* %74)
store i32 %75, i32* %10
%76 = load i32, i32* %10
%77 = load i32, i32* @EOF
%78 = icmp eq i32 %76, %77
br i1 %78, label %79, label %80
79: ; preds = %73
store i8 1, i8* %16
br label %81
80: ; preds = %73
br label %70
81: ; preds = %79, %70
br label %82
82: ; preds = %81, %57
%83 = load i32*, i32** %6
%84 = load i32, i32* @SEEK_CUR
%85 = call i32 @fseek(i32* %83, i64 -1, i32 %84)
br label %86
86: ; preds = %266, %82
%87 = load i32*, i32** %6
%88 = call i32 @feof(i32* %87)
%89 = icmp ne i32 %88, 0
%90 = xor i1 %89, true
br i1 %90, label %91, label %267
91: ; preds = %86
%92 = load i32, i32* %10
%93 = icmp eq i32 %92, 153
br i1 %93, label %94, label %259
94: ; preds = %91
%95 = load i32, i32* %13
%96 = add nsw i32 %95, 1
store i32 %96, i32* %13
%97 = load i32*, i32** %6
%98 = call i32 @fgetc(i32* %97)
store i32 %98, i32* %12
%99 = load i32, i32* %12
%100 = sub nsw i32 %99, 2
%101 = zext i32 %100 to i64
%102 = call i8* @llvm.stacksave()
store i8* %102, i8** %18
%103 = alloca i32, i64 %101
store i64 %101, i64* %19
store i32 0, i32* %20
br label %104
104: ; preds = %115, %94
%105 = load i32, i32* %20
%106 = load i32, i32* %12
%107 = sub nsw i32 %106, 2
%108 = icmp slt i32 %105, %107
br i1 %108, label %109, label %118
109: ; preds = %104
%110 = load i32*, i32** %6
%111 = call i32 @fgetc(i32* %110)
%112 = load i32, i32* %20
%113 = sext i32 %112 to i64
%114 = getelementptr inbounds i32, i32* %103, i64 %113
store i32 %111, i32* %114
br label %115
115: ; preds = %109
%116 = load i32, i32* %20
%117 = add nsw i32 %116, 1
store i32 %117, i32* %20
br label %104
118: ; preds = %104
%119 = load i32*, i32** %6
%120 = call i32 @fgetc(i32* %119)
store i32 %120, i32* %11
%121 = load i32, i32* %11
%122 = icmp ne i32 %121, 153
br i1 %122, label %123, label %144
123: ; preds = %118
%124 = load i32, i32* %14
%125 = add nsw i32 %124, 1
store i32 %125, i32* %14
br label %126
126: ; preds = %136, %123
%127 = load i32*, i32** %6
%128 = call i32 @fgetc(i32* %127)
%129 = icmp ne i32 %128, 153
br i1 %129, label %130, label %137
130: ; preds = %126
%131 = load i32, i32* %17
%132 = load i32*, i32** %6
%133 = call i32 @ftell(i32* %132)
%134 = icmp sle i32 %131, %133
br i1 %134, label %135, label %136
135: ; preds = %130
br label %137
136: ; preds = %130
br label %126
137: ; preds = %135, %126
store i8 1, i8* %15
%138 = load i32, i32* %17
%139 = load i32*, i32** %6
%140 = call i32 @ftell(i32* %139)
%141 = icmp sle i32 %138, %140
br i1 %141, label %142, label %143
142: ; preds = %137
store i32 5, i32* %21
br label %255
143: ; preds = %137
br label %144
144: ; preds = %143, %118
%145 = load i32*, i32** %6
%146 = load i32, i32* @SEEK_CUR
%147 = call i32 @fseek(i32* %145, i64 -1, i32 %146)
%148 = load i32*, i32** %6
%149 = call i32 @fgetc(i32* %148)
store i32 %149, i32* %10
%150 = load i8, i8* %15
%151 = sext i8 %150 to i32
%152 = icmp ne i32 %151, 1
br i1 %152, label %153, label %253
153: ; preds = %144
%154 = getelementptr inbounds i32, i32* %103, i64 1
%155 = load i32, i32* %154
%156 = icmp eq i32 %155, 129
br i1 %156, label %157, label %189
157: ; preds = %153
%158 = getelementptr inbounds i32, i32* %103, i64 2
%159 = load i32, i32* %158
%160 = getelementptr inbounds i32, i32* %103, i64 3
%161 = load i32, i32* %160
%162 = shl i32 %161, 8
%163 = add nsw i32 %159, %162
%164 = getelementptr inbounds i32, i32* %103, i64 4
%165 = load i32, i32* %164
%166 = shl i32 %165, 16
%167 = add nsw i32 %163, %166
%168 = getelementptr inbounds i32, i32* %103, i64 5
%169 = load i32, i32* %168
%170 = shl i32 %169, 24
%171 = add nsw i32 %167, %170
store i32 %171, i32* %8
%172 = load i32, i32* %8
%173 = mul nsw i32 %172, 10
store i32 %173, i32* %8
%174 = load i32, i32* %8
%175 = and i32 %174, 255
%176 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 0
store i32 %175, i32* %176
%177 = load i32, i32* %8
%178 = ashr i32 %177, 8
%179 = and i32 %178, 255
%180 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 1
store i32 %179, i32* %180
%181 = load i32, i32* %8
%182 = ashr i32 %181, 16
%183 = and i32 %182, 255
%184 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 2
store i32 %183, i32* %184
%185 = load i32, i32* %8
%186 = ashr i32 %185, 24
%187 = and i32 %186, 255
%188 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 3
store i32 %187, i32* %188
br label %189
189: ; preds = %157, %153
%190 = load i32*, i32** %7
%191 = call i32 @fputc(i32 153, i32* %190)
%192 = load i32, i32* %12
%193 = sub nsw i32 %192, 4
%194 = load i32*, i32** %7
%195 = call i32 @fputc(i32 %193, i32* %194)
%196 = load i32*, i32** %7
%197 = call i32 @fputc(i32 0, i32* %196)
%198 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 0
%199 = load i32, i32* %198
%200 = load i32*, i32** %7
%201 = call i32 @fputc(i32 %199, i32* %200)
%202 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 1
%203 = load i32, i32* %202
%204 = load i32*, i32** %7
%205 = call i32 @fputc(i32 %203, i32* %204)
%206 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 2
%207 = load i32, i32* %206
%208 = load i32*, i32** %7
%209 = call i32 @fputc(i32 %207, i32* %208)
%210 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 3
%211 = load i32, i32* %210
%212 = load i32*, i32** %7
%213 = call i32 @fputc(i32 %211, i32* %212)
%214 = load i32, i32* %12
%215 = sub nsw i32 %214, 4
%216 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 0
%217 = load i32, i32* %216
%218 = add nsw i32 %215, %217
%219 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 1
%220 = load i32, i32* %219
%221 = add nsw i32 %218, %220
%222 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 2
%223 = load i32, i32* %222
%224 = add nsw i32 %221, %223
%225 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 3
%226 = load i32, i32* %225
%227 = add nsw i32 %224, %226
store i32 %227, i32* %22
store i32 0, i32* %20
br label %228
228: ; preds = %246, %189
%229 = load i32, i32* %20
%230 = load i32, i32* %12
%231 = sub nsw i32 %230, 4
%232 = icmp slt i32 %229, %231
br i1 %232, label %233, label %249
233: ; preds = %228
%234 = load i32, i32* %20
%235 = sext i32 %234 to i64
%236 = getelementptr inbounds i32, i32* %103, i64 %235
%237 = load i32, i32* %236
%238 = load i32*, i32** %7
%239 = call i32 @fputc(i32 %237, i32* %238)
%240 = load i32, i32* %20
%241 = sext i32 %240 to i64
%242 = getelementptr inbounds i32, i32* %103, i64 %241
%243 = load i32, i32* %242
%244 = load i32, i32* %22
%245 = add nsw i32 %244, %243
store i32 %245, i32* %22
br label %246
246: ; preds = %233
%247 = load i32, i32* %20
%248 = add nsw i32 %247, 1
store i32 %248, i32* %20
br label %228
249: ; preds = %228
%250 = load i32, i32* %22
%251 = load i32*, i32** %7
%252 = call i32 @fputc(i32 %250, i32* %251)
br label %254
253: ; preds = %144
store i8 0, i8* %15
br label %254
254: ; preds = %253, %249
store i32 0, i32* %21
br label %255
255: ; preds = %254, %142
%256 = load i8*, i8** %18
%257 = load i32, i32* %21
switch i32 %257, label %323 [
i32 0, label %258
i32 5, label %267
]
258: ; preds = %255
br label %259
259: ; preds = %258, %91
%260 = load i32, i32* %17
%261 = load i32*, i32** %6
%262 = call i32 @ftell(i32* %261)
%263 = add nsw i32 %262, 2
%264 = icmp slt i32 %260, %263
br i1 %264, label %265, label %266
265: ; preds = %259
br label %267
266: ; preds = %259
br label %86
267: ; preds = %265, %255, %86
%268 = load i32*, i32** %7
%269 = load i32, i32* @SEEK_END
%270 = call i32 @fseek(i32* %268, i64 0, i32 %269)
%271 = load i32*, i32** %7
%272 = call i32 @ftell(i32* %271)
store i32 %272, i32* %23
%273 = load i32*, i32** %7
%274 = call i32 @fgetc(i32* %273)
store i32 %274, i32* %24
br label %275
275: ; preds = %284, %267
%276 = load i32, i32* %24
%277 = icmp ne i32 %276, 153
br i1 %277, label %278, label %282
278: ; preds = %275
%279 = load i8, i8* %16
%280 = sext i8 %279 to i32
%281 = icmp eq i32 %280, 0
br label %282
282: ; preds = %278, %275
%283 = phi i1 [ false, %275 ], [ %281, %278 ]
br i1 %283, label %284, label %290
284: ; preds = %282
%285 = load i32*, i32** %7
%286 = load i32, i32* @SEEK_CUR
%287 = call i32 @fseek(i32* %285, i64 -2, i32 %286)
%288 = load i32*, i32** %7
%289 = call i32 @fgetc(i32* %288)
store i32 %289, i32* %24
br label %275
290: ; preds = %282
%291 = load i32*, i32** %7
%292 = load i32, i32* @SEEK_CUR
%293 = call i32 @fseek(i32* %291, i64 -1, i32 %292)
br label %294
294: ; preds = %299, %290
%295 = load i32*, i32** %7
%296 = call i32 @ftell(i32* %295)
%297 = load i32, i32* %23
%298 = icmp ne i32 %296, %297
br i1 %298, label %299, label %302
299: ; preds = %294
%300 = load i32*, i32** %7
%301 = call i32 @fputc(i32 0, i32* %300)
br label %294
302: ; preds = %294
%303 = load i32, i32* %12
%304 = icmp eq i32 %303, 0
br i1 %304, label %305, label %308
305: ; preds = %302
%306 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([474 x i8], [474 x i8]* @.str.6, i64 0, i64 0))
%307 = load i32, i32* @EXIT_FAILURE
store i32 %307, i32* %3
br label %321
308: ; preds = %302
%309 = load i32, i32* %8
%310 = icmp eq i32 %309, 0
br i1 %310, label %311, label %314
311: ; preds = %308
%312 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([239 x i8], [239 x i8]* @.str.7, i64 0, i64 0), i32 129)
%313 = load i32, i32* @EXIT_FAILURE
store i32 %313, i32* %3
br label %321
314: ; preds = %308
%315 = load i32, i32* %13
%316 = load i32, i32* %14
%317 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([129 x i8], [129 x i8]* @.str.8, i64 0, i64 0), i32 %315, i32 %316)
br label %318
318: ; preds = %314
br label %319
319: ; preds = %318
%320 = load i32, i32* @EXIT_SUCCESS
store i32 %320, i32* %3
br label %321
321: ; preds = %319, %311, %305, %54, %37, %28
%322 = load i32, i32* %3
ret i32 %322
323: ; preds = %255
unreachable
}

LLVM IR (-O2):
@.str = [74 x i8] c"wrong number of parameters!\0Ausage is openlog2tlm <inuptfile> <outputfile>\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [47 x i8] c"openlog2tlm wasn't able to open the inputfile\0A\00"
@SEEK_END = global i32 0
@SEEK_SET = global i32 0
@.str.3 = [3 x i8] c"w+\00"
@.str.4 = [48 x i8] c"openlog2tlm wasn't able to open the outputfile\0A\00"
@.str.5 = [25 x i8] c"now converting %s to %s\0A\00"
@EOF = global i32 0
@SEEK_CUR = global i32 0
@.str.6 = [474 x i8] c"\0AThere have been no messages at all. Perhaps you misconfigured your Openlog, so it uses the wrong baudrate, or you aren't using the transparent telemetry, or this even wasn't a Paparazzi-log. For debugging you can open the logfile using a hexeditor and check there is a more or less periodic occurance of the Paparazzi STX (0x99)\0A Also check your wiring and the configfile of the openlog. It should be named CONFIG.TXT and contain 57600,26,3,0 if your baudrate is 57600.\0A\0A \00"
@.str.7 = [239 x i8] c"There have been messages but openlog2tlm didn't find the TIMESTAMP-Message. Check the messages-tool if there is a message called \22TIMESTAMP\22. Make sure the Openlog-Module was loaded and check the messages.xml, the Timestamp was really %i\0A\00"
@.str.8 = [129 x i8] c"The conversion from the logfile from the SD to TLM seems to be successful, %i have been converted, %i packages have been broken\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([74 x i8], [74 x i8]* @.str, i64 0, i64 0))
br label %210
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0))
br label %210
13: ; preds = %6
%14 = load i32, i32* @SEEK_END
%15 = tail call i32 @fseek(i32* %9, i64 0, i32 %14)
%16 = tail call i32 @ftell(i32* %9)
%17 = load i32, i32* @SEEK_SET
%18 = tail call i32 @fseek(i32* %9, i64 0, i32 %17)
%19 = getelementptr inbounds i8*, i8** %1, i64 2
%20 = load i8*, i8** %19
%21 = tail call i32* @fopen(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %25
23: ; preds = %13
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @.str.4, i64 0, i64 0))
br label %210
25: ; preds = %13
%26 = load i8*, i8** %7
%27 = load i8*, i8** %19
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), i8* %26, i8* %27)
%29 = tail call i32 @fgetc(i32* %9)
%30 = icmp eq i32 %29, 153
br i1 %30, label %39, label %31
31: ; preds = %25, %31
%32 = tail call i32 @fgetc(i32* %9)
%33 = load i32, i32* @EOF
%34 = icmp eq i32 %32, %33
%35 = icmp eq i32 %32, 153
%36 = or i1 %34, %35
br i1 %36, label %37, label %31
37: ; preds = %31
%38 = xor i1 %34, true
br label %39
39: ; preds = %37, %25
%40 = phi i32 [ 153, %25 ], [ %32, %37 ]
%41 = phi i1 [ true, %25 ], [ %38, %37 ]
%42 = load i32, i32* @SEEK_CUR
%43 = tail call i32 @fseek(i32* %9, i64 -1, i32 %42)
br label %44
44: ; preds = %161, %39
%45 = phi i32 [ 0, %39 ], [ %162, %161 ]
%46 = phi i32 [ 0, %39 ], [ %163, %161 ]
%47 = phi i32 [ %40, %39 ], [ %164, %161 ]
%48 = phi i32 [ 0, %39 ], [ %165, %161 ]
%49 = phi i32 [ 0, %39 ], [ %166, %161 ]
%50 = phi i32 [ 0, %39 ], [ %167, %161 ]
%51 = phi i8 [ 0, %39 ], [ %168, %161 ]
%52 = phi i32 [ 0, %39 ], [ %169, %161 ]
%53 = phi i32 [ 0, %39 ], [ %170, %161 ]
%54 = phi i32 [ 0, %39 ], [ %171, %161 ]
%55 = tail call i32 @feof(i32* %9)
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %175
57: ; preds = %44
%58 = icmp eq i32 %47, 153
br i1 %58, label %59, label %161
59: ; preds = %57
%60 = add nsw i32 %49, 1
%61 = tail call i32 @fgetc(i32* %9)
%62 = add i32 %61, -2
%63 = zext i32 %62 to i64
%64 = tail call i8* @llvm.stacksave()
%65 = alloca i32, i64 %63
%66 = icmp sgt i32 %61, 2
br i1 %66, label %67, label %73
67: ; preds = %59, %67
%68 = phi i64 [ %71, %67 ], [ 0, %59 ]
%69 = tail call i32 @fgetc(i32* %9)
%70 = getelementptr inbounds i32, i32* %65, i64 %68
store i32 %69, i32* %70
%71 = add nuw nsw i64 %68, 1
%72 = icmp eq i64 %71, %63
br i1 %72, label %73, label %67
73: ; preds = %67, %59
%74 = tail call i32 @fgetc(i32* %9)
%75 = icmp eq i32 %74, 153
br i1 %75, label %87, label %76
76: ; preds = %73
%77 = add nsw i32 %50, 1
br label %78
78: ; preds = %81, %76
%79 = tail call i32 @fgetc(i32* %9)
%80 = icmp eq i32 %79, 153
br i1 %80, label %84, label %81
81: ; preds = %78
%82 = tail call i32 @ftell(i32* %9)
%83 = icmp sgt i32 %16, %82
br i1 %83, label %78, label %84
84: ; preds = %81, %78
%85 = tail call i32 @ftell(i32* %9)
%86 = icmp sgt i32 %16, %85
br i1 %86, label %87, label %160
87: ; preds = %84, %73
%88 = phi i32 [ %77, %84 ], [ %50, %73 ]
%89 = phi i8 [ 1, %84 ], [ %51, %73 ]
%90 = load i32, i32* @SEEK_CUR
%91 = tail call i32 @fseek(i32* %9, i64 -1, i32 %90)
%92 = tail call i32 @fgetc(i32* %9)
%93 = icmp eq i8 %89, 1
br i1 %93, label %153, label %94
94: ; preds = %87
%95 = getelementptr inbounds i32, i32* %65, i64 1
%96 = load i32, i32* %95
%97 = icmp eq i32 %96, 129
br i1 %97, label %98, label %120
98: ; preds = %94
%99 = getelementptr inbounds i32, i32* %65, i64 2
%100 = load i32, i32* %99
%101 = getelementptr inbounds i32, i32* %65, i64 3
%102 = load i32, i32* %101
%103 = shl i32 %102, 8
%104 = add nsw i32 %103, %100
%105 = getelementptr inbounds i32, i32* %65, i64 4
%106 = load i32, i32* %105
%107 = shl i32 %106, 16
%108 = add nsw i32 %104, %107
%109 = getelementptr inbounds i32, i32* %65, i64 5
%110 = load i32, i32* %109
%111 = shl i32 %110, 24
%112 = add nsw i32 %108, %111
%113 = mul nsw i32 %112, 10
%114 = and i32 %113, 254
%115 = lshr i32 %113, 8
%116 = and i32 %115, 255
%117 = lshr i32 %113, 16
%118 = and i32 %117, 255
%119 = lshr i32 %113, 24
br label %120
120: ; preds = %98, %94
%121 = phi i32 [ %118, %98 ], [ %45, %94 ]
%122 = phi i32 [ %119, %98 ], [ %46, %94 ]
%123 = phi i32 [ %116, %98 ], [ %52, %94 ]
%124 = phi i32 [ %114, %98 ], [ %53, %94 ]
%125 = phi i32 [ %113, %98 ], [ %54, %94 ]
%126 = tail call i32 @fputc(i32 153, i32* %21)
%127 = add nsw i32 %61, -4
%128 = tail call i32 @fputc(i32 %127, i32* %21)
%129 = tail call i32 @fputc(i32 0, i32* %21)
%130 = tail call i32 @fputc(i32 %124, i32* %21)
%131 = tail call i32 @fputc(i32 %123, i32* %21)
%132 = tail call i32 @fputc(i32 %121, i32* %21)
%133 = tail call i32 @fputc(i32 %122, i32* %21)
%134 = add i32 %121, %127
%135 = add i32 %134, %122
%136 = add i32 %135, %123
%137 = add i32 %136, %124
%138 = icmp sgt i32 %61, 4
br i1 %138, label %139, label %150
139: ; preds = %120
%140 = zext i32 %127 to i64
br label %141
141: ; preds = %139, %141
%142 = phi i64 [ 0, %139 ], [ %148, %141 ]
%143 = phi i32 [ %137, %139 ], [ %147, %141 ]
%144 = getelementptr inbounds i32, i32* %65, i64 %142
%145 = load i32, i32* %144
%146 = tail call i32 @fputc(i32 %145, i32* %21)
%147 = add nsw i32 %145, %143
%148 = add nuw nsw i64 %142, 1
%149 = icmp eq i64 %148, %140
br i1 %149, label %150, label %141
150: ; preds = %141, %120
%151 = phi i32 [ %137, %120 ], [ %147, %141 ]
%152 = tail call i32 @fputc(i32 %151, i32* %21)
br label %153
153: ; preds = %87, %150
%154 = phi i32 [ %45, %87 ], [ %121, %150 ]
%155 = phi i32 [ %46, %87 ], [ %122, %150 ]
%156 = phi i8 [ 0, %87 ], [ %89, %150 ]
%157 = phi i32 [ %52, %87 ], [ %123, %150 ]
%158 = phi i32 [ %53, %87 ], [ %124, %150 ]
%159 = phi i32 [ %54, %87 ], [ %125, %150 ]
tail call void @llvm.stackrestore(i8* %64)
br label %161
160: ; preds = %84
tail call void @llvm.stackrestore(i8* %64)
br label %175
161: ; preds = %153, %57
%162 = phi i32 [ %45, %57 ], [ %154, %153 ]
%163 = phi i32 [ %46, %57 ], [ %155, %153 ]
%164 = phi i32 [ %47, %57 ], [ %92, %153 ]
%165 = phi i32 [ %48, %57 ], [ %61, %153 ]
%166 = phi i32 [ %49, %57 ], [ %60, %153 ]
%167 = phi i32 [ %50, %57 ], [ %88, %153 ]
%168 = phi i8 [ %51, %57 ], [ %156, %153 ]
%169 = phi i32 [ %52, %57 ], [ %157, %153 ]
%170 = phi i32 [ %53, %57 ], [ %158, %153 ]
%171 = phi i32 [ %54, %57 ], [ %159, %153 ]
%172 = tail call i32 @ftell(i32* %9)
%173 = add nsw i32 %172, 2
%174 = icmp slt i32 %16, %173
br i1 %174, label %175, label %44
175: ; preds = %161, %44, %160
%176 = phi i32 [ %61, %160 ], [ %48, %44 ], [ %165, %161 ]
%177 = phi i32 [ %60, %160 ], [ %49, %44 ], [ %166, %161 ]
%178 = phi i32 [ %77, %160 ], [ %50, %44 ], [ %167, %161 ]
%179 = phi i32 [ %54, %160 ], [ %54, %44 ], [ %171, %161 ]
%180 = load i32, i32* @SEEK_END
%181 = tail call i32 @fseek(i32* %21, i64 0, i32 %180)
%182 = tail call i32 @ftell(i32* %21)
%183 = tail call i32 @fgetc(i32* %21)
%184 = icmp ne i32 %183, 153
%185 = and i1 %41, %184
br i1 %185, label %186, label %191
186: ; preds = %175, %186
%187 = load i32, i32* @SEEK_CUR
%188 = tail call i32 @fseek(i32* %21, i64 -2, i32 %187)
%189 = tail call i32 @fgetc(i32* %21)
%190 = icmp eq i32 %189, 153
br i1 %190, label %191, label %186
191: ; preds = %186, %175
%192 = load i32, i32* @SEEK_CUR
%193 = tail call i32 @fseek(i32* %21, i64 -1, i32 %192)
%194 = tail call i32 @ftell(i32* %21)
%195 = icmp eq i32 %194, %182
br i1 %195, label %200, label %196
196: ; preds = %191, %196
%197 = tail call i32 @fputc(i32 0, i32* %21)
%198 = tail call i32 @ftell(i32* %21)
%199 = icmp eq i32 %198, %182
br i1 %199, label %200, label %196
200: ; preds = %196, %191
%201 = icmp eq i32 %176, 0
br i1 %201, label %202, label %204
202: ; preds = %200
%203 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([474 x i8], [474 x i8]* @.str.6, i64 0, i64 0))
br label %210
204: ; preds = %200
%205 = icmp eq i32 %179, 0
br i1 %205, label %206, label %208
206: ; preds = %204
%207 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([239 x i8], [239 x i8]* @.str.7, i64 0, i64 0), i32 129)
br label %210
208: ; preds = %204
%209 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([129 x i8], [129 x i8]* @.str.8, i64 0, i64 0), i32 %177, i32 %178)
br label %210
210: ; preds = %23, %208, %206, %202, %11, %4
%211 = phi i32* [ @EXIT_FAILURE, %4 ], [ @EXIT_FAILURE, %11 ], [ @EXIT_FAILURE, %23 ], [ @EXIT_FAILURE, %202 ], [ @EXIT_FAILURE, %206 ], [ @EXIT_SUCCESS, %208 ]
%212 = load i32, i32* %211
ret i32 %212
}