#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 scalar_t__ u_int64_t;
typedef int u_int32_t;
typedef int u_int16_t;
typedef int u_char;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, scalar_t__, int, int);
int fread(int *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  FILE *fraw, *fout;
  u_char buf[4096];
  u_int32_t secs, nsecs;
  u_int64_t tstamp;
  u_int64_t epoch = 0;
  u_int16_t len, caplen;
  int i = 0, j = 0, ret = 0;
  char filename[100];
  if (argc != 3) {
    printf("Uso: %s <fichero_RAW_de_entrada> <fichero_PCAP_de_salida>\n",
           argv[0]);
    exit(-1);
  }
  fraw = fopen(argv[1], "r");
  if (!fraw) {
    perror("fopen");
    exit(-1);
  }
  fout = fopen(argv[2], "w");
  if (!fout) {
    perror("fopen");
    fclose(fout);
    exit(-1);
  }
  i = 0;
  while (1) {
    if (fread(&secs, 1, sizeof(u_int32_t), fraw) != sizeof(u_int32_t)) {
      printf("Segundos\n");
      break;
    }
    if (fread(&nsecs, 1, sizeof(u_int32_t), fraw) != sizeof(u_int32_t)) {
      printf("Nanosegundos\n");
      break;
    }
    if (nsecs >= (1000000000)) {
      printf("Wrong NS value (file=%d,pkt=%d)\n", j, i);
    }
    if ((secs == 0) && (nsecs == 0)) {
      fread(&caplen, 1, sizeof(u_int16_t), fraw);
      fread(&len, 1, sizeof(u_int16_t), fraw);
      if (len != caplen)
        printf("Wrong padding format [len=%d,caplen=%d]\n", len, caplen);
      else
        printf("Padding de %d bytes\n", caplen);
      break;
    }
    if (epoch == 0)
      epoch = secs;
    if (fread(&caplen, 1, sizeof(u_int16_t), fraw) != sizeof(u_int16_t)) {
      printf("Caplen\n");
      break;
    }
    if (fread(&len, 1, sizeof(u_int16_t), fraw) != sizeof(u_int16_t)) {
      printf("Longitud\n");
      break;
    }
    tstamp = secs - epoch;
    tstamp *= 1000000000ul;
    tstamp += nsecs;
    if (len > 0) {
      ret = fread(buf, 1, len, fraw);
      if (ret != len) {
        printf("Lectura del paquete\n");
        break;
      }
    }
    fprintf(fout, "%lu\t%d\t%d\n", tstamp, len, caplen);
    i++;
  }
  printf("%d paquetes leidos\n", i);
  fclose(fout);
  fclose(fraw);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40b0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x4038(%rbp)
movl   $0x0,-0x4044(%rbp)
movl   $0x0,-0x4048(%rbp)
movl   $0x0,-0x404c(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     11db <main+0x6b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe51(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1214 <main+0xa4>
lea    0xe38(%rip),%rdi
call   1080 <perror@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe20(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1256 <main+0xe6>
lea    0xdff(%rip),%rdi
call   1080 <perror@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    $0xffffffff,%edi
call   1090 <exit@plt>
movl   $0x0,-0x4044(%rbp)
mov    -0x18(%rbp),%rcx
lea    -0x4024(%rbp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
call   1030 <fread@plt>
cltq
cmp    $0x4,%rax
je     1299 <main+0x129>
lea    0xdb8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    14ee <main+0x37e>
mov    -0x18(%rbp),%rcx
lea    -0x4028(%rbp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
call   1030 <fread@plt>
cltq
cmp    $0x4,%rax
je     12d2 <main+0x162>
lea    0xd89(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    14ee <main+0x37e>
cmpl   $0x3b9aca00,-0x4028(%rbp)
ca 9a 3b
jl     12fc <main+0x18c>
mov    -0x4048(%rbp),%esi
mov    -0x4044(%rbp),%edx
lea    0xd68(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x0,-0x4024(%rbp)
jne    1394 <main+0x224>
cmpl   $0x0,-0x4028(%rbp)
jne    1394 <main+0x224>
mov    -0x18(%rbp),%rcx
lea    -0x4040(%rbp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
call   1030 <fread@plt>
mov    -0x18(%rbp),%rcx
lea    -0x403c(%rbp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
call   1030 <fread@plt>
mov    -0x403c(%rbp),%eax
cmp    -0x4040(%rbp),%eax
je     137b <main+0x20b>
mov    -0x403c(%rbp),%esi
mov    -0x4040(%rbp),%edx
lea    0xd0f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    138f <main+0x21f>
mov    -0x4040(%rbp),%esi
lea    0xd1f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    14ee <main+0x37e>
cmpq   $0x0,-0x4038(%rbp)
jne    13b0 <main+0x240>
movslq -0x4024(%rbp),%rax
mov    %rax,-0x4038(%rbp)
mov    -0x18(%rbp),%rcx
lea    -0x4040(%rbp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
call   1030 <fread@plt>
cltq
cmp    $0x4,%rax
je     13e9 <main+0x279>
lea    0xcdf(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    14ee <main+0x37e>
mov    -0x18(%rbp),%rcx
lea    -0x403c(%rbp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
call   1030 <fread@plt>
cltq
cmp    $0x4,%rax
je     1422 <main+0x2b2>
lea    0xcae(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    14ee <main+0x37e>
movslq -0x4024(%rbp),%rax
sub    -0x4038(%rbp),%rax
mov    %rax,-0x4030(%rbp)
imul   $0x3b9aca00,-0x4030(%rbp),%rax
mov    %rax,-0x4030(%rbp)
movslq -0x4028(%rbp),%rax
add    -0x4030(%rbp),%rax
mov    %rax,-0x4030(%rbp)
cmpl   $0x0,-0x403c(%rbp)
jle    14b6 <main+0x346>
lea    -0x4020(%rbp),%rdi
mov    -0x403c(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1030 <fread@plt>
mov    %eax,-0x404c(%rbp)
mov    -0x404c(%rbp),%eax
cmp    -0x403c(%rbp),%eax
je     14b1 <main+0x341>
lea    0xc29(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    14ee <main+0x37e>
jmp    14b6 <main+0x346>
mov    -0x20(%rbp),%rdi
mov    -0x4030(%rbp),%rdx
mov    -0x403c(%rbp),%ecx
mov    -0x4040(%rbp),%r8d
lea    0xc0e(%rip),%rsi
call   1060 <fprintf@plt>
mov    -0x4044(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4044(%rbp)
jmp    1260 <main+0xf0>
mov    -0x4044(%rbp),%esi
lea    0xbf3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1040 <fclose@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x40b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4028,%rsp
mov    %rsi,%rbp
cmp    $0x3,%edi
jne    13db <main+0x25b>
mov    0x8(%rbp),%rdi
lea    0xe93(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     13f7 <main+0x277>
mov    %rax,%rbx
mov    0x10(%rbp),%rdi
lea    0xe7f(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,0x18(%rsp)
test   %rax,%rax
je     140d <main+0x28d>
lea    0x10(%rsp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
xor    %ebp,%ebp
cmp    $0x4,%eax
jne    131e <main+0x19e>
xor    %r13d,%r13d
xor    %ebp,%ebp
jmp    1249 <main+0xc9>
sub    %r13,%r14
imul   $0x3b9aca00,%r14,%rdx
add    %r15,%rdx
mov    0x8(%rsp),%r8d
mov    0x18(%rsp),%rdi
lea    0xe86(%rip),%rsi
mov    %r12d,%ecx
call   1070 <fprintf@plt>
add    $0x1,%ebp
lea    0x10(%rsp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
cmp    $0x4,%eax
jne    131e <main+0x19e>
lea    0x14(%rsp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
cmp    $0x4,%eax
jne    1360 <main+0x1e0>
movslq 0x14(%rsp),%r15
cmp    $0x3b9aca00,%r15
jl     1290 <main+0x110>
lea    0xdc7(%rip),%rdi
xor    %esi,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x10(%rsp),%eax
jmp    129f <main+0x11f>
nop
mov    0x10(%rsp),%eax
mov    %eax,%ecx
or     %r15d,%ecx
je     137b <main+0x1fb>
test   %r13,%r13
movslq %eax,%r14
cmove  %r14,%r13
lea    0x8(%rsp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
cmp    $0x4,%eax
jne    1369 <main+0x1e9>
lea    0xc(%rsp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
cmp    $0x4,%eax
jne    1372 <main+0x1f2>
mov    0xc(%rsp),%r12d
test   %r12d,%r12d
jle    1200 <main+0x80>
lea    0x20(%rsp),%rdi
mov    $0x1,%esi
mov    %r12d,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
cmp    %r12d,%eax
je     1200 <main+0x80>
lea    0xda7(%rip),%rdi
jmp    1325 <main+0x1a5>
lea    0xdcf(%rip),%rdi
call   1030 <puts@plt>
lea    0xd7e(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x18(%rsp),%rdi
call   1050 <fclose@plt>
mov    %rbx,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x4028,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd80(%rip),%rdi
jmp    1325 <main+0x1a5>
lea    0xd70(%rip),%rdi
jmp    1325 <main+0x1a5>
lea    0xd5e(%rip),%rdi
jmp    1325 <main+0x1a5>
lea    0x8(%rsp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
lea    0xc(%rsp),%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1040 <fread@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
cmp    %edx,%esi
jne    13c8 <main+0x248>
lea    0xcd3(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    132a <main+0x1aa>
lea    0xc97(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    132a <main+0x1aa>
mov    0x0(%rbp),%rsi
lea    0xc1a(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
lea    0xc3f(%rip),%rdi
call   1090 <perror@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>
lea    0xc29(%rip),%rdi
call   1090 <perror@plt>
xor    %edi,%edi
call   1050 <fclose@plt>
mov    $0xffffffff,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
@.str = [59 x i8] c"Uso: %s <fichero_RAW_de_entrada> <fichero_PCAP_de_salida>\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [6 x i8] c"fopen\00"
@.str.3 = [2 x i8] c"w\00"
@.str.4 = [10 x i8] c"Segundos\0A\00"
@.str.5 = [14 x i8] c"Nanosegundos\0A\00"
@.str.6 = [33 x i8] c"Wrong NS value (file=%d,pkt=%d)\0A\00"
@.str.7 = [41 x i8] c"Wrong padding format [len=%d,caplen=%d]\0A\00"
@.str.8 = [21 x i8] c"Padding de %d bytes\0A\00"
@.str.9 = [8 x i8] c"Caplen\0A\00"
@.str.10 = [10 x i8] c"Longitud\0A\00"
@.str.11 = [21 x i8] c"Lectura del paquete\0A\00"
@.str.12 = [11 x i8] c"%lu\09%d\09%d\0A\00"
@.str.13 = [20 x i8] c"%d paquetes leidos\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca [4096 x i32]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i64
%12 = alloca i64
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca [100 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %12
store i32 0, i32* %15
store i32 0, i32* %16
store i32 0, i32* %17
%19 = load i32, i32* %4
%20 = icmp ne i32 %19, 3
br i1 %20, label %21, label %27
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8* %24)
%26 = call i32 @exit(i32 -1)
unreachable
27: ; preds = %2
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32* @fopen(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %31, i32** %6
%32 = load i32*, i32** %6
%33 = icmp ne i32* %32, null
br i1 %33, label %37, label %34
34: ; preds = %27
%35 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%36 = call i32 @exit(i32 -1)
unreachable
37: ; preds = %27
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 2
%40 = load i8*, i8** %39
%41 = call i32* @fopen(i8* %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %41, i32** %7
%42 = load i32*, i32** %7
%43 = icmp ne i32* %42, null
br i1 %43, label %49, label %44
44: ; preds = %37
%45 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%46 = load i32*, i32** %7
%47 = call i32 @fclose(i32* %46)
%48 = call i32 @exit(i32 -1)
unreachable
49: ; preds = %37
store i32 0, i32* %15
br label %50
50: ; preds = %49, %137
%51 = load i32*, i32** %6
%52 = call i32 @fread(i32* %9, i32 1, i32 4, i32* %51)
%53 = sext i32 %52 to i64
%54 = icmp ne i64 %53, 4
br i1 %54, label %55, label %57
55: ; preds = %50
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
br label %145
57: ; preds = %50
%58 = load i32*, i32** %6
%59 = call i32 @fread(i32* %10, i32 1, i32 4, i32* %58)
%60 = sext i32 %59 to i64
%61 = icmp ne i64 %60, 4
br i1 %61, label %62, label %64
62: ; preds = %57
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0))
br label %145
64: ; preds = %57
%65 = load i32, i32* %10
%66 = icmp sge i32 %65, 1000000000
br i1 %66, label %67, label %71
67: ; preds = %64
%68 = load i32, i32* %16
%69 = load i32, i32* %15
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i32 %68, i32 %69)
br label %71
71: ; preds = %67, %64
%72 = load i32, i32* %9
%73 = icmp eq i32 %72, 0
br i1 %73, label %74, label %93
74: ; preds = %71
%75 = load i32, i32* %10
%76 = icmp eq i32 %75, 0
br i1 %76, label %77, label %93
77: ; preds = %74
%78 = load i32*, i32** %6
%79 = call i32 @fread(i32* %14, i32 1, i32 4, i32* %78)
%80 = load i32*, i32** %6
%81 = call i32 @fread(i32* %13, i32 1, i32 4, i32* %80)
%82 = load i32, i32* %13
%83 = load i32, i32* %14
%84 = icmp ne i32 %82, %83
br i1 %84, label %85, label %89
85: ; preds = %77
%86 = load i32, i32* %13
%87 = load i32, i32* %14
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0), i32 %86, i32 %87)
br label %92
89: ; preds = %77
%90 = load i32, i32* %14
%91 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i32 %90)
br label %92
92: ; preds = %89, %85
br label %145
93: ; preds = %74, %71
%94 = load i64, i64* %12
%95 = icmp eq i64 %94, 0
br i1 %95, label %96, label %99
96: ; preds = %93
%97 = load i32, i32* %9
%98 = sext i32 %97 to i64
store i64 %98, i64* %12
br label %99
99: ; preds = %96, %93
%100 = load i32*, i32** %6
%101 = call i32 @fread(i32* %14, i32 1, i32 4, i32* %100)
%102 = sext i32 %101 to i64
%103 = icmp ne i64 %102, 4
br i1 %103, label %104, label %106
104: ; preds = %99
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
br label %145
106: ; preds = %99
%107 = load i32*, i32** %6
%108 = call i32 @fread(i32* %13, i32 1, i32 4, i32* %107)
%109 = sext i32 %108 to i64
%110 = icmp ne i64 %109, 4
br i1 %110, label %111, label %113
111: ; preds = %106
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.10, i64 0, i64 0))
br label %145
113: ; preds = %106
%114 = load i32, i32* %9
%115 = sext i32 %114 to i64
%116 = load i64, i64* %12
%117 = sub nsw i64 %115, %116
store i64 %117, i64* %11
%118 = load i64, i64* %11
%119 = mul i64 %118, 1000000000
store i64 %119, i64* %11
%120 = load i32, i32* %10
%121 = sext i32 %120 to i64
%122 = load i64, i64* %11
%123 = add nsw i64 %122, %121
store i64 %123, i64* %11
%124 = load i32, i32* %13
%125 = icmp sgt i32 %124, 0
br i1 %125, label %126, label %137
126: ; preds = %113
%127 = getelementptr inbounds [4096 x i32], [4096 x i32]* %8, i64 0, i64 0
%128 = load i32, i32* %13
%129 = load i32*, i32** %6
%130 = call i32 @fread(i32* %127, i32 1, i32 %128, i32* %129)
store i32 %130, i32* %17
%131 = load i32, i32* %17
%132 = load i32, i32* %13
%133 = icmp ne i32 %131, %132
br i1 %133, label %134, label %136
134: ; preds = %126
%135 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0))
br label %145
136: ; preds = %126
br label %137
137: ; preds = %136, %113
%138 = load i32*, i32** %7
%139 = load i64, i64* %11
%140 = load i32, i32* %13
%141 = load i32, i32* %14
%142 = call i32 @fprintf(i32* %138, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i64 0, i64 0), i64 %139, i32 %140, i32 %141)
%143 = load i32, i32* %15
%144 = add nsw i32 %143, 1
store i32 %144, i32* %15
br label %50
145: ; preds = %134, %111, %104, %92, %62, %55
%146 = load i32, i32* %15
%147 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.13, i64 0, i64 0), i32 %146)
%148 = load i32*, i32** %7
%149 = call i32 @fclose(i32* %148)
%150 = load i32*, i32** %6
%151 = call i32 @fclose(i32* %150)
ret i32 0
}

LLVM IR (-O2):
@.str = [59 x i8] c"Uso: %s <fichero_RAW_de_entrada> <fichero_PCAP_de_salida>\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [6 x i8] c"fopen\00"
@.str.3 = [2 x i8] c"w\00"
@.str.6 = [33 x i8] c"Wrong NS value (file=%d,pkt=%d)\0A\00"
@.str.7 = [41 x i8] c"Wrong padding format [len=%d,caplen=%d]\0A\00"
@.str.8 = [21 x i8] c"Padding de %d bytes\0A\00"
@.str.12 = [11 x i8] c"%lu\09%d\09%d\0A\00"
@.str.13 = [20 x i8] c"%d paquetes leidos\0A\00"
@str = [20 x i8] c"Lectura del paquete\00"
@str.14 = [9 x i8] c"Longitud\00"
@str.15 = [7 x i8] c"Caplen\00"
@str.16 = [13 x i8] c"Nanosegundos\00"
@str.17 = [9 x i8] c"Segundos\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4096 x i32]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = bitcast [4096 x i32]* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = bitcast i32* %6 to i8*
%12 = bitcast i32* %7 to i8*
%13 = icmp eq i32 %0, 3
br i1 %13, label %18, label %14
14: ; preds = %2
%15 = load i8*, i8** %1
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([59 x i8], [59 x i8]* @.str, i64 0, i64 0), i8* %15)
%17 = tail call i32 @exit(i32 -1)
unreachable
18: ; preds = %2
%19 = getelementptr inbounds i8*, i8** %1, i64 1
%20 = load i8*, i8** %19
%21 = tail call i32* @fopen(i8* %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp eq i32* %21, null
br i1 %22, label %23, label %26
23: ; preds = %18
%24 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%25 = tail call i32 @exit(i32 -1)
unreachable
26: ; preds = %18
%27 = getelementptr inbounds i8*, i8** %1, i64 2
%28 = load i8*, i8** %27
%29 = tail call i32* @fopen(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%30 = icmp eq i32* %29, null
br i1 %30, label %36, label %31
31: ; preds = %26
%32 = call i32 @fread(i32* %4, i32 1, i32 4, i32* %21)
%33 = icmp eq i32 %32, 4
br i1 %33, label %34, label %40
34: ; preds = %31
%35 = getelementptr inbounds [4096 x i32], [4096 x i32]* %3, i64 0, i64 0
br label %43
36: ; preds = %26
%37 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%38 = tail call i32 @fclose(i32* null)
%39 = tail call i32 @exit(i32 -1)
unreachable
40: ; preds = %97, %31
%41 = phi i32 [ 0, %31 ], [ %100, %97 ]
%42 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.17, i64 0, i64 0))
br label %103
43: ; preds = %34, %97
%44 = phi i64 [ 0, %34 ], [ %75, %97 ]
%45 = phi i32 [ 0, %34 ], [ %100, %97 ]
%46 = call i32 @fread(i32* %5, i32 1, i32 4, i32* %21)
%47 = icmp eq i32 %46, 4
br i1 %47, label %50, label %48
48: ; preds = %43
%49 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.16, i64 0, i64 0))
br label %103
50: ; preds = %43
%51 = load i32, i32* %5
%52 = icmp sgt i32 %51, 999999999
br i1 %52, label %53, label %56
53: ; preds = %50
%54 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0), i32 0, i32 %45)
%55 = load i32, i32* %4
br label %71
56: ; preds = %50
%57 = load i32, i32* %4
%58 = icmp eq i32 %57, 0
%59 = icmp eq i32 %51, 0
%60 = select i1 %58, i1 %59, i1 false
br i1 %60, label %61, label %71
61: ; preds = %56
%62 = call i32 @fread(i32* %7, i32 1, i32 4, i32* %21)
%63 = call i32 @fread(i32* %6, i32 1, i32 4, i32* %21)
%64 = load i32, i32* %6
%65 = load i32, i32* %7
%66 = icmp eq i32 %64, %65
br i1 %66, label %69, label %67
67: ; preds = %61
%68 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.7, i64 0, i64 0), i32 %64, i32 %65)
br label %103
69: ; preds = %61
%70 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i32 %64)
br label %103
71: ; preds = %53, %56
%72 = phi i32 [ %55, %53 ], [ %57, %56 ]
%73 = icmp eq i64 %44, 0
%74 = sext i32 %72 to i64
%75 = select i1 %73, i64 %74, i64 %44
%76 = call i32 @fread(i32* %7, i32 1, i32 4, i32* %21)
%77 = icmp eq i32 %76, 4
br i1 %77, label %80, label %78
78: ; preds = %71
%79 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.15, i64 0, i64 0))
br label %103
80: ; preds = %71
%81 = call i32 @fread(i32* %6, i32 1, i32 4, i32* %21)
%82 = icmp eq i32 %81, 4
br i1 %82, label %85, label %83
83: ; preds = %80
%84 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.14, i64 0, i64 0))
br label %103
85: ; preds = %80
%86 = sub nsw i64 %74, %75
%87 = mul i64 %86, 1000000000
%88 = sext i32 %51 to i64
%89 = add nsw i64 %87, %88
%90 = load i32, i32* %6
%91 = icmp sgt i32 %90, 0
br i1 %91, label %92, label %97
92: ; preds = %85
%93 = call i32 @fread(i32* %35, i32 1, i32 %90, i32* %21)
%94 = icmp eq i32 %93, %90
br i1 %94, label %97, label %95
95: ; preds = %92
%96 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
br label %103
97: ; preds = %92, %85
%98 = load i32, i32* %7
%99 = tail call i32 @fprintf(i32* %29, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i64 0, i64 0), i64 %89, i32 %90, i32 %98)
%100 = add nuw nsw i32 %45, 1
%101 = call i32 @fread(i32* %4, i32 1, i32 4, i32* %21)
%102 = icmp eq i32 %101, 4
br i1 %102, label %43, label %40
103: ; preds = %67, %69, %95, %83, %78, %48, %40
%104 = phi i32 [ %45, %67 ], [ %45, %69 ], [ %45, %95 ], [ %45, %83 ], [ %45, %78 ], [ %45, %48 ], [ %41, %40 ]
%105 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.13, i64 0, i64 0), i32 %104)
%106 = tail call i32 @fclose(i32* %29)
%107 = tail call i32 @fclose(i32* %21)
ret i32 0
}