#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
unsigned int buf_uint(unsigned char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(unsigned char *);
int fsize(int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  FILE *infile;
  char filename_mem[80], filename_nopath[80];
  unsigned char *buf;
  FILE *file_mem;
  int infile_size, buf_size, i, j;
  int ret;
  int buf_pos;
  unsigned int incl_len;
  unsigned int orig_len;
  int mem_pos = 0;
  if (argc < 2) {
    fprintf(stderr, "ERROR: no input file specified. Quitting\n");
    exit(1);
  }
  infile = fopen(argv[1], "rb");
  if (infile == NULL) {
    fprintf(stderr, "ERROR: Can't open %s. Quitting\n", argv[1]);
    exit(1);
  }
  infile_size = fsize(infile);
  buf = (unsigned char *)malloc(infile_size);
  buf_size = fread(buf, 1, infile_size, infile);
  fclose(infile);
  if (buf_size != infile_size) {
    fprintf(stderr,
            "%s ERROR: Input %s file length is %d bytes long, buffer read "
            "buf_size %d\n",
            argv[0], argv[1], infile_size, buf_size);
    exit(1);
  }
  if (infile_size > 0x1000000) {
    fprintf(stderr,
            "%s WARNING: Input %s file length is %d bytes long, greater than "
            "boot-loader can handle \n",
            argv[0], argv[1], infile_size);
  }
  buf_pos = 6 * 4;
  while (buf_pos < infile_size) {
    buf_pos = buf_pos + 8;
    incl_len = buf_uint(&buf[buf_pos]);
    buf_pos += 4;
    orig_len = buf_uint(&buf[buf_pos]);
    buf_pos += 4;
    if (incl_len != orig_len) {
      fprintf(
          stderr,
          "Warning: the full packet was not captured in the tcpdump file\n");
      fprintf(stderr, "incl_len %d != orig_len %d\n", incl_len, orig_len);
    }
    if (orig_len > 255) {
      fprintf(stderr,
              "Error: the packet is too long. Max length is 255 bytes\n");
      fprintf(stderr, "orig_len %d\n", orig_len);
      goto error_return;
    }
    if (buf_pos + incl_len > infile_size) {
      fprintf(stderr,
              "Error: end of current packet is after the end of the buffer\n");
      goto error_return;
    }
    printf("// incl_len %d, orig_len %d\n", incl_len, orig_len);
    printf("// ip-sa %d.%d.%d.%d, ip-da %d.%d.%d.%d, protocol %d\n",
           buf[buf_pos + 26], buf[buf_pos + 27], buf[buf_pos + 28],
           buf[buf_pos + 29], buf[buf_pos + 30], buf[buf_pos + 31],
           buf[buf_pos + 32], buf[buf_pos + 33], buf[buf_pos + 23]);
    printf("@%04x %02x\n", mem_pos++, orig_len);
    for (i = buf_pos; i < buf_pos + incl_len; i++, mem_pos++) {
      printf("@%04x %02x\n", mem_pos, buf[i]);
    }
    if (orig_len > incl_len) {
      for (i = incl_len; i < orig_len; i++, mem_pos++) {
        printf("@%04x 00\n", mem_pos);
      }
    }
    buf_pos += incl_len;
  }
  free(buf);
  return 0;
error_return:
  free(buf);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x118,%rsp
movl   $0x0,-0xc(%rbp)
mov    %edi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0xf4(%rbp)
cmpl   $0x2,-0x10(%rbp)
jge    11ef <main+0x4f>
mov    0x2e0b(%rip),%rax
mov    (%rax),%edi
lea    0xe22(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe2c(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    123b <main+0x9b>
mov    0x2dc7(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe03(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x20(%rbp),%rdi
call   10a0 <fsize@plt>
mov    %eax,-0xd4(%rbp)
mov    -0xd4(%rbp),%edi
call   1090 <malloc@plt>
mov    %rax,-0xc8(%rbp)
mov    -0xc8(%rbp),%rdi
mov    -0xd4(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    $0x1,%esi
call   1050 <fread@plt>
mov    %eax,-0xd8(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0xd8(%rbp),%eax
cmp    -0xd4(%rbp),%eax
je     12d6 <main+0x136>
mov    0x2d41(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%rdx
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rcx
mov    -0xd4(%rbp),%r8d
mov    -0xd8(%rbp),%r9d
lea    0xd88(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
cmpl   $0x1000000,-0xd4(%rbp)
jle    1313 <main+0x173>
mov    0x2cf3(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rax
mov    (%rax),%rdx
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rcx
mov    -0xd4(%rbp),%r8d
lea    0xd8b(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x18,-0xe8(%rbp)
mov    -0xe8(%rbp),%eax
cmp    -0xd4(%rbp),%eax
jge    1680 <main+0x4e0>
mov    -0xe8(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0xe8(%rbp)
mov    -0xc8(%rbp),%rdi
movslq -0xe8(%rbp),%rax
add    %rax,%rdi
call   1040 <buf_uint@plt>
mov    %eax,-0xec(%rbp)
mov    -0xe8(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0xe8(%rbp)
mov    -0xc8(%rbp),%rdi
movslq -0xe8(%rbp),%rax
add    %rax,%rdi
call   1040 <buf_uint@plt>
mov    %eax,-0xf0(%rbp)
mov    -0xe8(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0xe8(%rbp)
mov    -0xec(%rbp),%eax
cmp    -0xf0(%rbp),%eax
je     13e0 <main+0x240>
mov    0x2c33(%rip),%rax
mov    (%rax),%edi
lea    0xd3a(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2c1c(%rip),%rax
mov    (%rax),%edi
mov    -0xec(%rbp),%edx
mov    -0xf0(%rbp),%ecx
lea    0xd56(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
cmpl   $0xff,-0xf0(%rbp)
jbe    1429 <main+0x289>
mov    0x2be9(%rip),%rax
mov    (%rax),%edi
lea    0xd4b(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2bd2(%rip),%rax
mov    (%rax),%edi
mov    -0xf0(%rbp),%edx
lea    0xdb3(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    1698 <main+0x4f8>
mov    -0xe8(%rbp),%eax
add    -0xec(%rbp),%eax
cmp    -0xd4(%rbp),%eax
jbe    145d <main+0x2bd>
mov    0x2b98(%rip),%rax
mov    (%rax),%edi
lea    0xd32(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
jmp    1698 <main+0x4f8>
mov    -0xec(%rbp),%esi
mov    -0xf0(%rbp),%edx
lea    0xd50(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0xc8(%rbp),%rax
mov    -0xe8(%rbp),%ecx
add    $0x1a,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%esi
mov    -0xc8(%rbp),%rax
mov    -0xe8(%rbp),%ecx
add    $0x1b,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%edx
mov    -0xc8(%rbp),%rax
mov    -0xe8(%rbp),%ecx
add    $0x1c,%ecx
movslq %ecx,%rcx
movzbl (%rax,%rcx,1),%ecx
mov    -0xc8(%rbp),%rax
mov    -0xe8(%rbp),%edi
add    $0x1d,%edi
movslq %edi,%rdi
movzbl (%rax,%rdi,1),%r8d
mov    -0xc8(%rbp),%rax
mov    -0xe8(%rbp),%edi
add    $0x1e,%edi
movslq %edi,%rdi
movzbl (%rax,%rdi,1),%r9d
mov    -0xc8(%rbp),%rax
mov    -0xe8(%rbp),%edi
add    $0x1f,%edi
movslq %edi,%rdi
movzbl (%rax,%rdi,1),%ebx
mov    -0xc8(%rbp),%rax
mov    -0xe8(%rbp),%edi
add    $0x20,%edi
movslq %edi,%rdi
movzbl (%rax,%rdi,1),%r11d
mov    -0xc8(%rbp),%rax
mov    -0xe8(%rbp),%edi
add    $0x21,%edi
movslq %edi,%rdi
movzbl (%rax,%rdi,1),%r10d
mov    -0xc8(%rbp),%rax
mov    -0xe8(%rbp),%edi
add    $0x17,%edi
movslq %edi,%rdi
movzbl (%rax,%rdi,1),%eax
lea    0xc8c(%rip),%rdi
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0xf4(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0xf4(%rbp)
mov    -0xf0(%rbp),%edx
lea    0xc8c(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0xe8(%rbp),%eax
mov    %eax,-0xdc(%rbp)
mov    -0xdc(%rbp),%eax
mov    -0xe8(%rbp),%ecx
add    -0xec(%rbp),%ecx
cmp    %ecx,%eax
jae    15fd <main+0x45d>
mov    -0xf4(%rbp),%esi
mov    -0xc8(%rbp),%rax
movslq -0xdc(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
lea    0xc40(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0xdc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xdc(%rbp)
mov    -0xf4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf4(%rbp)
jmp    159a <main+0x3fa>
mov    -0xf0(%rbp),%eax
cmp    -0xec(%rbp),%eax
jbe    1669 <main+0x4c9>
mov    -0xec(%rbp),%eax
mov    %eax,-0xdc(%rbp)
mov    -0xdc(%rbp),%eax
cmp    -0xf0(%rbp),%eax
jae    1664 <main+0x4c4>
mov    -0xf4(%rbp),%esi
lea    0xbe5(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
mov    -0xdc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xdc(%rbp)
mov    -0xf4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf4(%rbp)
jmp    161b <main+0x47b>
jmp    1669 <main+0x4c9>
mov    -0xec(%rbp),%eax
add    -0xe8(%rbp),%eax
mov    %eax,-0xe8(%rbp)
jmp    131d <main+0x17d>
mov    -0xc8(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0xc(%rbp)
jmp    16ab <main+0x50b>
mov    -0xc8(%rbp),%rdi
call   1030 <free@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
add    $0x118,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
cmp    $0x1,%edi
jle    148b <main+0x2eb>
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
lea    0xe65(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     14ac <main+0x30c>
mov    %rax,%rbp
mov    %rax,%rdi
call   10a0 <fsize@plt>
mov    %eax,%r13d
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,0x18(%rsp)
mov    %rax,%rdi
mov    $0x1,%esi
mov    %r13d,%edx
mov    %rbp,%rcx
call   1050 <fread@plt>
mov    %eax,%r15d
mov    %rbp,%rdi
call   1060 <fclose@plt>
cmp    %r13d,%r15d
jne    14d1 <main+0x331>
cmp    $0x1000001,%r13d
jl     1240 <main+0xa0>
mov    0x2dbc(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
mov    0x8(%r14),%rcx
lea    0xe63(%rip),%rsi
mov    %r13d,%r8d
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    124c <main+0xac>
xor    %ebp,%ebp
cmp    $0x19,%r13d
jl     1470 <main+0x2d0>
mov    $0x18,%r12d
xor    %r14d,%r14d
mov    0x18(%rsp),%rbp
mov    %r13d,0xc(%rsp)
jmp    127e <main+0xde>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0xc(%rsp),%r13d
cmp    %r13d,%r12d
jge    1424 <main+0x284>
movslq %r12d,%rbx
lea    (%rbx,%rbp,1),%rdi
add    $0x8,%rdi
call   1040 <buf_uint@plt>
mov    %eax,%r15d
lea    (%rbx,%rbp,1),%rdi
add    $0xc,%rdi
call   1040 <buf_uint@plt>
mov    %r15,%rsi
mov    %eax,%r15d
cmp    %eax,%esi
je     12e7 <main+0x147>
mov    0x2d31(%rip),%rax
mov    (%rax),%edi
mov    %rsi,%r13
lea    0xe35(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    0x2d17(%rip),%rax
mov    (%rax),%edi
lea    0xe5d(%rip),%rsi
mov    %r13d,%edx
mov    %r15d,%ecx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    %r13,%rsi
mov    0xc(%rsp),%r13d
cmp    $0x100,%r15d
jae    1428 <main+0x288>
mov    %r13d,%eax
mov    %r12d,%r13d
add    $0x10,%r13d
lea    (%rsi,%r13,1),%r12d
cmp    %eax,%r12d
ja     1454 <main+0x2b4>
lea    0xeae(%rip),%rdi
mov    %rsi,0x20(%rsp)
mov    %r15d,%edx
xor    %eax,%eax
call   1070 <printf@plt>
movzbl 0x2a(%rbx,%rbp,1),%esi
movzbl 0x2b(%rbx,%rbp,1),%edx
movzbl 0x2c(%rbx,%rbp,1),%ecx
movzbl 0x2d(%rbx,%rbp,1),%r8d
movzbl 0x2e(%rbx,%rbp,1),%r9d
movzbl 0x2f(%rbx,%rbp,1),%eax
mov    %rax,0x10(%rsp)
movzbl 0x30(%rbx,%rbp,1),%r11d
movzbl 0x31(%rbx,%rbp,1),%r10d
movzbl 0x27(%rbx,%rbp,1),%ebx
lea    0xe7f(%rip),%rdi
xor    %eax,%eax
push   %rbx
push   %r10
push   %r11
push   0x28(%rsp)
call   1070 <printf@plt>
add    $0x20,%rsp
lea    0xe9a(%rip),%rdi
mov    %r14d,%esi
mov    %r15d,0x10(%rsp)
mov    %r15d,%edx
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%r14d
cmp    %r12d,%r13d
jae    13d1 <main+0x231>
movslq %r13d,%rbx
add    %rbp,%rbx
lea    0xe72(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl (%rbx),%edx
mov    %r15,%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%r14d
add    $0x1,%rbx
add    $0x1,%r13d
cmp    %r13d,%r12d
ja     13b0 <main+0x210>
mov    0x10(%rsp),%eax
mov    %eax,%ebx
mov    0x20(%rsp),%rcx
sub    %ecx,%ebx
jbe    1270 <main+0xd0>
add    %r14d,%eax
sub    %ecx,%eax
mov    %eax,0x10(%rsp)
mov    0xc(%rsp),%r13d
lea    0xe26(%rip),%r15
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1070 <printf@plt>
add    $0x1,%r14d
add    $0xffffffff,%ebx
jne    1400 <main+0x260>
mov    0x10(%rsp),%r14d
cmp    %r13d,%r12d
jl     127e <main+0xde>
xor    %ebp,%ebp
jmp    1470 <main+0x2d0>
mov    0x2bb1(%rip),%rbx
mov    (%rbx),%edi
lea    0xd13(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    (%rbx),%edi
lea    0xd88(%rip),%rsi
mov    %r15d,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
jmp    146b <main+0x2cb>
mov    0x2b85(%rip),%rax
mov    (%rax),%edi
lea    0xd1f(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%ebp
mov    0x18(%rsp),%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2b4e(%rip),%rax
mov    (%rax),%edi
lea    0xb65(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    0x2b2d(%rip),%rax
mov    (%rax),%edi
mov    0x8(%r14),%rdx
lea    0xb6d(%rip),%rsi
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    0x2b08(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
mov    0x8(%r14),%rcx
lea    0xb65(%rip),%rsi
mov    %r13d,%r8d
mov    %r15d,%r9d
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [42 x i8] c"ERROR: no input file specified. Quitting\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [32 x i8] c"ERROR: Can't open %s. Quitting\0A\00"
@.str.3 = [74 x i8] c"%s ERROR: Input %s file length is %d bytes long, buffer read buf_size %d\0A\00"
@.str.4 = [89 x i8] c"%s WARNING: Input %s file length is %d bytes long, greater than boot-loader can handle \0A\00"
@.str.5 = [63 x i8] c"Warning: the full packet was not captured in the tcpdump file\0A\00"
@.str.6 = [28 x i8] c"incl_len %d != orig_len %d\0A\00"
@.str.7 = [56 x i8] c"Error: the packet is too long. Max length is 255 bytes\0A\00"
@.str.8 = [13 x i8] c"orig_len %d\0A\00"
@.str.9 = [61 x i8] c"Error: end of current packet is after the end of the buffer\0A\00"
@.str.10 = [29 x i8] c"// incl_len %d, orig_len %d\0A\00"
@.str.11 = [54 x i8] c"// ip-sa %d.%d.%d.%d, ip-da %d.%d.%d.%d, protocol %d\0A\00"
@.str.12 = [12 x i8] c"@%04x %02x\0A\00"
@.str.13 = [10 x i8] c"@%04x 00\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [80 x i8]
%8 = alloca [80 x i8]
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %19
%20 = load i32, i32* %4
%21 = icmp slt i32 %20, 2
br i1 %21, label %22, label %26
22: ; preds = %2
%23 = load i32, i32* @stderr
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %2
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 1
%29 = load i8*, i8** %28
%30 = call i32* @fopen(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %30, i32** %6
%31 = load i32*, i32** %6
%32 = icmp eq i32* %31, null
br i1 %32, label %33, label %40
33: ; preds = %26
%34 = load i32, i32* @stderr
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %37)
%39 = call i32 @exit(i32 1)
unreachable
40: ; preds = %26
%41 = load i32*, i32** %6
%42 = call i32 @fsize(i32* %41)
store i32 %42, i32* %11
%43 = load i32, i32* %11
%44 = call i64 @malloc(i32 %43)
%45 = inttoptr i64 %44 to i8*
store i8* %45, i8** %9
%46 = load i8*, i8** %9
%47 = load i32, i32* %11
%48 = load i32*, i32** %6
%49 = call i32 @fread(i8* %46, i32 1, i32 %47, i32* %48)
store i32 %49, i32* %12
%50 = load i32*, i32** %6
%51 = call i32 @fclose(i32* %50)
%52 = load i32, i32* %12
%53 = load i32, i32* %11
%54 = icmp ne i32 %52, %53
br i1 %54, label %55, label %67
55: ; preds = %40
%56 = load i32, i32* @stderr
%57 = load i8**, i8*** %5
%58 = getelementptr inbounds i8*, i8** %57, i64 0
%59 = load i8*, i8** %58
%60 = load i8**, i8*** %5
%61 = getelementptr inbounds i8*, i8** %60, i64 1
%62 = load i8*, i8** %61
%63 = load i32, i32* %11
%64 = load i32, i32* %12
%65 = call i32 (i32, i8*, ...) @fprintf(i32 %56, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.3, i64 0, i64 0), i8* %59, i8* %62, i32 %63, i32 %64)
%66 = call i32 @exit(i32 1)
unreachable
67: ; preds = %40
%68 = load i32, i32* %11
%69 = icmp sgt i32 %68, 16777216
br i1 %69, label %70, label %80
70: ; preds = %67
%71 = load i32, i32* @stderr
%72 = load i8**, i8*** %5
%73 = getelementptr inbounds i8*, i8** %72, i64 0
%74 = load i8*, i8** %73
%75 = load i8**, i8*** %5
%76 = getelementptr inbounds i8*, i8** %75, i64 1
%77 = load i8*, i8** %76
%78 = load i32, i32* %11
%79 = call i32 (i32, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.4, i64 0, i64 0), i8* %74, i8* %77, i32 %78)
br label %80
80: ; preds = %70, %67
store i32 24, i32* %16
br label %81
81: ; preds = %242, %80
%82 = load i32, i32* %16
%83 = load i32, i32* %11
%84 = icmp slt i32 %82, %83
br i1 %84, label %85, label %246
85: ; preds = %81
%86 = load i32, i32* %16
%87 = add nsw i32 %86, 8
store i32 %87, i32* %16
%88 = load i8*, i8** %9
%89 = load i32, i32* %16
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds i8, i8* %88, i64 %90
%92 = call i32 @buf_uint(i8* %91)
store i32 %92, i32* %17
%93 = load i32, i32* %16
%94 = add nsw i32 %93, 4
store i32 %94, i32* %16
%95 = load i8*, i8** %9
%96 = load i32, i32* %16
%97 = sext i32 %96 to i64
%98 = getelementptr inbounds i8, i8* %95, i64 %97
%99 = call i32 @buf_uint(i8* %98)
store i32 %99, i32* %18
%100 = load i32, i32* %16
%101 = add nsw i32 %100, 4
store i32 %101, i32* %16
%102 = load i32, i32* %17
%103 = load i32, i32* %18
%104 = icmp ne i32 %102, %103
br i1 %104, label %105, label %112
105: ; preds = %85
%106 = load i32, i32* @stderr
%107 = call i32 (i32, i8*, ...) @fprintf(i32 %106, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.5, i64 0, i64 0))
%108 = load i32, i32* @stderr
%109 = load i32, i32* %17
%110 = load i32, i32* %18
%111 = call i32 (i32, i8*, ...) @fprintf(i32 %108, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i32 %109, i32 %110)
br label %112
112: ; preds = %105, %85
%113 = load i32, i32* %18
%114 = icmp ugt i32 %113, 255
br i1 %114, label %115, label %121
115: ; preds = %112
%116 = load i32, i32* @stderr
%117 = call i32 (i32, i8*, ...) @fprintf(i32 %116, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.7, i64 0, i64 0))
%118 = load i32, i32* @stderr
%119 = load i32, i32* %18
%120 = call i32 (i32, i8*, ...) @fprintf(i32 %118, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32 %119)
br label %249
121: ; preds = %112
%122 = load i32, i32* %16
%123 = load i32, i32* %17
%124 = add i32 %122, %123
%125 = load i32, i32* %11
%126 = icmp ugt i32 %124, %125
br i1 %126, label %127, label %130
127: ; preds = %121
%128 = load i32, i32* @stderr
%129 = call i32 (i32, i8*, ...) @fprintf(i32 %128, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.9, i64 0, i64 0))
br label %249
130: ; preds = %121
%131 = load i32, i32* %17
%132 = load i32, i32* %18
%133 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i32 %131, i32 %132)
%134 = load i8*, i8** %9
%135 = load i32, i32* %16
%136 = add nsw i32 %135, 26
%137 = sext i32 %136 to i64
%138 = getelementptr inbounds i8, i8* %134, i64 %137
%139 = load i8, i8* %138
%140 = zext i8 %139 to i32
%141 = load i8*, i8** %9
%142 = load i32, i32* %16
%143 = add nsw i32 %142, 27
%144 = sext i32 %143 to i64
%145 = getelementptr inbounds i8, i8* %141, i64 %144
%146 = load i8, i8* %145
%147 = zext i8 %146 to i32
%148 = load i8*, i8** %9
%149 = load i32, i32* %16
%150 = add nsw i32 %149, 28
%151 = sext i32 %150 to i64
%152 = getelementptr inbounds i8, i8* %148, i64 %151
%153 = load i8, i8* %152
%154 = zext i8 %153 to i32
%155 = load i8*, i8** %9
%156 = load i32, i32* %16
%157 = add nsw i32 %156, 29
%158 = sext i32 %157 to i64
%159 = getelementptr inbounds i8, i8* %155, i64 %158
%160 = load i8, i8* %159
%161 = zext i8 %160 to i32
%162 = load i8*, i8** %9
%163 = load i32, i32* %16
%164 = add nsw i32 %163, 30
%165 = sext i32 %164 to i64
%166 = getelementptr inbounds i8, i8* %162, i64 %165
%167 = load i8, i8* %166
%168 = zext i8 %167 to i32
%169 = load i8*, i8** %9
%170 = load i32, i32* %16
%171 = add nsw i32 %170, 31
%172 = sext i32 %171 to i64
%173 = getelementptr inbounds i8, i8* %169, i64 %172
%174 = load i8, i8* %173
%175 = zext i8 %174 to i32
%176 = load i8*, i8** %9
%177 = load i32, i32* %16
%178 = add nsw i32 %177, 32
%179 = sext i32 %178 to i64
%180 = getelementptr inbounds i8, i8* %176, i64 %179
%181 = load i8, i8* %180
%182 = zext i8 %181 to i32
%183 = load i8*, i8** %9
%184 = load i32, i32* %16
%185 = add nsw i32 %184, 33
%186 = sext i32 %185 to i64
%187 = getelementptr inbounds i8, i8* %183, i64 %186
%188 = load i8, i8* %187
%189 = zext i8 %188 to i32
%190 = load i8*, i8** %9
%191 = load i32, i32* %16
%192 = add nsw i32 %191, 23
%193 = sext i32 %192 to i64
%194 = getelementptr inbounds i8, i8* %190, i64 %193
%195 = load i8, i8* %194
%196 = zext i8 %195 to i32
%197 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.11, i64 0, i64 0), i32 %140, i32 %147, i32 %154, i32 %161, i32 %168, i32 %175, i32 %182, i32 %189, i32 %196)
%198 = load i32, i32* %19
%199 = add nsw i32 %198, 1
store i32 %199, i32* %19
%200 = load i32, i32* %18
%201 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0), i32 %198, i32 %200)
%202 = load i32, i32* %16
store i32 %202, i32* %13
br label %203
203: ; preds = %218, %130
%204 = load i32, i32* %13
%205 = load i32, i32* %16
%206 = load i32, i32* %17
%207 = add i32 %205, %206
%208 = icmp ult i32 %204, %207
br i1 %208, label %209, label %223
209: ; preds = %203
%210 = load i32, i32* %19
%211 = load i8*, i8** %9
%212 = load i32, i32* %13
%213 = sext i32 %212 to i64
%214 = getelementptr inbounds i8, i8* %211, i64 %213
%215 = load i8, i8* %214
%216 = zext i8 %215 to i32
%217 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0), i32 %210, i32 %216)
br label %218
218: ; preds = %209
%219 = load i32, i32* %13
%220 = add nsw i32 %219, 1
store i32 %220, i32* %13
%221 = load i32, i32* %19
%222 = add nsw i32 %221, 1
store i32 %222, i32* %19
br label %203
223: ; preds = %203
%224 = load i32, i32* %18
%225 = load i32, i32* %17
%226 = icmp ugt i32 %224, %225
br i1 %226, label %227, label %242
227: ; preds = %223
%228 = load i32, i32* %17
store i32 %228, i32* %13
br label %229
229: ; preds = %236, %227
%230 = load i32, i32* %13
%231 = load i32, i32* %18
%232 = icmp ult i32 %230, %231
br i1 %232, label %233, label %241
233: ; preds = %229
%234 = load i32, i32* %19
%235 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i64 0, i64 0), i32 %234)
br label %236
236: ; preds = %233
%237 = load i32, i32* %13
%238 = add nsw i32 %237, 1
store i32 %238, i32* %13
%239 = load i32, i32* %19
%240 = add nsw i32 %239, 1
store i32 %240, i32* %19
br label %229
241: ; preds = %229
br label %242
242: ; preds = %241, %223
%243 = load i32, i32* %17
%244 = load i32, i32* %16
%245 = add i32 %244, %243
store i32 %245, i32* %16
br label %81
246: ; preds = %81
%247 = load i8*, i8** %9
%248 = call i32 @free(i8* %247)
store i32 0, i32* %3
br label %252
249: ; preds = %127, %115
%250 = load i8*, i8** %9
%251 = call i32 @free(i8* %250)
store i32 1, i32* %3
br label %252
252: ; preds = %249, %246
%253 = load i32, i32* %3
ret i32 %253
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [42 x i8] c"ERROR: no input file specified. Quitting\0A\00"
@.str.1 = [3 x i8] c"rb\00"
@.str.2 = [32 x i8] c"ERROR: Can't open %s. Quitting\0A\00"
@.str.3 = [74 x i8] c"%s ERROR: Input %s file length is %d bytes long, buffer read buf_size %d\0A\00"
@.str.4 = [89 x i8] c"%s WARNING: Input %s file length is %d bytes long, greater than boot-loader can handle \0A\00"
@.str.5 = [63 x i8] c"Warning: the full packet was not captured in the tcpdump file\0A\00"
@.str.6 = [28 x i8] c"incl_len %d != orig_len %d\0A\00"
@.str.7 = [56 x i8] c"Error: the packet is too long. Max length is 255 bytes\0A\00"
@.str.8 = [13 x i8] c"orig_len %d\0A\00"
@.str.9 = [61 x i8] c"Error: end of current packet is after the end of the buffer\0A\00"
@.str.10 = [29 x i8] c"// incl_len %d, orig_len %d\0A\00"
@.str.11 = [54 x i8] c"// ip-sa %d.%d.%d.%d, ip-da %d.%d.%d.%d, protocol %d\0A\00"
@.str.12 = [12 x i8] c"@%04x %02x\0A\00"
@.str.13 = [10 x i8] c"@%04x 00\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @exit(i32 1)
unreachable
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %18
13: ; preds = %8
%14 = load i32, i32* @stderr
%15 = load i8*, i8** %9
%16 = tail call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i8* %15)
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %8
%19 = tail call i32 @fsize(i32* %11)
%20 = tail call i64 @malloc(i32 %19)
%21 = inttoptr i64 %20 to i8*
%22 = tail call i32 @fread(i8* %21, i32 1, i32 %19, i32* %11)
%23 = tail call i32 @fclose(i32* %11)
%24 = icmp eq i32 %22, %19
br i1 %24, label %31, label %25
25: ; preds = %18
%26 = load i32, i32* @stderr
%27 = load i8*, i8** %1
%28 = load i8*, i8** %9
%29 = tail call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.3, i64 0, i64 0), i8* %27, i8* %28, i32 %19, i32 %22)
%30 = tail call i32 @exit(i32 1)
unreachable
31: ; preds = %18
%32 = icmp sgt i32 %19, 16777216
br i1 %32, label %33, label %38
33: ; preds = %31
%34 = load i32, i32* @stderr
%35 = load i8*, i8** %1
%36 = load i8*, i8** %9
%37 = tail call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.4, i64 0, i64 0), i8* %35, i8* %36, i32 %19)
br label %40
38: ; preds = %31
%39 = icmp sgt i32 %19, 24
br i1 %39, label %40, label %150
40: ; preds = %33, %38
br label %41
41: ; preds = %40, %147
%42 = phi i32 [ %148, %147 ], [ 0, %40 ]
%43 = phi i32 [ %67, %147 ], [ 24, %40 ]
%44 = add nsw i32 %43, 8
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds i8, i8* %21, i64 %45
%47 = tail call i32 @buf_uint(i8* %46)
%48 = add nsw i32 %43, 12
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %21, i64 %49
%51 = tail call i32 @buf_uint(i8* %50)
%52 = add i32 %43, 16
%53 = icmp eq i32 %47, %51
br i1 %53, label %59, label %54
54: ; preds = %41
%55 = load i32, i32* @stderr
%56 = tail call i32 (i32, i8*, ...) @fprintf(i32 %55, i8* getelementptr inbounds ([63 x i8], [63 x i8]* @.str.5, i64 0, i64 0))
%57 = load i32, i32* @stderr
%58 = tail call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0), i32 %47, i32 %51)
br label %59
59: ; preds = %54, %41
%60 = icmp ugt i32 %51, 255
br i1 %60, label %61, label %66
61: ; preds = %59
%62 = load i32, i32* @stderr
%63 = tail call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.7, i64 0, i64 0))
%64 = load i32, i32* @stderr
%65 = tail call i32 (i32, i8*, ...) @fprintf(i32 %64, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i32 %51)
br label %150
66: ; preds = %59
%67 = add i32 %47, %52
%68 = icmp ugt i32 %67, %19
br i1 %68, label %69, label %72
69: ; preds = %66
%70 = load i32, i32* @stderr
%71 = tail call i32 (i32, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([61 x i8], [61 x i8]* @.str.9, i64 0, i64 0))
br label %150
72: ; preds = %66
%73 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.10, i64 0, i64 0), i32 %47, i32 %51)
%74 = add nsw i32 %43, 42
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i8, i8* %21, i64 %75
%77 = load i8, i8* %76
%78 = zext i8 %77 to i32
%79 = add nsw i32 %43, 43
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i8, i8* %21, i64 %80
%82 = load i8, i8* %81
%83 = zext i8 %82 to i32
%84 = add nsw i32 %43, 44
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i8, i8* %21, i64 %85
%87 = load i8, i8* %86
%88 = zext i8 %87 to i32
%89 = add nsw i32 %43, 45
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds i8, i8* %21, i64 %90
%92 = load i8, i8* %91
%93 = zext i8 %92 to i32
%94 = add nsw i32 %43, 46
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds i8, i8* %21, i64 %95
%97 = load i8, i8* %96
%98 = zext i8 %97 to i32
%99 = add nsw i32 %43, 47
%100 = sext i32 %99 to i64
%101 = getelementptr inbounds i8, i8* %21, i64 %100
%102 = load i8, i8* %101
%103 = zext i8 %102 to i32
%104 = add nsw i32 %43, 48
%105 = sext i32 %104 to i64
%106 = getelementptr inbounds i8, i8* %21, i64 %105
%107 = load i8, i8* %106
%108 = zext i8 %107 to i32
%109 = add nsw i32 %43, 49
%110 = sext i32 %109 to i64
%111 = getelementptr inbounds i8, i8* %21, i64 %110
%112 = load i8, i8* %111
%113 = zext i8 %112 to i32
%114 = add nsw i32 %43, 39
%115 = sext i32 %114 to i64
%116 = getelementptr inbounds i8, i8* %21, i64 %115
%117 = load i8, i8* %116
%118 = zext i8 %117 to i32
%119 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.11, i64 0, i64 0), i32 %78, i32 %83, i32 %88, i32 %93, i32 %98, i32 %103, i32 %108, i32 %113, i32 %118)
%120 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0), i32 %42, i32 %51)
%121 = add nsw i32 %42, 1
%122 = icmp ult i32 %52, %67
br i1 %122, label %123, label %136
123: ; preds = %72
%124 = sext i32 %52 to i64
br label %125
125: ; preds = %123, %125
%126 = phi i64 [ %124, %123 ], [ %132, %125 ]
%127 = phi i32 [ %121, %123 ], [ %133, %125 ]
%128 = getelementptr inbounds i8, i8* %21, i64 %126
%129 = load i8, i8* %128
%130 = zext i8 %129 to i32
%131 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.12, i64 0, i64 0), i32 %127, i32 %130)
%132 = add nsw i64 %126, 1
%133 = add nsw i32 %127, 1
%134 = trunc i64 %132 to i32
%135 = icmp ugt i32 %67, %134
br i1 %135, label %125, label %136
136: ; preds = %125, %72
%137 = phi i32 [ %121, %72 ], [ %133, %125 ]
%138 = icmp ugt i32 %51, %47
br i1 %138, label %139, label %147
139: ; preds = %136
%140 = add i32 %51, %137
%141 = sub i32 %140, %47
br label %142
142: ; preds = %139, %142
%143 = phi i32 [ %145, %142 ], [ %137, %139 ]
%144 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.13, i64 0, i64 0), i32 %143)
%145 = add i32 %143, 1
%146 = icmp eq i32 %145, %141
br i1 %146, label %147, label %142
147: ; preds = %142, %136
%148 = phi i32 [ %137, %136 ], [ %141, %142 ]
%149 = icmp slt i32 %67, %19
br i1 %149, label %41, label %150
150: ; preds = %147, %61, %69, %38
%151 = phi i32 [ 0, %38 ], [ 1, %69 ], [ 1, %61 ], [ 0, %147 ]
%152 = tail call i32 @free(i8* %21)
ret i32 %151
}