// File: /workspace/github_c_makefile_star2_O0/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
subq $0x100, %rsp            # imm = 0x100
movl %edi, -0xc(%rbp)
movl %esi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x40, %edi
callq 0x7ab10
movl -0x10(%rbp), %edi
movl $0x1, %esi
movl $0x2, %edx
callq 0x1ae30
movq -0x18(%rbp), %rdi
xorl %esi, %esi
callq 0x1c280
movq %rax, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
cmpl $0x2, -0x10(%rbp)
jne 0x4d7d5
xorl %eax, %eax
testb $0x1, %al
jne 0x4d75e
jmp 0x4d78c
movq -0x18(%rbp), %rax
movsd 0x8(%rax), %xmm0
ucomisd %xmm0, %xmm0
setp %al
testb $0x1, %al
jne 0x4d774
jmp 0x4d7ad
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
shrq $0x2f, %rax
andq $0xf, %rax
cmpq $0x0, %rax
je 0x4d7ad
jmp 0x4d7c1
movq -0x18(%rbp), %rcx
movabsq $-0x800000000000, %rax  # imm = 0xFFFF800000000000
andq 0x8(%rcx), %rax
movabsq $-0x5000000000000, %rcx # imm = 0xFFFB000000000000
cmpq %rcx, %rax
jne 0x4d7c1
movq -0x18(%rbp), %rdi
movl $0x1, %esi
callq 0x1b3a0
movq %rax, -0x30(%rbp)
jmp 0x4d7d3
movq -0x18(%rbp), %rdi
movl $0x1, %esi
callq 0x1b1f0
movq %rax, -0x28(%rbp)
jmp 0x4d7e0
xorl %edi, %edi
callq 0x692f0
movq %rax, -0x28(%rbp)
cmpl $0x0, -0xc(%rbp)
je 0x4d7fe
movq -0x20(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x12280
movl %eax, -0xc4(%rbp)
jmp 0x4d814
movq -0x20(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x12350
movl %eax, -0xc4(%rbp)
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl -0xc4(%rbp), %eax
jne 0x4d839
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x7b460
movq %rax, -0x8(%rbp)
jmp 0x4d987
xorl %eax, %eax
cmpq -0x30(%rbp), %rax
jne 0x4d8f8
leaq 0x61174(%rip), %rax     # 0xae9c0
movq %rax, -0xd0(%rbp)
movq -0xd0(%rbp), %rax
cmpq $0x0, (%rax)
je 0x4d8dc
movq -0x28(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0xd0(%rbp), %rax
movq (%rax), %rdi
callq 0x68d90
movq %rax, %rdi
movabsq $-0x5000000000000, %rsi # imm = 0xFFFB000000000000
callq 0x7b550
movq %rax, -0xd8(%rbp)
movq -0xd0(%rbp), %rax
leaq -0xc0(%rbp), %rdi
callq *0x8(%rax)
movq -0xf8(%rbp), %rdi
movq %rax, -0xe0(%rbp)
movq -0xd8(%rbp), %rsi
movq -0xe0(%rbp), %rdx
callq 0x697e0
movq -0xd0(%rbp), %rax
addq $0x10, %rax
movq %rax, -0xd0(%rbp)
jmp 0x4d853
movq -0x28(%rbp), %rdi
movabsq $-0x3800000000000, %rsi # imm = 0xFFFC800000000000
callq 0x7b610
movq %rax, -0x8(%rbp)
jmp 0x4d987
leaq 0x610c1(%rip), %rax     # 0xae9c0
movq %rax, -0xe8(%rbp)
movq -0xe8(%rbp), %rax
cmpq $0x0, (%rax)
je 0x4d958
movq -0x30(%rbp), %rdi
movq -0xe8(%rbp), %rax
movq (%rax), %rsi
callq 0x6b2b0
cmpl $0x0, %eax
je 0x4d92d
jmp 0x4d944
movq -0xe8(%rbp), %rax
leaq -0xc0(%rbp), %rdi
callq *0x8(%rax)
movq %rax, -0x8(%rbp)
jmp 0x4d987
movq -0xe8(%rbp), %rax
addq $0x10, %rax
movq %rax, -0xe8(%rbp)
jmp 0x4d906
movq -0x30(%rbp), %rdi
movabsq $-0x5000000000000, %rsi # imm = 0xFFFB000000000000
callq 0x7b550
movq %rax, -0xf0(%rbp)
movq -0xf0(%rbp), %rsi
leaq 0x41c34(%rip), %rdi     # 0x8f5b4
movb $0x0, %al
callq 0x1ac40
movq -0x8(%rbp), %rax
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nopw %cs:(%rax,%rax)