#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 ssize_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ *fdopen(int, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getline(char **, size_t *, int /*<<< orphan*/ *);
int /*<<< orphan*/ sscanf(char *, char *, float *, int *, int *, int *, int *,
                          int *, unsigned short *, unsigned short *,
                          unsigned short *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
char *strtok(char *, char *);
int trace_flow(int id, int fd) {
  char *line = NULL;
  char *tokens = NULL;
  size_t len = 0;
  ssize_t read;
  float time;
  int code, pid, fid, tos, bif;
  unsigned short s, d, pos;
  int current_amount_packets = 0;
  int packets_all = 0;
  int packets_lost = 0;
  int packets_received = 0;
  float start = 0, end = 0;
  int first_time = 1;
  FILE *file = fdopen(fd, "r");
  if (file == NULL) {
    fprintf(stderr, "Error opening stream from file descriptor\n");
    exit(EXIT_FAILURE);
  }
  fprintf(stdout, "Tracing flow of ID %d...\n\n", id);
  while ((read = getline(&line, &len, file)) != -1) {
    tokens = strtok(line, "\t");
    while (tokens != NULL) {
      sscanf(tokens, "%f %d %d %d %d %d N%hu N%hu N%hu", &time, &code, &pid,
             &fid, &tos, &bif, &s, &d, &pos);
      if (id == fid) {
        switch (code) {
        case 0:
          if (first_time)
            start = time;
          current_amount_packets++;
          packets_all++;
          break;
        case 1:
          break;
        case 2:
          break;
        case 3:
          end = time;
          current_amount_packets--;
          packets_received++;
          break;
        case 4:
          end = time;
          current_amount_packets--;
          packets_lost++;
          break;
        }
      }
      tokens = strtok(NULL, "\t");
    }
  }
  fprintf(stdout, "+--------------------------------------+\n");
  fprintf(stdout, "|                RESULTS               |\n");
  fprintf(stdout, "+--------------------------------------+\n");
  fprintf(stdout, "| Total amount of packets    : %7d |\n", packets_all);
  fprintf(stdout, "| Amount of packets received : %7d |\n", packets_received);
  fprintf(stdout, "| Amount of packets lost     : %7d |\n", packets_lost);
  fprintf(stdout, "+--------------------------------------+\n");
  fprintf(stdout, "| Loss rate (percentage)     : %.5f |\n",
          100 * (double)packets_lost / (double)packets_all);
  fprintf(stdout, "| Lifetime (in seconds)      : %.5f |\n", end - start);
  fprintf(stdout, "+--------------------------------------+\n\n");
  return 0;
}


x86 assembly (clang, -O0):
<trace_flow>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0xa0,%rsp
mov    %edi,-0x14(%rbp)
mov    %esi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movl   $0x0,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
movl   $0x0,-0x60(%rbp)
movl   $0x0,-0x64(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x68(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x6c(%rbp)
movl   $0x1,-0x70(%rbp)
mov    -0x18(%rbp),%edi
lea    0xe53(%rip),%rsi
call   1050 <fdopen@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x78(%rbp)
jne    1202 <trace_flow+0xa2>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
lea    0xe31(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2ddd(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>
mov    0x2dc7(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xe34(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x78(%rbp),%rdx
lea    -0x20(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1070 <getline@plt>
mov    %eax,-0x34(%rbp)
cmp    $0xffffffff,%eax
je     136a <trace_flow+0x20a>
mov    -0x20(%rbp),%rdi
lea    0xe20(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1365 <trace_flow+0x205>
mov    -0x28(%rbp),%rdi
lea    0xe03(%rip),%rsi
lea    -0x38(%rbp),%rdx
lea    -0x3c(%rbp),%rcx
lea    -0x40(%rbp),%r8
lea    -0x44(%rbp),%r9
lea    -0x48(%rbp),%r14
lea    -0x4c(%rbp),%rbx
lea    -0x4e(%rbp),%r11
lea    -0x50(%rbp),%r10
lea    -0x52(%rbp),%rax
mov    %r14,(%rsp)
mov    %rbx,0x8(%rsp)
mov    %r11,0x10(%rsp)
mov    %r10,0x18(%rsp)
mov    %rax,0x20(%rsp)
call   1040 <sscanf@plt>
mov    -0x14(%rbp),%eax
cmp    -0x44(%rbp),%eax
jne    134c <trace_flow+0x1ec>
mov    -0x3c(%rbp),%eax
mov    %rax,-0x80(%rbp)
sub    $0x4,%rax
ja     1347 <trace_flow+0x1e7>
mov    -0x80(%rbp),%rax
lea    0xd3c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
cmpl   $0x0,-0x70(%rbp)
je     12e9 <trace_flow+0x189>
movss  -0x38(%rbp),%xmm0
movss  %xmm0,-0x68(%rbp)
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    1347 <trace_flow+0x1e7>
jmp    1347 <trace_flow+0x1e7>
jmp    1347 <trace_flow+0x1e7>
movss  -0x38(%rbp),%xmm0
movss  %xmm0,-0x6c(%rbp)
mov    -0x58(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x58(%rbp)
mov    -0x64(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x64(%rbp)
jmp    1347 <trace_flow+0x1e7>
movss  -0x38(%rbp),%xmm0
movss  %xmm0,-0x6c(%rbp)
mov    -0x58(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x58(%rbp)
mov    -0x60(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x60(%rbp)
jmp    134c <trace_flow+0x1ec>
xor    %eax,%eax
mov    %eax,%edi
lea    0xd0d(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x28(%rbp)
jmp    124d <trace_flow+0xed>
jmp    121c <trace_flow+0xbc>
mov    0x2c5f(%rip),%rax
mov    (%rax),%edi
lea    0xd0d(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2c48(%rip),%rax
mov    (%rax),%edi
lea    0xd20(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2c31(%rip),%rax
mov    (%rax),%edi
lea    0xcdf(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2c1a(%rip),%rax
mov    (%rax),%edi
mov    -0x5c(%rbp),%edx
lea    0xd19(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2c00(%rip),%rax
mov    (%rax),%edi
mov    -0x64(%rbp),%edx
lea    0xd25(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2be6(%rip),%rax
mov    (%rax),%edi
mov    -0x60(%rbp),%edx
lea    0xd31(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2bcc(%rip),%rax
mov    (%rax),%edi
lea    0xc7a(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    0x2bb5(%rip),%rax
mov    (%rax),%edi
cvtsi2sdl -0x60(%rbp),%xmm1
movsd  0xbd6(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x5c(%rbp),%xmm1
divsd  %xmm1,%xmm0
lea    0xd0f(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
mov    0x2b84(%rip),%rax
mov    (%rax),%edi
movss  -0x6c(%rbp),%xmm0
subss  -0x68(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd11(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
mov    0x2b5f(%rip),%rax
mov    (%rax),%edi
lea    0xd21(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

x86 assembly (clang, -O2):
<trace_flow>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %esi,%eax
mov    %edi,%ebp
movq   $0x0,0x20(%rsp)
movq   $0x0,0x38(%rsp)
lea    0xe7d(%rip),%rsi
mov    %eax,%edi
call   1050 <fdopen@plt>
test   %rax,%rax
je     1431 <trace_flow+0x2d1>
mov    %rax,%rbx
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
lea    0xe87(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
lea    0x20(%rsp),%rdi
lea    0x38(%rsp),%rsi
mov    %rbx,%rdx
call   1070 <getline@plt>
cmp    $0xffffffff,%eax
je     1307 <trace_flow+0x1a7>
mov    %rbx,0x40(%rsp)
xor    %eax,%eax
mov    %rax,0x18(%rsp)
xorps  %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
lea    0xe62(%rip),%rbx
lea    0x14(%rsp),%r14
lea    0x2c(%rsp),%r15
lea    0x54(%rsp),%r13
lea    0x28(%rsp),%r12
xorps  %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
movl   $0x0,0xc(%rsp)
movl   $0x0,0x10(%rsp)
mov    0x20(%rsp),%rdi
jmp    1242 <trace_flow+0xe2>
movss  0x14(%rsp),%xmm0
movss  %xmm0,0x4(%rsp)
addl   $0x1,0xc(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %edi,%edi
mov    %rbx,%rsi
call   1060 <strtok@plt>
test   %rax,%rax
je     12e4 <trace_flow+0x184>
sub    $0x8,%rsp
mov    %rax,%rdi
lea    0xdf1(%rip),%rsi
mov    %r14,%rdx
mov    %r15,%rcx
mov    %r13,%r8
mov    %r12,%r9
lea    0x3a(%rsp),%rax
push   %rax
lea    0x44(%rsp),%rax
push   %rax
lea    0x4e(%rsp),%rax
push   %rax
lea    0x6c(%rsp),%rax
push   %rax
lea    0x78(%rsp),%rax
push   %rax
call   1040 <sscanf@plt>
add    $0x30,%rsp
cmp    %ebp,0x28(%rsp)
jne    1240 <trace_flow+0xe0>
mov    0x2c(%rsp),%eax
cmp    $0x4,%eax
je     1222 <trace_flow+0xc2>
cmp    $0x3,%eax
je     12c6 <trace_flow+0x166>
test   %eax,%eax
jne    1240 <trace_flow+0xe0>
movss  0x14(%rsp),%xmm0
movss  %xmm0,0x8(%rsp)
addl   $0x1,0x10(%rsp)
jmp    1240 <trace_flow+0xe0>
movss  0x14(%rsp),%xmm0
movss  %xmm0,0x4(%rsp)
mov    0x18(%rsp),%rax
add    $0x1,%eax
mov    %rax,0x18(%rsp)
jmp    1240 <trace_flow+0xe0>
lea    0x20(%rsp),%rdi
lea    0x38(%rsp),%rsi
mov    0x40(%rsp),%rdx
call   1070 <getline@plt>
cmp    $0xffffffff,%eax
je     1330 <trace_flow+0x1d0>
mov    0x20(%rsp),%rdi
jmp    1242 <trace_flow+0xe2>
movl   $0x0,0x10(%rsp)
xorps  %xmm0,%xmm0
movss  %xmm0,0x8(%rsp)
movl   $0x0,0xc(%rsp)
xor    %eax,%eax
mov    %rax,0x18(%rsp)
xorps  %xmm0,%xmm0
movss  %xmm0,0x4(%rsp)
movss  0x4(%rsp),%xmm0
subss  0x8(%rsp),%xmm0
movss  %xmm0,0x4(%rsp)
mov    0x2c87(%rip),%r15
mov    (%r15),%edi
lea    0xd20(%rip),%r14
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r15),%edi
lea    0xd36(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r15),%edi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r15),%edi
lea    0xd42(%rip),%rsi
mov    0x10(%rsp),%ebx
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r15),%edi
lea    0xd51(%rip),%rsi
mov    0x18(%rsp),%rdx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r15),%edi
lea    0xd61(%rip),%rsi
mov    0xc(%rsp),%ebp
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    (%r15),%edi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
mulsd  0xc25(%rip),%xmm0
mov    (%r15),%edi
cvtsi2sd %ebx,%xmm1
divsd  %xmm1,%xmm0
lea    0xd4c(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
mov    (%r15),%edi
movss  0x4(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd58(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
mov    (%r15),%edi
lea    0xd6e(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2ba8(%rip),%rax
mov    (%rax),%edi
lea    0xbc9(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    0x2b89(%rip),%rax
mov    (%rax),%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [43 x i8] c"Error opening stream from file descriptor\0A\00"
@EXIT_FAILURE = global i32 0
@stdout = global i32 0
@.str.2 = [27 x i8] c"Tracing flow of ID %d...\0A\0A\00"
@.str.3 = [2 x i8] c"\09\00"
@.str.4 = [33 x i8] c"%f %d %d %d %d %d N%hu N%hu N%hu\00"
@.str.5 = [42 x i8] c"+--------------------------------------+\0A\00"
@.str.6 = [42 x i8] c"| RESULTS |\0A\00"
@.str.7 = [38 x i8] c"| Total amount of packets : %7d |\0A\00"
@.str.8 = [38 x i8] c"| Amount of packets received : %7d |\0A\00"
@.str.9 = [38 x i8] c"| Amount of packets lost : %7d |\0A\00"
@.str.10 = [39 x i8] c"| Loss rate (percentage) : %.5f |\0A\00"
@.str.11 = [39 x i8] c"| Lifetime (in seconds) : %.5f |\0A\00"
@.str.12 = [43 x i8] c"+--------------------------------------+\0A\0A\00"
define i32 @trace_flow(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca float
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i16
%16 = alloca i16
%17 = alloca i16
%18 = alloca i32
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
%22 = alloca float
%23 = alloca float
%24 = alloca i32
%25 = alloca i32*
store i32 %0, i32* %3
store i32 %1, i32* %4
store i8* null, i8** %5
store i8* null, i8** %6
store i64 0, i64* %7
store i32 0, i32* %18
store i32 0, i32* %19
store i32 0, i32* %20
store i32 0, i32* %21
store float 0.000000e+00, float* %22
store float 0.000000e+00, float* %23
store i32 1, i32* %24
%26 = load i32, i32* %4
%27 = call i32* @fdopen(i32 %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %27, i32** %25
%28 = load i32*, i32** %25
%29 = icmp eq i32* %28, null
br i1 %29, label %30, label %35
30: ; preds = %2
%31 = load i32, i32* @stderr
%32 = call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%33 = load i32, i32* @EXIT_FAILURE
%34 = call i32 @exit(i32 %33)
unreachable
35: ; preds = %2
%36 = load i32, i32* @stdout
%37 = load i32, i32* %3
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %37)
br label %39
39: ; preds = %84, %35
%40 = load i32*, i32** %25
%41 = call i32 @getline(i8** %5, i64* %7, i32* %40)
store i32 %41, i32* %8
%42 = icmp ne i32 %41, -1
br i1 %42, label %43, label %85
43: ; preds = %39
%44 = load i8*, i8** %5
%45 = call i8* @strtok(i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i8* %45, i8** %6
br label %46
46: ; preds = %82, %43
%47 = load i8*, i8** %6
%48 = icmp ne i8* %47, null
br i1 %48, label %49, label %84
49: ; preds = %46
%50 = load i8*, i8** %6
%51 = call i32 @sscanf(i8* %50, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), float* %9, i32* %10, i32* %11, i32* %12, i32* %13, i32* %14, i16* %15, i16* %16, i16* %17)
%52 = load i32, i32* %3
%53 = load i32, i32* %12
%54 = icmp eq i32 %52, %53
br i1 %54, label %55, label %82
55: ; preds = %49
%56 = load i32, i32* %10
switch i32 %56, label %81 [
i32 0, label %57
i32 1, label %67
i32 2, label %68
i32 3, label %69
i32 4, label %75
]
57: ; preds = %55
%58 = load i32, i32* %24
%59 = icmp ne i32 %58, 0
br i1 %59, label %60, label %62
60: ; preds = %57
%61 = load float, float* %9
store float %61, float* %22
br label %62
62: ; preds = %60, %57
%63 = load i32, i32* %18
%64 = add nsw i32 %63, 1
store i32 %64, i32* %18
%65 = load i32, i32* %19
%66 = add nsw i32 %65, 1
store i32 %66, i32* %19
br label %81
67: ; preds = %55
br label %81
68: ; preds = %55
br label %81
69: ; preds = %55
%70 = load float, float* %9
store float %70, float* %23
%71 = load i32, i32* %18
%72 = add nsw i32 %71, -1
store i32 %72, i32* %18
%73 = load i32, i32* %21
%74 = add nsw i32 %73, 1
store i32 %74, i32* %21
br label %81
75: ; preds = %55
%76 = load float, float* %9
store float %76, float* %23
%77 = load i32, i32* %18
%78 = add nsw i32 %77, -1
store i32 %78, i32* %18
%79 = load i32, i32* %20
%80 = add nsw i32 %79, 1
store i32 %80, i32* %20
br label %81
81: ; preds = %55, %75, %69, %68, %67, %62
br label %82
82: ; preds = %81, %49
%83 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i8* %83, i8** %6
br label %46
84: ; preds = %46
br label %39
85: ; preds = %39
%86 = load i32, i32* @stdout
%87 = call i32 (i32, i8*, ...) @fprintf(i32 %86, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0))
%88 = load i32, i32* @stdout
%89 = call i32 (i32, i8*, ...) @fprintf(i32 %88, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0))
%90 = load i32, i32* @stdout
%91 = call i32 (i32, i8*, ...) @fprintf(i32 %90, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0))
%92 = load i32, i32* @stdout
%93 = load i32, i32* %19
%94 = call i32 (i32, i8*, ...) @fprintf(i32 %92, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.7, i64 0, i64 0), i32 %93)
%95 = load i32, i32* @stdout
%96 = load i32, i32* %21
%97 = call i32 (i32, i8*, ...) @fprintf(i32 %95, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0), i32 %96)
%98 = load i32, i32* @stdout
%99 = load i32, i32* %20
%100 = call i32 (i32, i8*, ...) @fprintf(i32 %98, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.9, i64 0, i64 0), i32 %99)
%101 = load i32, i32* @stdout
%102 = call i32 (i32, i8*, ...) @fprintf(i32 %101, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0))
%103 = load i32, i32* @stdout
%104 = load i32, i32* %20
%105 = sitofp i32 %104 to double
%106 = fmul double 1.000000e+02, %105
%107 = load i32, i32* %19
%108 = sitofp i32 %107 to double
%109 = fdiv double %106, %108
%110 = call i32 (i32, i8*, ...) @fprintf(i32 %103, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.10, i64 0, i64 0), double %109)
%111 = load i32, i32* @stdout
%112 = load float, float* %23
%113 = load float, float* %22
%114 = fsub float %112, %113
%115 = fpext float %114 to double
%116 = call i32 (i32, i8*, ...) @fprintf(i32 %111, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.11, i64 0, i64 0), double %115)
%117 = load i32, i32* @stdout
%118 = call i32 (i32, i8*, ...) @fprintf(i32 %117, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.12, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [43 x i8] c"Error opening stream from file descriptor\0A\00"
@EXIT_FAILURE = global i32 0
@stdout = global i32 0
@.str.2 = [27 x i8] c"Tracing flow of ID %d...\0A\0A\00"
@.str.3 = [2 x i8] c"\09\00"
@.str.4 = [33 x i8] c"%f %d %d %d %d %d N%hu N%hu N%hu\00"
@.str.5 = [42 x i8] c"+--------------------------------------+\0A\00"
@.str.6 = [42 x i8] c"| RESULTS |\0A\00"
@.str.7 = [38 x i8] c"| Total amount of packets : %7d |\0A\00"
@.str.8 = [38 x i8] c"| Amount of packets received : %7d |\0A\00"
@.str.9 = [38 x i8] c"| Amount of packets lost : %7d |\0A\00"
@.str.10 = [39 x i8] c"| Loss rate (percentage) : %.5f |\0A\00"
@.str.11 = [39 x i8] c"| Lifetime (in seconds) : %.5f |\0A\00"
@.str.12 = [43 x i8] c"+--------------------------------------+\0A\0A\00"
define i32 @trace_flow(i32 %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca float
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i16
%12 = alloca i16
%13 = alloca i16
%14 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%15 = bitcast i64* %4 to i8*
store i64 0, i64* %4
%16 = bitcast float* %5 to i8*
%17 = bitcast i32* %6 to i8*
%18 = bitcast i32* %7 to i8*
%19 = bitcast i32* %8 to i8*
%20 = bitcast i32* %9 to i8*
%21 = bitcast i32* %10 to i8*
%22 = bitcast i16* %11 to i8*
%23 = bitcast i16* %12 to i8*
%24 = bitcast i16* %13 to i8*
%25 = tail call i32* @fdopen(i32 %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%26 = icmp eq i32* %25, null
br i1 %26, label %27, label %32
27: ; preds = %2
%28 = load i32, i32* @stderr
%29 = tail call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0))
%30 = load i32, i32* @EXIT_FAILURE
%31 = tail call i32 @exit(i32 %30)
unreachable
32: ; preds = %2
%33 = load i32, i32* @stdout
%34 = tail call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %0)
%35 = call i32 @getline(i8** %3, i64* %4, i32* %25)
%36 = icmp eq i32 %35, -1
br i1 %36, label %83, label %45
37: ; preds = %75, %45
%38 = phi i32 [ %50, %45 ], [ %76, %75 ]
%39 = phi i32 [ %49, %45 ], [ %77, %75 ]
%40 = phi i32 [ %48, %45 ], [ %78, %75 ]
%41 = phi float [ %47, %45 ], [ %79, %75 ]
%42 = phi float [ %46, %45 ], [ %80, %75 ]
%43 = call i32 @getline(i8** %3, i64* %4, i32* %25)
%44 = icmp eq i32 %43, -1
br i1 %44, label %83, label %45
45: ; preds = %32, %37
%46 = phi float [ %42, %37 ], [ 0.000000e+00, %32 ]
%47 = phi float [ %41, %37 ], [ 0.000000e+00, %32 ]
%48 = phi i32 [ %40, %37 ], [ 0, %32 ]
%49 = phi i32 [ %39, %37 ], [ 0, %32 ]
%50 = phi i32 [ %38, %37 ], [ 0, %32 ]
%51 = load i8*, i8** %3
%52 = call i8* @strtok(i8* %51, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%53 = icmp eq i8* %52, null
br i1 %53, label %37, label %54
54: ; preds = %45, %75
%55 = phi i8* [ %81, %75 ], [ %52, %45 ]
%56 = phi float [ %80, %75 ], [ %46, %45 ]
%57 = phi float [ %79, %75 ], [ %47, %45 ]
%58 = phi i32 [ %78, %75 ], [ %48, %45 ]
%59 = phi i32 [ %77, %75 ], [ %49, %45 ]
%60 = phi i32 [ %76, %75 ], [ %50, %45 ]
%61 = call i32 @sscanf(i8* %55, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), float* %5, i32* %6, i32* %7, i32* %8, i32* %9, i32* %10, i16* %11, i16* %12, i16* %13)
%62 = load i32, i32* %8
%63 = icmp eq i32 %62, %0
br i1 %63, label %64, label %75
64: ; preds = %54
%65 = load i32, i32* %6
switch i32 %65, label %75 [
i32 0, label %66
i32 4, label %72
i32 3, label %69
]
66: ; preds = %64
%67 = load float, float* %5
%68 = add nsw i32 %60, 1
br label %75
69: ; preds = %64
%70 = load float, float* %5
%71 = add nsw i32 %58, 1
br label %75
72: ; preds = %64
%73 = load float, float* %5
%74 = add nsw i32 %59, 1
br label %75
75: ; preds = %66, %69, %72, %64, %54
%76 = phi i32 [ %60, %64 ], [ %60, %69 ], [ %60, %72 ], [ %68, %66 ], [ %60, %54 ]
%77 = phi i32 [ %59, %64 ], [ %59, %69 ], [ %74, %72 ], [ %59, %66 ], [ %59, %54 ]
%78 = phi i32 [ %58, %64 ], [ %71, %69 ], [ %58, %72 ], [ %58, %66 ], [ %58, %54 ]
%79 = phi float [ %57, %64 ], [ %57, %69 ], [ %57, %72 ], [ %67, %66 ], [ %57, %54 ]
%80 = phi float [ %56, %64 ], [ %70, %69 ], [ %73, %72 ], [ %56, %66 ], [ %56, %54 ]
%81 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%82 = icmp eq i8* %81, null
br i1 %82, label %37, label %54
83: ; preds = %37, %32
%84 = phi i32 [ 0, %32 ], [ %38, %37 ]
%85 = phi i32 [ 0, %32 ], [ %39, %37 ]
%86 = phi i32 [ 0, %32 ], [ %40, %37 ]
%87 = phi float [ 0.000000e+00, %32 ], [ %41, %37 ]
%88 = phi float [ 0.000000e+00, %32 ], [ %42, %37 ]
%89 = load i32, i32* @stdout
%90 = call i32 (i32, i8*, ...) @fprintf(i32 %89, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0))
%91 = load i32, i32* @stdout
%92 = call i32 (i32, i8*, ...) @fprintf(i32 %91, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0))
%93 = load i32, i32* @stdout
%94 = call i32 (i32, i8*, ...) @fprintf(i32 %93, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0))
%95 = load i32, i32* @stdout
%96 = call i32 (i32, i8*, ...) @fprintf(i32 %95, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.7, i64 0, i64 0), i32 %84)
%97 = load i32, i32* @stdout
%98 = call i32 (i32, i8*, ...) @fprintf(i32 %97, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.8, i64 0, i64 0), i32 %86)
%99 = load i32, i32* @stdout
%100 = call i32 (i32, i8*, ...) @fprintf(i32 %99, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.9, i64 0, i64 0), i32 %85)
%101 = load i32, i32* @stdout
%102 = call i32 (i32, i8*, ...) @fprintf(i32 %101, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0))
%103 = load i32, i32* @stdout
%104 = sitofp i32 %85 to double
%105 = fmul double %104, 1.000000e+02
%106 = sitofp i32 %84 to double
%107 = fdiv double %105, %106
%108 = call i32 (i32, i8*, ...) @fprintf(i32 %103, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.10, i64 0, i64 0), double %107)
%109 = load i32, i32* @stdout
%110 = fsub float %88, %87
%111 = fpext float %110 to double
%112 = call i32 (i32, i8*, ...) @fprintf(i32 %109, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.11, i64 0, i64 0), double %111)
%113 = load i32, i32* @stdout
%114 = call i32 (i32, i8*, ...) @fprintf(i32 %113, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.12, i64 0, i64 0))
ret i32 0
}