// File: /workspace/github_cpp_makefile_star2_O3/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 $0x78, %rsp
movq %rcx, %r15
movq %rdx, %r14
movq %rsi, %rbx
movq 0x8(%rdx), %rax
subq (%rdx), %rax
movq 0xb0(%rsp), %rcx
sarq $0x4, %rax
movabsq $-0x3333333333333333, %r13 # imm = 0xCCCCCCCCCCCCCCCD
imulq %rax, %r13
movq %r9, 0x20(%rsp)
movslq (%r9), %r12
movq (%rcx,%r12,8), %rax
andl $0x9fffffff, %eax       # imm = 0x9FFFFFFF
leaq 0x1fb4d(%rip), %rcx     # 0x256e0
cmpl 0x20(%rcx), %eax
movl $0x10, %esi
movl $0x42, %edx
cmovel %edx, %esi
cmpl 0x10(%rcx), %eax
movq %rdi, 0x8(%rsp)
cmovel %edx, %esi
movl %esi, 0x4(%rsp)
movq 0x18(%r15), %rax
movl 0x20(%r15), %r8d
movslq %r8d, %rdx
cmpl $0x1f, -0x8(%rax,%rdx,4)
jne 0x5bdc
movslq -0x4(%rax,%rdx,4), %rsi
movq (%rbx,%r12,8), %rcx
movq %rcx, %rdi
subq %rdx, %rdi
addq $0x2, %rdi
cmpq %rsi, %rdi
je 0x5bf7
movq %r15, %rdi
movl $0x1f, %esi
xorl %edx, %edx
callq 0x1346e
movl 0x20(%r15), %r8d
movq (%rbx,%r12,8), %rcx
movq 0x18(%r15), %rax
movq %r12, 0x10(%rsp)
movq %rbx, 0x18(%rsp)
movl %r8d, (%rsp)
movl %r8d, %edx
subl %ecx, %edx
addl $-0x2, %edx
movl %edx, 0x4(%rax,%rcx,4)
testl %r13d, %r13d
jle 0x5cf3
andl $0x7fffffff, %r13d      # imm = 0x7FFFFFFF
xorl %ebx, %ebx
leaq 0x28(%rsp), %r12
movq (%r14), %rbp
leaq (%rbx,%rbp), %rsi
movq %r12, %rdi
callq 0xfa88
leaq (%rbx,%rbp), %rsi
addq $0x18, %rsi
leaq 0x40(%rsp), %rdi
callq 0xfa88
leaq (%rbx,%rbp), %rsi
addq $0x30, %rsi
leaq 0x58(%rsp), %rdi
callq 0xfb08
movq 0x48(%rbp,%rbx), %rax
movq %rax, 0x70(%rsp)
movq %r15, %rdi
movq %r12, %rsi
callq 0x4949
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x5c87
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x3320
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x5c9e
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x3320
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x5cb5
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x3320
movq %r15, %rdi
movl 0x4(%rsp), %esi
movl $0x3, %edx
movl $0x4, %ecx
callq 0x1348e
movq (%r14), %rax
movl 0x48(%rax,%rbx), %edx
subl 0x20(%r15), %edx
addl $-0x2, %edx
movq %r15, %rdi
movl $0x1c, %esi
callq 0x1346e
addq $0x50, %rbx
decq %r13
jne 0x5c28
movq 0x10(%rsp), %rbx
movq 0x8(%rsp), %rax
movl (%rax,%rbx,4), %edx
cmpl $-0x1, %edx
je 0x5d19
subl 0x20(%r15), %edx
addl $-0x2, %edx
movq %r15, %rdi
movl $0x1f, %esi
callq 0x1346e
movl 0x20(%r15), %eax
movq 0x18(%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
movl (%rsp), %ecx
subl %ecx, %eax
movslq %ecx, %rcx
movl %eax, -0x4(%rdx,%rcx,4)
movq (%r14), %rsi
movq %r14, %rdi
callq 0x1012a
movq 0x20(%rsp), %rax
decl (%rax)
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x5d85
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x5d85
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x3320
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x5dab
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x3320
jmp 0x5dab
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0xf8aa
movq %rbx, %rdi
callq 0x3560