// File: /workspace/github_cpp_makefile_star2_O3/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 0x418(%rsp), %rdi
callq 0x3320
leaq 0x218(%rsp), %rdi
callq 0x3450
leaq 0x28(%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 0x6204
leaq 0x3f41(%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 0x418f
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3300
testl %ebp, %ebp
je 0x4212
leaq 0x60(%rsp), %rdi
callq 0x5d4e
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x41b9
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x3300
movq 0x6e00(%rip), %rax      # 0xafc0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq 0x220(%rsp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, 0x218(%rsp,%rcx)
callq 0x3260
leaq 0x310(%rsp), %rdi
callq 0x30f0
leaq 0x418(%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), %r14
movq %r14, -0x10(%r14)
movq (%rbx), %rsi
movq 0x8(%rbx), %rdx
addq %rsi, %rdx
leaq 0x90(%rsp), %rdi
callq 0x6204
leaq 0x3e5f(%rip), %rsi      # 0x809b
leaq 0x90(%rsp), %r15
movq %r15, %rdi
callq 0x34d0
movq 0x90(%rsp), %rsi
leaq 0x418(%rsp), %r13
movq %r13, %rdi
movl $0x8, %edx
callq 0x31a0
movq 0x90(%rsp), %rdi
cmpq %r14, %rdi
je 0x4286
movq 0xa0(%rsp), %rsi
incq %rsi
callq 0x3300
movl $0x80, %eax
leaq 0x620(%rsp), %rbp
leaq (%rax,%rbp), %rcx
movq %rcx, 0x8(%rsp)
addq %r15, %rax
movq %rax, 0x10(%rsp)
leaq 0x86(%rsp), %rbx
movq 0x6cf5(%rip), %r12      # 0xafa8
movq 0x418(%rsp), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x32d0
movsbl %al, %ecx
movl $0xa, %edx
movq %r13, %rdi
movq %rbx, %rsi
callq 0x34e0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x4193
movq %r13, %r14
movq 0x20(%rsp), %r13
movq %rbx, %rdi
callq 0x3120
leaq 0x18(%rsp), %rdi
xorl %esi, %esi
movq %r13, %rdx
movq %r14, %r13
movq %rbx, %rcx
movq %rax, %r8
callq 0x33f0
movq %r15, %rdi
leaq 0x18(%rsp), %rsi
movl $0x18, %edx
callq 0x3400
movl $0x0, 0x4(%rsp)
movq %r15, %rdi
leaq 0x4(%rsp), %rsi
callq 0x3190
movslq 0x4(%rsp), %rax
movq 0x38(%rsp), %rcx
movq (%rcx), %rcx
shlq $0x5, %rax
movb $0x1, 0x4(%rcx,%rax)
movq %rbp, %rdi
callq 0x31e0
movq %rbp, %rdi
movq %r15, %rsi
callq 0x34c0
movq %rbp, %rdi
movq %r12, %rsi
callq 0x3200
movq 0x8(%rsp), %rdi
callq 0x30f0
movq %r15, %rdi
movq %r12, %rsi
callq 0x3200
movq 0x10(%rsp), %rdi
callq 0x30f0
jmp 0x42b3
jmp 0x439a
movq %rax, %rbx
movq 0x90(%rsp), %rdi
cmpq %r14, %rdi
je 0x4429
movq 0xa0(%rsp), %rsi
jmp 0x43c8
jmp 0x4426
movq %rax, %rbx
movq 0x40(%rsp), %rdi
cmpq %r14, %rdi
je 0x4429
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x3300
jmp 0x4429
jmp 0x4426
movq %rax, %rbx
jmp 0x445c
movq %rax, %rbx
movq 0x6bc2(%rip), %rsi      # 0xafa8
leaq 0x620(%rsp), %rdi
callq 0x3200
movq 0x8(%rsp), %rdi
callq 0x30f0
jmp 0x4406
jmp 0x4403
jmp 0x4426
movq %rax, %rbx
movq 0x6b9b(%rip), %rsi      # 0xafa8
leaq 0x90(%rsp), %rdi
callq 0x3200
movq 0x10(%rsp), %rdi
callq 0x30f0
jmp 0x4429
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x5d4e
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0x444f
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x3300
leaq 0x218(%rsp), %rdi
callq 0x33d0
leaq 0x418(%rsp), %rdi
callq 0x3080
movq %rbx, %rdi
callq 0x3480
nop