// File: /workspace/github_c_makefile_star2_O2/janet-lang[P]janet/src/core/util.c
// Function: janet_binding_from_entry
JanetBinding janet_binding_from_entry(Janet entry) {
    JanetTable *entry_table;
    JanetBinding binding = {
        JANET_BINDING_NONE,
        janet_wrap_nil(),
        JANET_BINDING_DEP_NONE
    };

    /* Check environment for entry */
    if (!janet_checktype(entry, JANET_TABLE))
        return binding;
    entry_table = janet_unwrap_table(entry);

    /* deprecation check */
    Janet deprecate = janet_table_get(entry_table, janet_ckeywordv("deprecated"));
    if (janet_checktype(deprecate, JANET_KEYWORD)) {
        JanetKeyword depkw = janet_unwrap_keyword(deprecate);
        if (!janet_cstrcmp(depkw, "relaxed")) {
            binding.deprecation = JANET_BINDING_DEP_RELAXED;
        } else if (!janet_cstrcmp(depkw, "normal")) {
            binding.deprecation = JANET_BINDING_DEP_NORMAL;
        } else if (!janet_cstrcmp(depkw, "strict")) {
            binding.deprecation = JANET_BINDING_DEP_STRICT;
        }
    } else if (!janet_checktype(deprecate, JANET_NIL)) {
        binding.deprecation = JANET_BINDING_DEP_NORMAL;
    }

    int macro = janet_truthy(janet_table_get(entry_table, janet_ckeywordv("macro")));
    Janet value = janet_table_get(entry_table, janet_ckeywordv("value"));
    Janet ref = janet_table_get(entry_table, janet_ckeywordv("ref"));
    int ref_is_valid = janet_checktype(ref, JANET_ARRAY);
    int redef = ref_is_valid && janet_truthy(janet_table_get(entry_table, janet_ckeywordv("redef")));

    if (macro) {
        binding.value = redef ? ref : value;
        binding.type = redef ? JANET_BINDING_DYNAMIC_MACRO : JANET_BINDING_MACRO;
        return binding;
    }

    if (ref_is_valid) {
        binding.value = ref;
        binding.type = redef ? JANET_BINDING_DYNAMIC_DEF : JANET_BINDING_VAR;
    } else {
        binding.value = value;
        binding.type = JANET_BINDING_DEF;
    }

    return binding;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movabsq $-0x7800000000000, %r15 # imm = 0xFFF8800000000000
andl $0x0, (%rdi)
leaq 0x1(%r15), %rdi
callq 0x4b313
movq %rax, 0x8(%rbx)
andl $0x0, 0x10(%rbx)
movq %r14, %rax
shrq $0x2f, %rax
cmpl $0x1fff9, %eax          # imm = 0x1FFF9
jne 0x459da
movabsq $-0x800000000000, %r12  # imm = 0xFFFF800000000000
movabsq $-0x5000000000000, %r13 # imm = 0xFFFB000000000000
movq %r14, %rdi
callq 0x4b1f1
movq %r15, %r14
movq %rax, %r15
leaq 0xae22(%rip), %rdi      # 0x5056b
callq 0x439c6
movq %rax, %rdi
movq %r13, %rsi
callq 0x4b366
movq %r15, %rdi
movq %rax, %rsi
callq 0x43c35
movq %rax, %rcx
andq %r12, %rcx
cmpq %r14, %rcx
je 0x457dc
pushq $0x2
popq %r12
cmpq %r13, %rcx
jne 0x457ce
movq %rax, %rdi
callq 0x4b1f1
movq %rax, %r14
leaq 0xaeaf(%rip), %rsi      # 0x50639
movq %rax, %rdi
callq 0x44ca9
testl %eax, %eax
je 0x457ca
leaq 0xaea4(%rip), %rsi      # 0x50641
movq %r14, %rdi
callq 0x44ca9
testl %eax, %eax
je 0x457ce
leaq 0xae98(%rip), %rsi      # 0x50648
movq %r14, %rdi
callq 0x44ca9
testl %eax, %eax
movabsq $-0x800000000000, %r12  # imm = 0xFFFF800000000000
jne 0x457dc
pushq $0x3
jmp 0x457cc
pushq $0x1
popq %r12
movl %r12d, 0x10(%rbx)
movabsq $-0x800000000000, %r12  # imm = 0xFFFF800000000000
leaq 0x21ec7(%rip), %rdi     # 0x676aa
callq 0x439c6
movq %rax, %rdi
movq %r13, %rsi
callq 0x4b366
movq %r15, %rdi
movq %rax, %rsi
callq 0x43c35
andq %r12, %rax
movabsq $-0x7000000000000, %r14 # imm = 0xFFF9000000000000
movabsq $-0x7800000000000, %rcx # imm = 0xFFF8800000000000
cmpq %rcx, %rax
jne 0x4581f
xorl %r12d, %r12d
jmp 0x45875
leaq 0x21e84(%rip), %rdi     # 0x676aa
callq 0x439c6
movq %rax, %rdi
movq %r13, %rsi
callq 0x4b366
movq %r15, %rdi
movq %rax, %rsi
callq 0x43c35
andq %r12, %rax
movb $0x1, %r12b
cmpq %r14, %rax
jne 0x45875
leaq 0x21e57(%rip), %rdi     # 0x676aa
callq 0x439c6
movq %rax, %rdi
movq %r13, %rsi
callq 0x4b366
movq %r15, %rdi
movq %rax, %rsi
callq 0x43c35
movq %rax, %r12
andb $0x1, %r12b
leaq 0x1378a(%rip), %rdi     # 0x59006
callq 0x439c6
movq %rax, %rdi
movq %r13, %rsi
callq 0x4b366
movq %r15, %rdi
movq %rax, %rsi
callq 0x43c35
movq %rax, -0x30(%rbp)
leaq 0x1e835(%rip), %rdi     # 0x640d7
callq 0x439c6
movq %rax, %rdi
movq %r13, %rsi
callq 0x4b366
movq %r15, %rdi
movq %rax, %rsi
callq 0x43c35
movq %rax, %r14
movabsq $-0x800000000000, %r13  # imm = 0xFFFF800000000000
andq %r13, %rax
movabsq $-0x4800000000000, %rcx # imm = 0xFFFB800000000000
cmpq %rcx, %rax
jne 0x4591e
leaq 0x1f12d(%rip), %rdi     # 0x64a10
callq 0x439c6
movq %rax, %rdi
movabsq $-0x5000000000000, %rsi # imm = 0xFFFB000000000000
callq 0x4b366
movq %r15, %rdi
movq %rax, %rsi
callq 0x43c35
andq %r13, %rax
movabsq $-0x7800000000000, %rcx # imm = 0xFFF8800000000000
cmpq %rcx, %rax
jne 0x45933
xorl %eax, %eax
jmp 0x4599e
testb %r12b, %r12b
je 0x459bd
pushq $0x3
popq %rcx
movq -0x30(%rbp), %rax
jmp 0x459b7
leaq 0x1f0d6(%rip), %rdi     # 0x64a10
callq 0x439c6
movq %rax, %rdi
movabsq $-0x5000000000000, %rsi # imm = 0xFFFB000000000000
callq 0x4b366
movq %r15, %rdi
movq %rax, %rsi
callq 0x43c35
movq %rax, %rcx
andq %r13, %rcx
movb $0x1, %al
movabsq $-0x7000000000000, %rdx # imm = 0xFFF9000000000000
cmpq %rdx, %rcx
jne 0x4599e
leaq 0x1f096(%rip), %rdi     # 0x64a10
callq 0x439c6
movq %rax, %rdi
movabsq $-0x5000000000000, %rsi # imm = 0xFFFB000000000000
callq 0x4b366
movq %r15, %rdi
movq %rax, %rsi
callq 0x43c35
andb $0x1, %al
testb %r12b, %r12b
je 0x459ca
movzbl %al, %ecx
leal 0x3(,%rcx,2), %ecx
testb %al, %al
movq -0x30(%rbp), %rax
cmovneq %r14, %rax
movq %rax, 0x8(%rbx)
jmp 0x459d8
movq -0x30(%rbp), %rax
movq %rax, 0x8(%rbx)
pushq $0x1
popq %rcx
jmp 0x459d8
movq %r14, 0x8(%rbx)
movzbl %al, %eax
leal 0x2(,%rax,2), %ecx
movl %ecx, (%rbx)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq