// File: /workspace/github_cpp_makefile_star2_O2/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 %r12
pushq %rbx
movq %rcx, %r14
movl %edx, %r15d
movq %rdi, %rbx
movl %esi, 0x4c0(%rdi)
movq 0x57d1(%rip), %r12      # 0x7fd0
leaq 0x2827(%rip), %rsi      # 0x502d
movq %r12, %rdi
callq 0x2240
movl 0x4c0(%rbx), %esi
movq %rax, %rdi
callq 0x2400
movq %rax, %rdi
callq 0x2150
movl %r15d, 0x4a8(%rbx)
leaq 0x428(%rbx), %r15
movq %r15, %rdi
movq %r14, %rsi
callq 0x2210
leaq 0x2819(%rip), %rsi      # 0x505d
movq %r12, %rdi
callq 0x2240
movq %rax, %rdi
movq %r15, %rsi
callq 0x2240
leaq 0x2815(%rip), %rsi      # 0x5073
movq %rax, %rdi
callq 0x2240
movq %rax, %rdi
movq %r14, %rsi
callq 0x2240
movq %rax, %rdi
callq 0x2150
movq %r15, %rdi
callq 0x2280
movq %rax, 0x4b0(%rbx)
testq %rax, %rax
je 0x297d
leaq 0x408(%rbx), %r14
pushq $0x10
popq %rsi
movq %r14, %rdi
callq 0x2410
movq 0x4b0(%rbx), %rax
movq 0x18(%rax), %rcx
movq (%rcx), %rsi
leaq 0x40c(%rbx), %rdi
movslq 0x14(%rax), %rdx
callq 0x23c0
movq 0x4b0(%rbx), %rax
movzwl 0x10(%rax), %eax
movw %ax, 0x408(%rbx)
movzwl 0x4a8(%rbx), %eax
movw %ax, 0x40a(%rbx)
pushq $0x2
popq %rdi
movl %edi, %esi
xorl %edx, %edx
callq 0x20c0
movl %eax, 0x404(%rbx)
cmpl $-0x1, %eax
je 0x2991
movq 0x56cd(%rip), %rdi      # 0x7fd0
leaq 0x2786(%rip), %rsi      # 0x5090
callq 0x2240
movq %rax, %rdi
callq 0x2150
cmpl $0x1, 0x4c0(%rbx)
jne 0x295a
movq 0x56a9(%rip), %rdi      # 0x7fd0
leaq 0x2779(%rip), %rsi      # 0x50a7
callq 0x2240
movq %rax, %rdi
callq 0x2150
movl 0x404(%rbx), %edi
pushq $0x10
popq %rdx
movq %r14, %rsi
callq 0x2070
cmpl $-0x1, %eax
je 0x299a
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq 0x566f(%rip), %rdi      # 0x7fd0
leaq 0x2766(%rip), %rsi      # 0x50ce
callq 0x2240
movq %rax, %rdi
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x2150
leaq 0x26f3(%rip), %rdi      # 0x5077
callq 0x21c0
pushq $0x1
popq %rdi
callq 0x22a0
leaq 0x26ed(%rip), %rdi      # 0x5085
jmp 0x29a1
leaq 0x2724(%rip), %rdi      # 0x50c5
callq 0x21c0
movl 0x404(%rbx), %edi
callq 0x275c
nop