// File: /workspace/github_cpp_makefile_star2_O2/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, 0xc(%rsp)
cmpb $0x2, %al
movq %r8, 0x10(%rsp)
jb 0x534c
movq %r8, %rdi
callq 0xfc58
leaq 0x203cf(%rip), %rdi     # 0x256f0
movl %eax, %esi
callq 0xfe60
cmpl $0x1d, %eax
jne 0x534c
movq 0x10(%rsp), %rdi
callq 0xfc84
pushq $0x1f
popq %rsi
movl $0x0, 0xc(%rsp)
movq %rbx, %rdi
xorl %edx, %edx
callq 0x11e4a
cmpq $0x0, (%rbp,%r12,8)
je 0x53c9
movq %r15, 0x18(%rsp)
movq %r14, 0x20(%rsp)
movq 0xb0(%rsp), %r14
movq %rbx, %rdi
callq 0x12512
imulq $0x18, %r12, %r15
movq (%r14,%r15), %rsi
cmpq %rsi, 0x8(%r14,%r15)
je 0x53a9
leaq 0x28(%rsp), %rdi
callq 0xe856
movq %rbx, %rdi
leaq 0x28(%rsp), %rsi
callq 0x47a6
addq %r15, %r14
leaq 0x28(%rsp), %rdi
callq 0xe82e
movq %r14, %rdi
callq 0xe84e
movl (%rbp,%r12,8), %edx
subl 0x20(%rbx), %edx
addl $-0x2, %edx
pushq $0x1f
popq %rsi
movq %rbx, %rdi
callq 0x11e4a
movq 0x20(%rsp), %r14
movq 0x18(%rsp), %r15
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, 0xc(%rsp)
je 0x542a
movslq (%r13), %rdi
leaq -0x1(%rdi), %rax
movl %eax, (%r13)
xorl %ebp, %ebp
cmpb $0xa, -0x1(%r15,%rdi)
jne 0x546c
addl $-0x2, %edi
movl %edi, (%r13)
xorl %ebp, %ebp
xorl %esi, %esi
movq %rbx, %rdx
callq 0x519a
testl %eax, %eax
jle 0x546c
movl %eax, %ecx
subq %rcx, 0x8d40(%rbx)
pushq $0x2
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rdi
movl %eax, %ecx
callq 0x11e6a
jmp 0x546c
movq 0x10(%rsp), %r13
movq %r13, %rdi
callq 0xfc58
leaq 0x202b2(%rip), %rdi     # 0x256f0
movl %eax, %esi
callq 0xfe60
cmpl $0x17, %eax
jne 0x5459
movb $0x5, (%r15,%r12)
movq %r13, %rdi
callq 0xfc84
jmp 0x545e
movb $0x6, (%r15,%r12)
movslq 0x20(%rbx), %rax
decq %rax
movq %rax, (%r14,%r12,8)
pushq $0x1
popq %rbp
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 0xe82e
movq %rbx, %rdi
callq 0x3560