// File: /workspace/github_c_makefile_star2_O1/janet-lang[P]janet/src/core/os.c
// Function: os_stat_or_lstat
static Janet os_stat_or_lstat(int do_lstat, int32_t argc, Janet *argv) {
    janet_sandbox_assert(JANET_SANDBOX_FS_READ);
    janet_arity(argc, 1, 2);
    const char *path = janet_getcstring(argv, 0);
    JanetTable *tab = NULL;
    const uint8_t *key = NULL;
    if (argc == 2) {
        if (janet_checktype(argv[1], JANET_KEYWORD)) {
            key = janet_getkeyword(argv, 1);
        } else {
            tab = janet_gettable(argv, 1);
        }
    } else {
        tab = janet_table(0);
    }

    /* Build result */
    jstat_t st;
#ifdef JANET_WINDOWS
    (void) do_lstat;
    int res = _stat(path, &st);
#else
    int res;
    if (do_lstat) {
        res = lstat(path, &st);
    } else {
        res = stat(path, &st);
    }
#endif
    if (-1 == res) {
        return janet_wrap_nil();
    }

    if (NULL == key) {
        /* Put results in table */
        for (const struct OsStatGetter *sg = os_stat_getters; sg->name != NULL; sg++) {
            janet_table_put(tab, janet_ckeywordv(sg->name), sg->fn(&st));
        }
        return janet_wrap_table(tab);
    } else {
        /* Get one result */
        for (const struct OsStatGetter *sg = os_stat_getters; sg->name != NULL; sg++) {
            if (janet_cstrcmp(key, sg->name)) continue;
            return sg->fn(&st);
        }
        janet_panicf("unexpected keyword %v", janet_wrap_keyword(key));
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rdx, %rbx
movl %esi, %r14d
movl %edi, %r15d
movl $0x40, %edi
callq 0x4f595
movl %r14d, %edi
movl $0x1, %esi
movl $0x2, %edx
callq 0x192cc
movq %rbx, %rdi
xorl %esi, %esi
callq 0x198dd
movq %rax, %r12
cmpl $0x2, %r14d
jne 0x37f17
movq 0x8(%rbx), %rax
shrq $0x2f, %rax
movq %rbx, %rdi
movl $0x1, %esi
cmpl $0x1fff6, %eax          # imm = 0x1FFF6
jne 0x37f25
callq 0x19505
movq %rax, %rbx
xorl %r14d, %r14d
jmp 0x37f2f
xorl %ebx, %ebx
xorl %edi, %edi
callq 0x47e96
movq %rax, %r14
jmp 0x37f2f
callq 0x19490
movq %rax, %r14
xorl %ebx, %ebx
leaq -0xb8(%rbp), %rsi
movq %r12, %rdi
testl %r15d, %r15d
je 0x37f45
callq 0x12280
jmp 0x37f4a
callq 0x12350
cmpl $-0x1, %eax
je 0x37f98
testq %rbx, %rbx
je 0x37fb8
leaq 0x2f6aa(%rip), %rsi     # 0x67605
movq %rbx, %rdi
callq 0x4920e
leaq 0x4c236(%rip), %r15     # 0x841a0
testl %eax, %eax
je 0x38020
movq 0x10(%r15), %rsi
testq %rsi, %rsi
sete %r14b
je 0x38030
addq $0x10, %r15
movq %rbx, %rdi
callq 0x4920e
testl %eax, %eax
jne 0x37f72
jmp 0x38023
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4f95a
leaq 0x2f646(%rip), %rdi     # 0x67605
leaq 0x4c1ea(%rip), %r13     # 0x841b0
movabsq $-0x5000000000000, %rbx # imm = 0xFFFB000000000000
leaq -0xb8(%rbp), %r15
callq 0x47cd3
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4f9ad
movq %rax, %r12
movq %r15, %rdi
callq *-0x8(%r13)
movq %r14, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x481b3
movq (%r13), %rdi
addq $0x10, %r13
testq %rdi, %rdi
jne 0x37fd7
movabsq $-0x3800000000000, %rsi # imm = 0xFFFC800000000000
movq %r14, %rdi
callq 0x4f9f2
jmp 0x38035
xorl %r14d, %r14d
leaq -0xb8(%rbp), %rdi
callq *0x8(%r15)
jmp 0x38030
testb %r14b, %r14b
jne 0x38047
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movabsq $-0x5000000000000, %rsi # imm = 0xFFFB000000000000
movq %rbx, %rdi
callq 0x4f9ad
leaq 0x2b4e4(%rip), %rdi     # 0x63544
movq %rax, %rsi
xorl %eax, %eax
callq 0x1917b