// File: /workspace/github_c_makefile_star2_O2/jfriesse[P]omping/addrfunc.c
// Function: af_is_supported_local_ifa
int
af_is_supported_local_ifa(const struct ifaddrs *ifa, int ip_ver, unsigned int if_flags)
{
	char ai_s[LOGGING_SA_TO_STR_LEN];

	logging_sa_to_str(ifa->ifa_addr, ai_s, sizeof(ai_s));

	if (ifa->ifa_flags & IFF_LOOPBACK) {
		DEBUG2_PRINTF("%s with addr %s is loopback", ifa->ifa_name, ai_s);

		return (0);
	}

	if (!(ifa->ifa_flags & IFF_UP)) {
		DEBUG2_PRINTF("%s with addr %s is not up", ifa->ifa_name, ai_s);

		return (0);
	}

	if (if_flags & IFF_MULTICAST) {
		if (!(ifa->ifa_flags & IFF_MULTICAST)) {
			DEBUG2_PRINTF("%s with addr %s doesn't support mcast", ifa->ifa_name, ai_s);

			return (0);
		}
	}

	if (if_flags & IFF_BROADCAST) {
		if (!(ifa->ifa_flags & IFF_BROADCAST)) {
			DEBUG2_PRINTF("%s with addr %s doesn't support broadcast", ifa->ifa_name,
			    ai_s);

			return (0);
		}
	}

	if (ip_ver != 0 && af_sa_supported_ipv(ifa->ifa_addr) != ip_ver) {
		DEBUG2_PRINTF("%s doesn't support requested ipv%d", ai_s, ip_ver);

		return (0);
	}


	if (ip_ver == 0 && af_sa_supported_ipv(ifa->ifa_addr) == 4) {
		DEBUG2_PRINTF("%s doesn't support ipv6. Saving ipv4 as fallback", ai_s);

		return (2);
	}

	DEBUG_PRINTF("Found local addr %s as device %s", ai_s, ifa->ifa_name);
	return (1);
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x40, %rsp
movl %edx, %ebx
movl %esi, %ebp
movq %rdi, %r14
movq 0x18(%rdi), %rdi
movq %rsp, %rsi
pushq $0x3e
popq %rdx
callq 0x4877
movl 0x10(%r14), %eax
testb $0x8, %al
jne 0x2a5c
testb $0x1, %al
jne 0x2a8d
movq 0x8(%r14), %r8
leaq 0x65da(%rip), %rdi      # 0x9020
leaq 0x66c4(%rip), %rcx      # 0x9111
xorl %ebx, %ebx
pushq $0x3
popq %rdx
movq %rsp, %r9
movl $0x193, %esi            # imm = 0x193
jmp 0x2a7b
movq 0x8(%r14), %r8
leaq 0x65b9(%rip), %rdi      # 0x9020
leaq 0x6687(%rip), %rcx      # 0x90f5
xorl %ebx, %ebx
pushq $0x3
popq %rdx
movq %rsp, %r9
movl $0x18d, %esi            # imm = 0x18D
xorl %eax, %eax
callq 0x4998
movl %ebx, %eax
addq $0x40, %rsp
popq %rbx
popq %r14
popq %rbp
retq
btl $0xc, %ebx
setae %cl
movl %eax, %edx
shrl $0xc, %edx
andl $0x1, %edx
orb %cl, %dl
jne 0x2ac1
movq 0x8(%r14), %r8
leaq 0x6575(%rip), %rdi      # 0x9020
leaq 0x6679(%rip), %rcx      # 0x912b
xorl %ebx, %ebx
pushq $0x3
popq %rdx
movq %rsp, %r9
movl $0x19a, %esi            # imm = 0x19A
jmp 0x2a7b
testb $0x2, %bl
sete %cl
andl $0x2, %eax
shrl %eax
orb %cl, %al
jne 0x2af1
movq 0x8(%r14), %r8
leaq 0x6545(%rip), %rdi      # 0x9020
leaq 0x666f(%rip), %rcx      # 0x9151
xorl %ebx, %ebx
pushq $0x3
popq %rdx
movq %rsp, %r9
movl $0x1a3, %esi            # imm = 0x1A3
jmp 0x2a7b
movq 0x18(%r14), %rax
movzwl (%rax), %eax
testl %ebp, %ebp
je 0x2b3e
xorl %ebx, %ebx
cmpw $0xa, %ax
pushq $0x6
popq %rcx
cmovnel %ebx, %ecx
cmpw $0x2, %ax
pushq $0x4
popq %rax
cmovnel %ecx, %eax
cmpl %ebp, %eax
je 0x2b68
leaq 0x6503(%rip), %rdi      # 0x9020
leaq 0x6657(%rip), %rcx      # 0x917b
pushq $0x3
popq %rdx
movq %rsp, %r8
movl $0x1aa, %esi            # imm = 0x1AA
movl %ebp, %r9d
xorl %eax, %eax
callq 0x4998
jmp 0x2a82
cmpw $0x2, %ax
jne 0x2b68
leaq 0x64d5(%rip), %rdi      # 0x9020
leaq 0x664c(%rip), %rcx      # 0x919e
pushq $0x3
popq %rdx
movq %rsp, %r8
movl $0x1b1, %esi            # imm = 0x1B1
xorl %eax, %eax
callq 0x4998
pushq $0x2
jmp 0x2b8e
movq 0x8(%r14), %r9
leaq 0x64ad(%rip), %rdi      # 0x9020
leaq 0x6655(%rip), %rcx      # 0x91cf
pushq $0x2
popq %rdx
movq %rsp, %r8
movl $0x1b6, %esi            # imm = 0x1B6
xorl %eax, %eax
callq 0x4998
pushq $0x1
popq %rbx
jmp 0x2a82