// File: /workspace/github_cpp_makefile_star2_O1/rofl0r[P]ascc/cs_parser.cpp
// Function: deal_with_end_of_ifelse(char*, long*, long*, ccCompiledScript*, ccInternalList*, int*, std::vector<ccChunk, std::allocator<ccChunk>>*)
int deal_with_end_of_ifelse (char*nested_type,long*nested_info,long*nested_start,
                             ccCompiledScript*scrip,ccInternalList*targ,int*nestlevel, std::vector<ccChunk> *nested_chunk) {
     int nested_level = nestlevel[0];
     int is_else=0;
     if (nested_type[nested_level] == NEST_ELSESINGLE) ;
     else if (nested_type[nested_level] == NEST_ELSE) ;
     else if (sym.get_type(targ->peeknext()) == SYM_ELSE) {
         targ->getnext();
         scrip->write_cmd1(SCMD_JMP,0);
         is_else=1;
     }
     if (nested_start[nested_level]) {
         scrip->flush_line_numbers();
         // if it's a for loop, drop the yanked chunk (loop increment) back in
         if(nested_chunk[nested_level].size() > 0) {
             write_chunk(scrip, nested_chunk[nested_level][0]);
             clear_chunk_list(&nested_chunk[nested_level]);
         }
         // it's a while loop, so write a jump back to the check again
        scrip->write_cmd1(SCMD_JMP,-((scrip->codesize+2) - nested_start[nested_level]) );
     }
     // write the correct relative jump location
     scrip->code[nested_info[nested_level]] =
         (scrip->codesize - nested_info[nested_level]) - 1;
     if (is_else) {
         // convert the IF into an ELSE
         if (sym.get_type(targ->peeknext()) == SYM_OPENBRACE) {
             nested_type[nested_level] = NEST_ELSE;
             targ->getnext();
         }
         else
             nested_type[nested_level] = NEST_ELSESINGLE;
         nested_info[nested_level] = scrip->codesize-1;
         return 1;
     }
     else
     {
         nestlevel[0]--;
         if(nested_type[nestlevel[0]] == NEST_FOR)
         {
             nestlevel[0]--;
             // find local variables that have just been removed
             int totalsub = remove_locals (nestlevel[0], 0, scrip);

             if (totalsub > 0) {
                 scrip->cur_sp -= totalsub;
                 scrip->write_cmd2(SCMD_SUB,SREG_SP,totalsub);
             }
         }
     }
     return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movq %r9, %r13
movq %rcx, %rbx
movq %rdx, %rbp
movq %rsi, %r14
movq %rdi, %r15
movslq (%r9), %r12
movb (%rdi,%r12), %al
addb $-0x5, %al
movb $0x1, %cl
movl %ecx, 0x4(%rsp)
cmpb $0x2, %al
movq %r8, 0x8(%rsp)
jb 0x5605
movq %r8, %rdi
callq 0x10f22
leaq 0x20108(%rip), %rdi     # 0x256e0
movl %eax, %esi
callq 0x111aa
cmpl $0x1d, %eax
jne 0x5605
movq 0x8(%rsp), %rdi
callq 0x10f88
movl $0x0, 0x4(%rsp)
movq %rbx, %rdi
movl $0x1f, %esi
xorl %edx, %edx
callq 0x135fc
cmpq $0x0, (%rbp,%r12,8)
je 0x5708
movq %r13, 0x10(%rsp)
movq %r15, 0x18(%rsp)
movq %r14, 0x20(%rsp)
movq %rbp, %r13
movq 0xb0(%rsp), %rbp
movq %rbx, %rdi
callq 0x13d98
leaq (%r12,%r12,2), %r15
movq (%rbp,%r15,8), %r14
cmpq %r14, 0x8(%rbp,%r15,8)
je 0x56e1
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0xfb88
leaq 0x40(%rsp), %rdi
leaq 0x18(%r14), %rsi
callq 0xfb88
leaq 0x58(%rsp), %rdi
leaq 0x30(%r14), %rsi
callq 0xfc08
movq 0x48(%r14), %rax
leaq 0x28(%rsp), %rsi
movq %rax, 0x48(%rsi)
movq %rbx, %rdi
callq 0x4969
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x569c
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x3320
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x56b3
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x3320
movq 0xb0(%rsp), %rax
leaq (%rax,%r15,8), %r14
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x56d6
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x3320
movq (%r14), %rsi
movq %r14, %rdi
callq 0x10246
movl (%r13,%r12,8), %edx
subl 0x20(%rbx), %edx
addl $-0x2, %edx
movq %rbx, %rdi
movl $0x1f, %esi
callq 0x135fc
movq 0x20(%rsp), %r14
movq 0x18(%rsp), %r15
movq 0x10(%rsp), %r13
movq (%r14,%r12,8), %rax
movl %eax, %ecx
notl %ecx
addl 0x20(%rbx), %ecx
movq 0x18(%rbx), %rdx
movl %ecx, (%rdx,%rax,4)
cmpb $0x0, 0x4(%rsp)
je 0x576d
movslq (%r13), %rdi
leaq -0x1(%rdi), %rax
movl %eax, (%r13)
xorl %ebp, %ebp
cmpb $0xa, -0x1(%r15,%rdi)
jne 0x57b1
addl $-0x2, %edi
movl %edi, (%r13)
xorl %ebp, %ebp
xorl %esi, %esi
movq %rbx, %rdx
callq 0x541e
testl %eax, %eax
jle 0x57b1
movl %eax, %ecx
subq %rcx, 0x8d40(%rbx)
movq %rbx, %rdi
movl $0x2, %esi
movl $0x1, %edx
movl %eax, %ecx
callq 0x1361c
jmp 0x57b1
movq 0x8(%rsp), %r13
movq %r13, %rdi
callq 0x10f22
leaq 0x1ff5f(%rip), %rdi     # 0x256e0
movl %eax, %esi
callq 0x111aa
cmpl $0x17, %eax
jne 0x579c
movb $0x5, (%r15,%r12)
movq %r13, %rdi
callq 0x10f88
jmp 0x57a1
movb $0x6, (%r15,%r12)
movslq 0x20(%rbx), %rax
decq %rax
movq %rax, (%r14,%r12,8)
movl $0x1, %ebp
movl %ebp, %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 0xf9aa
jmp 0x5807
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x57f0
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x3320
jmp 0x57f0
movq %rax, %rbx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x5807
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x3320
movq %rbx, %rdi
callq 0x3560