// File: /workspace/github_cpp_makefile_star2_O2/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 %rdi, 0x8(%rsp)
movq 0xb0(%rsp), %rcx
movq 0x8(%rdx), %rax
subq (%rdx), %rax
pushq $0x50
popq %rsi
cqto
idivq %rsi
movq %rax, %r13
movq %r9, 0x20(%rsp)
movslq (%r9), %r12
movq (%rcx,%r12,8), %rax
andl $0x9fffffff, %eax       # imm = 0x9FFFFFFF
leaq 0x1fe92(%rip), %rcx     # 0x256f0
cmpl 0x20(%rcx), %eax
pushq $0x10
popq %rsi
pushq $0x42
popq %rdx
cmovel %edx, %esi
cmpl 0x10(%rcx), %eax
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 0x589e
movslq -0x4(%rax,%rdx,4), %rsi
movq (%rbx,%r12,8), %rcx
movq %rcx, %rdi
subq %rdx, %rdi
addq $0x2, %rdi
cmpq %rsi, %rdi
je 0x58b7
pushq $0x1f
popq %rsi
movq %r15, %rdi
xorl %edx, %edx
callq 0x11e4a
movl 0x20(%r15), %r8d
movq (%rbx,%r12,8), %rcx
movq 0x18(%r15), %rax
movq %r12, 0x10(%rsp)
movq %rbx, 0x18(%rsp)
movl %r8d, %edx
subl %ecx, %edx
addl $-0x2, %edx
movl %edx, 0x4(%rax,%rcx,4)
xorl %r12d, %r12d
testl %r13d, %r13d
cmovlel %r12d, %r13d
imulq $0x50, %r13, %rbx
leaq 0x28(%rsp), %r13
movl %r8d, %ebp
cmpq %r12, %rbx
je 0x593e
movq (%r14), %rsi
addq %r12, %rsi
movq %r13, %rdi
callq 0xe856
movq %r15, %rdi
movq %r13, %rsi
callq 0x47a6
movq %r13, %rdi
callq 0xe82e
movq %r15, %rdi
movl 0x4(%rsp), %esi
pushq $0x3
popq %rdx
pushq $0x4
popq %rcx
callq 0x11e6a
movq (%r14), %rax
movl 0x48(%rax,%r12), %edx
subl 0x20(%r15), %edx
addl $-0x2, %edx
movq %r15, %rdi
pushq $0x1c
popq %rsi
callq 0x11e4a
addq $0x50, %r12
movl %ebp, %r8d
jmp 0x58e3
movq 0x10(%rsp), %rbx
movq 0x8(%rsp), %rax
movl (%rax,%rbx,4), %edx
cmpl $-0x1, %edx
je 0x5965
subl 0x20(%r15), %edx
addl $-0x2, %edx
pushq $0x1f
popq %rsi
movq %r15, %rdi
callq 0x11e4a
movl %ebp, %r8d
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
subl %r8d, %eax
movslq %r8d, %rcx
movl %eax, -0x4(%rdx,%rcx,4)
movq %r14, %rdi
callq 0xe84e
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
leaq 0x28(%rsp), %rdi
callq 0xe82e
movq %rbx, %rdi
callq 0x3560