// File: /workspace/github_c_makefile_star2_O0/janet-lang[P]janet/src/core/net.c
// Function: janet_get_addrinfo
static struct addrinfo *janet_get_addrinfo(Janet *argv, int32_t offset, int socktype, int passive, int *is_unix) {
    /* Unix socket support - not yet supported on windows. */
#ifndef JANET_WINDOWS
    if (janet_keyeq(argv[offset], "unix")) {
        const char *path = janet_getcstring(argv, offset + 1);
        struct sockaddr_un *saddr = janet_calloc(1, sizeof(struct sockaddr_un));
        if (saddr == NULL) {
            JANET_OUT_OF_MEMORY;
        }
        saddr->sun_family = AF_UNIX;
        size_t path_size = sizeof(saddr->sun_path);
#ifdef JANET_LINUX
        if (path[0] == '@') {
            saddr->sun_path[0] = '\0';
            snprintf(saddr->sun_path + 1, path_size - 1, "%s", path + 1);
        } else
#endif
        {
            snprintf(saddr->sun_path, path_size, "%s", path);
        }
        *is_unix = 1;
        return (struct addrinfo *) saddr;
    }
#endif
    /* Get host and port */
    char *host = (char *)janet_getcstring(argv, offset);
    char *port = NULL;
    if (janet_checkint(argv[offset + 1])) {
        port = (char *)janet_to_string(argv[offset + 1]);
    } else {
        port = (char *)janet_optcstring(argv, offset + 2, offset + 1, NULL);
    }
    /* getaddrinfo */
    struct addrinfo *ai = NULL;
    struct addrinfo hints;
    memset(&hints, 0, sizeof(hints));
    hints.ai_family = AF_UNSPEC;
    hints.ai_socktype = socktype;
    hints.ai_flags = passive ? AI_PASSIVE : 0;
    int status = getaddrinfo(host, port, &hints, &ai);
    if (status) {
        janet_panicf("could not get address info: %s", gai_strerror(status));
    }
    *is_unix = 0;
    return ai;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x476ad(%rip), %rsi     # 0x8f84c
callq 0x1b010
cmpl $0x0, %eax
je 0x48290
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
addl $0x1, %esi
callq 0x1c280
movq %rax, -0x30(%rbp)
movl $0x1, %edi
movl $0x6e, %esi
callq 0x125a0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x4820a
jmp 0x481dc
movq 0x67e0d(%rip), %rax     # 0xafff0
movq (%rax), %rdi
leaq 0x35e17(%rip), %rsi     # 0x7e004
leaq 0x47476(%rip), %rdx     # 0x8f66a
movl $0x15f, %ecx            # imm = 0x15F
movb $0x0, %al
callq 0x125f0
movl $0x1, %edi
callq 0x12a70
movq -0x38(%rbp), %rax
movw $0x1, (%rax)
movq $0x6c, -0x40(%rbp)
movq -0x30(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x40, %eax
jne 0x4825b
movq -0x38(%rbp), %rax
movb $0x0, 0x2(%rax)
movq -0x38(%rbp), %rdi
addq $0x2, %rdi
addq $0x1, %rdi
movq -0x40(%rbp), %rsi
subq $0x1, %rsi
movq -0x30(%rbp), %rcx
addq $0x1, %rcx
leaq 0x4d110(%rip), %rdx     # 0x95362
movb $0x0, %al
callq 0x12390
jmp 0x48279
movq -0x38(%rbp), %rdi
addq $0x2, %rdi
movq -0x40(%rbp), %rsi
movq -0x30(%rbp), %rcx
leaq 0x4d0f0(%rip), %rdx     # 0x95362
movb $0x0, %al
callq 0x12390
movq -0x28(%rbp), %rax
movl $0x1, (%rax)
movq -0x38(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x48392
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x1c280
movq %rax, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
callq 0x6d480
cmpl $0x0, %eax
je 0x482df
movq -0x10(%rbp), %rax
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
callq 0x5abf0
movq %rax, -0x50(%rbp)
jmp 0x482fc
movq -0x10(%rbp), %rdi
movl -0x14(%rbp), %esi
addl $0x2, %esi
movl -0x14(%rbp), %edx
addl $0x1, %edx
xorl %eax, %eax
movl %eax, %ecx
callq 0x1c1d0
movq %rax, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
leaq -0x88(%rbp), %rdi
xorl %esi, %esi
movl $0x30, %edx
callq 0x12420
movl $0x0, -0x84(%rbp)
movl -0x18(%rbp), %eax
movl %eax, -0x80(%rbp)
movl -0x1c(%rbp), %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x88(%rbp)
movq -0x48(%rbp), %rdi
movq -0x50(%rbp), %rsi
leaq -0x88(%rbp), %rdx
leaq -0x58(%rbp), %rcx
callq 0x12b20
movl %eax, -0x8c(%rbp)
cmpl $0x0, -0x8c(%rbp)
je 0x48380
movl -0x8c(%rbp), %edi
callq 0x123c0
movq %rax, %rsi
leaq 0x474d8(%rip), %rdi     # 0x8f851
movb $0x0, %al
callq 0x1ac40
movq -0x28(%rbp), %rax
movl $0x0, (%rax)
movq -0x58(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x90, %rsp
popq %rbp
retq
nop