// File: /workspace/github_c_makefile_star2_O0/jfriesse[P]omping/aiifunc.c
// Function: aii_ipbc_to_ai
int
aii_ipbc_to_ai(struct ai_item *ipbc_addr, const char *ipbc_addr_s, const char *port_s,
    const struct ifaddrs *ifa_local)
{
	struct addrinfo *ai_res, *ai_i;
	char ifa_ipbc_addr_s[INET6_ADDRSTRLEN];
	int ip_ver;

	ip_ver = 4;

	if (ifa_local->ifa_broadaddr == NULL) {
		errx(1, "selected local interface isn't broadcast aware");
	}

	if (ipbc_addr_s == NULL) {
		af_sa_to_str(ifa_local->ifa_broadaddr, ifa_ipbc_addr_s);
		ipbc_addr_s = ifa_ipbc_addr_s;
	}

	ipbc_addr->host_name = (char *)malloc(strlen(ipbc_addr_s) + 1);
	if (ipbc_addr->host_name == NULL) {
		errx(1, "Can't alloc memory");
	}
	memcpy(ipbc_addr->host_name, ipbc_addr_s, strlen(ipbc_addr_s) + 1);

	ai_res = af_host_to_ai(ipbc_addr_s, port_s, ip_ver);

	for (ai_i = ai_res; ai_i != NULL; ai_i = ai_i->ai_next) {
		if (af_ai_supported_ipv(ai_i) == ip_ver) {
			memcpy(&ipbc_addr->sas, ai_i->ai_addr, ai_i->ai_addrlen);
			break;
		}
	}

	if (ai_i == NULL) {
		DEBUG_PRINTF("Internal program error");
		err(1, "Internal program error");
	}

	freeaddrinfo(ai_res);

	/*
	 * Test if interface broadcast addr is same as returned broadcast addr
	 */
	if (!af_sockaddr_eq(ifa_local->ifa_broadaddr, AF_CAST_SA(&ipbc_addr->sas))) {
		return (-1);
	}

	return (0);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movl $0x4, -0x74(%rbp)
movq -0x28(%rbp), %rax
cmpq $0x0, 0x28(%rax)
jne 0x3bd0
movl $0x1, %edi
leaq 0xa6d9(%rip), %rsi      # 0xe2a2
movb $0x0, %al
callq 0x20d0
cmpq $0x0, -0x18(%rbp)
jne 0x3bf0
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rdi
leaq -0x70(%rbp), %rsi
callq 0x3360
leaq -0x70(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x20c0
movq %rax, %rdi
addq $0x1, %rdi
callq 0x2250
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x80(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x80(%rax)
jne 0x3c34
movl $0x1, %edi
leaq 0xa5a7(%rip), %rsi      # 0xe1d4
movb $0x0, %al
callq 0x20d0
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rax
movq %rax, -0x88(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x18(%rbp), %rdi
callq 0x20c0
movq -0x88(%rbp), %rdi
movq -0x80(%rbp), %rsi
movq %rax, %rdx
addq $0x1, %rdx
callq 0x2200
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movl -0x74(%rbp), %edx
callq 0x2db0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x3ccb
movq -0x38(%rbp), %rdi
callq 0x29d0
cmpl -0x74(%rbp), %eax
jne 0x3cbb
movq -0x10(%rbp), %rdi
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rsi
movq -0x38(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, %edx
callq 0x2200
jmp 0x3ccb
jmp 0x3cbd
movq -0x38(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0x3c8a
cmpq $0x0, -0x38(%rbp)
jne 0x3d04
leaq 0xa519(%rip), %rdi      # 0xe1f2
movl $0x124, %esi            # imm = 0x124
movl $0x2, %edx
leaq 0xa33d(%rip), %rcx      # 0xe027
movb $0x0, %al
callq 0x5dc0
movl $0x1, %edi
leaq 0xa32a(%rip), %rsi      # 0xe027
movb $0x0, %al
callq 0x2240
movq -0x30(%rbp), %rdi
callq 0x2340
movq -0x28(%rbp), %rax
movq 0x28(%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0x24e0
cmpl $0x0, %eax
jne 0x3d2c
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x3d33
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x90, %rsp
popq %rbp
retq
nop