// File: /workspace/github_cpp_makefile_star2_O2/metopa[P]HTTP_Server/src/network/CPortObtainer.cpp
// Function: CPortObtainer::CSocketWrapper::CSocketWrapper(addrinfo*, char const*)
CPortObtainer::CSocketWrapper::CSocketWrapper( addrinfo * servinfo, const char * port ) {
	int yes = 1;

	for ( addrinfo * it = servinfo; it != nullptr; it = it->ai_next ) {
		if ( ( sockfd_m = socket( it->ai_family, it->ai_socktype, it->ai_protocol ) ) == -1 ) {
			Log.ger<>( DEBUG_NETWORK, port, "socket() returned error:", strerror( errno ) );
			continue;
		}

		if ( setsockopt( sockfd_m, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof( int ) ) == -1 ) {
			throw PortInitializationException( "setsockopt()", strerror( errno ), port, sockfd_m );
		}

		if ( bind( sockfd_m, it->ai_addr, it->ai_addrlen ) == -1 ) {
			close( sockfd_m );
			sockfd_m = -1;
			Log.ger<>( DEBUG_NETWORK, "Function bind() returned error on port", port, strerror( errno ) );
			continue;
		}
		break;
	}

	if ( sockfd_m == -1 )
		throw PortInitializationException( "socket()", "Function failed on all addrinfo structures", port );
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x10(%rsp), %r15
movq %rdx, (%r15)
leaq 0xc(%rsp), %rax
movl $0x1, (%rax)
leaq 0x11ff0(%rip), %r13     # 0x215f0
pushq $0x5
popq %rbp
leaq 0x18(%rsp), %r12
testq %rbx, %rbx
je 0xf6c1
movl 0x4(%rbx), %edi
movl 0x8(%rbx), %esi
movl 0xc(%rbx), %edx
callq 0x5120
movl %eax, (%r14)
cmpl $-0x1, %eax
je 0xf690
movl %eax, %edi
pushq $0x1
popq %rsi
pushq $0x2
popq %rdx
leaq 0xc(%rsp), %rcx
pushq $0x4
popq %r8
callq 0x5780
cmpl $-0x1, %eax
je 0xf6da
movl (%r14), %edi
movq 0x18(%rbx), %rsi
movl 0x10(%rbx), %edx
callq 0x50a0
cmpl $-0x1, %eax
jne 0xf6c1
movl (%r14), %edi
callq 0x5810
orl $-0x1, (%r14)
callq 0x5060
movl (%rax), %edi
callq 0x51c0
movq %rax, 0x18(%rsp)
movq %r13, %rdi
movl %ebp, %esi
leaq 0x5401(%rip), %rdx      # 0x14a84
movq %r15, %rcx
movq %r12, %r8
callq 0xfa84
jmp 0xf6b8
callq 0x5060
movl (%rax), %edi
callq 0x51c0
movq %rax, 0x18(%rsp)
movq %r13, %rdi
movl %ebp, %esi
movq %r15, %rdx
leaq 0x53ae(%rip), %rcx      # 0x14a5e
movq %r12, %r8
callq 0xf9d0
movq 0x28(%rbx), %rbx
jmp 0xf608
cmpl $-0x1, (%r14)
je 0xf750
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x50
popq %rdi
callq 0x5230
movq %rax, %rbx
leaq 0x538b(%rip), %rsi      # 0x14a77
leaq 0x18(%rsp), %rdi
leaq 0xb(%rsp), %rdx
callq 0x712a
callq 0x5060
movl (%rax), %edi
callq 0x51c0
leaq 0x38(%rsp), %rdi
leaq 0xa(%rsp), %rdx
movq %rax, %rsi
callq 0x712a
movq 0x10(%rsp), %rcx
movl (%r14), %r8d
movb $0x1, %bpl
leaq 0x18(%rsp), %rsi
leaq 0x38(%rsp), %rdx
movq %rbx, %rdi
callq 0xf818
xorl %ebp, %ebp
leaq 0x11179(%rip), %rsi     # 0x208b8
leaq 0xe8(%rip), %rdx        # 0xf82e
movq %rbx, %rdi
callq 0x5740
jmp 0xf7bd
pushq $0x50
popq %rdi
callq 0x5230
movq %rax, %rbx
leaq 0x5349(%rip), %rsi      # 0x14aab
leaq 0x18(%rsp), %rdi
leaq 0xb(%rsp), %rdx
callq 0x712a
leaq 0x533c(%rip), %rsi      # 0x14ab4
leaq 0x38(%rsp), %rdi
leaq 0xa(%rsp), %rdx
callq 0x712a
movb $0x1, %bpl
movq 0x10(%rsp), %rcx
leaq 0x18(%rsp), %rsi
leaq 0x38(%rsp), %rdx
pushq $-0x2
popq %r8
movq %rbx, %rdi
callq 0xf818
xorl %ebp, %ebp
leaq 0x1110a(%rip), %rsi     # 0x208b8
leaq 0x79(%rip), %rdx        # 0xf82e
movq %rbx, %rdi
callq 0x5740
jmp 0xf7c3
jmp 0xf7d2
jmp 0xf7e9
movq %rax, %r14
leaq 0x38(%rsp), %rdi
callq 0x5210
jmp 0xf7d8
movq %rax, %r14
movb $0x1, %bpl
leaq 0x18(%rsp), %rdi
callq 0x5210
testb %bpl, %bpl
jne 0xf7ec
jmp 0xf7f4
movq %rax, %r14
movq %rbx, %rdi
callq 0x5300
movq %r14, %rdi
callq 0x5770