// File: /workspace/github_cpp_makefile_star2_O3/yasz24[P]eau2/src/network/./network_ip.h
// Function: NetworkIP::client_init(unsigned long, char*, unsigned long, char*, unsigned long)
void client_init(size_t idx, char* ip, size_t port, char* server_adr, size_t server_port) {
        this_node_ = idx;
        init_sock_(ip, port);
        nodes_ = new NodeInfo[1];
        nodes_[0].id = 0;
        nodes_[0].address.sin_family = AF_INET;

        nodes_[0].address.sin_addr.s_addr = inet_addr(ip);
        nodes_[0].address.sin_port = htons(server_port);
        
        char client_ip[INET_ADDRSTRLEN];
        inet_ntop(AF_INET, &ip_.sin_addr, client_ip, INET_ADDRSTRLEN);
        std::cout << "creating registration msg, port: " << port <<"\n";
        Register reg(this_node_, 0, msg_id, client_ip, port);

        send_msg(&reg);

        Directory* ipd = dynamic_cast<Directory*>(recv_msg());
        num_nodes_ = ipd->clients;
        NodeInfo * nodes = new NodeInfo[num_nodes_];
        for (size_t i = 0; i < num_nodes_; i++) {
            char* node_ip = ipd->addresses[i]->c_str();
            size_t node_port = ipd->ports[i];
            nodes[i].id = i;
            nodes[i].address.sin_family = AF_INET;
            if (inet_pton(AF_INET, node_ip, &nodes[i].address.sin_addr) < 0) {
                perror("Node storage:");
            }
            nodes[i].address.sin_port = htons(node_port);
            int decoded_port = ntohs(nodes[i].address.sin_port);
            char decoded_ip[INET_ADDRSTRLEN];
            inet_ntop(AF_INET, &nodes[i].address.sin_addr, decoded_ip, INET_ADDRSTRLEN);
            std::cout << "Directory: node " << i << ", ip: " <<  decoded_ip << ", port: " << decoded_port << "\n";
            //nodes[i].address.sin_addr.s_addr = inet_addr(node_ip);
        }
        nodes_ = nodes;
        delete ipd;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %r9, %r15
movq %rcx, %rbx
movq %rdx, %r14
movq %rdi, %r13
movq %rsi, 0x20(%rdi)
movq %rdx, %rsi
movq %rcx, %rdx
callq 0x7e70
movl $0x30, %edi
callq 0x7030
movq $0x1, (%rax)
leaq 0x8(%rax), %rcx
xorl %edx, %edx
movq %rdx, 0x10(%rax)
leaq 0x1faae(%rip), %r12     # 0x27358
movq %r12, 0x8(%rax)
movq %rcx, 0x10(%r13)
movq %rdx, 0x18(%rax)
movw $0x2, 0x20(%rax)
movq %r14, %rdi
callq 0x7240
movq 0x10(%r13), %rcx
movl %eax, 0x1c(%rcx)
rolw $0x8, %r15w
movw %r15w, 0x1a(%rcx)
leaq 0x30(%r13), %rsi
leaq -0x60(%rbp), %r15
movl $0x2, %edi
movq %r15, %rdx
movl $0x10, %ecx
callq 0x7260
movq 0x216da(%rip), %r14     # 0x28fd0
leaq 0x1586b(%rip), %rsi     # 0x1d168
movl $0x21, %edx
movq %r14, %rdi
callq 0x7290
movq %r14, %rdi
xorl %r14d, %r14d
movq %rbx, %rsi
callq 0x7170
leaq 0x157ca(%rip), %rsi     # 0x1d0e9
movl $0x1, %edx
movq %rax, %rdi
callq 0x7290
movq 0x20(%r13), %rax
movq 0x40(%r13), %rcx
leaq -0xa0(%rbp), %rsi
movq %r14, 0x8(%rsi)
leaq 0x1fa7a(%rip), %rdx     # 0x273c0
movq %rdx, (%rsi)
movl $0x8, 0x10(%rsi)
movq %rax, 0x18(%rsi)
movq %r14, 0x20(%rsi)
movq %rcx, 0x28(%rsi)
movq %r15, 0x30(%rsi)
movq %rbx, 0x38(%rsi)
movq (%r13), %rax
movq %r13, %rdi
callq *0x50(%rax)
movq (%r13), %rax
movq %r13, -0x30(%rbp)
movq %r13, %rdi
callq *0x58(%rax)
testq %rax, %rax
je 0x799c
leaq 0x1f990(%rip), %rsi     # 0x27318
leaq 0x1f9a1(%rip), %rdx     # 0x27330
movq %rax, %rdi
xorl %ecx, %ecx
callq 0x7280
movq %rax, %r14
movq 0x30(%r14), %rbx
movl $0x28, %ecx
movq %rbx, %rax
mulq %rcx
seto %cl
addq $0x8, %rax
movq $-0x1, %rdi
cmovbq %rdi, %rax
movq -0x30(%rbp), %rdx
movq %rbx, 0x18(%rdx)
testb %cl, %cl
cmoveq %rax, %rdi
callq 0x7030
movq %rax, %r15
movq %rbx, (%rax)
addq $0x8, %rax
movq %rax, -0x38(%rbp)
testq %rbx, %rbx
je 0x7b31
leaq (,%rbx,8), %rax
leaq (%rax,%rax,4), %rax
xorl %ecx, %ecx
movq $0x0, 0x10(%r15,%rcx)
movq %r12, 0x8(%r15,%rcx)
addq $0x28, %rcx
cmpq %rcx, %rax
jne 0x79f5
testq %rbx, %rbx
je 0x7b55
addq $0x24, %r15
xorl %r12d, %r12d
movq %r14, -0x40(%rbp)
movq 0x40(%r14), %rax
movq (%rax,%r12,8), %rdi
movq (%rdi), %rax
callq *0x30(%rax)
movq 0x38(%r14), %rcx
movq (%rcx,%r12,8), %rbx
movq %r12, -0xc(%r15)
movw $0x2, -0x4(%r15)
movl $0x2, %edi
movq %rax, %rsi
movq %r15, %rdx
callq 0x73e0
testl %eax, %eax
js 0x7b20
movl %ebx, %eax
rolw $0x8, %ax
movw %ax, -0x2(%r15)
movzwl %bx, %ebx
movl $0x2, %edi
movq %r15, %rsi
leaq -0x50(%rbp), %r13
movq %r13, %rdx
movl $0x10, %ecx
callq 0x7260
movl $0x10, %edx
movq 0x21544(%rip), %r14     # 0x28fd0
movq %r14, %rdi
leaq 0x15702(%rip), %rsi     # 0x1d198
callq 0x7290
movq %r14, %rdi
movq %r12, %rsi
callq 0x7170
movq %rax, %r14
movl $0x6, %edx
movq %rax, %rdi
leaq 0x156f1(%rip), %rsi     # 0x1d1a9
callq 0x7290
movq %r13, %rdi
callq 0x7100
movq %r14, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x7290
movl $0x8, %edx
movq %r14, %rdi
leaq 0x1569f(%rip), %rsi     # 0x1d181
callq 0x7290
movq %r14, %rdi
movl %ebx, %esi
callq 0x73a0
movl $0x1, %edx
movq %rax, %rdi
leaq 0x155e9(%rip), %rsi     # 0x1d0e9
callq 0x7290
incq %r12
addq $0x28, %r15
movq -0x30(%rbp), %rax
cmpq 0x18(%rax), %r12
movq -0x40(%rbp), %r14
jb 0x7a20
jmp 0x7b31
leaq 0x15663(%rip), %rdi     # 0x1d18a
callq 0x71c0
jmp 0x7a59
movq -0x30(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq (%r14), %rax
movq %r14, %rdi
callq *0x8(%rax)
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq -0x30(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rcx, 0x10(%rax)
testq %r14, %r14
jne 0x7b3d
jmp 0x7b46