// File: /workspace/github_cpp_makefile_star2_O1/rofl0r[P]ascc/cs_parser.cpp
// Function: deal_with_end_of_switch(int*, long*, std::vector<ccChunk, std::allocator<ccChunk>>*, ccCompiledScript*, ccInternalList*, int*, long*)
int deal_with_end_of_switch (int32_t *nested_assign_addr, long *nested_start, std::vector<ccChunk> *nested_chunk, ccCompiledScript *scrip, ccInternalList *targ, int *nestlevel, long *nested_info) {
    int index;
    int limit = nested_chunk->size();
    int nested_level = nestlevel[0];
    int skip;
    int operation = is_any_type_of_string(nested_info[nested_level]) ? SCMD_STRINGSNOTEQ : SCMD_NOTEQUAL;
    if(scrip->code[scrip->codesize - 2] != SCMD_JMP || scrip->code[scrip->codesize - 1] != nested_start[nested_level] - scrip->codesize + 2) {
        // If there was no terminating break, write a jump at the end of the last case
        scrip->write_cmd1(SCMD_JMP, 0);
    }
    skip = scrip->codesize;
    // Write the location for the jump to this point (the jump table)
    scrip->code[nested_start[nested_level] + 1] = (scrip->codesize - nested_start[nested_level]) - 2;
    for(index = 0; index < limit; index++) {
        // Put the result of the expression into AX
        write_chunk(scrip, (*nested_chunk)[index]);
        // Do the comparison
        scrip->write_cmd2(operation, SREG_AX, SREG_BX);
        scrip->write_cmd1(SCMD_JZ, (*nested_chunk)[index].codeoffset - scrip->codesize - 2);
    }
    // Write the default jump if necessary
    if(nested_assign_addr[nested_level] != -1)
        scrip->write_cmd1(SCMD_JMP, nested_assign_addr[nested_level] - scrip->codesize - 2);
    // Write the location for the jump to the end of the switch block (for break statements)
    scrip->code[nested_start[nested_level] + 3] = scrip->codesize - nested_start[nested_level] - 4;
    // Write the jump for the end of the switch block
    scrip->code[skip - 1] = scrip->codesize - skip;
    clear_chunk_list(nested_chunk);
    nestlevel[0]--;

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rcx, %r15
movq %rdx, %r14
movq %rsi, %rbx
movq %rdi, 0x18(%rsp)
movq 0xc0(%rsp), %rax
movq 0x8(%rdx), %rcx
subq (%rdx), %rcx
sarq $0x4, %rcx
movabsq $-0x3333333333333333, %r13 # imm = 0xCCCCCCCCCCCCCCCD
imulq %rcx, %r13
movq %r9, 0x30(%rsp)
movslq (%r9), %r12
movq (%rax,%r12,8), %rax
andl $0x9fffffff, %eax       # imm = 0x9FFFFFFF
leaq 0x1fabb(%rip), %rcx     # 0x256e0
cmpl 0x20(%rcx), %eax
movl $0x10, %esi
movl $0x42, %edx
cmovel %edx, %esi
cmpl 0x10(%rcx), %eax
cmovel %edx, %esi
movl %esi, 0xc(%rsp)
movq 0x18(%r15), %rcx
movslq 0x20(%r15), %rax
cmpl $0x1f, -0x8(%rcx,%rax,4)
jne 0x5c63
movslq -0x4(%rcx,%rax,4), %rcx
movq (%rbx,%r12,8), %rdx
subq %rax, %rdx
addq $0x2, %rdx
cmpq %rcx, %rdx
je 0x5c72
movq %r15, %rdi
movl $0x1f, %esi
xorl %edx, %edx
callq 0x135fc
movslq 0x20(%r15), %rcx
movq %rbx, 0x28(%rsp)
movq %r12, 0x20(%rsp)
movq (%rbx,%r12,8), %rax
movq %rcx, 0x10(%rsp)
subl %eax, %ecx
addl $-0x2, %ecx
movq 0x18(%r15), %rdx
movl %ecx, 0x4(%rdx,%rax,4)
testl %r13d, %r13d
jle 0x5d7b
andl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
xorl %ebx, %ebx
leaq 0x38(%rsp), %r12
movq (%r14), %rbp
leaq (%rbx,%rbp), %rsi
movq %r12, %rdi
callq 0xfb88
leaq (%rbx,%rbp), %rsi
addq $0x18, %rsi
leaq 0x50(%rsp), %rdi
callq 0xfb88
leaq (%rbx,%rbp), %rsi
addq $0x30, %rsi
leaq 0x68(%rsp), %rdi
callq 0xfc08
movq 0x48(%rbp,%rbx), %rax
movq %rax, 0x80(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x4969
movq 0x68(%rsp), %rdi
testq %rdi, %rdi
je 0x5d0f
movq 0x78(%rsp), %rsi
subq %rdi, %rsi
callq 0x3320
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x5d26
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x3320
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x5d3d
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x3320
movq %r15, %rdi
movl 0xc(%rsp), %esi
movl $0x3, %edx
movl $0x4, %ecx
callq 0x1361c
movq (%r14), %rax
movl 0x48(%rax,%rbx), %edx
subl 0x20(%r15), %edx
addl $-0x2, %edx
movq %r15, %rdi
movl $0x1c, %esi
callq 0x135fc
addq $0x50, %rbx
decq %r13
jne 0x5cad
movq 0x20(%rsp), %rbx
movq 0x18(%rsp), %rax
movl (%rax,%rbx,4), %edx
cmpl $-0x1, %edx
je 0x5da1
subl 0x20(%r15), %edx
addl $-0x2, %edx
movq %r15, %rdi
movl $0x1f, %esi
callq 0x135fc
movl 0x20(%r15), %eax
movq 0x28(%rsp), %rcx
movq (%rcx,%rbx,8), %rcx
subl %ecx, %eax
addl $-0x4, %eax
movq 0x18(%r15), %rdx
movl %eax, 0xc(%rdx,%rcx,4)
movl 0x20(%r15), %eax
movq 0x10(%rsp), %rcx
subl %ecx, %eax
movl %eax, -0x4(%rdx,%rcx,4)
movq (%r14), %rsi
movq %r14, %rdi
callq 0x10246
movq 0x30(%rsp), %rax
decl (%rax)
xorl %eax, %eax
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x5e0f
movq %rax, %rbx
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x5e0f
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x3320
movq 0x38(%rsp), %rdi
testq %rdi, %rdi
je 0x5e35
movq 0x48(%rsp), %rsi
subq %rdi, %rsi
callq 0x3320
jmp 0x5e35
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0xf9aa
movq %rbx, %rdi
callq 0x3560