// File: /workspace/github_c_makefile_star2_O1/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 0x1731a
movl %r15d, %ecx
leaq 0x3bb71(%rip), %rdx     # 0x52e60
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
leaq 0x128(%rbx), %rdi
jmp 0x1731a
leaq 0xf8(%rbx), %rdi
jmp 0x1731a
leaq 0x158(%rbx), %rdi
jmp 0x1731a
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 0x17520
leaq 0x3bb40(%rip), %rcx     # 0x52e80
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
ucomisd 0x3c127(%rip), %xmm0    # 0x53478
jb 0x174a5
movsd 0x3c121(%rip), %xmm1    # 0x53480
ucomisd %xmm0, %xmm1
jb 0x174a5
cvttpd2dq %xmm0, %xmm1
cvtdq2pd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jne 0x174a5
jp 0x174a5
cvttsd2si %xmm0, %r12d
movb $0x1, %al
jmp 0x174ad
testq %rdi, %rdi
sete %al
cmpl $0x6, %r15d
setne %cl
orb %al, %cl
jne 0x174b3
movq %r14, %rsi
callq 0x47f51
movq %rax, %xmm0
ucomisd %xmm0, %xmm0
setnp %cl
movabsq $0x7800000000000, %rdx  # imm = 0x7800000000000
testq %rdx, %rax
sete %al
orb %cl, %al
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
cmpb $0x1, %al
jne 0x173de
cvttsd2si %xmm0, %r12d
subl 0xec(%rbx), %r12d
testb %al, %al
jne 0x174f7
jmp 0x17520
movq %r14, -0x30(%rbp)
movq %r14, %rdi
callq 0x4f838
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
cmpl $0x4, %r15d
jne 0x174ed
movq %rax, %r13
cmpl $0x0, -0x10(%rax)
jle 0x174ea
xorl %r14d, %r14d
xorl %r12d, %r12d
movq (%r13,%r14,8), %rdx
movq %rbx, %rdi
movl $0x5, %esi
callq 0x172c5
orl %eax, %r12d
incq %r14
movslq -0x10(%r13), %rax
cmpq %rax, %r14
jl 0x1741a
jmp 0x174ed
testq %rdi, %rdi
je 0x17520
movq %r14, %rsi
callq 0x47f51
movq %rax, %xmm0
ucomisd %xmm0, %xmm0
setp %cl
movabsq $0x7800000000000, %rdx  # imm = 0x7800000000000
testq %rdx, %rax
setne %al
testb %al, %cl
jne 0x17549
cvttsd2si %xmm0, %r12d
cmpl $0x1, %r15d
jne 0x174f7
cmpl $-0x1, %r12d
jne 0x174f7
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1755b
movl %eax, %r12d
cmpl $-0x2, %eax
jg 0x174f7
leaq 0x3c639(%rip), %rdi     # 0x53ad9
jmp 0x17527
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
xorl %eax, %eax
testb %al, %al
jne 0x174f7
jmp 0x17520
movl %r15d, %eax
andl $-0x2, %eax
cmpl $0x4, %eax
jne 0x17520
movq %r14, %rdi
callq 0x4f838
leaq 0x68f13(%rip), %rdi     # 0x803e0
movl $0x13, %esi
movl $0x10, %edx
movq %rax, %rcx
callq 0x4927d
testq %rax, %rax
je 0x17552
movl 0x8(%rax), %r12d
jmp 0x174f7
xorl %r12d, %r12d
cmpl $0x4, %r15d
movq -0x30(%rbp), %r14
jne 0x17520
testl %r15d, %r15d
jne 0x1750e
movq 0x8(%rbx), %rax
cmpl 0x5c(%rax), %r12d
jl 0x1750e
leal 0x1(%r12), %ecx
movl %ecx, 0x5c(%rax)
movl %r12d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3c5c9(%rip), %rdi     # 0x53af0
movq %r14, %rsi
xorl %eax, %eax
callq 0x3fd86
movq %rax, 0xd8(%rbx)
addq $0x10, %rbx
movq %rbx, %rdi
movl $0x1, %esi
callq 0x128f0
leaq 0x3c579(%rip), %rdi     # 0x53ac9
jmp 0x17527
leaq 0x3c560(%rip), %rdi     # 0x53ab9
jmp 0x17527