// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x40
popq %rdi
callq 0x4af2d
pushq $0x1
popq %rsi
pushq $0x2
popq %rdx
movl %r14d, %edi
callq 0x1781a
movq %rbx, %rdi
xorl %esi, %esi
callq 0x17dae
movq %rax, %r12
cmpl $0x2, %r14d
jne 0x34a20
movq 0x8(%rbx), %rax
shrq $0x2f, %rax
pushq $0x1
popq %rsi
movq %rbx, %rdi
cmpl $0x1fff6, %eax          # imm = 0x1FFF6
jne 0x34a2f
callq 0x17a2c
movq %rax, %r14
xorl %ebx, %ebx
jmp 0x34a3a
xorl %r14d, %r14d
xorl %edi, %edi
callq 0x43b8a
movq %rax, %rbx
jmp 0x34a3a
callq 0x179b9
movq %rax, %rbx
xorl %r14d, %r14d
leaq -0xb8(%rbp), %rsi
movq %r12, %rdi
testl %r15d, %r15d
je 0x34a50
callq 0x12280
jmp 0x34a55
callq 0x12350
cmpl $-0x1, %eax
je 0x34a93
testq %r14, %r14
je 0x34ab3
leaq 0x49742(%rip), %rbx     # 0x7e1a8
movq -0x8(%rbx), %rsi
testq %rsi, %rsi
je 0x34b26
movq %r14, %rdi
callq 0x44ca9
testl %eax, %eax
je 0x34a85
addq $0x10, %rbx
jmp 0x34a66
leaq -0xb8(%rbp), %rdi
callq *(%rbx)
jmp 0x34b14
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4b313
leaq 0x496e6(%rip), %r13     # 0x7e1a0
movabsq $-0x5000000000000, %r14 # imm = 0xFFFB000000000000
leaq -0xb8(%rbp), %r15
movq (%r13), %rdi
testq %rdi, %rdi
je 0x34b02
callq 0x439c6
movq %rax, %rdi
movq %r14, %rsi
callq 0x4b366
movq %rax, %r12
movq %r15, %rdi
callq *0x8(%r13)
movq %rbx, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x43e19
addq $0x10, %r13
jmp 0x34acb
movabsq $-0x3800000000000, %rsi # imm = 0xFFFC800000000000
movq %rbx, %rdi
callq 0x4b3ab
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movabsq $-0x5000000000000, %rsi # imm = 0xFFFB000000000000
movq %r14, %rdi
callq 0x4b366
leaq 0x29a05(%rip), %rdi     # 0x5e544
movq %rax, %rsi
xorl %eax, %eax
callq 0x176c9