// File: /workspace/github_cpp_makefile_star2_O3/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 0x556e
movq %r8, %rdi
callq 0x10e06
leaq 0x2019f(%rip), %rdi     # 0x256e0
movl %eax, %esi
callq 0x1106e
cmpl $0x1d, %eax
jne 0x556e
movq 0x8(%rsp), %rdi
callq 0x10e44
movl $0x0, 0x4(%rsp)
movq %rbx, %rdi
movl $0x1f, %esi
xorl %edx, %edx
callq 0x1346e
cmpq $0x0, (%rbp,%r12,8)
je 0x5671
movq %r13, 0x10(%rsp)
movq %r15, 0x18(%rsp)
movq %r14, 0x20(%rsp)
movq %rbp, %r13
movq 0xb0(%rsp), %rbp
movq %rbx, %rdi
callq 0x13c16
leaq (%r12,%r12,2), %r15
movq (%rbp,%r15,8), %r14
cmpq %r14, 0x8(%rbp,%r15,8)
je 0x564a
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0xfa88
leaq 0x40(%rsp), %rdi
leaq 0x18(%r14), %rsi
callq 0xfa88
leaq 0x58(%rsp), %rdi
leaq 0x30(%r14), %rsi
callq 0xfb08
movq 0x48(%r14), %rax
leaq 0x28(%rsp), %rsi
movq %rax, 0x48(%rsi)
movq %rbx, %rdi
callq 0x4949
movq 0x58(%rsp), %rdi
testq %rdi, %rdi
je 0x5605
movq 0x68(%rsp), %rsi
subq %rdi, %rsi
callq 0x3320
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x561c
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 0x563f
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x3320
movq (%r14), %rsi
movq %r14, %rdi
callq 0x1012a
movl (%r13,%r12,8), %edx
subl 0x20(%rbx), %edx
addl $-0x2, %edx
movq %rbx, %rdi
movl $0x1f, %esi
callq 0x1346e
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 0x56d6
movslq (%r13), %rdi
leaq -0x1(%rdi), %rax
movl %eax, (%r13)
xorl %ebp, %ebp
cmpb $0xa, -0x1(%r15,%rdi)
jne 0x571a
addl $-0x2, %edi
movl %edi, (%r13)
xorl %ebp, %ebp
xorl %esi, %esi
movq %rbx, %rdx
callq 0x5399
testl %eax, %eax
jle 0x571a
movl %eax, %ecx
subq %rcx, 0x8d40(%rbx)
movq %rbx, %rdi
movl $0x2, %esi
movl $0x1, %edx
movl %eax, %ecx
callq 0x1348e
jmp 0x571a
movq 0x8(%rsp), %r13
movq %r13, %rdi
callq 0x10e06
leaq 0x1fff6(%rip), %rdi     # 0x256e0
movl %eax, %esi
callq 0x1106e
cmpl $0x17, %eax
jne 0x5705
movb $0x5, (%r15,%r12)
movq %r13, %rdi
callq 0x10e44
jmp 0x570a
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 0xf8aa
jmp 0x5770
movq %rax, %rbx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x5759
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x3320
jmp 0x5759
movq %rax, %rbx
movq 0x28(%rsp), %rdi
testq %rdi, %rdi
je 0x5770
movq 0x38(%rsp), %rsi
subq %rdi, %rsi
callq 0x3320
movq %rbx, %rdi
callq 0x3560