// File: yasz24[P]eau2/src/network/./network_ip.h
// Function: NetworkIP::server_init(unsigned long, char*, unsigned long, unsigned long)
void server_init(size_t idx, char* ip, size_t port, size_t num_nodes) {
        this_node_ = idx;
        init_sock_(ip, port);
        std::cout << "initialized socket, listening on " << ip << ":" << port << "\n";
        num_nodes_ = num_nodes;
        nodes_ = new NodeInfo[num_nodes];
        for (size_t i = 0; i < num_nodes_; i++) nodes_[i].id = 0;
        nodes_[0].address = ip_;
        nodes_[0].id = 0;
        for (size_t i = 1; i < num_nodes; i++) {
            Register* msg = dynamic_cast<Register*>(recv_msg());
            //std::cout  << "Registration msg received, " << "client: " << msg->client << ":" << msg->port_ <<"\n";
            nodes_[msg->sender()].id = msg->sender();
            nodes_[msg->sender()].address.sin_family = AF_INET;
            inet_pton(AF_INET, msg->client, &nodes_[msg->sender()].address.sin_addr);
            nodes_[msg->sender()].address.sin_port = htons(msg->port_);
        }
        size_t *ports = new size_t[num_nodes_];
        String** addresses = new String*[num_nodes_];
        for (size_t i = 0; i < num_nodes_; i++) {
            ports[i] = ntohs(nodes_[i].address.sin_port);
            char client_ip[INET_ADDRSTRLEN];
            inet_ntop(AF_INET, &nodes_[i].address.sin_addr, client_ip, INET_ADDRSTRLEN);
            addresses[i] = new String(client_ip);
        }
        Directory ipd(this_node_, 0, msg_id, num_nodes_, ports, addresses);

        for (size_t i = 1; i < num_nodes_; i++) {
            ipd.target_ = i;
            send_msg(&ipd);
        }
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xf0(%rbp)
movq -0x10(%rbp), %rax
movq %rax, 0x20(%rdi)
movq -0x18(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x97d0
movq 0x3359a(%rip), %rdi     # 0x3bfc0
leaq 0x237ab(%rip), %rsi     # 0x2c1d8
callq 0x8280
movq %rax, %rdi
movq -0x18(%rbp), %rsi
callq 0x8280
movq %rax, %rdi
leaq 0x236ec(%rip), %rsi     # 0x2c134
callq 0x8280
movq %rax, %rdi
movq -0x20(%rbp), %rsi
callq 0x80a0
movq %rax, %rdi
leaq 0x236cf(%rip), %rsi     # 0x2c132
callq 0x8280
movq -0xf0(%rbp), %rax
movq -0x28(%rbp), %rcx
movq %rcx, 0x18(%rax)
movq -0x28(%rbp), %rax
movq %rax, -0xe8(%rbp)
movl $0x28, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
addq $0x8, %rdi
setb %al
orb %al, %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x8030
movq %rax, %rcx
movq -0xe8(%rbp), %rax
movq %rcx, -0xe0(%rbp)
movq %rax, (%rcx)
addq $0x8, %rcx
movq %rcx, -0xd8(%rbp)
cmpq $0x0, %rax
je 0x8b2a
movq -0xd8(%rbp), %rax
movq -0xe8(%rbp), %rcx
imulq $0x28, %rcx, %rdx
movq %rax, %rcx
addq %rdx, %rcx
movq %rcx, -0x100(%rbp)
movq %rax, -0xf8(%rbp)
movq -0xf8(%rbp), %rdi
movq %rdi, -0x108(%rbp)
callq 0x9900
jmp 0x8b0c
movq -0x100(%rbp), %rcx
movq -0x108(%rbp), %rax
addq $0x28, %rax
cmpq %rcx, %rax
movq %rax, -0xf8(%rbp)
jne 0x8af7
movq -0xf0(%rbp), %rax
movq -0xd8(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq $0x0, -0x40(%rbp)
movq -0xf0(%rbp), %rcx
movq -0x40(%rbp), %rax
cmpq 0x18(%rcx), %rax
jae 0x8be8
movq -0xf0(%rbp), %rax
movq 0x10(%rax), %rax
imulq $0x28, -0x40(%rbp), %rcx
addq %rcx, %rax
movq $0x0, 0x10(%rax)
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x8b44
movq -0xd8(%rbp), %rcx
movq %rax, %rsi
movq -0x108(%rbp), %rax
movq %rsi, -0x30(%rbp)
movl %edx, -0x34(%rbp)
cmpq %rax, %rcx
movq %rax, -0x110(%rbp)
je 0x8bd7
movq -0x110(%rbp), %rdi
addq $-0x28, %rdi
movq %rdi, -0x118(%rbp)
callq 0x9940
movq -0xd8(%rbp), %rcx
movq -0x118(%rbp), %rax
cmpq %rcx, %rax
movq %rax, -0x110(%rbp)
jne 0x8ba6
movq -0xe0(%rbp), %rdi
callq 0x82f0
jmp 0x8fac
movq -0xf0(%rbp), %rax
movq 0x10(%rax), %rcx
movq 0x2c(%rax), %rdx
movq %rdx, 0x18(%rcx)
movq 0x34(%rax), %rdx
movq %rdx, 0x20(%rcx)
movq 0x10(%rax), %rax
movq $0x0, 0x10(%rax)
movq $0x1, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x28(%rbp), %rax
jae 0x8dab
movq -0xf0(%rbp), %rdi
movq (%rdi), %rax
callq *0x58(%rax)
movq %rax, -0x120(%rbp)
cmpq $0x0, %rax
je 0x8c66
movq -0x120(%rbp), %rdi
leaq 0x3157b(%rip), %rsi     # 0x3a1c8
leaq 0x3158c(%rip), %rdx     # 0x3a1e0
xorl %eax, %eax
movl %eax, %ecx
callq 0x82e0
movq %rax, -0x128(%rbp)
jmp 0x8c71
xorl %eax, %eax
movq %rax, -0x128(%rbp)
jmp 0x8c71
movq -0x128(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
callq 0x9960
movq %rax, %rcx
movq -0xf0(%rbp), %rax
movq %rcx, -0x158(%rbp)
movq 0x10(%rax), %rax
movq %rax, -0x160(%rbp)
movq -0x50(%rbp), %rdi
callq 0x9960
movq -0x160(%rbp), %rcx
movq -0x158(%rbp), %rdx
movq %rax, %rsi
movq -0xf0(%rbp), %rax
imulq $0x28, %rsi, %rsi
addq %rsi, %rcx
movq %rdx, 0x10(%rcx)
movq 0x10(%rax), %rax
movq %rax, -0x150(%rbp)
movq -0x50(%rbp), %rdi
callq 0x9960
movq -0x150(%rbp), %rcx
movq %rax, %rdx
movq -0xf0(%rbp), %rax
imulq $0x28, %rdx, %rdx
addq %rdx, %rcx
movw $0x2, 0x18(%rcx)
movq -0x50(%rbp), %rcx
movq 0x30(%rcx), %rcx
movq %rcx, -0x140(%rbp)
movq 0x10(%rax), %rax
movq %rax, -0x148(%rbp)
movq -0x50(%rbp), %rdi
callq 0x9960
movq -0x148(%rbp), %rdx
movq -0x140(%rbp), %rsi
imulq $0x28, %rax, %rax
addq %rax, %rdx
addq $0x18, %rdx
addq $0x4, %rdx
movl $0x2, %edi
callq 0x8430
movq -0x50(%rbp), %rax
movq 0x38(%rax), %rax
movzwl %ax, %edi
callq 0x8060
movw %ax, %cx
movq -0xf0(%rbp), %rax
movw %cx, -0x132(%rbp)
movq 0x10(%rax), %rax
movq %rax, -0x130(%rbp)
movq -0x50(%rbp), %rdi
callq 0x9960
movw -0x132(%rbp), %cx
movq %rax, %rdx
movq -0x130(%rbp), %rax
imulq $0x28, %rdx, %rdx
addq %rdx, %rax
movw %cx, 0x1a(%rax)
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x8c17
movq -0xf0(%rbp), %rax
movq 0x18(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x8030
movq %rax, %rcx
movq -0xf0(%rbp), %rax
movq %rcx, -0x58(%rbp)
movq 0x18(%rax), %rax
movl $0x8, %ecx
mulq %rcx
movq %rax, %rdi
seto %cl
movq $-0x1, %rax
testb $0x1, %cl
cmovneq %rax, %rdi
callq 0x8030
movq %rax, -0x60(%rbp)
movq $0x0, -0x68(%rbp)
movq -0xf0(%rbp), %rcx
movq -0x68(%rbp), %rax
cmpq 0x18(%rcx), %rax
jae 0x8ef4
movq -0xf0(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x68(%rbp), %rcx
leaq (%rcx,%rcx,4), %rcx
movzwl 0x1a(%rax,%rcx,8), %edi
callq 0x8420
movw %ax, %cx
movq -0xf0(%rbp), %rax
movzwl %cx, %ecx
movl %ecx, %esi
movq -0x58(%rbp), %rcx
movq -0x68(%rbp), %rdx
movq %rsi, (%rcx,%rdx,8)
movq 0x10(%rax), %rax
movq -0x68(%rbp), %rcx
leaq (%rcx,%rcx,4), %rcx
leaq 0x1c(%rax,%rcx,8), %rsi
movl $0x2, %edi
leaq -0x80(%rbp), %rdx
movq %rdx, -0x170(%rbp)
movl $0x10, %ecx
callq 0x82b0
movl $0x20, %edi
callq 0x8290
movq -0x170(%rbp), %rsi
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x168(%rbp)
callq 0x9980
jmp 0x8eb3
movq -0x168(%rbp), %rdx
movq -0x60(%rbp), %rax
movq -0x68(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
jmp 0x8e16
movq -0x168(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
callq 0x8260
jmp 0x8fac
movq -0xf0(%rbp), %rax
movq 0x20(%rax), %rsi
movq 0x40(%rax), %rcx
movq 0x18(%rax), %r8
movq -0x58(%rbp), %r9
movq -0x60(%rbp), %rax
leaq -0xc8(%rbp), %rdi
xorl %edx, %edx
movq %rax, (%rsp)
callq 0x99c0
movq $0x1, -0xd0(%rbp)
movq -0xf0(%rbp), %rcx
movq -0xd0(%rbp), %rax
cmpq 0x18(%rcx), %rax
jae 0x8f97
movq -0xf0(%rbp), %rdi
movq -0xd0(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq (%rdi), %rax
movq 0x50(%rax), %rax
leaq -0xc8(%rbp), %rsi
callq *%rax
jmp 0x8f67
jmp 0x8f69
movq -0xd0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xd0(%rbp)
jmp 0x8f2c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x30(%rbp)
movl %eax, -0x34(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x9b40
jmp 0x8fac
leaq -0xc8(%rbp), %rdi
callq 0x9b40
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
movq -0x30(%rbp), %rdi
callq 0x83e0
nopw %cs:(%rax,%rax)
nop