// File: /workspace/github_cpp_makefile_star2_O3/bchu7796[P]p2p-file-sharing/server.cpp
// Function: server::location_reply(int)
int server::location_reply(int process_fd){
    std::string file_name;
    recv(process_fd, &file_name, sizeof(file_name), 0);
    int i;
    for(i = 0; i < files.size(); i++){
        if(files[i].file_name == file_name){
            uint16_t number_of_address = files[i].peers.size();
            send(process_fd, &number_of_address, sizeof(number_of_address), 0);
            send(process_fd, &files[i].file_length, sizeof(files[i].file_length), 0);
            for(int j=0; j<number_of_address; j++){
                send(process_fd, &files[i].peers[j].address, sizeof(files[i].peers[j].address), 0);
                send(process_fd, &files[i].peers[j].port, sizeof(files[i].peers[j].port), 0);
                uint16_t number_of_chunks = files[i].peers[j].chunks.size();
                send(process_fd, &number_of_chunks, sizeof(number_of_chunks), 0);
                for(int k = 0; k < number_of_chunks; k++){
                    send(process_fd, &files[i].peers[j].chunks[k], sizeof(files[i].peers[j].chunks[k]), 0);
                }
            }
        }
    }
    if( i == files.size()){
        uint16_t number_of_address = 0;
        send(process_fd, &number_of_address, sizeof(number_of_address), 0);
    }
    close(process_fd);
    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movl %esi, %ebx
leaq 0x20(%rsp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x10(%rsp), %rsi
movl $0x20, %edx
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x2080
movq 0x5756(%rip), %r14      # 0x8190
movq 0x5747(%rip), %r12      # 0x8188
movq %r14, %rax
subq %r12, %rax
je 0x2bd2
xorl %ecx, %ecx
movq %rcx, %rbp
shlq $0x6, %rbp
movq 0x8(%r12,%rbp), %rdx
cmpq 0x18(%rsp), %rdx
jne 0x2bba
leaq (%r12,%rbp), %r15
testq %rdx, %rdx
je 0x2a8a
movq 0x10(%rsp), %rsi
movq (%r15), %rdi
movq %rcx, %r13
callq 0x21e0
movq %r13, %rcx
testl %eax, %eax
jne 0x2bba
movq %rcx, 0x30(%rsp)
movl 0x30(%r15), %eax
subl 0x28(%r15), %eax
shrl $0x5, %eax
movw %ax, 0xc(%rsp)
movl $0x2, %edx
movl %ebx, %edi
leaq 0xc(%rsp), %rsi
xorl %ecx, %ecx
callq 0x20e0
movq 0x56cf(%rip), %rax      # 0x8188
leaq (%rax,%rbp), %rsi
addq $0x20, %rsi
movl $0x4, %edx
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x20e0
cmpw $0x0, 0xc(%rsp)
je 0x2ba7
xorl %r14d, %r14d
movq 0x56a3(%rip), %rax      # 0x8188
movq %r14, %r12
shlq $0x5, %r12
movq 0x28(%rax,%rbp), %rsi
addq %r12, %rsi
movl $0x4, %edx
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x20e0
movq 0x567f(%rip), %rax      # 0x8188
movq 0x28(%rax,%rbp), %rax
leaq (%rax,%r12), %rsi
addq $0x4, %rsi
movl $0x2, %edx
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x20e0
movq 0x565d(%rip), %rax      # 0x8188
movq 0x28(%rax,%rbp), %rax
movl 0x10(%rax,%r12), %ecx
subl 0x8(%rax,%r12), %ecx
shrl $0x2, %ecx
movw %cx, 0xe(%rsp)
movl $0x2, %edx
movl %ebx, %edi
leaq 0xe(%rsp), %rsi
xorl %ecx, %ecx
callq 0x20e0
cmpw $0x0, 0xe(%rsp)
je 0x2b96
xorl %r15d, %r15d
xorl %r13d, %r13d
movq 0x561e(%rip), %rax      # 0x8188
movq 0x28(%rax,%rbp), %rax
movq 0x8(%rax,%r12), %rsi
addq %r15, %rsi
movl $0x4, %edx
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x20e0
incq %r13
movzwl 0xe(%rsp), %eax
addq $0x4, %r15
cmpq %rax, %r13
jb 0x2b63
incq %r14
movzwl 0xc(%rsp), %eax
cmpq %rax, %r14
jb 0x2ade
movq 0x55e2(%rip), %r14      # 0x8190
movq 0x55d3(%rip), %r12      # 0x8188
movq 0x30(%rsp), %rcx
incq %rcx
movq %r14, %rax
subq %r12, %rax
sarq $0x6, %rax
cmpq %rcx, %rax
ja 0x2a4f
jmp 0x2bd8
sarq $0x6, %rax
xorl %ecx, %ecx
cmpq %rcx, %rax
jne 0x2bf5
leaq 0xc(%rsp), %rsi
movw $0x0, (%rsi)
movl $0x2, %edx
movl %ebx, %edi
xorl %ecx, %ecx
callq 0x20e0
movl %ebx, %edi
callq 0x22b0
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x2c18
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21d0
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2c35
jmp 0x2c35
jmp 0x2c35
jmp 0x2c35
jmp 0x2c35
jmp 0x2c35
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x2c54
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21d0
movq %rbx, %rdi
callq 0x2290