// File: /workspace/github_cpp_makefile_star2_O2/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, -0x38(%rbp)
movq %rsi, -0x30(%rbp)
movq %rdi, %rbx
movq (%rdi), %rdi
leaq 0x13b5(%rip), %rsi      # 0x4146
callq 0x21f0
testq %rax, %rax
je 0x2ea5
movq %rax, %r15
movq %rbx, -0x40(%rbp)
xorl %r13d, %r13d
leaq -0x250(%rbp), %rbx
leaq -0x450(%rbp), %r14
movq %r15, %rdi
callq 0x2240
testl %eax, %eax
jne 0x2e4f
movl $0x1fa, %edx            # imm = 0x1FA
movq %rbx, %rdi
xorl %esi, %esi
callq 0x2110
movl $0x1fa, %edx            # imm = 0x1FA
movq %rbx, %rdi
pushq $0x1
popq %rsi
movq %r15, %rcx
callq 0x2220
movq %rax, %r12
cmpq $0x1fa, %rax            # imm = 0x1FA
je 0x2e04
movq %r15, %rdi
callq 0x2240
testl %eax, %eax
je 0x2edc
movzbl %r13b, %ecx
movzwl %r12w, %edx
movq %r14, %rdi
movq %rbx, %rsi
pushq $0x3
popq %r8
callq 0x385a
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq -0x30(%rbp), %rdi
movq %r14, %rsi
callq 0x3310
movq -0x38(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x3356
incl %r13d
movl %r13d, %eax
cltd
pushq $0x20
popq %rcx
idivl %ecx
movl %edx, %r13d
jmp 0x2db7
movzbl %r13b, %esi
leaq -0x450(%rbp), %rbx
pushq $0x3
popq %rdx
movq %rbx, %rdi
callq 0x37fa
xorps %xmm0, %xmm0
leaq -0x250(%rbp), %r14
movaps %xmm0, (%r14)
movq -0x30(%rbp), %rdi
movq %rbx, %rsi
callq 0x3310
movq -0x38(%rbp), %rdi
movq %r14, %rsi
callq 0x3356
movq %r15, %rdi
callq 0x21c0
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x3144(%rip), %rdi      # 0x5ff0
leaq 0x1296(%rip), %rsi      # 0x4149
callq 0x21b0
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2190
movq %rax, %rdi
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x20f0
movq %r15, %rdi
callq 0x21c0
movq 0x3105(%rip), %rdi      # 0x5ff0
leaq 0x1274(%rip), %rsi      # 0x4166
callq 0x21b0
movq %rax, %rdi
movq -0x40(%rbp), %rsi
callq 0x2190
movq %rax, %rdi
callq 0x20f0
pushq $0x1
popq %rdi
callq 0x2200