// File: /workspace/github_c_makefile_star2_O0/jfriesse[P]omping/aiifunc.c
// Function: aii_return_ip_ver
int
aii_return_ip_ver(struct aii_list *aii_list, int ip_ver, const char *mcast_addr, const char *port)
{
	struct addrinfo *ai_res;
	struct ai_item *aip;
	int mcast_ipver;
	int ipver_res, ipver_res2;

	if (ip_ver != 0) {
		DEBUG_PRINTF("user forced forced ip_ver is %d, using that", ip_ver);
		return (ip_ver);
	}

	if (mcast_addr != NULL) {
		ai_res = af_host_to_ai(mcast_addr, port, ip_ver);
		mcast_ipver = af_ai_deep_supported_ipv(ai_res);

		DEBUG2_PRINTF("mcast_ipver for %s is %d", mcast_addr, mcast_ipver);

		freeaddrinfo(ai_res);

		if (mcast_ipver == -1) {
			errx(1, "Mcast address %s doesn't support ipv4 or ipv6", mcast_addr);
		}

		if (mcast_ipver != 0) {
			DEBUG_PRINTF("mcast address for %s supports only ipv%d, using that",
			    mcast_addr, mcast_ipver);

			/*
			 * Walk thru all addresses to find out, what it supports
			 */
			TAILQ_FOREACH(aip, aii_list, entries) {
				ipver_res = af_ai_deep_supported_ipv(aip->ai);
				DEBUG2_PRINTF("ipver for %s is %d", aip->host_name, ipver_res);

				if (ipver_res == -1) {
					errx(1, "Host %s doesn't support ipv4 or ipv6",
					    aip->host_name);
				}

				if (ipver_res != 0 && ipver_res != mcast_ipver) {
					errx(1, "Multicast address is ipv%d but host %s supports"
					    " only ipv%d", mcast_ipver, aip->host_name, ipver_res);
				}
			}

			return (mcast_ipver);
		}
	}

	ipver_res = 0;

	/*
	 * Walk thru all addresses to find out, what it supports
	 */
	TAILQ_FOREACH(aip, aii_list, entries) {
		ipver_res = af_ai_deep_supported_ipv(aip->ai);
		DEBUG2_PRINTF("ipver for %s is %d", aip->host_name, ipver_res);

		if (ipver_res == -1) {
			errx(1, "Host %s doesn't support ipv4 or ipv6", aip->host_name);
		}

		if (ipver_res != 0) {
			break;
		}
	}

	if (ipver_res == 0) {
		/*
		 * Every address support every version
		 */
		DEBUG_PRINTF("Every address support all IP versions");
		return (0);
	}

	if (ipver_res != 0) {
		/*
		 * Host supports only one version.
		 * Test availability for that version on all hosts
		 */
		TAILQ_FOREACH(aip, aii_list, entries) {
			ipver_res2 = af_ai_deep_supported_ipv(aip->ai);
			DEBUG2_PRINTF("ipver for %s is %d", aip->host_name, ipver_res2);

			if (ipver_res2 == -1) {
				errx(1, "Host %s doesn't support ipv4 or ipv6", aip->host_name);
			}

			if (ipver_res2 != 0 && ipver_res2 != ipver_res) {
				/*
				 * Host doesn't support ip version of other members
				 */
				errx(1, "Host %s doesn't support IP version %d", aip->host_name,
				    ipver_res);
			}
		}
	}

	DEBUG_PRINTF("Every address support ipv%d", ipver_res);

	return (ipver_res);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x418b
movl -0x14(%rbp), %r8d
leaq 0xa08a(%rip), %rdi      # 0xe1f2
movl $0x1c1, %esi            # imm = 0x1C1
movl $0x2, %edx
leaq 0xa25e(%rip), %rcx      # 0xe3d7
movb $0x0, %al
callq 0x5dc0
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x44bb
cmpq $0x0, -0x20(%rbp)
je 0x4301
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x14(%rbp), %edx
callq 0x2db0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
callq 0x28e0
movl %eax, -0x3c(%rbp)
movq -0x20(%rbp), %r8
movl -0x3c(%rbp), %r9d
leaq 0xa02d(%rip), %rdi      # 0xe1f2
movl $0x1c9, %esi            # imm = 0x1C9
movl $0x3, %edx
leaq 0xa22d(%rip), %rcx      # 0xe403
movb $0x0, %al
callq 0x5dc0
movq -0x30(%rbp), %rdi
callq 0x2340
cmpl $-0x1, -0x3c(%rbp)
jne 0x4203
movq -0x20(%rbp), %rdx
movl $0x1, %edi
leaq 0xa220(%rip), %rsi      # 0xe41c
movb $0x0, %al
callq 0x20d0
cmpl $0x0, -0x3c(%rbp)
je 0x42ff
movq -0x20(%rbp), %r8
movl -0x3c(%rbp), %r9d
leaq 0x9fd6(%rip), %rdi      # 0xe1f2
movl $0x1d3, %esi            # imm = 0x1D3
movl $0x2, %edx
leaq 0xa21d(%rip), %rcx      # 0xe44a
movb $0x0, %al
callq 0x5dc0
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x42f4
movq -0x38(%rbp), %rax
movq (%rax), %rdi
callq 0x28e0
movl %eax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movq 0x80(%rax), %r8
movl -0x40(%rbp), %r9d
leaq 0x9f83(%rip), %rdi      # 0xe1f2
movl $0x1da, %esi            # imm = 0x1DA
movl $0x3, %edx
leaq 0xa189(%rip), %rcx      # 0xe409
movb $0x0, %al
callq 0x5dc0
cmpl $-0x1, -0x40(%rbp)
jne 0x42ab
movq -0x38(%rbp), %rax
movq 0x80(%rax), %rdx
movl $0x1, %edi
leaq 0xa1db(%rip), %rsi      # 0xe47f
movb $0x0, %al
callq 0x20d0
cmpl $0x0, -0x40(%rbp)
je 0x42de
movl -0x40(%rbp), %eax
cmpl -0x3c(%rbp), %eax
je 0x42de
movl -0x3c(%rbp), %edx
movq -0x38(%rbp), %rax
movq 0x80(%rax), %rcx
movl -0x40(%rbp), %r8d
movl $0x1, %edi
leaq 0xa1cd(%rip), %rsi      # 0xe4a4
movb $0x0, %al
callq 0x20d0
jmp 0x42e0
movq -0x38(%rbp), %rax
movq 0x88(%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0x423f
movl -0x3c(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x44bb
jmp 0x4301
movl $0x0, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x4399
movq -0x38(%rbp), %rax
movq (%rax), %rdi
callq 0x28e0
movl %eax, -0x40(%rbp)
movq -0x38(%rbp), %rax
movq 0x80(%rax), %r8
movl -0x40(%rbp), %r9d
leaq 0x9eb3(%rip), %rdi      # 0xe1f2
movl $0x1f2, %esi            # imm = 0x1F2
movl $0x3, %edx
leaq 0xa0b9(%rip), %rcx      # 0xe409
movb $0x0, %al
callq 0x5dc0
cmpl $-0x1, -0x40(%rbp)
jne 0x437b
movq -0x38(%rbp), %rax
movq 0x80(%rax), %rdx
movl $0x1, %edi
leaq 0xa10b(%rip), %rsi      # 0xe47f
movb $0x0, %al
callq 0x20d0
cmpl $0x0, -0x40(%rbp)
je 0x4383
jmp 0x4399
jmp 0x4385
movq -0x38(%rbp), %rax
movq 0x88(%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0x4313
cmpl $0x0, -0x40(%rbp)
jne 0x43ca
leaq 0x9e4c(%rip), %rdi      # 0xe1f2
movl $0x201, %esi            # imm = 0x201
movl $0x2, %edx
leaq 0xa128(%rip), %rcx      # 0xe4df
movb $0x0, %al
callq 0x5dc0
movl $0x0, -0x4(%rbp)
jmp 0x44bb
cmpl $0x0, -0x40(%rbp)
je 0x4492
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x4490
movq -0x38(%rbp), %rax
movq (%rax), %rdi
callq 0x28e0
movl %eax, -0x44(%rbp)
movq -0x38(%rbp), %rax
movq 0x80(%rax), %r8
movl -0x44(%rbp), %r9d
leaq 0x9de3(%rip), %rdi      # 0xe1f2
movl $0x20c, %esi            # imm = 0x20C
movl $0x3, %edx
leaq 0x9fe9(%rip), %rcx      # 0xe409
movb $0x0, %al
callq 0x5dc0
cmpl $-0x1, -0x44(%rbp)
jne 0x444b
movq -0x38(%rbp), %rax
movq 0x80(%rax), %rdx
movl $0x1, %edi
leaq 0xa03b(%rip), %rsi      # 0xe47f
movb $0x0, %al
callq 0x20d0
cmpl $0x0, -0x44(%rbp)
je 0x447a
movl -0x44(%rbp), %eax
cmpl -0x40(%rbp), %eax
je 0x447a
movq -0x38(%rbp), %rax
movq 0x80(%rax), %rdx
movl -0x40(%rbp), %ecx
movl $0x1, %edi
leaq 0xa092(%rip), %rsi      # 0xe505
movb $0x0, %al
callq 0x20d0
jmp 0x447c
movq -0x38(%rbp), %rax
movq 0x88(%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0x43df
jmp 0x4492
movl -0x40(%rbp), %r8d
leaq 0x9d55(%rip), %rdi      # 0xe1f2
movl $0x21c, %esi            # imm = 0x21C
movl $0x2, %edx
leaq 0xa07d(%rip), %rcx      # 0xe52b
movb $0x0, %al
callq 0x5dc0
movl -0x40(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop