// File: /workspace/github_c_makefile_star2_O0/janet-lang[P]janet/src/core/specials.c
// Function: dohead_destructure
SlotHeadPair *dohead_destructure(JanetCompiler *c, SlotHeadPair *into, JanetFopts opts, Janet lhs, Janet rhs) {

    /* Detect if we can do an optimization to avoid some allocations */
    int can_destructure_lhs = janet_checktype(lhs, JANET_TUPLE)
                              || janet_checktype(lhs, JANET_ARRAY);
    int rhs_is_indexed = janet_checktype(rhs, JANET_ARRAY)
                         || (janet_checktype(rhs, JANET_TUPLE) && (janet_tuple_flag(janet_unwrap_tuple(rhs)) & JANET_TUPLE_FLAG_BRACKETCTOR));
    uint32_t has_drop = opts.flags & JANET_FOPTS_DROP;

    JanetFopts subopts = janetc_fopts_default(c);
    subopts.flags = opts.flags & ~(JANET_FOPTS_TAIL | JANET_FOPTS_DROP);

    if (has_drop && can_destructure_lhs && rhs_is_indexed) {
        /* Code is of the form (def [a b] [1 2]), avoid the allocation of two tuples */
        JanetView view_lhs = {0};
        JanetView view_rhs = {0};
        janet_indexed_view(lhs, &view_lhs.items, &view_lhs.len);
        janet_indexed_view(rhs, &view_rhs.items, &view_rhs.len);
        int found_amp = 0;
        for (int32_t i = 0; i < view_lhs.len; i++) {
            if (janet_symeq(view_lhs.items[i], "&")) {
                found_amp = 1;
                /* Good error will be generated later. */
                break;
            }
        }
        if (!found_amp) {
            for (int32_t i = 0; i < view_lhs.len; i++) {
                Janet sub_rhs = view_rhs.len <= i ? janet_wrap_nil() : view_rhs.items[i];
                into = dohead_destructure(c, into, subopts, view_lhs.items[i], sub_rhs);
            }
            return into;
        }
    }

    /* No optimization, do the simple way */
    subopts.hint = opts.hint;
    JanetSlot ret = janetc_value(subopts, rhs);
    SlotHeadPair shp = {lhs, ret};
    janet_v_push(into, shp);
    return into;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
leaq 0x10(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq %rdx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movq %rdi, -0x20(%rbp)
movq %rsi, -0x28(%rbp)
xorl %eax, %eax
testb $0x1, %al
jne 0x5e8ae
jmp 0x5e8e5
movsd -0x10(%rbp), %xmm0
ucomisd %xmm0, %xmm0
setp %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0xd9(%rbp)
jne 0x5e8c9
jmp 0x5e92e
movq -0x10(%rbp), %rcx
shrq $0x2f, %rcx
andq $0xf, %rcx
movb $0x1, %al
cmpq $0x0, %rcx
movb %al, -0xd9(%rbp)
je 0x5e92e
jmp 0x5e90a
movabsq $-0x800000000000, %rcx  # imm = 0xFFFF800000000000
andq -0x10(%rbp), %rcx
movb $0x1, %al
movabsq $-0x4000000000000, %rdx # imm = 0xFFFC000000000000
cmpq %rdx, %rcx
movb %al, -0xd9(%rbp)
je 0x5e92e
movabsq $-0x800000000000, %rax  # imm = 0xFFFF800000000000
andq -0x10(%rbp), %rax
movabsq $-0x4800000000000, %rcx # imm = 0xFFFB800000000000
cmpq %rcx, %rax
sete %al
movb %al, -0xd9(%rbp)
movb -0xd9(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x2c(%rbp)
xorl %eax, %eax
testb $0x1, %al
jne 0x5e944
jmp 0x5e982
movsd -0x18(%rbp), %xmm0
ucomisd %xmm0, %xmm0
setp %cl
movb $0x1, %al
testb $0x1, %cl
movb %al, -0xda(%rbp)
jne 0x5e962
jmp 0x5ea2f
movq -0x18(%rbp), %rcx
shrq $0x2f, %rcx
andq $0xf, %rcx
movb $0x1, %al
cmpq $0x0, %rcx
movb %al, -0xda(%rbp)
je 0x5ea2f
jmp 0x5e9ab
movabsq $-0x800000000000, %rcx  # imm = 0xFFFF800000000000
andq -0x18(%rbp), %rcx
movb $0x1, %al
movabsq $-0x4800000000000, %rdx # imm = 0xFFFB800000000000
cmpq %rdx, %rcx
movb %al, -0xda(%rbp)
je 0x5ea2f
xorl %eax, %eax
testb $0x1, %al
jne 0x5e9b3
jmp 0x5e9e1
movsd -0x18(%rbp), %xmm0
ucomisd %xmm0, %xmm0
setp %al
testb $0x1, %al
jne 0x5e9c5
jmp 0x5ea06
movq -0x18(%rbp), %rcx
shrq $0x2f, %rcx
andq $0xf, %rcx
xorl %eax, %eax
cmpq $0x0, %rcx
movb %al, -0xdb(%rbp)
je 0x5ea06
jmp 0x5ea23
movabsq $-0x800000000000, %rcx  # imm = 0xFFFF800000000000
andq -0x18(%rbp), %rcx
xorl %eax, %eax
movabsq $-0x4000000000000, %rdx # imm = 0xFFFC000000000000
cmpq %rdx, %rcx
movb %al, -0xdb(%rbp)
jne 0x5ea23
movq -0x18(%rbp), %rdi
callq 0x7b260
movl -0x20(%rax), %eax
andl $0x10000, %eax          # imm = 0x10000
cmpl $0x0, %eax
setne %al
movb %al, -0xdb(%rbp)
movb -0xdb(%rbp), %al
movb %al, -0xda(%rbp)
movq -0xd8(%rbp), %rax
movb -0xda(%rbp), %cl
andb $0x1, %cl
movzbl %cl, %ecx
movl %ecx, -0x30(%rbp)
movl 0x20(%rax), %eax
andl $0x40000, %eax          # imm = 0x40000
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rsi
leaq -0x60(%rbp), %rdi
callq 0x1fed0
movq -0xd8(%rbp), %rax
movl 0x20(%rax), %eax
andl $0xfffaffff, %eax       # imm = 0xFFFAFFFF
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x34(%rbp)
je 0x5ebf8
cmpl $0x0, -0x2c(%rbp)
je 0x5ebf8
cmpl $0x0, -0x30(%rbp)
je 0x5ebf8
leaq -0x70(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x12420
leaq -0x80(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0x12420
leaq -0x70(%rbp), %rsi
leaq -0x70(%rbp), %rdx
addq $0x8, %rdx
movq -0x10(%rbp), %rdi
callq 0x6d0d0
leaq -0x80(%rbp), %rsi
leaq -0x80(%rbp), %rdx
addq $0x8, %rdx
movq -0x18(%rbp), %rdi
callq 0x6d0d0
movl $0x0, -0x84(%rbp)
movl $0x0, -0x88(%rbp)
movl -0x88(%rbp), %eax
cmpl -0x68(%rbp), %eax
jge 0x5eb35
movq -0x70(%rbp), %rax
movslq -0x88(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x2c4a6(%rip), %rsi     # 0x8afb2
callq 0x1c790
cmpl $0x0, %eax
je 0x5eb22
movl $0x1, -0x84(%rbp)
jmp 0x5eb35
jmp 0x5eb24
movl -0x88(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x88(%rbp)
jmp 0x5eaeb
cmpl $0x0, -0x84(%rbp)
jne 0x5ebf6
movl $0x0, -0x8c(%rbp)
movl -0x8c(%rbp), %eax
cmpl -0x68(%rbp), %eax
jge 0x5ebe9
movl -0x78(%rbp), %eax
cmpl -0x8c(%rbp), %eax
jg 0x5eb7e
movabsq $-0x77fffffffffff, %rdi # imm = 0xFFF8800000000001
callq 0x7b460
movq %rax, -0x98(%rbp)
jmp 0x5eb94
movq -0x80(%rbp), %rax
movslq -0x8c(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x98(%rbp)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x70(%rbp), %rax
movslq -0x8c(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movq -0x98(%rbp), %rcx
movq -0x40(%rbp), %r8
movq %rsp, %rax
movq %r8, 0x20(%rax)
movups -0x60(%rbp), %xmm0
movups -0x50(%rbp), %xmm1
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x5e880
movq %rax, -0x28(%rbp)
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0x5eb4c
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x5ecfb
jmp 0x5ebf8
movq -0xd8(%rbp), %rax
movq 0x8(%rax), %rcx
movq %rcx, -0x58(%rbp)
movq 0x10(%rax), %rcx
movq %rcx, -0x50(%rbp)
movq 0x18(%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x18(%rbp), %rsi
movq -0x40(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x20(%rax)
movups -0x60(%rbp), %xmm0
movups -0x50(%rbp), %xmm1
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
leaq -0xb0(%rbp), %rdi
callq 0x21590
movq -0x10(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0xb0(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0xa8(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0xa0(%rbp), %rax
movq %rax, -0xb8(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x5ec90
movq -0x28(%rbp), %rax
movl -0x4(%rax), %eax
addl $0x1, %eax
movq -0x28(%rbp), %rcx
cmpl -0x8(%rcx), %eax
jl 0x5eca9
movq -0x28(%rbp), %rdi
movl $0x1, %esi
movl $0x20, %edx
callq 0x70760
movq %rax, -0x28(%rbp)
jmp 0x5ecab
jmp 0x5ecab
movq -0x28(%rbp), %rax
movq -0x28(%rbp), %rdx
movl -0x4(%rdx), %ecx
movl %ecx, %esi
addl $0x1, %esi
movl %esi, -0x4(%rdx)
movslq %ecx, %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq -0xd0(%rbp), %rcx
movq %rcx, (%rax)
movq -0xc8(%rbp), %rcx
movq %rcx, 0x8(%rax)
movq -0xc0(%rbp), %rcx
movq %rcx, 0x10(%rax)
movq -0xb8(%rbp), %rcx
movq %rcx, 0x18(%rax)
movq -0x28(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
nopl (%rax,%rax)