// File: /workspace/github_cpp_makefile_star2_O1/bchu7796[P]p2p-file-sharing/peers.cpp
// Function: client::read_log(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::vector<chunk, std::allocator<chunk>>&, int)
int client::read_log(std::string file_name, std::vector<chunk>& chunks, int file_length){
    std::ifstream log;
    std::ofstream download_file;
    char buffer[10];
    std::string log_line;
    std::vector<std::string> elements;

    
    if(!file_exist(file_name + ".log")){
        /*
        download_file.open(file_name);
        for(int i=0; i < file_length; i++){
            download_file << "0";
        }
        download_file.close();
        */
        return 0;
    }
    

    log.open((file_name + ".log").c_str());
    
    while(log.getline(buffer, 10)){
        log_line = buffer;
        std::stringstream s(log_line);
        int index = 0;
        s >> index;
        chunks[index].is_possessed = true;
        std::stringstream().swap(s);
    }
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x7a8, %rsp            # imm = 0x7A8
movq %rdx, 0x38(%rsp)
movq %rsi, %rbx
leaq 0x218(%rsp), %rdi
callq 0x3320
leaq 0x420(%rsp), %rdi
callq 0x3450
leaq 0x20(%rsp), %rcx
movq %rcx, -0x10(%rcx)
xorl %eax, %eax
movq %rax, -0x8(%rcx)
movb $0x0, (%rcx)
movq %rax, 0x70(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
leaq 0x50(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq 0x40(%rsp), %rdi
callq 0x620c
leaq 0x3f49(%rip), %rsi      # 0x809b
leaq 0x40(%rsp), %rdi
callq 0x34d0
movq 0x40(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x3290
movl %eax, %ebp
movq 0x40(%rsp), %rdi
cmpq %r14, %rdi
je 0x4187
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3300
testl %ebp, %ebp
je 0x420a
leaq 0x60(%rsp), %rdi
callq 0x5d2c
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x41b1
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3300
movq 0x6e08(%rip), %rax      # 0xafc0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x428(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x420(%rsp,%rcx)
callq 0x3260
leaq 0x518(%rsp), %rdi
callq 0x30f0
leaq 0x218(%rsp), %rdi
callq 0x3080
xorl %eax, %eax
addq $0x7a8, %rsp            # imm = 0x7A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xa0(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq 0x90(%rsp), %rdi
callq 0x620c
leaq 0x3e67(%rip), %rsi      # 0x809b
leaq 0x90(%rsp), %r14
movq %r14, %rdi
callq 0x34d0
movq 0x90(%rsp), %rsi
leaq 0x218(%rsp), %rdi
movl $0x8, %edx
callq 0x31a0
movq 0x90(%rsp), %rdi
cmpq %r15, %rdi
je 0x427b
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x3300
movl $0x80, %r12d
leaq 0x620(%rsp), %r13
leaq (%r12,%r13), %rax
movq %rax, 0x30(%rsp)
addq %r14, %r12
leaq 0x86(%rsp), %rbx
movq 0x6d04(%rip), %rbp      # 0xafa8
leaq 0x218(%rsp), %r15
movq 0x218(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x32d0
movsbl %al, %ecx
movl $0xa, %edx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x34e0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x418b
movq 0x18(%rsp), %r15
movq %rbx, %rdi
callq 0x3120
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
movq %r15, %rdx
leaq 0x218(%rsp), %r15
movq %rbx, %rcx
movq %rax, %r8
callq 0x33f0
movq %r14, %rdi
leaq 0x10(%rsp), %rsi
movl $0x18, %edx
callq 0x3400
movl $0x0, 0xc(%rsp)
movq %r14, %rdi
leaq 0xc(%rsp), %rsi
callq 0x3190
movslq 0xc(%rsp), %rax
movq 0x38(%rsp), %rcx
movq (%rcx), %rcx
shlq $0x5, %rax
movb $0x1, 0x4(%rcx,%rax)
movq %r13, %rdi
callq 0x31e0
movq %r13, %rdi
movq %r14, %rsi
callq 0x34c0
movq %r13, %rdi
movq %rbp, %rsi
callq 0x3200
movq 0x30(%rsp), %rdi
callq 0x30f0
movq %r14, %rdi
movq %rbp, %rsi
callq 0x3200
movq %r12, %rdi
callq 0x30f0
jmp 0x42ac
jmp 0x4393
movq %rax, %rbx
movq 0x90(%rsp), %rdi
cmpq %r15, %rdi
je 0x442c
movq 0xa0(%rsp), %rsi
jmp 0x43c5
jmp 0x4429
movq %rax, %rbx
movq 0x40(%rsp), %rdi
cmpq %r14, %rdi
je 0x442c
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3300
jmp 0x442c
jmp 0x4429
movq %rax, %rbx
jmp 0x445f
movq %rax, %rbx
movq 0x6bc5(%rip), %rsi      # 0xafa8
leaq 0x620(%rsp), %rdi
callq 0x3200
leaq 0x6a0(%rsp), %rdi
callq 0x30f0
jmp 0x4406
jmp 0x4403
jmp 0x4429
movq %rax, %rbx
movq 0x6b9b(%rip), %rsi      # 0xafa8
leaq 0x90(%rsp), %rdi
callq 0x3200
leaq 0x110(%rsp), %rdi
callq 0x30f0
jmp 0x442c
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x5d2c
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x4452
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x3300
leaq 0x420(%rsp), %rdi
callq 0x33d0
leaq 0x218(%rsp), %rdi
callq 0x3080
movq %rbx, %rdi
callq 0x3480