// File: /workspace/github_cpp_makefile_star2_O3/CDISC2020[P]Projet_satellite_agile/src/ARINC/ARINC_Com.cpp
// Function: QueuingPort::QueuingPort(int, int, char*)
QueuingPort::QueuingPort (int m, int p, char* S) {

              // Parameters
                mode=m; // m=1 client, m=2 server
                cout << "Initialization in mode (O: client; 1:server) = " << mode << endl;
                port=p;
                strcpy(host_s, S);
cout << "*** TRACE : host_s = " << host_s << " S=" << S << endl;

                // Initialisation of host entry
                if ((s_h = gethostbyname(host_s)) == NULL) {
                        perror("gethostbyname");
                        exit(1);
                        } 

                // Initialisation of server address
                bzero((char *) &s_a, sizeof(s_a));
                bcopy(s_h->h_addr, (char *)&s_a.sin_addr, s_h->h_length);
                s_a.sin_family = s_h->h_addrtype;
                s_a.sin_port = port /* SERVER port */ ;

                // Creation of the Socket
                 if ((s_d = socket(AF_INET, SOCK_DGRAM, 0)) == SOCK_ERR) {
                        perror("C-> socket");
                        bye(s_d);
                }
                cout << "Socket creation... ok!" << endl;

                // Binding in server mode
                if (mode==1) { // Server mode
                        cout << "Status Server mode (bind)... " << endl;
                        if (bind(s_d, (struct sockaddr *)&s_a, sizeof(s_a)) == SOCK_ERR) { 
                        perror("S-> bind");
                        bye(s_d);
                        }
                }
                else 
                        cout << "Status Client Mode..." << endl;

        }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r15
movl %edx, %r12d
movq %rdi, %r14
movl %esi, 0x4c0(%rdi)
movq 0x64e6(%rip), %rbx      # 0x9fd0
leaq 0x353c(%rip), %rsi      # 0x702d
movl $0x2f, %edx
movq %rbx, %rdi
callq 0x3300
movl 0x4c0(%r14), %esi
movq %rbx, %rdi
callq 0x3460
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
movq %r13, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31a0
movl %r12d, 0x4a8(%r14)
leaq 0x428(%r14), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x3260
leaq 0x3506(%rip), %rsi      # 0x705d
movl $0x15, %edx
movq %rbx, %rdi
callq 0x3300
movq %r12, %rdi
callq 0x3130
movq %rbx, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x3300
leaq 0x34f2(%rip), %rsi      # 0x7073
movl $0x3, %edx
movq %rbx, %rdi
callq 0x3300
testq %r15, %r15
je 0x3baf
movq %r15, %rdi
callq 0x3130
movq 0x642e(%rip), %rdi      # 0x9fd0
movq %r15, %rsi
movq %rax, %rdx
callq 0x3300
jmp 0x3bc6
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x3440
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31a0
movq %r12, %rdi
callq 0x32f0
movq %rax, 0x4b0(%r14)
testq %rax, %rax
je 0x3d70
leaq 0x408(%r14), %r15
movl $0x10, %esi
movq %r15, %rdi
callq 0x3470
movq 0x4b0(%r14), %rax
movq 0x18(%rax), %rcx
movq (%rcx), %rsi
leaq 0x40c(%r14), %rdi
movslq 0x14(%rax), %rdx
callq 0x3420
movq 0x4b0(%r14), %rax
movzwl 0x10(%rax), %eax
movw %ax, 0x408(%r14)
movzwl 0x4a8(%r14), %eax
movw %ax, 0x40a(%r14)
movl $0x2, %edi
movl $0x2, %esi
xorl %edx, %edx
callq 0x30c0
leaq 0x404(%r14), %r12
movl %eax, 0x404(%r14)
cmpl $-0x1, %eax
je 0x3d75
leaq 0x3407(%rip), %rsi      # 0x7090
movl $0x16, %edx
movq %rbx, %rdi
callq 0x3300
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31a0
cmpl $0x1, 0x4c0(%r14)
jne 0x3d27
leaq 0x33d9(%rip), %rsi      # 0x70a7
movl $0x1d, %edx
movq %rbx, %rdi
callq 0x3300
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x31a0
movl (%r12), %edi
movq %r15, %rsi
movl $0x10, %edx
callq 0x3080
cmpl $-0x1, %eax
je 0x3d7d
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x33a0(%rip), %rsi      # 0x70ce
movl $0x15, %edx
movq %rbx, %rdi
callq 0x3300
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3290
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x31a0
callq 0x3538
movq %r12, %rdi
callq 0x351c
movq %r12, %rdi
callq 0x3500
nop