// File: /workspace/github_c_makefile_star2_O3/janet-lang[P]janet/src/core/asm.c
// Function: doarg_1
static int32_t doarg_1(
    JanetAssembler *a,
    enum JanetOpArgType argtype,
    Janet x) {
    int32_t ret = -1;
    JanetTable *c;
    switch (argtype) {
        default:
            c = NULL;
            break;
        case JANET_OAT_SLOT:
            c = &a->slots;
            break;
        case JANET_OAT_ENVIRONMENT:
            c = &a->envs;
            break;
        case JANET_OAT_LABEL:
            c = &a->labels;
            break;
        case JANET_OAT_FUNCDEF:
            c = &a->defs;
            break;
    }
    switch (janet_type(x)) {
        default:
            goto error;
            break;
        case JANET_NUMBER: {
            double y = janet_unwrap_number(x);
            if (janet_checkintrange(y)) {
                ret = (int32_t) y;
            } else {
                goto error;
            }
            break;
        }
        case JANET_TUPLE: {
            const Janet *t = janet_unwrap_tuple(x);
            if (argtype == JANET_OAT_TYPE) {
                int32_t i = 0;
                ret = 0;
                for (i = 0; i < janet_tuple_length(t); i++) {
                    ret |= doarg_1(a, JANET_OAT_SIMPLETYPE, t[i]);
                }
            } else {
                goto error;
            }
            break;
        }
        case JANET_KEYWORD: {
            if (NULL != c && argtype == JANET_OAT_LABEL) {
                Janet result = janet_table_get(c, x);
                if (janet_checktype(result, JANET_NUMBER)) {
                    ret = janet_unwrap_integer(result) - a->bytecode_count;
                } else {
                    goto error;
                }
            } else if (argtype == JANET_OAT_TYPE || argtype == JANET_OAT_SIMPLETYPE) {
                const TypeAlias *alias = janet_strbinsearch(
                                             &type_aliases,
                                             sizeof(type_aliases) / sizeof(TypeAlias),
                                             sizeof(TypeAlias),
                                             janet_unwrap_keyword(x));
                if (alias) {
                    ret = alias->mask;
                } else {
                    janet_asm_errorv(a, janet_formatc("unknown type %v", x));
                }
            } else {
                goto error;
            }
            break;
        }
        case JANET_SYMBOL: {
            if (NULL != c) {
                Janet result = janet_table_get(c, x);
                if (janet_checktype(result, JANET_NUMBER)) {
                    ret = (int32_t) janet_unwrap_number(result);
                } else {
                    janet_asm_errorv(a, janet_formatc("unknown name %v", x));
                }
            } else {
                goto error;
            }
            if (argtype == JANET_OAT_ENVIRONMENT && ret == -1) {
                /* Add a new env */
                ret = janet_asm_addenv(a, x);
                if (ret < -1) {
                    janet_asm_errorv(a, janet_formatc("unknown environment %v", x));
                }
            }
            break;
        }
    }
    if (argtype == JANET_OAT_SLOT && ret >= a->def->slotcount)
        a->def->slotcount = (int32_t) ret + 1;
    return ret;

error:
    janet_asm_errorv(a, janet_formatc("error parsing instruction argument %v", x));
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movl %esi, %r15d
movq %rdi, %rbx
xorl %eax, %eax
xorl %edi, %edi
cmpl $0x7, %esi
ja 0x172ef
movl %r15d, %ecx
leaq 0x3ab9c(%rip), %rdx     # 0x51e60
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
leaq 0x128(%rbx), %rdi
jmp 0x172ef
leaq 0xf8(%rbx), %rdi
jmp 0x172ef
leaq 0x158(%rbx), %rdi
jmp 0x172ef
leaq 0x188(%rbx), %rdi
movq %r14, %xmm0
movq %r14, %rcx
shrq $0x2f, %rcx
andl $0xf, %ecx
ucomisd %xmm0, %xmm0
cmovpl %ecx, %eax
cmpl $0x8, %eax
ja 0x174c0
leaq 0x3ab6b(%rip), %rcx     # 0x51e80
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
ucomisd 0x3b152(%rip), %xmm0    # 0x52478
jb 0x174c0
movsd 0x3b14c(%rip), %xmm1    # 0x52480
ucomisd %xmm0, %xmm1
jb 0x174c0
cvttpd2dq %xmm0, %xmm1
cvtdq2pd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x174c0
jp 0x174c0
cvttsd2si %xmm0, %r12d
jmp 0x1745c
testq %rdi, %rdi
sete %al
cmpl $0x6, %r15d
setne %cl
orb %al, %cl
jne 0x17475
movq %r14, %rsi
callq 0x474e0
movq %rax, %xmm0
ucomisd %xmm0, %xmm0
setp %cl
movabsq $0x7800000000000, %rdx  # imm = 0x7800000000000
testq %rdx, %rax
setne %al
testb %al, %cl
jne 0x174c0
cvttsd2si %xmm0, %r12d
subl 0xec(%rbx), %r12d
jmp 0x174ae
movq %r14, %rdi
callq 0x4ebc4
cmpl $0x4, %r15d
jne 0x174c0
movq %rax, %r13
cmpl $0x0, -0x10(%rax)
jle 0x174ab
xorl %r14d, %r14d
xorl %r12d, %r12d
movq (%r13,%r14,8), %rdx
movq %rbx, %rdi
movl $0x5, %esi
callq 0x1729a
orl %eax, %r12d
incq %r14
movslq -0x10(%r13), %rax
cmpq %rax, %r14
jl 0x173d7
jmp 0x1745c
testq %rdi, %rdi
je 0x174c0
movq %r14, %rsi
callq 0x474e0
movq %rax, %xmm0
ucomisd %xmm0, %xmm0
setp %cl
movabsq $0x7800000000000, %rdx  # imm = 0x7800000000000
testq %rdx, %rax
setne %al
testb %al, %cl
jne 0x174e9
cvttsd2si %xmm0, %r12d
cmpl $0x1, %r15d
jne 0x1745c
cmpl $-0x1, %r12d
jne 0x1745c
movq %rbx, %rdi
movq %r14, %rsi
callq 0x174fb
movl %eax, %r12d
cmpl $-0x2, %eax
jg 0x174ae
leaq 0x3b67f(%rip), %rdi     # 0x52ad9
jmp 0x174c7
testl %r15d, %r15d
jne 0x174ae
movq 0x8(%rbx), %rax
cmpl 0x5c(%rax), %r12d
jl 0x174ae
leal 0x1(%r12), %ecx
movl %ecx, 0x5c(%rax)
jmp 0x174ae
andl $-0x2, %r15d
cmpl $0x4, %r15d
jne 0x174c0
movq %r14, %rdi
callq 0x4ebc4
leaq 0x67f52(%rip), %rdi     # 0x7f3e0
movl $0x13, %esi
movl $0x10, %edx
movq %rax, %rcx
callq 0x48773
testq %rax, %rax
je 0x174f2
movl 0x8(%rax), %r12d
jmp 0x174ae
xorl %r12d, %r12d
movl %r12d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3b629(%rip), %rdi     # 0x52af0
movq %r14, %rsi
xorl %eax, %eax
callq 0x3f652
movq %rax, 0xd8(%rbx)
addq $0x10, %rbx
movq %rbx, %rdi
movl $0x1, %esi
callq 0x128e0
leaq 0x3b5d9(%rip), %rdi     # 0x52ac9
jmp 0x174c7
leaq 0x3b5c0(%rip), %rdi     # 0x52ab9
jmp 0x174c7