// File: /workspace/github_cpp_makefile_star2_O3/maclellant[P]ReliableGoBackN/server.cpp
// Function: parse_file(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, std::vector<Packet, std::allocator<Packet>>&, std::vector<Timer, std::allocator<Timer>>&)
void parse_file(std::string& filename, vector<Packet>& packets, vector<Timer>& timers)
{
    FILE *infile;
    infile = fopen(filename.c_str(), "rb");
    if (infile == NULL)
    {
        std::cerr << "Error: Could not open file: " << filename << std::endl;
        return;
    }

    int current_seq = 0;
    size_t numread = 0;

    while(!feof(infile))
    {
        char data[PACKET_SIZE - HEADER_SIZE];
        bzero(data, PACKET_SIZE - HEADER_SIZE);
        numread = fread(data, 1, PACKET_SIZE - HEADER_SIZE, infile);
        if (numread != PACKET_SIZE - HEADER_SIZE && !feof(infile))
        {
            fclose(infile);
            std::cerr << "Error: Could not properly read file: " << filename << std::endl;
            exit(EXIT_FAILURE);
        }

        Packet packet = Packet(data, numread, current_seq, TRN);
        Timer timer = Timer();
        packets.push_back(packet);
        timers.push_back(timer);
        current_seq = (current_seq + 1) % SEQ_NUM;
    }

    Packet final_packet = Packet(current_seq, TRN);
    Timer final_timer = Timer();
    packets.push_back(final_packet);
    timers.push_back(final_timer);

    fclose(infile);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x428, %rsp            # imm = 0x428
movq %rdx, %r14
movq %rsi, -0x30(%rbp)
movq %rdi, %r12
movq (%rdi), %rdi
leaq 0x10ec(%rip), %rsi      # 0x4146
callq 0x2200
testq %rax, %rax
je 0x31d1
movq %rax, %rbx
movq %r12, -0x38(%rbp)
movq %rax, %rdi
callq 0x2240
xorl %r13d, %r13d
testl %eax, %eax
jne 0x3182
leaq -0x250(%rbp), %r12
movq %r14, -0x40(%rbp)
movl $0x1fa, %edx            # imm = 0x1FA
movq %r12, %rdi
xorl %esi, %esi
callq 0x20f0
movl $0x1, %esi
movl $0x1fa, %edx            # imm = 0x1FA
movq %rbx, %rcx
movq %r12, %rbx
movq %r12, %rdi
movq %rcx, %r14
callq 0x2220
movq %rax, %r12
cmpq $0x1fa, %rax            # imm = 0x1FA
je 0x30d2
movq %r14, %rdi
callq 0x2240
testl %eax, %eax
je 0x328e
movzbl %r13b, %ecx
movzwl %r12w, %edx
leaq -0x450(%rbp), %r15
movq %r15, %rdi
movq %rbx, %r12
movq %rbx, %rsi
movl $0x3, %r8d
callq 0x3ce2
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq -0x30(%rbp), %rbx
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x3124
movl $0x200, %edx            # imm = 0x200
movq %rsi, %rdi
movq %r15, %rsi
callq 0x2150
addq $0x200, 0x8(%rbx)       # imm = 0x200
jmp 0x312f
movq %rbx, %rdi
movq %r15, %rdx
callq 0x39a6
movq %r14, %rbx
movq -0x40(%rbp), %r14
movq 0x8(%r14), %rsi
cmpq 0x10(%r14), %rsi
je 0x314e
movaps -0x50(%rbp), %xmm0
movups %xmm0, (%rsi)
addq $0x10, 0x8(%r14)
jmp 0x315a
movq %r14, %rdi
leaq -0x50(%rbp), %rdx
callq 0x3b32
leal 0x1(%r13), %eax
leal 0x20(%r13), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
andl $-0x20, %ecx
negl %ecx
addl %ecx, %r13d
incl %r13d
movq %rbx, %rdi
callq 0x2240
testl %eax, %eax
je 0x308d
movzbl %r13b, %esi
leaq -0x450(%rbp), %rdi
movl $0x3, %edx
callq 0x3c86
xorps %xmm0, %xmm0
movaps %xmm0, -0x250(%rbp)
movq -0x30(%rbp), %r15
movq 0x8(%r15), %rax
cmpq 0x10(%r15), %rax
je 0x3238
leaq -0x450(%rbp), %rsi
movl $0x200, %edx            # imm = 0x200
movq %rax, %rdi
callq 0x2150
addq $0x200, 0x8(%r15)       # imm = 0x200
jmp 0x324a
movq 0x2e18(%rip), %rbx      # 0x5ff0
leaq 0xf6a(%rip), %rsi       # 0x4149
movl $0x1c, %edx
movq %rbx, %rdi
callq 0x21f0
movq (%r12), %rsi
movq 0x8(%r12), %rdx
movq %rbx, %rdi
callq 0x21f0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2110
leaq -0x450(%rbp), %rdx
movq %r15, %rdi
movq %rax, %rsi
callq 0x39a6
movq 0x8(%r14), %rsi
cmpq 0x10(%r14), %rsi
je 0x3265
movaps -0x250(%rbp), %xmm0
movups %xmm0, (%rsi)
addq $0x10, 0x8(%r14)
jmp 0x3274
leaq -0x250(%rbp), %rdx
movq %r14, %rdi
callq 0x3b32
movq %rbx, %rdi
callq 0x21c0
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r14, %rdi
callq 0x21c0
movq 0x2d53(%rip), %rdi      # 0x5ff0
leaq 0xec2(%rip), %rsi       # 0x4166
callq 0x21b0
movq %rax, %rdi
movq -0x38(%rbp), %rsi
callq 0x2180
movq %rax, %rdi
callq 0x20d0
movl $0x1, %edi
callq 0x2210