// File: /workspace/github_cpp_makefile_star2_O1/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 0x64f6(%rip), %rbx      # 0x9fd0
leaq 0x354c(%rip), %rsi      # 0x702d
movl $0x2f, %edx
movq %rbx, %rdi
callq 0x32f0
movl 0x4c0(%r14), %esi
movq %rbx, %rdi
callq 0x3450
movq %rax, %r13
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r13, %rdi
movl $0xa, %esi
callq 0x3280
movsbl %al, %esi
movq %r13, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3190
movl %r12d, 0x4a8(%r14)
leaq 0x428(%r14), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x3250
leaq 0x3516(%rip), %rsi      # 0x705d
movl $0x15, %edx
movq %rbx, %rdi
callq 0x32f0
movq %r12, %rdi
callq 0x3130
movq %rbx, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x32f0
leaq 0x3502(%rip), %rsi      # 0x7073
movl $0x3, %edx
movq %rbx, %rdi
callq 0x32f0
testq %r15, %r15
je 0x3b9f
movq %r15, %rdi
callq 0x3130
movq 0x643e(%rip), %rdi      # 0x9fd0
movq %r15, %rsi
movq %rax, %rdx
callq 0x32f0
jmp 0x3bb6
movq (%rbx), %rax
movq -0x18(%rax), %rax
leaq (%rbx,%rax), %rdi
movl 0x20(%rbx,%rax), %esi
orl $0x1, %esi
callq 0x3430
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3280
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3190
movq %r12, %rdi
callq 0x32e0
movq %rax, 0x4b0(%r14)
testq %rax, %rax
je 0x3d60
leaq 0x408(%r14), %r15
movl $0x10, %esi
movq %r15, %rdi
callq 0x3460
movq 0x4b0(%r14), %rax
movq 0x18(%rax), %rcx
movq (%rcx), %rsi
leaq 0x40c(%r14), %rdi
movslq 0x14(%rax), %rdx
callq 0x3410
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 0x3d65
leaq 0x3417(%rip), %rsi      # 0x7090
movl $0x16, %edx
movq %rbx, %rdi
callq 0x32f0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3280
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3190
cmpl $0x1, 0x4c0(%r14)
jne 0x3d17
leaq 0x33e9(%rip), %rsi      # 0x70a7
movl $0x1d, %edx
movq %rbx, %rdi
callq 0x32f0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3280
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3190
movl (%r12), %edi
movq %r15, %rsi
movl $0x10, %edx
callq 0x3080
cmpl $-0x1, %eax
je 0x3d6d
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x33b0(%rip), %rsi      # 0x70ce
movl $0x15, %edx
movq %rbx, %rdi
callq 0x32f0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3280
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 0x3190
callq 0x3528
movq %r12, %rdi
callq 0x350c
movq %r12, %rdi
callq 0x34f0
nop