// File: /workspace/github_cpp_makefile_star2_O1/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), %rax      # 0x8190
movq 0x5747(%rip), %r14      # 0x8188
subq %r14, %rax
je 0x2bc6
xorl %r15d, %r15d
movq %r15, %rbp
shlq $0x6, %rbp
movq 0x8(%r14,%rbp), %rdx
cmpq 0x18(%rsp), %rdx
jne 0x2ba3
addq %rbp, %r14
testq %rdx, %rdx
je 0x2a81
movq 0x10(%rsp), %rsi
movq (%r14), %rdi
callq 0x21e0
testl %eax, %eax
jne 0x2ba3
movq %r15, 0x30(%rsp)
movl 0x30(%r14), %eax
subl 0x28(%r14), %eax
shrl $0x5, %eax
movw %ax, 0xc(%rsp)
movl $0x2, %edx
movl %ebx, %edi
leaq 0xc(%rsp), %rsi
xorl %ecx, %ecx
callq 0x20e0
movq 0x56d8(%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 0x2b9e
xorl %r14d, %r14d
movq 0x56ac(%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 0x5688(%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 0x5666(%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 0x2b8d
xorl %r15d, %r15d
xorl %r13d, %r13d
movq 0x5627(%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 0x2b5a
incq %r14
movzwl 0xc(%rsp), %eax
cmpq %rax, %r14
jb 0x2ad5
movq 0x30(%rsp), %r15
incq %r15
movq 0x55e3(%rip), %rax      # 0x8190
movq 0x55d4(%rip), %r14      # 0x8188
subq %r14, %rax
sarq $0x6, %rax
cmpq %r15, %rax
ja 0x2a4d
jmp 0x2bcd
sarq $0x6, %rax
xorl %r15d, %r15d
cmpq %r15, %rax
jne 0x2bea
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 0x2c0d
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 0x2c2a
jmp 0x2c2a
jmp 0x2c2a
jmp 0x2c2a
jmp 0x2c2a
jmp 0x2c2a
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x2c49
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x21d0
movq %rbx, %rdi
callq 0x2290
nop