// File: /workspace/github_c_makefile_star2_O2/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, socklen_t *sizeout) {
    /* 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);
        snprintf(saddr->sun_path, path_size, "%s", path);
        *sizeout = sizeof(struct sockaddr_un);
#ifdef JANET_LINUX
        if (path[0] == '@') {
            saddr->sun_path[0] = '\0';
            *sizeout = offsetof(struct sockaddr_un, sun_path) + janet_string_length(path);
        }
#endif
        *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;
#ifdef JANET_WINDOWS
    *sizeout = 0;
#else
    *sizeout = sizeof(struct sockaddr_un);
#endif
    return ai;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %r8, %r14
movq %rcx, %rbx
movl %edx, %r15d
movl %esi, %r12d
movq %rdi, %r13
movq (%rdi), %rdi
leaq 0x2d406(%rip), %rsi     # 0x5e7c0
callq 0x17922
testl %eax, %eax
je 0x31431
pushq $0x1
popq %rsi
movq %r13, %rdi
callq 0x17dae
movq %rax, %r12
pushq $0x1
popq %rdi
pushq $0x6e
popq %rsi
callq 0x125a0
testq %rax, %rax
je 0x314c0
movq %rax, %r15
movw $0x1, (%rax)
movq %rax, %r13
addq $0x2, %r13
leaq 0x32c37(%rip), %rdx     # 0x64032
pushq $0x6c
popq %rsi
movq %r13, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0x12390
movl $0x6e, (%r14)
cmpb $0x40, (%r12)
jne 0x31429
movb $0x0, (%r13)
movl -0x8(%r12), %eax
addl $0x2, %eax
movl %eax, (%r14)
movl $0x1, (%rbx)
jmp 0x314ae
movq %r13, %rdi
xorl %esi, %esi
callq 0x17dae
movq %rax, -0x30(%rbp)
movq 0x8(%r13), %rdi
callq 0x45e2b
testl %eax, %eax
je 0x31457
movq 0x8(%r13), %rdi
callq 0x3b7f1
jmp 0x31467
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
movq %r13, %rdi
xorl %ecx, %ecx
callq 0x17d87
leaq -0x38(%rbp), %rcx
andq $0x0, (%rcx)
xorps %xmm0, %xmm0
leaq -0x70(%rbp), %rdx
movaps %xmm0, (%rdx)
movaps %xmm0, 0x20(%rdx)
movaps %xmm0, 0x10(%rdx)
movl %r12d, 0x8(%rdx)
xorl %esi, %esi
testl %r15d, %r15d
setne %sil
movl %esi, (%rdx)
movq -0x30(%rbp), %rdi
movq %rax, %rsi
callq 0x12b10
testl %eax, %eax
jne 0x314ec
andl $0x0, (%rbx)
movl $0x6e, (%r14)
movq -0x38(%rbp), %r15
movq %r15, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x4eb29(%rip), %rax     # 0x7fff0
movq (%rax), %rdi
leaq 0x1bb33(%rip), %rsi     # 0x4d004
leaq 0x2d122(%rip), %rdx     # 0x5e5fa
movl $0x15f, %ecx            # imm = 0x15F
xorl %eax, %eax
callq 0x125e0
pushq $0x1
popq %rdi
callq 0x12a60
movl %eax, %edi
callq 0x123c0
leaq 0x2d2cb(%rip), %rdi     # 0x5e7c5
movq %rax, %rsi
xorl %eax, %eax
callq 0x176c9