// File: /workspace/github_c_makefile_star2_O0/MartinNovotny25[P]VUT-FIT-IFJ2020/semantics.c
// Function: enter_for_body
void enter_for_body(TDLList *L, tBSTNodePtrLocal *fornode, functionData params, char *id){

    tBSTNodePtrLocal for_node;
    BSTInitLocal(&for_node);
    char *nametodelete;
    PushTreeMain(&mainstack, &for_node);
    if(L->Act->rptr->tdata.type != T_SEMICOLON){
        // uloz premennu resp. uzol stromu do tempnode
        nametodelete = L->Act->rptr->tdata.lex;
    } else {
        nametodelete = "none";
    }
    
    for_control(L, fornode, params);
   
    while(L->Act->tdata.type != t_BRACES_R){        
        if ((L->Act->tdata.type == t_IDENTIFIER) && (L->Act->lptr->tdata.type != t_FUNC) && (L->Act->rptr->tdata.type == t_LEFT_BRACKET)) {
            checkCallFunction(L, L->Act->tdata.lex, &for_node);
        }
        if(L->Act->tdata.type == t_IDENTIFIER && L->Act->rptr->tdata.type == t_ASSIGN){
			TDLLElemPtr temp_node = L->Act;
			while(temp_node->tdata.type != t_EOL){
				if(temp_node->lptr->tdata.type == t_EOL){                   
					assign_vals_control(L, &for_node, params);
					break;
				}
				TDLLPred(L);
				temp_node = temp_node->lptr;
			}
		}
        
        if (L->Act->tdata.type == t_DEFINITION_2) {
            TDLLPred(L);
			dec_var_control(L, &for_node, params);
        }
        if (L->Act->tdata.type == t_FOR) {          
            enter_for_body(L, &for_node, params, id);   
        }
        if (L->Act->tdata.type == t_IF) {
            TDLLSucc(L);
			enter_if_body(L, &for_node, params, id);
        }
        if (L->Act->tdata.type == t_RETURN) {
            checkReturnStatement(L, id, fornode);
        }
        TDLLSucc(L);
    }

    // chod za }
    // v enterfuncbody sa nezapocitalo {
    // tak sa nemoze ani }
    // inac ide o chybne pocitanie
    TDLLSucc(L);
    
    if(!(strcmp(nametodelete, "none"))){

    }else{
        BSTDelete(fornode, nametodelete);
    }
    for_node = PopTreeMain(&mainstack);
    BSTDisposeLocal(&for_node);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1070, %rsp           # imm = 0x1070
leaq 0x10(%rbp), %rax
movq %rax, -0x38(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x6980
leaq 0x62a9(%rip), %rdi      # 0x10488
leaq -0x20(%rbp), %rsi
callq 0x6e10
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rax
cmpl $0x38, 0x8(%rax)
je 0xa20f
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rax
movq (%rax), %rax
movq %rax, -0x28(%rbp)
jmp 0xa21a
leaq 0x33c0(%rip), %rax      # 0xd5d6
movq %rax, -0x28(%rbp)
movq -0x38(%rbp), %rsi
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x48(%rbp)
movq %rsp, %rdi
movl $0x201, %ecx            # imm = 0x201
rep  movsq (%rsi), %es:(%rdi)
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdi
callq 0xa740
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0x33, 0x8(%rax)
je 0xa402
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0x13, 0x8(%rax)
jne 0xa2a2
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x10(%rax), %rax
cmpl $0x1c, 0x8(%rax)
je 0xa2a2
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rax
cmpl $0x6, 0x8(%rax)
jne 0xa2a2
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rsi
leaq -0x20(%rbp), %rdx
callq 0x79d0
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0x13, 0x8(%rax)
jne 0xa325
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rax
cmpl $0x3, 0x8(%rax)
jne 0xa325
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpl $0x2f, 0x8(%rax)
je 0xa323
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
cmpl $0x2f, 0x8(%rax)
jne 0xa30c
movq -0x38(%rbp), %rsi
movq -0x8(%rbp), %rax
movq %rax, -0x50(%rbp)
movq %rsp, %rdi
movl $0x201, %ecx            # imm = 0x201
rep  movsq (%rsi), %es:(%rdi)
movq -0x50(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x8810
jmp 0xa323
movq -0x8(%rbp), %rdi
callq 0x1ab0
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
jmp 0xa2ce
jmp 0xa325
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0x32, 0x8(%rax)
jne 0xa360
movq -0x8(%rbp), %rdi
callq 0x1ab0
movq -0x38(%rbp), %rsi
movq -0x8(%rbp), %rax
movq %rax, -0x58(%rbp)
movq %rsp, %rdi
movl $0x201, %ecx            # imm = 0x201
rep  movsq (%rsi), %es:(%rdi)
movq -0x58(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0x9940
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0x1a, 0x8(%rax)
jne 0xa396
movq -0x38(%rbp), %rsi
movq -0x8(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x18(%rbp), %rdx
movq %rsp, %rdi
movl $0x201, %ecx            # imm = 0x201
rep  movsq (%rsi), %es:(%rdi)
movq -0x60(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0xa1b0
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0x16, 0x8(%rax)
jne 0xa3d5
movq -0x8(%rbp), %rdi
callq 0x12e0
movq -0x38(%rbp), %rsi
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x18(%rbp), %rdx
movq %rsp, %rdi
movl $0x201, %ecx            # imm = 0x201
rep  movsq (%rsi), %es:(%rdi)
movq -0x68(%rbp), %rdi
leaq -0x20(%rbp), %rsi
callq 0xa460
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0x19, 0x8(%rax)
jne 0xa3f4
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x10(%rbp), %rdx
callq 0x76c0
movq -0x8(%rbp), %rdi
callq 0x12e0
jmp 0xa246
movq -0x8(%rbp), %rdi
callq 0x12e0
movq -0x28(%rbp), %rdi
leaq 0x31c0(%rip), %rsi      # 0xd5d6
callq 0x1070
cmpl $0x0, %eax
jne 0xa422
jmp 0xa42f
movq -0x10(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x6c20
leaq 0x6052(%rip), %rdi      # 0x10488
callq 0x6e70
movq %rax, -0x20(%rbp)
leaq -0x20(%rbp), %rdi
callq 0x6d90
addq $0x1070, %rsp           # imm = 0x1070
popq %rbp
retq
nopw %cs:(%rax,%rax)