// File: /workspace/github_cpp_makefile_star2_O3/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 %rdi, %r14
movq %rdx, 0x28(%rsp)
movl $0x1, 0x34(%rsp)
testq %rsi, %rsi
je 0x12aaf
movq %rsi, %rbx
leaq 0xfbe1(%rip), %r15      # 0x225c0
leaq 0x28(%rsp), %r13
leaq 0x8(%rsp), %rbp
leaq 0x34(%rsp), %r12
movl 0x4(%rbx), %edi
movl 0x8(%rbx), %esi
movl 0xc(%rbx), %edx
callq 0x5100
movl %eax, (%r14)
cmpl $-0x1, %eax
je 0x12a77
movl %eax, %edi
movl $0x1, %esi
movl $0x2, %edx
movq %r12, %rcx
movl $0x4, %r8d
callq 0x5730
cmpl $-0x1, %eax
je 0x12ac8
movl (%r14), %edi
movq 0x18(%rbx), %rsi
movl 0x10(%rbx), %edx
callq 0x50a0
cmpl $-0x1, %eax
jne 0x12aaf
movl (%r14), %edi
callq 0x57b0
movl $0xffffffff, (%r14)     # imm = 0xFFFFFFFF
callq 0x5060
movl (%rax), %edi
callq 0x51b0
movq %rax, 0x8(%rsp)
movq %r15, %rdi
movl $0x5, %esi
leaq 0x600a(%rip), %rdx      # 0x18a74
movq %r13, %rcx
movq %rbp, %r8
callq 0x13056
jmp 0x12aa2
callq 0x5060
movl (%rax), %edi
callq 0x51b0
movq %rax, 0x8(%rsp)
movq %r15, %rdi
movl $0x5, %esi
movq %r13, %rdx
leaq 0x5fb4(%rip), %rcx      # 0x18a4e
movq %rbp, %r8
callq 0x12f40
movq 0x28(%rbx), %rbx
testq %rbx, %rbx
jne 0x129ee
cmpl $-0x1, (%r14)
je 0x12b58
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x50, %edi
callq 0x5200
movq %rax, %rbx
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x5f82(%rip), %rsi      # 0x18a67
leaq 0x5f87(%rip), %rdx      # 0x18a73
leaq 0x8(%rsp), %rdi
callq 0x8e2c
callq 0x5060
movl (%rax), %edi
callq 0x51b0
leaq 0x38(%rsp), %rdi
leaq 0x7(%rsp), %rdx
movq %rax, %rsi
callq 0x7ae4
movq 0x28(%rsp), %rcx
movl (%r14), %r8d
movb $0x1, %bpl
leaq 0x8(%rsp), %rsi
leaq 0x38(%rsp), %rdx
movq %rbx, %rdi
callq 0x131a4
leaq 0xee90(%rip), %rax      # 0x219c8
movq %rax, (%rbx)
xorl %ebp, %ebp
leaq 0xed44(%rip), %rsi      # 0x21888
leaq 0x139(%rip), %rdx       # 0x12c84
movq %rbx, %rdi
callq 0x56f0
jmp 0x12bea
movl $0x50, %edi
callq 0x5200
movq %rax, %rbx
leaq 0x18(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x5f26(%rip), %rsi      # 0x18a9b
leaq 0x5f27(%rip), %rdx      # 0x18aa3
leaq 0x8(%rsp), %rdi
callq 0x8e2c
leaq 0x48(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x5f0d(%rip), %rsi      # 0x18aa4
leaq 0x5f30(%rip), %rdx      # 0x18ace
leaq 0x38(%rsp), %rdi
callq 0x8e2c
movb $0x1, %bpl
movq 0x28(%rsp), %rcx
leaq 0x8(%rsp), %rsi
leaq 0x38(%rsp), %rdx
movq %rbx, %rdi
movl $0xfffffffe, %r8d       # imm = 0xFFFFFFFE
callq 0x131a4
leaq 0xedf9(%rip), %rax      # 0x219c8
movq %rax, (%rbx)
xorl %ebp, %ebp
leaq 0xecad(%rip), %rsi      # 0x21888
leaq 0xa2(%rip), %rdx        # 0x12c84
movq %rbx, %rdi
callq 0x56f0
movq %rax, %r14
movq 0x38(%rsp), %rdi
cmpq %r12, %rdi
jne 0x12c0e
jmp 0x12c1b
jmp 0x12c39
jmp 0x12c55
movq %rax, %r14
leaq 0x48(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x12c1b
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x53f0
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x12c32
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x53f0
testb %bpl, %bpl
jne 0x12c58
jmp 0x12c60
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %r15, %rdi
je 0x12c58
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x53f0
jmp 0x12c58
movq %rax, %r14
movq %rbx, %rdi
callq 0x52e0
movq %r14, %rdi
callq 0x5720