#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 can_frame {
  int can_id;
  int can_dlc;
  int *data;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int CAN_EFF_FLAG;
int CAN_EFF_MASK;
int CAN_ERR_FLAG;
int CAN_RTR_FLAG;
int /*<<< orphan*/ basename(char *);
char *ctime(int *);
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 can_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 can_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))
        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.can_dlc);
          for (i = 0; i < cf.can_dlc; i++) {
            fprintf(outfile, " %02X", cf.data[i]);
          }
        }
      }
      if (crlf)
        fprintf(outfile, "\r");
      fprintf(outfile, "\n");
    }
  }
  fflush(outfile);
  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    0x2dd3(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    0x2d95(%rip),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xde0(%rip),%rdx
call   10e0 <getopt@plt>
mov    %eax,0x3369(%rip)
cmp    $0xffffffff,%eax
je     1390 <main+0x1b0>
mov    0x335a(%rip),%eax
mov    %eax,-0x34(%rbp)
sub    $0x34,%eax
je     1320 <main+0x140>
jmp    124b <main+0x6b>
mov    -0x34(%rbp),%eax
sub    $0x3f,%eax
je     132f <main+0x14f>
jmp    125c <main+0x7c>
mov    -0x34(%rbp),%eax
sub    $0x49,%eax
je     128f <main+0xaf>
jmp    126d <main+0x8d>
mov    -0x34(%rbp),%eax
sub    $0x4f,%eax
je     12d0 <main+0xf0>
jmp    127e <main+0x9e>
mov    -0x34(%rbp),%eax
sub    $0x6e,%eax
je     1311 <main+0x131>
jmp    134e <main+0x16e>
mov    0x2d62(%rip),%rax
mov    (%rax),%edi
lea    0xd69(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    12cb <main+0xeb>
lea    0xd50(%rip),%rdi
call   10d0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1852 <main+0x672>
jmp    138b <main+0x1ab>
mov    0x2d21(%rip),%rax
mov    (%rax),%edi
lea    0xd31(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    130c <main+0x12c>
lea    0xd18(%rip),%rdi
call   10d0 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1852 <main+0x672>
jmp    138b <main+0x1ab>
movl   $0x1,0x3271(%rip)
jmp    138b <main+0x1ab>
movl   $0x1,0x3266(%rip)
jmp    138b <main+0x1ab>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1080 <basename@plt>
mov    %eax,%edi
call   1100 <print_usage@plt>
movl   $0x0,-0x4(%rbp)
jmp    1852 <main+0x672>
mov    0x2c63(%rip),%rax
mov    (%rax),%rdi
mov    0x3236(%rip),%edx
lea    0xcb6(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1080 <basename@plt>
mov    %eax,%edi
call   1100 <print_usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1852 <main+0x672>
jmp    1212 <main+0x32>
mov    -0x8(%rbp),%eax
mov    0x2c2e(%rip),%rcx
sub    (%rcx),%eax
mov    %eax,0x31de(%rip)
cmpl   $0x0,0x31d7(%rip)
jne    13e6 <main+0x206>
mov    0x2c02(%rip),%rax
mov    (%rax),%rdi
lea    0xc6e(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1080 <basename@plt>
mov    %eax,%edi
call   1100 <print_usage@plt>
movl   $0x1,-0x4(%rbp)
jmp    1852 <main+0x672>
jmp    13eb <main+0x20b>
mov    -0x28(%rbp),%rdx
lea    0x2caa(%rip),%rdi
mov    $0x18f,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     1842 <main+0x662>
lea    0x2c8f(%rip),%rdi
call   1040 <strlen@plt>
cmp    $0x18e,%eax
jl     1445 <main+0x265>
mov    0x2b90(%rip),%rax
mov    (%rax),%rdi
lea    0xc18(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1852 <main+0x672>
movsbl 0x2c54(%rip),%eax
cmp    $0x28,%eax
je     145a <main+0x27a>
jmp    13eb <main+0x20b>
lea    0x2c3f(%rip),%rdi
lea    0xc02(%rip),%rsi
lea    0x30ed(%rip),%rdx
mov    %rdx,%rcx
add    $0x4,%rcx
lea    0x2db3(%rip),%r8
lea    0x2f3c(%rip),%r9
call   10b0 <sscanf@plt>
cmp    $0x4,%eax
je     14b6 <main+0x2d6>
mov    0x2b1f(%rip),%rax
mov    (%rax),%rdi
lea    0xbd7(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1852 <main+0x672>
cmpl   $0x0,0x30a7(%rip)
jne    1554 <main+0x374>
mov    0x3092(%rip),%rax
mov    %rax,0x3093(%rip)
mov    -0x30(%rbp),%rax
mov    %rax,-0x40(%rbp)
lea    0x3084(%rip),%rdi
call   1030 <ctime@plt>
mov    -0x40(%rbp),%rdi
mov    %rax,%rdx
lea    0xba9(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x30(%rbp),%rdi
mov    0x3088(%rip),%ecx
lea    0xbba(%rip),%rdx
lea    0xbb2(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
lea    0xb84(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x30(%rbp),%rdi
mov    0x305b(%rip),%ecx
lea    0xb8d(%rip),%rdx
lea    0xb85(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rdx
lea    0xb7a(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x0,0x302a(%rip)
movl   $0x0,0x301c(%rip)
mov    0x301a(%rip),%eax
cmp    0x300c(%rip),%eax
jge    15d6 <main+0x3f6>
mov    -0x10(%rbp),%rax
mov    0x2a43(%rip),%rcx
mov    (%rcx),%ecx
add    0x2ffb(%rip),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
lea    0x2c95(%rip),%rdi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    15bd <main+0x3dd>
mov    0x2fd9(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2fcc(%rip)
jmp    15d6 <main+0x3f6>
jmp    15c2 <main+0x3e2>
mov    0x2fc0(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2fb7(%rip)
jmp    1568 <main+0x388>
cmpl   $0x0,0x2fa7(%rip)
je     183d <main+0x65d>
lea    0x2dd6(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1090 <parse_canframe@plt>
cmp    $0x0,%rax
je     1609 <main+0x429>
movl   $0x1,-0x4(%rbp)
jmp    1852 <main+0x672>
mov    0x2f4d(%rip),%eax
sub    0x2f4f(%rip),%eax
mov    %eax,0x2f41(%rip)
mov    0x2f3f(%rip),%eax
sub    0x2f41(%rip),%eax
mov    %eax,0x2f33(%rip)
cmpl   $0x0,0x2f2c(%rip)
jge    165a <main+0x47a>
mov    0x2f1c(%rip),%eax
add    $0xffffffff,%eax
mov    %eax,0x2f13(%rip)
mov    0x2f11(%rip),%eax
add    $0xf4240,%eax
mov    %eax,0x2f06(%rip)
cmpl   $0x0,0x2efb(%rip)
jge    167b <main+0x49b>
movl   $0x0,0x2eef(%rip)
movl   $0x0,0x2ee1(%rip)
cmpl   $0x0,0x2f0e(%rip)
je     16bb <main+0x4db>
mov    -0x30(%rbp),%rdi
mov    0x2eca(%rip),%eax
mov    %eax,-0x44(%rbp)
mov    0x2ec5(%rip),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    -0x44(%rbp),%edx
mov    %eax,%ecx
lea    0xa34(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    16d9 <main+0x4f9>
mov    -0x30(%rbp),%rdi
mov    0x2e97(%rip),%edx
mov    0x2e95(%rip),%ecx
lea    0xa1d(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x30(%rbp),%rdi
mov    0x2ea1(%rip),%edx
lea    0xa11(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x20(%rbp),%eax
mov    0x28e5(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     171d <main+0x53d>
mov    -0x30(%rbp),%rdi
lea    0x9f0(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    180c <main+0x62c>
mov    -0x20(%rbp),%edx
mov    0x28b1(%rip),%rax
and    (%rax),%edx
mov    -0x20(%rbp),%esi
mov    0x287d(%rip),%rax
and    (%rax),%esi
mov    $0x20,%eax
mov    $0x78,%ecx
cmp    $0x0,%esi
cmovne %ecx,%eax
lea    0x2e04(%rip),%rdi
lea    0x9b9(%rip),%rsi
movsbl %al,%ecx
call   10f0 <sprintf@plt>
mov    -0x30(%rbp),%rdi
lea    0x9ab(%rip),%rsi
lea    0x2de3(%rip),%rdx
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x20(%rbp),%eax
mov    0x282a(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     17a0 <main+0x5c0>
mov    -0x30(%rbp),%rdi
lea    0x874(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    1807 <main+0x627>
mov    -0x30(%rbp),%rdi
mov    -0x1c(%rbp),%edx
lea    0x96f(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
movl   $0x0,0x2dc9(%rip)
mov    0x2dc3(%rip),%eax
cmp    -0x1c(%rbp),%eax
jge    1802 <main+0x622>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rax
movslq 0x2dab(%rip),%rcx
mov    (%rax,%rcx,4),%edx
lea    0x93b(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    0x2d94(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2d8b(%rip)
jmp    17bf <main+0x5df>
jmp    1807 <main+0x627>
jmp    180c <main+0x62c>
cmpl   $0x0,0x2d79(%rip)
je     182b <main+0x64b>
mov    -0x30(%rbp),%rdi
lea    0x904(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
mov    -0x30(%rbp),%rdi
lea    0x88f(%rip),%rsi
mov    $0x0,%al
call   1070 <fprintf@plt>
jmp    13eb <main+0x20b>
mov    -0x30(%rbp),%rdi
call   10a0 <fflush@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    0x2db6(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x10(%rsp)
mov    0x2d77(%rip),%rax
mov    (%rax),%rax
mov    %rax,0x8(%rsp)
lea    0xe38(%rip),%rbx
lea    0x335d(%rip),%r12
lea    0xdba(%rip),%r15
lea    0x3353(%rip),%r14
jmp    125b <main+0x5b>
nop
mov    %r12,%rcx
cmp    $0x6e,%eax
jne    12cd <main+0xcd>
movb   $0x1,(%rcx)
mov    %ebp,%edi
mov    %r13,%rsi
mov    %rbx,%rdx
call   10f0 <getopt@plt>
lea    -0x34(%rax),%ecx
cmp    $0x1b,%ecx
ja     1250 <main+0x50>
movslq (%r15,%rcx,4),%rcx
add    %r15,%rcx
jmp    *%rcx
mov    %r14,%rcx
jmp    1258 <main+0x58>
mov    0x2d73(%rip),%rax
mov    (%rax),%edi
lea    0xdea(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,0x10(%rsp)
test   %rax,%rax
jne    125b <main+0x5b>
jmp    1727 <main+0x527>
mov    0x2d4f(%rip),%rax
mov    (%rax),%edi
lea    0xdcf(%rip),%rsi
call   10d0 <fopen@plt>
mov    %rax,0x8(%rsp)
test   %rax,%rax
jne    125b <main+0x5b>
lea    0xdbb(%rip),%rdi
jmp    172e <main+0x52e>
cmp    $0xffffffff,%eax
jne    1316 <main+0x116>
mov    0x2cef(%rip),%rax
sub    (%rax),%ebp
mov    %ebp,0x32af(%rip)
je     16a9 <main+0x4a9>
lea    0x2dc2(%rip),%rdi
mov    $0x18f,%esi
mov    0x10(%rsp),%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     169b <main+0x49b>
lea    0x2da3(%rip),%r15
lea    0xe7e(%rip),%r12
jmp    137b <main+0x17b>
mov    0x2c9b(%rip),%rcx
mov    (%rcx),%rdi
lea    0xd64(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    16c9 <main+0x4c9>
mov    0x0(%r13),%rdi
call   1090 <basename@plt>
mov    %eax,%edi
call   1120 <print_usage@plt>
jmp    16a5 <main+0x4a5>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1050 <fputc@plt>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    $0x18f,%esi
mov    0x10(%rsp),%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     169b <main+0x49b>
mov    %r15,%rdi
call   1040 <strlen@plt>
cmp    $0x18e,%eax
jge    16ed <main+0x4ed>
cmpb   $0x28,0x2d1b(%rip)
jne    1360 <main+0x160>
mov    %r15,%rdi
lea    0xd39(%rip),%rsi
lea    0x31c8(%rip),%rdx
lea    0x31c5(%rip),%rcx
lea    0x2e8a(%rip),%r8
lea    0x3013(%rip),%r9
call   10c0 <sscanf@plt>
cmp    $0x4,%eax
jne    1705 <main+0x505>
cmpl   $0x0,0x31a6(%rip)
jne    1453 <main+0x253>
mov    0x3195(%rip),%rax
mov    %rax,0x3196(%rip)
lea    0x318f(%rip),%rdi
call   1030 <ctime@plt>
mov    0x8(%rsp),%rbx
mov    %rbx,%rdi
lea    0xd0f(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
cmpb   $0x0,0x318e(%rip)
lea    0xd20(%rip),%r14
mov    %r14,%rdx
lea    0xd15(%rip),%rbp
cmovne %rbp,%rdx
mov    %rbx,%rdi
lea    0xce7(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
cmpb   $0x0,0x3161(%rip)
mov    %r14,%rdx
cmovne %rbp,%rdx
mov    %rbx,%rdi
lea    0xceb(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
movl   $0x0,0x313b(%rip)
movl   $0x0,0x312d(%rip)
mov    0x3123(%rip),%ebx
test   %ebx,%ebx
jle    1360 <main+0x160>
mov    0x2b4c(%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   1070 <strcmp@plt>
test   %eax,%eax
je     14b8 <main+0x2b8>
add    $0x1,%rbp
mov    %ebp,0x30ea(%rip)
cmp    %rbp,%rbx
jne    1490 <main+0x290>
jmp    1360 <main+0x160>
add    $0x1,%ebp
mov    %ebp,0x30d3(%rip)
lea    0x2f08(%rip),%rdi
lea    0x18(%rsp),%rsi
call   10a0 <parse_canframe@plt>
test   %rax,%rax
jne    16d9 <main+0x4d9>
mov    0x308f(%rip),%edx
sub    0x3091(%rip),%edx
mov    %edx,0x3083(%rip)
mov    0x3081(%rip),%ecx
sub    0x3083(%rip),%ecx
mov    %ecx,0x3075(%rip)
jns    1516 <main+0x316>
add    $0xffffffff,%edx
mov    %edx,0x3066(%rip)
add    $0xf4240,%ecx
mov    %ecx,0x305e(%rip)
mov    0x8(%rsp),%rbx
mov    %r12,%r14
test   %edx,%edx
js     154e <main+0x34e>
cmpb   $0x1,0x3077(%rip)
jne    1566 <main+0x366>
movslq %ecx,%rax
imul   $0x51eb851f,%rax,%rcx
mov    %rcx,%rax
shr    $0x3f,%rax
sar    $0x25,%rcx
add    %eax,%ecx
mov    %rbx,%rdi
lea    0xc07(%rip),%rsi
jmp    1570 <main+0x370>
movq   $0x0,0x3017(%rip)
xor    %ecx,%ecx
xor    %edx,%edx
cmpb   $0x1,0x303c(%rip)
je     152b <main+0x32b>
mov    %rbx,%rdi
lea    0xbef(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x3017(%rip),%edx
mov    %rbx,%rdi
lea    0xbe4(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x18(%rsp),%eax
mov    0x2a47(%rip),%rcx
test   %eax,(%rcx)
je     15bb <main+0x3bb>
mov    $0xa,%esi
mov    $0x1,%edx
lea    0xbc3(%rip),%rdi
mov    %rbx,%rcx
call   1110 <fwrite@plt>
jmp    167c <main+0x47c>
mov    0x2a16(%rip),%rcx
mov    (%rcx),%edx
and    %eax,%edx
mov    0x29e3(%rip),%rcx
and    (%rcx),%eax
mov    $0x78,%ecx
mov    $0x20,%eax
cmove  %eax,%ecx
lea    0x2f7d(%rip),%rbp
mov    %rbp,%rdi
lea    0xb8f(%rip),%rsi
call   1100 <sprintf@plt>
mov    %rbx,%rdi
lea    0xb85(%rip),%rsi
mov    %rbp,%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x299b(%rip),%rax
mov    (%rax),%eax
test   %eax,0x18(%rsp)
je     1624 <main+0x424>
mov    $0x72,%edi
mov    %rbx,%rsi
call   1050 <fputc@plt>
jmp    167c <main+0x47c>
mov    0x1c(%rsp),%edx
mov    %rbx,%rdi
lea    0xb5b(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
movl   $0x0,0x2f55(%rip)
cmpl   $0x0,0x1c(%rsp)
jle    167c <main+0x47c>
xor    %eax,%eax
nopl   0x0(%rax)
mov    0x20(%rsp),%rcx
cltq
mov    (%rcx,%rax,4),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x2f2b(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2f22(%rip)
cmp    0x1c(%rsp),%eax
jl     1650 <main+0x450>
cmpb   $0x1,0x2f19(%rip)
jne    134a <main+0x14a>
mov    $0xd,%edi
mov    %rbx,%rsi
call   1050 <fputc@plt>
jmp    134a <main+0x14a>
mov    0x8(%rsp),%rdi
call   10b0 <fflush@plt>
xor    %eax,%eax
jmp    16de <main+0x4de>
mov    0x2908(%rip),%rax
mov    (%rax),%rcx
lea    0x9e4(%rip),%rdi
mov    $0x1b,%esi
mov    $0x1,%edx
call   1110 <fwrite@plt>
mov    0x0(%r13),%rdi
call   1090 <basename@plt>
mov    %eax,%edi
call   1120 <print_usage@plt>
mov    $0x1,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x28c4(%rip),%rax
mov    (%rax),%rcx
lea    0x9bc(%rip),%rdi
mov    $0x1f,%esi
jmp    171b <main+0x51b>
mov    0x28ac(%rip),%rax
mov    (%rax),%rcx
lea    0x9d4(%rip),%rdi
mov    $0x21,%esi
mov    $0x1,%edx
call   1110 <fwrite@plt>
jmp    16d9 <main+0x4d9>
lea    0x94c(%rip),%rdi
call   10e0 <perror@plt>
jmp    16d9 <main+0x4d9>

LLVM IR (-O0):
%struct.timeval = type { i32, i32 }
%struct.can_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"
@.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.can_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 %241
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 %241
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 %241
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 %241
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 %241
66: ; preds = %52
br label %67
67: ; preds = %237, %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 %238
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 %241
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 %241
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 %237
132: ; preds = %129
%133 = call i64 @parse_canframe(i8* getelementptr inbounds ([400 x i8], [400 x i8]* @main.ascframe, i64 0, i64 0), %struct.can_frame* %6)
%134 = icmp ne i64 %133, 0
br i1 %134, label %135, label %136
135: ; preds = %132
store i32 1, i32* %3
br label %241
136: ; preds = %132
%137 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i32 0, i32 0)
%138 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.start_tv, i32 0, i32 0)
%139 = sub nsw i32 %137, %138
store i32 %139, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i32 0, i32 0)
%140 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i32 0, i32 1)
%141 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.start_tv, i32 0, i32 1)
%142 = sub nsw i32 %140, %141
store i32 %142, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i32 0, i32 1)
%143 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i32 0, i32 1)
%144 = icmp slt i32 %143, 0
br i1 %144, label %145, label %150
145: ; preds = %136
%146 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i32 0, i32 0)
%147 = add nsw i32 %146, -1
store i32 %147, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i32 0, i32 0)
%148 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i32 0, i32 1)
%149 = add nsw i32 %148, 1000000
store i32 %149, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i32 0, i32 1)
br label %150
150: ; preds = %145, %136
%151 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i32 0, i32 0)
%152 = icmp slt i32 %151, 0
br i1 %152, label %153, label %154
153: ; preds = %150
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 %154
154: ; preds = %153, %150
%155 = load i32, i32* @main.d4
%156 = icmp ne i32 %155, 0
br i1 %156, label %157, label %163
157: ; preds = %154
%158 = load i32*, i32** %8
%159 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i32 0, i32 0)
%160 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i32 0, i32 1)
%161 = sdiv i32 %160, 100
%162 = call i32 (i32*, i8*, ...) @fprintf(i32* %158, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i64 0, i64 0), i32 %159, i32 %161)
br label %168
163: ; preds = %154
%164 = load i32*, i32** %8
%165 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i32 0, i32 0)
%166 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i32 0, i32 1)
%167 = call i32 (i32*, i8*, ...) @fprintf(i32* %164, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.16, i64 0, i64 0), i32 %165, i32 %166)
br label %168
168: ; preds = %163, %157
%169 = load i32*, i32** %8
%170 = load i32, i32* @main.devno
%171 = call i32 (i32*, i8*, ...) @fprintf(i32* %169, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0), i32 %170)
%172 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %6, i32 0, i32 0
%173 = load i32, i32* %172
%174 = load i32, i32* @CAN_ERR_FLAG
%175 = and i32 %173, %174
%176 = icmp ne i32 %175, 0
br i1 %176, label %177, label %180
177: ; preds = %168
%178 = load i32*, i32** %8
%179 = call i32 (i32*, i8*, ...) @fprintf(i32* %178, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.18, i64 0, i64 0))
br label %228
180: ; preds = %168
%181 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %6, i32 0, i32 0
%182 = load i32, i32* %181
%183 = load i32, i32* @CAN_EFF_MASK
%184 = and i32 %182, %183
%185 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %6, i32 0, i32 0
%186 = load i32, i32* %185
%187 = load i32, i32* @CAN_EFF_FLAG
%188 = and i32 %186, %187
%189 = icmp ne i32 %188, 0
%190 = zext i1 %189 to i64
%191 = select i1 %189, i32 120, i32 32
%192 = trunc i32 %191 to i8
%193 = 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 %184, i8 signext %192)
%194 = load i32*, i32** %8
%195 = call i32 (i32*, i8*, ...) @fprintf(i32* %194, 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))
%196 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %6, i32 0, i32 0
%197 = load i32, i32* %196
%198 = load i32, i32* @CAN_RTR_FLAG
%199 = and i32 %197, %198
%200 = icmp ne i32 %199, 0
br i1 %200, label %201, label %204
201: ; preds = %180
%202 = load i32*, i32** %8
%203 = call i32 (i32*, i8*, ...) @fprintf(i32* %202, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %227
204: ; preds = %180
%205 = load i32*, i32** %8
%206 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %6, i32 0, i32 1
%207 = load i32, i32* %206
%208 = call i32 (i32*, i8*, ...) @fprintf(i32* %205, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.21, i64 0, i64 0), i32 %207)
store i32 0, i32* @main.i
br label %209
209: ; preds = %223, %204
%210 = load i32, i32* @main.i
%211 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %6, i32 0, i32 1
%212 = load i32, i32* %211
%213 = icmp slt i32 %210, %212
br i1 %213, label %214, label %226
214: ; preds = %209
%215 = load i32*, i32** %8
%216 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %6, i32 0, i32 2
%217 = load i32*, i32** %216
%218 = load i32, i32* @main.i
%219 = sext i32 %218 to i64
%220 = getelementptr inbounds i32, i32* %217, i64 %219
%221 = load i32, i32* %220
%222 = call i32 (i32*, i8*, ...) @fprintf(i32* %215, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.22, i64 0, i64 0), i32 %221)
br label %223
223: ; preds = %214
%224 = load i32, i32* @main.i
%225 = add nsw i32 %224, 1
store i32 %225, i32* @main.i
br label %209
226: ; preds = %209
br label %227
227: ; preds = %226, %201
br label %228
228: ; preds = %227, %177
%229 = load i32, i32* @main.crlf
%230 = icmp ne i32 %229, 0
br i1 %230, label %231, label %234
231: ; preds = %228
%232 = load i32*, i32** %8
%233 = call i32 (i32*, i8*, ...) @fprintf(i32* %232, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.23, i64 0, i64 0))
br label %234
234: ; preds = %231, %228
%235 = load i32*, i32** %8
%236 = call i32 (i32*, i8*, ...) @fprintf(i32* %235, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
br label %237
237: ; preds = %234, %129
br label %67
238: ; preds = %67
%239 = load i32*, i32** %8
%240 = call i32 @fflush(i32* %239)
store i32 0, i32* %3
br label %241
241: ; preds = %238, %135, %85, %74, %58, %42, %36, %31, %23
%242 = load i32, i32* %3
ret i32 %242
}

LLVM IR (-O2):
%struct.timeval = type { i32, i32 }
%struct.can_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"
@.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.can_frame
%4 = bitcast %struct.can_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 %183
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 %183
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 %183
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 %183
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 %181, label %46
46: ; preds = %43
%47 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %3, i64 0, i32 0
%48 = getelementptr inbounds %struct.can_frame, %struct.can_frame* %3, i64 0, i32 1
%49 = getelementptr inbounds %struct.can_frame, %struct.can_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 %183
56: ; preds = %46, %178
%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 %183
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 %178
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 %183
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 %178
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 %178, 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.can_frame* %3)
%106 = icmp eq i64 %105, 0
br i1 %106, label %107, label %183
107: ; preds = %102
%108 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i64 0, i32 0)
%109 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.start_tv, i64 0, i32 0)
%110 = sub nsw i32 %108, %109
store i32 %110, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i64 0, i32 0)
%111 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i64 0, i32 1)
%112 = load i32, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.start_tv, i64 0, i32 1)
%113 = sub nsw i32 %111, %112
store i32 %113, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i64 0, i32 1)
%114 = icmp slt i32 %113, 0
br i1 %114, label %115, label %118
115: ; preds = %107
%116 = add nsw i32 %110, -1
store i32 %116, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i64 0, i32 0)
%117 = add nsw i32 %113, 1000000
store i32 %117, i32* getelementptr inbounds (%struct.timeval, %struct.timeval* @main.tv, i64 0, i32 1)
br label %118
118: ; preds = %107, %115
%119 = phi i32 [ %117, %115 ], [ %113, %107 ]
%120 = phi i32 [ %116, %115 ], [ %110, %107 ]
%121 = icmp slt i32 %120, 0
br i1 %121, label %122, label %123
122: ; preds = %118
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 %123
123: ; preds = %122, %118
%124 = phi i32 [ 0, %122 ], [ %119, %118 ]
%125 = phi i32 [ 0, %122 ], [ %120, %118 ]
%126 = load i1, i1* @main.d4
br i1 %126, label %127, label %130
127: ; preds = %123
%128 = sdiv i32 %124, 100
%129 = call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.15, i64 0, i64 0), i32 %125, i32 %128)
br label %132
130: ; preds = %123
%131 = call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.16, i64 0, i64 0), i32 %125, i32 %124)
br label %132
132: ; preds = %130, %127
%133 = load i32, i32* @main.devno
%134 = call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.17, i64 0, i64 0), i32 %133)
%135 = load i32, i32* %47
%136 = load i32, i32* @CAN_ERR_FLAG
%137 = and i32 %136, %135
%138 = icmp eq i32 %137, 0
br i1 %138, label %141, label %139
139: ; preds = %132
%140 = 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 %172
141: ; preds = %132
%142 = load i32, i32* @CAN_EFF_MASK
%143 = and i32 %142, %135
%144 = load i32, i32* @CAN_EFF_FLAG
%145 = and i32 %144, %135
%146 = icmp eq i32 %145, 0
%147 = select i1 %146, i8 32, i8 120
%148 = 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 %143, i8 signext %147)
%149 = 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))
%150 = load i32, i32* %47
%151 = load i32, i32* @CAN_RTR_FLAG
%152 = and i32 %151, %150
%153 = icmp eq i32 %152, 0
br i1 %153, label %156, label %154
154: ; preds = %141
%155 = call i32 @fputc(i32 114, i32* %11)
br label %172
156: ; preds = %141
%157 = load i32, i32* %48
%158 = call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.21, i64 0, i64 0), i32 %157)
store i32 0, i32* @main.i
%159 = load i32, i32* %48
%160 = icmp sgt i32 %159, 0
br i1 %160, label %161, label %172
161: ; preds = %156, %161
%162 = phi i32 [ %169, %161 ], [ 0, %156 ]
%163 = load i32*, i32** %49
%164 = sext i32 %162 to i64
%165 = getelementptr inbounds i32, i32* %163, i64 %164
%166 = load i32, i32* %165
%167 = call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.22, i64 0, i64 0), i32 %166)
%168 = load i32, i32* @main.i
%169 = add nsw i32 %168, 1
store i32 %169, i32* @main.i
%170 = load i32, i32* %48
%171 = icmp slt i32 %169, %170
br i1 %171, label %161, label %172
172: ; preds = %161, %156, %154, %139
%173 = load i1, i1* @main.crlf
br i1 %173, label %174, label %176
174: ; preds = %172
%175 = call i32 @fputc(i32 13, i32* %11)
br label %176
176: ; preds = %174, %172
%177 = call i32 @fputc(i32 10, i32* %11)
br label %178
178: ; preds = %98, %84, %176, %62
%179 = call i64 @fgets(i8* getelementptr inbounds ([400 x i8], [400 x i8]* @main.buf, i64 0, i64 0), i32 399, i32* %8)
%180 = icmp eq i64 %179, 0
br i1 %180, label %181, label %56
181: ; preds = %178, %43
%182 = call i32 @fflush(i32* %11)
br label %183
183: ; preds = %102, %181, %68, %59, %50, %31, %27, %24, %18
%184 = phi i32 [ 1, %31 ], [ 0, %27 ], [ 1, %24 ], [ 1, %18 ], [ 1, %59 ], [ 1, %68 ], [ 0, %181 ], [ 1, %50 ], [ 1, %102 ]
ret i32 %184
}