#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 */
struct timeval {
  int tv_sec;
  int tv_usec;
};
struct canfd_frame {
  int can_id;
  int len;
  int *data;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int CAN_EFF_FLAG;
int CAN_EFF_MASK;
int CAN_ERR_FLAG;
scalar_t__ CAN_MTU;
int CAN_RTR_FLAG;
int /*<<< orphan*/ basename(char *);
char *ctime(int *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fflush(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(int /*<<< orphan*/, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int getopt(int, char **, char *);
int /*<<< orphan*/ optarg;
int optind;
scalar_t__ parse_canframe(char *, struct canfd_frame *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ print_usage(int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, int, char);
int sscanf(char *, char *, int *, int *, char *, char *);
int /*<<< orphan*/ *stderr;
int /*<<< orphan*/ *stdin;
int /*<<< orphan*/ *stdout;
int /*<<< orphan*/ strcmp(char *, char *);
int strlen(char *);
int main(int argc, char **argv) {
  static char buf[400], device[400], ascframe[400], id[10];
  struct canfd_frame cf;
  static struct timeval tv, start_tv;
  FILE *infile = stdin;
  FILE *outfile = stdout;
  static int maxdev, devno, i, crlf, d4, opt;
  while ((opt = getopt(argc, argv, "I:O:4n?")) != -1) {
    switch (opt) {
    case 'I':
      infile = fopen(optarg, "r");
      if (!infile) {
        perror("infile");
        return 1;
      }
      break;
    case 'O':
      outfile = fopen(optarg, "w");
      if (!outfile) {
        perror("outfile");
        return 1;
      }
      break;
    case 'n':
      crlf = 1;
      break;
    case '4':
      d4 = 1;
      break;
    case '?':
      print_usage(basename(argv[0]));
      return 0;
      break;
    default:
      fprintf(stderr, "Unknown option %c\n", opt);
      print_usage(basename(argv[0]));
      return 1;
      break;
    }
  }
  maxdev = argc - optind;
  if (!maxdev) {
    fprintf(stderr, "no CAN interfaces defined!\n");
    print_usage(basename(argv[0]));
    return 1;
  }
  while (fgets(buf, 400 - 1, infile)) {
    if (strlen(buf) >= 400 - 2) {
      fprintf(stderr, "line too long for input buffer\n");
      return 1;
    }
    if (buf[0] != '(')
      continue;
    if (sscanf(buf, "(%ld.%ld) %s %s", &tv.tv_sec, &tv.tv_usec, device,
               ascframe) != 4) {
      fprintf(stderr, "incorrect line format in logfile\n");
      return 1;
    }
    if (!start_tv.tv_sec) {
      start_tv = tv;
      fprintf(outfile, "date %s", ctime(&start_tv.tv_sec));
      fprintf(outfile, "base hex  timestamps absolute%s",
              (crlf) ? "\r\n" : "\n");
      fprintf(outfile, "no internal events logged%s", (crlf) ? "\r\n" : "\n");
    }
    for (i = 0, devno = 0; i < maxdev; i++) {
      if (!strcmp(device, argv[optind + i])) {
        devno = i + 1;
        break;
      }
    }
    if (devno) {
      if (parse_canframe(ascframe, &cf) != CAN_MTU)
        return 1;
      tv.tv_sec = tv.tv_sec - start_tv.tv_sec;
      tv.tv_usec = tv.tv_usec - start_tv.tv_usec;
      if (tv.tv_usec < 0)
        tv.tv_sec--, tv.tv_usec += 1000000;
      if (tv.tv_sec < 0)
        tv.tv_sec = tv.tv_usec = 0;
      if (d4)
        fprintf(outfile, "%4ld.%04ld ", tv.tv_sec, tv.tv_usec / 100);
      else
        fprintf(outfile, "%4ld.%06ld ", tv.tv_sec, tv.tv_usec);
      fprintf(outfile, "%-2d ", devno);
      if (cf.can_id & CAN_ERR_FLAG)
        fprintf(outfile, "ErrorFrame");
      else {
        sprintf(id, "%X%c", cf.can_id & CAN_EFF_MASK,
                (cf.can_id & CAN_EFF_FLAG) ? 'x' : ' ');
        fprintf(outfile, "%-15s Rx   ", id);
        if (cf.can_id & CAN_RTR_FLAG)
          fprintf(outfile, "r");
        else {
          fprintf(outfile, "d %d", cf.len);
          for (i = 0; i < cf.len; i++) {
            fprintf(outfile, " %02X", cf.data[i]);
          }
        }
      }
      if (crlf)
        fprintf(outfile, "\r");
      fprintf(outfile, "\n");
    }
  }
  fflush(outfile);
  fclose(outfile);
  fclose(infile);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2dc3(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    0x2d7d(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xdd0(%rip),%rdx
call   10f0 <getopt@plt>
mov    %eax,0x3369(%rip)
cmp    $0xffffffff,%eax
je     13a0 <main+0x1b0>
mov    0x335a(%rip),%eax
mov    %eax,-0x34(%rbp)
sub    $0x34,%eax
je     1330 <main+0x140>
jmp    125b <main+0x6b>
mov    -0x34(%rbp),%eax
sub    $0x3f,%eax
je     133f <main+0x14f>
jmp    126c <main+0x7c>
mov    -0x34(%rbp),%eax
sub    $0x49,%eax
je     129f <main+0xaf>
jmp    127d <main+0x8d>
mov    -0x34(%rbp),%eax
sub    $0x4f,%eax
je     12e0 <main+0xf0>
jmp    128e <main+0x9e>
mov    -0x34(%rbp),%eax
sub    $0x6e,%eax
je     1321 <main+0x131>
jmp    135e <main+0x16e>
mov    0x2d52(%rip),%rax
mov    (%rax),%edi
lea    0xd59(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    12db <main+0xeb>
lea    0xd40(%rip),%rdi
call   10e0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    187a <main+0x68a>
jmp    139b <main+0x1ab>
mov    0x2d11(%rip),%rax
mov    (%rax),%edi
lea    0xd21(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    131c <main+0x12c>
lea    0xd08(%rip),%rdi
call   10e0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    187a <main+0x68a>
jmp    139b <main+0x1ab>
movl   $0x1,0x3271(%rip)
jmp    139b <main+0x1ab>
movl   $0x1,0x3266(%rip)
jmp    139b <main+0x1ab>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1090 <basename@plt>
mov    %eax,%edi
call   1110 <print_usage@plt>
movl   $0x0,-0x4(%rbp)
jmp    187a <main+0x68a>
mov    0x2c53(%rip),%rax
mov    (%rax),%rdi
mov    0x3236(%rip),%edx
lea    0xca6(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1090 <basename@plt>
mov    %eax,%edi
call   1110 <print_usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    187a <main+0x68a>
jmp    1222 <main+0x32>
mov    -0x8(%rbp),%eax
mov    0x2c1e(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,0x31de(%rip)
cmpl   $0x0,0x31d7(%rip)
jne    13f6 <main+0x206>
mov    0x2bf2(%rip),%rax
mov    (%rax),%rdi
lea    0xc5e(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1090 <basename@plt>
mov    %eax,%edi
call   1110 <print_usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    187a <main+0x68a>
jmp    13fb <main+0x20b>
mov    -0x28(%rbp),%rdx
lea    0x2caa(%rip),%rdi
mov    $0x18f,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1858 <main+0x668>
lea    0x2c8f(%rip),%rdi
call   1050 <strlen@plt>
cmp    $0x18e,%eax
jl     1455 <main+0x265>
mov    0x2b80(%rip),%rax
mov    (%rax),%rdi
lea    0xc08(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    187a <main+0x68a>
movsbl 0x2c54(%rip),%eax
cmp    $0x28,%eax
je     146a <main+0x27a>
jmp    13fb <main+0x20b>
lea    0x2c3f(%rip),%rdi
lea    0xbf2(%rip),%rsi
lea    0x30ed(%rip),%rdx
mov    %rdx,%rcx
add    $0x4,%rcx
lea    0x2db3(%rip),%r8
lea    0x2f3c(%rip),%r9
call   10c0 <sscanf@plt>
cmp    $0x4,%eax
je     14c6 <main+0x2d6>
mov    0x2b0f(%rip),%rax
mov    (%rax),%rdi
lea    0xbc7(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    187a <main+0x68a>
cmpl   $0x0,0x30a7(%rip)
jne    1564 <main+0x374>
mov    0x3092(%rip),%rax
mov    %rax,0x3093(%rip)
mov    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    0x3084(%rip),%rdi
call   1040 <ctime@plt>
mov    -0x40(%rbp),%rdi
mov    %rax,%rdx
lea    0xb99(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x30(%rbp),%rdi
mov    0x3088(%rip),%ecx
lea    0xbaa(%rip),%rdx
lea    0xba2(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
lea    0xb74(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x30(%rbp),%rdi
mov    0x305b(%rip),%ecx
lea    0xb7d(%rip),%rdx
lea    0xb75(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
lea    0xb6a(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,0x302a(%rip)
movl   $0x0,0x301c(%rip)
mov    0x301a(%rip),%eax
cmp    0x300c(%rip),%eax
jge    15e6 <main+0x3f6>
mov    -0x10(%rbp),%rax
mov    0x2a33(%rip),%rcx
mov    (%rcx),%ecx
add    0x2ffb(%rip),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
lea    0x2c95(%rip),%rdi
call   1070 <strcmp@plt>
cmp    $0x0,%eax
jne    15cd <main+0x3dd>
mov    0x2fd9(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2fcc(%rip)
jmp    15e6 <main+0x3f6>
jmp    15d2 <main+0x3e2>
mov    0x2fc0(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2fb7(%rip)
jmp    1578 <main+0x388>
cmpl   $0x0,0x2fa7(%rip)
je     1853 <main+0x663>
lea    0x2dd6(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   10a0 <parse_canframe@plt>
mov    0x29a6(%rip),%rcx
cmp    (%rcx),%rax
je     161f <main+0x42f>
movl   $0x1,-0x4(%rbp)
jmp    187a <main+0x68a>
mov    0x2f47(%rip),%eax
sub    0x2f49(%rip),%eax
mov    %eax,0x2f3b(%rip)
mov    0x2f39(%rip),%eax
sub    0x2f3b(%rip),%eax
mov    %eax,0x2f2d(%rip)
cmpl   $0x0,0x2f26(%rip)
jge    1670 <main+0x480>
mov    0x2f16(%rip),%eax
add    $0xffffffff,%eax
mov    %eax,0x2f0d(%rip)
mov    0x2f0b(%rip),%eax
add    $0xf4240,%eax
mov    %eax,0x2f00(%rip)
cmpl   $0x0,0x2ef5(%rip)
jge    1691 <main+0x4a1>
movl   $0x0,0x2ee9(%rip)
movl   $0x0,0x2edb(%rip)
cmpl   $0x0,0x2f08(%rip)
je     16d1 <main+0x4e1>
mov    -0x30(%rbp),%rdi
mov    0x2ec4(%rip),%eax
mov    %eax,-0x44(%rbp)
mov    0x2ebf(%rip),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    -0x44(%rbp),%edx
mov    %eax,%ecx
lea    0xa1e(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    16ef <main+0x4ff>
mov    -0x30(%rbp),%rdi
mov    0x2e91(%rip),%edx
mov    0x2e8f(%rip),%ecx
lea    0xa07(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x30(%rbp),%rdi
mov    0x2e9b(%rip),%edx
lea    0x9fb(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x20(%rbp),%eax
mov    0x28cf(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1733 <main+0x543>
mov    -0x30(%rbp),%rdi
lea    0x9da(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    1822 <main+0x632>
mov    -0x20(%rbp),%edx
mov    0x289b(%rip),%rax
and    (%rax),%edx
mov    -0x20(%rbp),%esi
mov    0x285f(%rip),%rax
and    (%rax),%esi
mov    $0x20,%eax
mov    $0x78,%ecx
cmp    $0x0,%esi
cmovne %ecx,%eax
lea    0x2dfe(%rip),%rdi
lea    0x9a3(%rip),%rsi
movsbl %al,%ecx
call   1100 <sprintf@plt>
mov    -0x30(%rbp),%rdi
lea    0x995(%rip),%rsi
lea    0x2ddd(%rip),%rdx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x20(%rbp),%eax
mov    0x280c(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     17b6 <main+0x5c6>
mov    -0x30(%rbp),%rdi
lea    0x85e(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    181d <main+0x62d>
mov    -0x30(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0x959(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x0,0x2dc3(%rip)
mov    0x2dbd(%rip),%eax
cmp    -0x1c(%rbp),%eax
jge    1818 <main+0x628>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq 0x2da5(%rip),%rcx
mov    (%rax,%rcx,4),%edx
lea    0x925(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2d8e(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2d85(%rip)
jmp    17d5 <main+0x5e5>
jmp    181d <main+0x62d>
jmp    1822 <main+0x632>
cmpl   $0x0,0x2d73(%rip)
je     1841 <main+0x651>
mov    -0x30(%rbp),%rdi
lea    0x8ee(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x30(%rbp),%rdi
lea    0x879(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    13fb <main+0x20b>
mov    -0x30(%rbp),%rdi
call   10b0 <fflush@plt>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%r13
mov    %edi,%ebp
mov    0x2da6(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x10(%rsp)
mov    0x2d5f(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x8(%rsp)
lea    0xe28(%rip),%rbx
lea    0x335d(%rip),%r12
lea    0xdaa(%rip),%r14
lea    0x3353(%rip),%r15
jmp    126b <main+0x5b>
nop
mov    %r12,%rcx
cmp    $0x6e,%eax
jne    12dd <main+0xcd>
movb   $0x1,(%rcx)
mov    %ebp,%edi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1100 <getopt@plt>
lea    -0x34(%rax),%ecx
cmp    $0x1b,%ecx
ja     1260 <main+0x50>
movslq (%r14,%rcx,4),%rcx
add    %r14,%rcx
jmp    *%rcx
mov    %r15,%rcx
jmp    1268 <main+0x58>
mov    0x2d63(%rip),%rax
mov    (%rax),%edi
lea    0xdda(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,0x10(%rsp)
test   %rax,%rax
jne    126b <main+0x5b>
jmp    175c <main+0x54c>
mov    0x2d3f(%rip),%rax
mov    (%rax),%edi
lea    0xdbf(%rip),%rsi
call   10e0 <fopen@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
jne    126b <main+0x5b>
lea    0xdab(%rip),%rdi
jmp    1763 <main+0x553>
cmp    $0xffffffff,%eax
jne    1326 <main+0x116>
mov    0x2cdf(%rip),%rax
sub    (%rax),%ebp
mov    %ebp,0x32af(%rip)
je     16de <main+0x4ce>
lea    0x2dc2(%rip),%rdi
mov    $0x18f,%esi
mov    0x10(%rsp),%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     16bb <main+0x4ab>
lea    0x2da3(%rip),%r15
lea    0xe6e(%rip),%r12
jmp    138b <main+0x17b>
mov    0x2c8b(%rip),%rcx
mov    (%rcx),%rdi
lea    0xd54(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1090 <fprintf@plt>
jmp    16fe <main+0x4ee>
mov    0x0(%r13),%rdi
call   10a0 <basename@plt>
mov    %eax,%edi
call   1130 <print_usage@plt>
jmp    16da <main+0x4ca>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    $0x18f,%esi
mov    0x10(%rsp),%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     16bb <main+0x4ab>
mov    %r15,%rdi
call   1050 <strlen@plt>
cmp    $0x18e,%eax
jge    1722 <main+0x512>
cmpb   $0x28,0x2d1b(%rip)
jne    1370 <main+0x160>
mov    %r15,%rdi
lea    0xd29(%rip),%rsi
lea    0x31c8(%rip),%rdx
lea    0x31c5(%rip),%rcx
lea    0x2e8a(%rip),%r8
lea    0x3013(%rip),%r9
call   10d0 <sscanf@plt>
cmp    $0x4,%eax
jne    173a <main+0x52a>
cmpl   $0x0,0x31a6(%rip)
jne    1463 <main+0x253>
mov    0x3195(%rip),%rax
mov    %rax,0x3196(%rip)
lea    0x318f(%rip),%rdi
call   1040 <ctime@plt>
mov    0x8(%rsp),%rbx
mov    %rbx,%rdi
lea    0xcff(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
cmpb   $0x0,0x318e(%rip)
lea    0xd10(%rip),%r14
mov    %r14,%rdx
lea    0xd05(%rip),%rbp
cmovne %rbp,%rdx
mov    %rbx,%rdi
lea    0xcd7(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
cmpb   $0x0,0x3161(%rip)
mov    %r14,%rdx
cmovne %rbp,%rdx
mov    %rbx,%rdi
lea    0xcdb(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
movl   $0x0,0x313b(%rip)
movl   $0x0,0x312d(%rip)
mov    0x3123(%rip),%ebx
test   %ebx,%ebx
jle    1370 <main+0x160>
mov    0x2b3c(%rip),%rax
movslq (%rax),%rax
lea    0x0(,%rax,8),%r14
add    %r13,%r14
xor    %ebp,%ebp
nopl   0x0(%rax)
mov    (%r14,%rbp,8),%rsi
lea    0x2da5(%rip),%rdi
call   1080 <strcmp@plt>
test   %eax,%eax
je     14c8 <main+0x2b8>
add    $0x1,%rbp
mov    %ebp,0x30ea(%rip)
cmp    %rbp,%rbx
jne    14a0 <main+0x290>
jmp    1370 <main+0x160>
add    $0x1,%ebp
mov    %ebp,0x30d3(%rip)
lea    0x2f08(%rip),%rdi
lea    0x18(%rsp),%rsi
call   10b0 <parse_canframe@plt>
mov    0x2ac7(%rip),%rcx
cmp    (%rcx),%rax
jne    170e <main+0x4fe>
mov    0x3088(%rip),%edx
sub    0x308a(%rip),%edx
mov    %edx,0x307c(%rip)
mov    0x307a(%rip),%ecx
sub    0x307c(%rip),%ecx
mov    %ecx,0x306e(%rip)
jns    152d <main+0x31d>
add    $0xffffffff,%edx
mov    %edx,0x305f(%rip)
add    $0xf4240,%ecx
mov    %ecx,0x3057(%rip)
mov    0x8(%rsp),%rbx
mov    %r12,%r14
test   %edx,%edx
js     1565 <main+0x355>
cmpb   $0x1,0x3070(%rip)
jne    157d <main+0x36d>
movslq %ecx,%rax
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rax
shr    $0x3f,%rax
sar    $0x25,%rcx
add    %eax,%ecx
mov    %rbx,%rdi
lea    0xbf0(%rip),%rsi
jmp    1587 <main+0x377>
movq   $0x0,0x3010(%rip)
xor    %ecx,%ecx
xor    %edx,%edx
cmpb   $0x1,0x3035(%rip)
je     1542 <main+0x332>
mov    %rbx,%rdi
lea    0xbd8(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x3010(%rip),%edx
mov    %rbx,%rdi
lea    0xbcd(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x18(%rsp),%eax
mov    0x2a30(%rip),%rcx
test   %eax,(%rcx)
je     15d2 <main+0x3c2>
mov    $0xa,%esi
mov    $0x1,%edx
lea    0xbac(%rip),%rdi
mov    %rbx,%rcx
call   1120 <fwrite@plt>
jmp    169c <main+0x48c>
mov    0x29ff(%rip),%rcx
mov    (%rcx),%edx
and    %eax,%edx
mov    0x29c4(%rip),%rcx
and    (%rcx),%eax
mov    $0x78,%ecx
mov    $0x20,%eax
cmove  %eax,%ecx
lea    0x2f76(%rip),%rbp
mov    %rbp,%rdi
lea    0xb78(%rip),%rsi
call   1110 <sprintf@plt>
mov    %rbx,%rdi
lea    0xb6e(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x297c(%rip),%rax
mov    (%rax),%eax
test   %eax,0x18(%rsp)
je     163b <main+0x42b>
mov    $0x72,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
jmp    169c <main+0x48c>
mov    0x1c(%rsp),%edx
mov    %rbx,%rdi
lea    0xb44(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
movl   $0x0,0x2f4e(%rip)
cmpl   $0x0,0x1c(%rsp)
jle    169c <main+0x48c>
xor    %eax,%eax
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x20(%rsp),%rcx
cltq
mov    (%rcx,%rax,4),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    0x2f1b(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2f12(%rip)
cmp    0x1c(%rsp),%eax
jl     1670 <main+0x460>
cmpb   $0x1,0x2f09(%rip)
jne    135a <main+0x14a>
mov    $0xd,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
jmp    135a <main+0x14a>
mov    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   10c0 <fflush@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    0x10(%rsp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
jmp    1713 <main+0x503>
mov    0x28d3(%rip),%rax
mov    (%rax),%rcx
lea    0x9af(%rip),%rdi
mov    $0x1b,%esi
mov    $0x1,%edx
call   1120 <fwrite@plt>
mov    0x0(%r13),%rdi
call   10a0 <basename@plt>
mov    %eax,%edi
call   1130 <print_usage@plt>
mov    $0x1,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x288f(%rip),%rax
mov    (%rax),%rcx
lea    0x987(%rip),%rdi
mov    $0x1f,%esi
jmp    1750 <main+0x540>
mov    0x2877(%rip),%rax
mov    (%rax),%rcx
lea    0x99f(%rip),%rdi
mov    $0x21,%esi
mov    $0x1,%edx
call   1120 <fwrite@plt>
jmp    170e <main+0x4fe>
lea    0x917(%rip),%rdi
call   10f0 <perror@plt>
jmp    170e <main+0x4fe>

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
%struct.canfd_frame = type { i32, i32, i32* }
@main.buf = internal global [400 x i8] zeroinitializer
@main.device = internal global [400 x i8] zeroinitializer
@main.ascframe = internal global [400 x i8] zeroinitializer
@main.id = internal global [10 x i8] zeroinitializer
@main.tv = internal global %struct.timeval zeroinitializer
@main.start_tv = internal global %struct.timeval zeroinitializer
@stdin = global i32* null
@stdout = global i32* null
@main.maxdev = internal global i32 0
@main.devno = internal global i32 0
@main.i = internal global i32 0
@main.crlf = internal global i32 0
@main.d4 = internal global i32 0
@main.opt = internal global i32 0
@.str = [8 x i8] c"I:O:4n?\00"
@optarg = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [7 x i8] c"infile\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [8 x i8] c"outfile\00"
@stderr = global i32* null
@.str.5 = [19 x i8] c"Unknown option %c\0A\00"
@optind = global i32 0
@.str.6 = [28 x i8] c"no CAN interfaces defined!\0A\00"
@.str.7 = [32 x i8] c"line too long for input buffer\0A\00"
@.str.8 = [16 x i8] c"(%ld.%ld) %s %s\00"
@.str.9 = [34 x i8] c"incorrect line format in logfile\0A\00"
@.str.10 = [8 x i8] c"date %s\00"
@.str.11 = [32 x i8] c"base hex timestamps absolute%s\00"
@.str.12 = [3 x i8] c"\0D\0A\00"
@.str.13 = [2 x i8] c"\0A\00"
@.str.14 = [28 x i8] c"no internal events logged%s\00"
@CAN_MTU = global i64 0
@.str.15 = [12 x i8] c"%4ld.%04ld \00"
@.str.16 = [12 x i8] c"%4ld.%06ld \00"
@.str.17 = [6 x i8] c"%-2d \00"
@CAN_ERR_FLAG = global i32 0
@.str.18 = [11 x i8] c"ErrorFrame\00"
@.str.19 = [5 x i8] c"%X%c\00"
@CAN_EFF_MASK = global i32 0
@CAN_EFF_FLAG = global i32 0
@.str.20 = [12 x i8] c"%-15s Rx \00"
@CAN_RTR_FLAG = global i32 0
@.str.21 = [5 x i8] c"d %d\00"
@.str.22 = [6 x i8] c" %02X\00"
@.str.23 = [2 x i8] c"\0D\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.canfd_frame
%7 = alloca i32*
%8 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32*, i32** @stdin
store i32* %9, i32** %7
%10 = load i32*, i32** @stdout
store i32* %10, i32** %8
br label %11
11: ; preds = %51, %2
%12 = load i32, i32* %4
%13 = load i8**, i8*** %5
%14 = call i32 @getopt(i32 %12, i8** %13, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
store i32 %14, i32* @main.opt
%15 = icmp ne i32 %14, -1
br i1 %15, label %16, label %52
16: ; preds = %11
%17 = load i32, i32* @main.opt
switch i32 %17, label %42 [
i32 73, label %18
i32 79, label %26
i32 110, label %34
i32 52, label %35
i32 63, label %36
]
18: ; preds = %16
%19 = load i32, i32* @optarg
%20 = call i32* @fopen(i32 %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %20, i32** %7
%21 = load i32*, i32** %7
%22 = icmp ne i32* %21, null
br i1 %22, label %25, label %23
23: ; preds = %18
%24 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %246
25: ; preds = %18
br label %51
26: ; preds = %16
%27 = load i32, i32* @optarg
%28 = call i32* @fopen(i32 %27, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %28, i32** %8
%29 = load i32*, i32** %8
%30 = icmp ne i32* %29, null
br i1 %30, label %33, label %31
31: ; preds = %26
%32 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
store i32 1, i32* %3
br label %246
33: ; preds = %26
br label %51
34: ; preds = %16
store i32 1, i32* @main.crlf
br label %51
35: ; preds = %16
store i32 1, i32* @main.d4
br label %51
36: ; preds = %16
%37 = load i8**, i8*** %5
%38 = getelementptr inbounds i8*, i8** %37, i64 0
%39 = load i8*, i8** %38
%40 = call i32 @basename(i8* %39)
%41 = call i32 @print_usage(i32 %40)
store i32 0, i32* %3
br label %246
42: ; preds = %16
%43 = load i32*, i32** @stderr
%44 = load i32, i32* @main.opt
%45 = call i32 (i32*, i8*, ...) @fprintf(i32* %43, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %44)
%46 = load i8**, i8*** %5
%47 = getelementptr inbounds i8*, i8** %46, i64 0
%48 = load i8*, i8** %47
%49 = call i32 @basename(i8* %48)
%50 = call i32 @print_usage(i32 %49)
store i32 1, i32* %3
br label %246
51: ; preds = %35, %34, %33, %25
br label %11
52: ; preds = %11
%53 = load i32, i32* %4
%54 = load i32, i32* @optind
%55 = sub nsw i32 %53, %54
store i32 %55, i32* @main.maxdev
%56 = load i32, i32* @main.maxdev
%57 = icmp ne i32 %56, 0
br i1 %57, label %66, label %58
58: ; preds = %52
%59 = load i32*, i32** @stderr
%60 = call i32 (i32*, i8*, ...) @fprintf(i32* %59, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
%61 = load i8**, i8*** %5
%62 = getelementptr inbounds i8*, i8** %61, i64 0
%63 = load i8*, i8** %62
%64 = call i32 @basename(i8* %63)
%65 = call i32 @print_usage(i32 %64)
store i32 1, i32* %3
br label %246
66: ; preds = %52
br label %67
67: ; preds = %238, %81, %66
%68 = load i32*, i32** %7
%69 = call i64 @fgets(i8* getelementptr inbounds ([400 x i8], [400 x i8]* @main.buf, i64 0, i64 0), i32 399, i32* %68)
%70 = icmp ne i64 %69, 0
br i1 %70, label %71, label %239
71: ; preds = %67
%72 = call i32 @strlen(i8* getelementptr inbounds ([400 x i8], [400 x i8]* @main.buf, i64 0, i64 0))
%73 = icmp sge i32 %72, 398
br i1 %73, label %74, label %77
74: ; preds = %71
%75 = load i32*, i32** @stderr
%76 = call i32 (i32*, i8*, ...) @fprintf(i32* %75, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %3
br label %246
77: ; preds = %71
%78 = load i8, i8* getelementptr inbounds ([400 x i8], [400 x i8]* @main.buf, i64 0, i64 0)
%79 = sext i8 %78 to i32
%80 = icmp ne i32 %79, 40
br i1 %80, label %81, label %82
81: ; preds = %77
br label %67
82: ; preds = %77
%83 = call i32 @sscanf(i8* getelementptr inbounds ([400 x i8], [400 x i8]* @main.buf, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i32 0, i32 0), i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i32 0, i32 1), i8* getelementptr inbounds ([400 x i8], [400 x i8]* @main.device, i64 0, i64 0), i8* getelementptr inbounds ([400 x i8], [400 x i8]* @main.ascframe, i64 0, i64 0))
%84 = icmp ne i32 %83, 4
br i1 %84, label %85, label %88
85: ; preds = %82
%86 = load i32*, i32** @stderr
%87 = call i32 (i32*, i8*, ...) @fprintf(i32* %86, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0))
store i32 1, i32* %3
br label %246
88: ; preds = %82
%89 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.start_tv, i32 0, i32 0)
%90 = icmp ne i32 %89, 0
br i1 %90, label %107, label %91
91: ; preds = %88
%92 = load i32*, i32** %8
%93 = call i8* @ctime(i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.start_tv, i32 0, i32 0))
%94 = call i32 (i32*, i8*, ...) @fprintf(i32* %92, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i8* %93)
%95 = load i32*, i32** %8
%96 = load i32, i32* @main.crlf
%97 = icmp ne i32 %96, 0
%98 = zext i1 %97 to i64
%99 = select i1 %97, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0)
%100 = call i32 (i32*, i8*, ...) @fprintf(i32* %95, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.11, i64 0, i64 0), i8* %99)
%101 = load i32*, i32** %8
%102 = load i32, i32* @main.crlf
%103 = icmp ne i32 %102, 0
%104 = zext i1 %103 to i64
%105 = select i1 %103, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0)
%106 = call i32 (i32*, i8*, ...) @fprintf(i32* %101, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.14, i64 0, i64 0), i8* %105)
br label %107
107: ; preds = %91, %88
store i32 0, i32* @main.i
store i32 0, i32* @main.devno
br label %108
108: ; preds = %126, %107
%109 = load i32, i32* @main.i
%110 = load i32, i32* @main.maxdev
%111 = icmp slt i32 %109, %110
br i1 %111, label %112, label %129
112: ; preds = %108
%113 = load i8**, i8*** %5
%114 = load i32, i32* @optind
%115 = load i32, i32* @main.i
%116 = add nsw i32 %114, %115
%117 = sext i32 %116 to i64
%118 = getelementptr inbounds i8*, i8** %113, i64 %117
%119 = load i8*, i8** %118
%120 = call i32 @strcmp(i8* getelementptr inbounds ([400 x i8], [400 x i8]* @main.device, i64 0, i64 0), i8* %119)
%121 = icmp ne i32 %120, 0
br i1 %121, label %125, label %122
122: ; preds = %112
%123 = load i32, i32* @main.i
%124 = add nsw i32 %123, 1
store i32 %124, i32* @main.devno
br label %129
125: ; preds = %112
br label %126
126: ; preds = %125
%127 = load i32, i32* @main.i
%128 = add nsw i32 %127, 1
store i32 %128, i32* @main.i
br label %108
129: ; preds = %122, %108
%130 = load i32, i32* @main.devno
%131 = icmp ne i32 %130, 0
br i1 %131, label %132, label %238
132: ; preds = %129
%133 = call i64 @parse_canframe(i8* getelementptr inbounds ([400 x i8], [400 x i8]* @main.ascframe, i64 0, i64 0), %struct.canfd_frame* %6)
%134 = load i64, i64* @CAN_MTU
%135 = icmp ne i64 %133, %134
br i1 %135, label %136, label %137
136: ; preds = %132
store i32 1, i32* %3
br label %246
137: ; preds = %132
%138 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i32 0, i32 0)
%139 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.start_tv, i32 0, i32 0)
%140 = sub nsw i32 %138, %139
store i32 %140, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i32 0, i32 0)
%141 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i32 0, i32 1)
%142 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.start_tv, i32 0, i32 1)
%143 = sub nsw i32 %141, %142
store i32 %143, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i32 0, i32 1)
%144 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i32 0, i32 1)
%145 = icmp slt i32 %144, 0
br i1 %145, label %146, label %151
146: ; preds = %137
%147 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i32 0, i32 0)
%148 = add nsw i32 %147, -1
store i32 %148, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i32 0, i32 0)
%149 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i32 0, i32 1)
%150 = add nsw i32 %149, 1000000
store i32 %150, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i32 0, i32 1)
br label %151
151: ; preds = %146, %137
%152 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i32 0, i32 0)
%153 = icmp slt i32 %152, 0
br i1 %153, label %154, label %155
154: ; preds = %151
store i32 0, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i32 0, i32 1)
store i32 0, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i32 0, i32 0)
br label %155
155: ; preds = %154, %151
%156 = load i32, i32* @main.d4
%157 = icmp ne i32 %156, 0
br i1 %157, label %158, label %164
158: ; preds = %155
%159 = load i32*, i32** %8
%160 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i32 0, i32 0)
%161 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i32 0, i32 1)
%162 = sdiv i32 %161, 100
%163 = call i32 (i32*, i8*, ...) @fprintf(i32* %159, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i64 0, i64 0), i32 %160, i32 %162)
br label %169
164: ; preds = %155
%165 = load i32*, i32** %8
%166 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i32 0, i32 0)
%167 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i32 0, i32 1)
%168 = call i32 (i32*, i8*, ...) @fprintf(i32* %165, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.16, i64 0, i64 0), i32 %166, i32 %167)
br label %169
169: ; preds = %164, %158
%170 = load i32*, i32** %8
%171 = load i32, i32* @main.devno
%172 = call i32 (i32*, i8*, ...) @fprintf(i32* %170, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0), i32 %171)
%173 = getelementptr inbounds %struct.canfd_frame, %struct.canfd_frame* %6, i32 0, i32 0
%174 = load i32, i32* %173
%175 = load i32, i32* @CAN_ERR_FLAG
%176 = and i32 %174, %175
%177 = icmp ne i32 %176, 0
br i1 %177, label %178, label %181
178: ; preds = %169
%179 = load i32*, i32** %8
%180 = call i32 (i32*, i8*, ...) @fprintf(i32* %179, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.18, i64 0, i64 0))
br label %229
181: ; preds = %169
%182 = getelementptr inbounds %struct.canfd_frame, %struct.canfd_frame* %6, i32 0, i32 0
%183 = load i32, i32* %182
%184 = load i32, i32* @CAN_EFF_MASK
%185 = and i32 %183, %184
%186 = getelementptr inbounds %struct.canfd_frame, %struct.canfd_frame* %6, i32 0, i32 0
%187 = load i32, i32* %186
%188 = load i32, i32* @CAN_EFF_FLAG
%189 = and i32 %187, %188
%190 = icmp ne i32 %189, 0
%191 = zext i1 %190 to i64
%192 = select i1 %190, i32 120, i32 32
%193 = trunc i32 %192 to i8
%194 = call i32 @sprintf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @main.id, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.19, i64 0, i64 0), i32 %185, i8 signext %193)
%195 = load i32*, i32** %8
%196 = call i32 (i32*, i8*, ...) @fprintf(i32* %195, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.20, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @main.id, i64 0, i64 0))
%197 = getelementptr inbounds %struct.canfd_frame, %struct.canfd_frame* %6, i32 0, i32 0
%198 = load i32, i32* %197
%199 = load i32, i32* @CAN_RTR_FLAG
%200 = and i32 %198, %199
%201 = icmp ne i32 %200, 0
br i1 %201, label %202, label %205
202: ; preds = %181
%203 = load i32*, i32** %8
%204 = call i32 (i32*, i8*, ...) @fprintf(i32* %203, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %228
205: ; preds = %181
%206 = load i32*, i32** %8
%207 = getelementptr inbounds %struct.canfd_frame, %struct.canfd_frame* %6, i32 0, i32 1
%208 = load i32, i32* %207
%209 = call i32 (i32*, i8*, ...) @fprintf(i32* %206, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.21, i64 0, i64 0), i32 %208)
store i32 0, i32* @main.i
br label %210
210: ; preds = %224, %205
%211 = load i32, i32* @main.i
%212 = getelementptr inbounds %struct.canfd_frame, %struct.canfd_frame* %6, i32 0, i32 1
%213 = load i32, i32* %212
%214 = icmp slt i32 %211, %213
br i1 %214, label %215, label %227
215: ; preds = %210
%216 = load i32*, i32** %8
%217 = getelementptr inbounds %struct.canfd_frame, %struct.canfd_frame* %6, i32 0, i32 2
%218 = load i32*, i32** %217
%219 = load i32, i32* @main.i
%220 = sext i32 %219 to i64
%221 = getelementptr inbounds i32, i32* %218, i64 %220
%222 = load i32, i32* %221
%223 = call i32 (i32*, i8*, ...) @fprintf(i32* %216, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.22, i64 0, i64 0), i32 %222)
br label %224
224: ; preds = %215
%225 = load i32, i32* @main.i
%226 = add nsw i32 %225, 1
store i32 %226, i32* @main.i
br label %210
227: ; preds = %210
br label %228
228: ; preds = %227, %202
br label %229
229: ; preds = %228, %178
%230 = load i32, i32* @main.crlf
%231 = icmp ne i32 %230, 0
br i1 %231, label %232, label %235
232: ; preds = %229
%233 = load i32*, i32** %8
%234 = call i32 (i32*, i8*, ...) @fprintf(i32* %233, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.23, i64 0, i64 0))
br label %235
235: ; preds = %232, %229
%236 = load i32*, i32** %8
%237 = call i32 (i32*, i8*, ...) @fprintf(i32* %236, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
br label %238
238: ; preds = %235, %129
br label %67
239: ; preds = %67
%240 = load i32*, i32** %8
%241 = call i32 @fflush(i32* %240)
%242 = load i32*, i32** %8
%243 = call i32 @fclose(i32* %242)
%244 = load i32*, i32** %7
%245 = call i32 @fclose(i32* %244)
store i32 0, i32* %3
br label %246
246: ; preds = %239, %136, %85, %74, %58, %42, %36, %31, %23
%247 = load i32, i32* %3
ret i32 %247
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
%struct.canfd_frame = type { i32, i32, i32* }
@main.buf = internal global [400 x i8] zeroinitializer
@main.device = internal global [400 x i8] zeroinitializer
@main.ascframe = internal global [400 x i8] zeroinitializer
@main.id = internal global [10 x i8] zeroinitializer
@main.tv = internal global %struct.timeval zeroinitializer
@main.start_tv = internal global %struct.timeval zeroinitializer
@stdin = global i32* null
@stdout = global i32* null
@main.maxdev = internal unnamed_addr global i32 0
@main.devno = internal unnamed_addr global i32 0
@main.i = internal unnamed_addr global i32 0
@main.crlf = internal unnamed_addr global i1 false
@main.d4 = internal unnamed_addr global i1 false
@.str = [8 x i8] c"I:O:4n?\00"
@optarg = global i32 0
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [7 x i8] c"infile\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [8 x i8] c"outfile\00"
@stderr = global i32* null
@.str.5 = [19 x i8] c"Unknown option %c\0A\00"
@optind = global i32 0
@.str.6 = [28 x i8] c"no CAN interfaces defined!\0A\00"
@.str.7 = [32 x i8] c"line too long for input buffer\0A\00"
@.str.8 = [16 x i8] c"(%ld.%ld) %s %s\00"
@.str.9 = [34 x i8] c"incorrect line format in logfile\0A\00"
@.str.10 = [8 x i8] c"date %s\00"
@.str.11 = [32 x i8] c"base hex timestamps absolute%s\00"
@.str.12 = [3 x i8] c"\0D\0A\00"
@.str.13 = [2 x i8] c"\0A\00"
@.str.14 = [28 x i8] c"no internal events logged%s\00"
@CAN_MTU = global i64 0
@.str.15 = [12 x i8] c"%4ld.%04ld \00"
@.str.16 = [12 x i8] c"%4ld.%06ld \00"
@.str.17 = [6 x i8] c"%-2d \00"
@CAN_ERR_FLAG = global i32 0
@.str.18 = [11 x i8] c"ErrorFrame\00"
@.str.19 = [5 x i8] c"%X%c\00"
@CAN_EFF_MASK = global i32 0
@CAN_EFF_FLAG = global i32 0
@.str.20 = [12 x i8] c"%-15s Rx \00"
@CAN_RTR_FLAG = global i32 0
@.str.21 = [5 x i8] c"d %d\00"
@.str.22 = [6 x i8] c" %02X\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.canfd_frame
%4 = bitcast %struct.canfd_frame* %3 to i8*
%5 = load i32*, i32** @stdin
%6 = load i32*, i32** @stdout
br label %7
7: ; preds = %14, %2
%8 = phi i32* [ %16, %14 ], [ %5, %2 ]
%9 = phi i32* [ %11, %14 ], [ %6, %2 ]
br label %10
10: ; preds = %7, %20
%11 = phi i32* [ %9, %7 ], [ %22, %20 ]
br label %12
12: ; preds = %10, %37
%13 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
switch i32 %13, label %31 [
i32 -1, label %39
i32 73, label %14
i32 79, label %20
i32 110, label %37
i32 52, label %26
i32 63, label %27
]
14: ; preds = %12
%15 = load i32, i32* @optarg
%16 = tail call i32* @fopen(i32 %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %7
18: ; preds = %14
%19 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %186
20: ; preds = %12
%21 = load i32, i32* @optarg
%22 = tail call i32* @fopen(i32 %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %10
24: ; preds = %20
%25 = tail call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %186
26: ; preds = %12
br label %37
27: ; preds = %12
%28 = load i8*, i8** %1
%29 = tail call i32 @basename(i8* %28)
%30 = tail call i32 @print_usage(i32 %29)
br label %186
31: ; preds = %12
%32 = load i32*, i32** @stderr
%33 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %32, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %13)
%34 = load i8*, i8** %1
%35 = tail call i32 @basename(i8* %34)
%36 = tail call i32 @print_usage(i32 %35)
br label %186
37: ; preds = %12, %26
%38 = phi i1* [ @main.d4, %26 ], [ @main.crlf, %12 ]
store i1 true, i1* %38
br label %12
39: ; preds = %12
%40 = load i32, i32* @optind
%41 = sub nsw i32 %0, %40
store i32 %41, i32* @main.maxdev
%42 = icmp eq i32 %41, 0
br i1 %42, label %50, label %43
43: ; preds = %39
%44 = call i64 @fgets(i8* getelementptr inbounds ([400 x i8], [400 x i8]* @main.buf, i64 0, i64 0), i32 399, i32* %8)
%45 = icmp eq i64 %44, 0
br i1 %45, label %182, label %46
46: ; preds = %43
%47 = getelementptr inbounds %struct.canfd_frame, %struct.canfd_frame* %3, i64 0, i32 0
%48 = getelementptr inbounds %struct.canfd_frame, %struct.canfd_frame* %3, i64 0, i32 1
%49 = getelementptr inbounds %struct.canfd_frame, %struct.canfd_frame* %3, i64 0, i32 2
br label %56
50: ; preds = %39
%51 = load i32*, i32** @stderr
%52 = tail call i64 @fwrite(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i64 27, i64 1, i32* %51)
%53 = load i8*, i8** %1
%54 = tail call i32 @basename(i8* %53)
%55 = tail call i32 @print_usage(i32 %54)
br label %186
56: ; preds = %46, %179
%57 = call i32 @strlen(i8* getelementptr inbounds ([400 x i8], [400 x i8]* @main.buf, i64 0, i64 0))
%58 = icmp sgt i32 %57, 397
br i1 %58, label %59, label %62
59: ; preds = %56
%60 = load i32*, i32** @stderr
%61 = call i64 @fwrite(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.7, i64 0, i64 0), i64 31, i64 1, i32* %60)
br label %186
62: ; preds = %56
%63 = load i8, i8* getelementptr inbounds ([400 x i8], [400 x i8]* @main.buf, i64 0, i64 0)
%64 = icmp eq i8 %63, 40
br i1 %64, label %65, label %179
65: ; preds = %62
%66 = call i32 @sscanf(i8* getelementptr inbounds ([400 x i8], [400 x i8]* @main.buf, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0), i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i64 0, i32 0), i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i64 0, i32 1), i8* getelementptr inbounds ([400 x i8], [400 x i8]* @main.device, i64 0, i64 0), i8* getelementptr inbounds ([400 x i8], [400 x i8]* @main.ascframe, i64 0, i64 0))
%67 = icmp eq i32 %66, 4
br i1 %67, label %71, label %68
68: ; preds = %65
%69 = load i32*, i32** @stderr
%70 = call i64 @fwrite(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0), i64 33, i64 1, i32* %69)
br label %186
71: ; preds = %65
%72 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.start_tv, i64 0, i32 0)
%73 = icmp eq i32 %72, 0
br i1 %73, label %74, label %84
74: ; preds = %71
%75 = load i64, i64* bitcast (%struct.timeval* @main.tv to i64*)
store i64 %75, i64* bitcast (%struct.timeval* @main.start_tv to i64*)
%76 = call i8* @ctime(i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.start_tv, i64 0, i32 0))
%77 = call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0), i8* %76)
%78 = load i1, i1* @main.crlf
%79 = select i1 %78, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0)
%80 = call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.11, i64 0, i64 0), i8* %79)
%81 = load i1, i1* @main.crlf
%82 = select i1 %81, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.12, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0)
%83 = call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.14, i64 0, i64 0), i8* %82)
br label %84
84: ; preds = %74, %71
store i32 0, i32* @main.i
store i32 0, i32* @main.devno
%85 = load i32, i32* @main.maxdev
%86 = icmp sgt i32 %85, 0
br i1 %86, label %87, label %179
87: ; preds = %84
%88 = load i32, i32* @optind
%89 = sext i32 %88 to i64
%90 = zext i32 %85 to i64
br label %91
91: ; preds = %87, %98
%92 = phi i64 [ 0, %87 ], [ %99, %98 ]
%93 = add nsw i64 %92, %89
%94 = getelementptr inbounds i8*, i8** %1, i64 %93
%95 = load i8*, i8** %94
%96 = call i32 @strcmp(i8* dereferenceable(1) getelementptr inbounds ([400 x i8], [400 x i8]* @main.device, i64 0, i64 0), i8* dereferenceable(1) %95)
%97 = icmp eq i32 %96, 0
br i1 %97, label %102, label %98
98: ; preds = %91
%99 = add nuw nsw i64 %92, 1
%100 = trunc i64 %99 to i32
store i32 %100, i32* @main.i
%101 = icmp eq i64 %99, %90
br i1 %101, label %179, label %91
102: ; preds = %91
%103 = trunc i64 %92 to i32
%104 = add nuw nsw i32 %103, 1
store i32 %104, i32* @main.devno
%105 = call i64 @parse_canframe(i8* getelementptr inbounds ([400 x i8], [400 x i8]* @main.ascframe, i64 0, i64 0), %struct.canfd_frame* %3)
%106 = load i64, i64* @CAN_MTU
%107 = icmp eq i64 %105, %106
br i1 %107, label %108, label %186
108: ; preds = %102
%109 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i64 0, i32 0)
%110 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.start_tv, i64 0, i32 0)
%111 = sub nsw i32 %109, %110
store i32 %111, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i64 0, i32 0)
%112 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i64 0, i32 1)
%113 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.start_tv, i64 0, i32 1)
%114 = sub nsw i32 %112, %113
store i32 %114, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i64 0, i32 1)
%115 = icmp slt i32 %114, 0
br i1 %115, label %116, label %119
116: ; preds = %108
%117 = add nsw i32 %111, -1
store i32 %117, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i64 0, i32 0)
%118 = add nsw i32 %114, 1000000
store i32 %118, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i64 0, i32 1)
br label %119
119: ; preds = %108, %116
%120 = phi i32 [ %118, %116 ], [ %114, %108 ]
%121 = phi i32 [ %117, %116 ], [ %111, %108 ]
%122 = icmp slt i32 %121, 0
br i1 %122, label %123, label %124
123: ; preds = %119
store i32 0, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i64 0, i32 1)
store i32 0, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i64 0, i32 0)
br label %124
124: ; preds = %123, %119
%125 = phi i32 [ 0, %123 ], [ %120, %119 ]
%126 = phi i32 [ 0, %123 ], [ %121, %119 ]
%127 = load i1, i1* @main.d4
br i1 %127, label %128, label %131
128: ; preds = %124
%129 = sdiv i32 %125, 100
%130 = call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i64 0, i64 0), i32 %126, i32 %129)
br label %133
131: ; preds = %124
%132 = call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.16, i64 0, i64 0), i32 %126, i32 %125)
br label %133
133: ; preds = %131, %128
%134 = load i32, i32* @main.devno
%135 = call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0), i32 %134)
%136 = load i32, i32* %47
%137 = load i32, i32* @CAN_ERR_FLAG
%138 = and i32 %137, %136
%139 = icmp eq i32 %138, 0
br i1 %139, label %142, label %140
140: ; preds = %133
%141 = call i64 @fwrite(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.18, i64 0, i64 0), i64 10, i64 1, i32* %11)
br label %173
142: ; preds = %133
%143 = load i32, i32* @CAN_EFF_MASK
%144 = and i32 %143, %136
%145 = load i32, i32* @CAN_EFF_FLAG
%146 = and i32 %145, %136
%147 = icmp eq i32 %146, 0
%148 = select i1 %147, i8 32, i8 120
%149 = call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @main.id, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.19, i64 0, i64 0), i32 %144, i8 signext %148)
%150 = call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.20, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @main.id, i64 0, i64 0))
%151 = load i32, i32* %47
%152 = load i32, i32* @CAN_RTR_FLAG
%153 = and i32 %152, %151
%154 = icmp eq i32 %153, 0
br i1 %154, label %157, label %155
155: ; preds = %142
%156 = call i32 @fputc(i32 114, i32* %11)
br label %173
157: ; preds = %142
%158 = load i32, i32* %48
%159 = call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.21, i64 0, i64 0), i32 %158)
store i32 0, i32* @main.i
%160 = load i32, i32* %48
%161 = icmp sgt i32 %160, 0
br i1 %161, label %162, label %173
162: ; preds = %157, %162
%163 = phi i32 [ %170, %162 ], [ 0, %157 ]
%164 = load i32*, i32** %49
%165 = sext i32 %163 to i64
%166 = getelementptr inbounds i32, i32* %164, i64 %165
%167 = load i32, i32* %166
%168 = call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.22, i64 0, i64 0), i32 %167)
%169 = load i32, i32* @main.i
%170 = add nsw i32 %169, 1
store i32 %170, i32* @main.i
%171 = load i32, i32* %48
%172 = icmp slt i32 %170, %171
br i1 %172, label %162, label %173
173: ; preds = %162, %157, %155, %140
%174 = load i1, i1* @main.crlf
br i1 %174, label %175, label %177
175: ; preds = %173
%176 = call i32 @fputc(i32 13, i32* %11)
br label %177
177: ; preds = %175, %173
%178 = call i32 @fputc(i32 10, i32* %11)
br label %179
179: ; preds = %98, %84, %177, %62
%180 = call i64 @fgets(i8* getelementptr inbounds ([400 x i8], [400 x i8]* @main.buf, i64 0, i64 0), i32 399, i32* %8)
%181 = icmp eq i64 %180, 0
br i1 %181, label %182, label %56
182: ; preds = %179, %43
%183 = call i32 @fflush(i32* %11)
%184 = call i32 @fclose(i32* %11)
%185 = call i32 @fclose(i32* %8)
br label %186
186: ; preds = %102, %182, %68, %59, %50, %31, %27, %24, %18
%187 = phi i32 [ 1, %31 ], [ 0, %27 ], [ 1, %24 ], [ 1, %18 ], [ 1, %59 ], [ 1, %68 ], [ 0, %182 ], [ 1, %50 ], [ 1, %102 ]
ret i32 %187
}