// File: martinda3[P]Compiler/src/JVM/JVMgenerateStatement.cpp
// Function: toyc::JVMgenerateStatement::genStatement(toyc::ASdefinition*, toyc::JVMtargetCode*)
void JVMgenerateStatement::genStatement(ASdefinition *ast,JVMtargetCode *tc) {
      ASfuncDef *Functions = dynamic_cast<ASfuncDef*>(ast);

      int FunctionDeclarations = Functions->getNumVarDef();

      if (FunctionDeclarations < 2) { tc->add(new limit("stack",10)); }
      else { tc->add(new limit("stack",10 )); }

      for (int Function = 0 ; Function <  FunctionDeclarations; Function++) // Not sure if needed
      {
//          ASvarDef *VarInit = JVMgenerateStatement::ASvarDefinition(dynamic_cast<ASvarDef*>(Functions->getVarDef(Function)), tc);
//          AStype *step = dynamic_cast<AStype*>(VarInit->getIdentifier(Function));
//          std::cout << "  "<< step->getExpr()->getLexeme() << std::endl;
//          JVMgenUtils::gen_ISTORE(*symTable->getSym(symTable->find(step->getExpr()->getLexeme())),tc);
      }

      ASblockState *FunctionBlock = dynamic_cast<ASblockState*>(Functions->getStatement());
      JVMgenerateStatement::BlockStatement(FunctionBlock, tc);
  }

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xe0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x90(%rbp)
cmpq $0x0, %rax
je 0x264ab
movq -0x90(%rbp), %rdi
leaq 0x1c606(%rip), %rsi     # 0x42a98
leaq 0x1c5d7(%rip), %rdx     # 0x42a70
xorl %eax, %eax
movl %eax, %ecx
callq 0x93e0
movq %rax, -0x98(%rbp)
jmp 0x264b6
xorl %eax, %eax
movq %rax, -0x98(%rbp)
jmp 0x264b6
movq -0x98(%rbp), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x13b20
movl %eax, -0x1c(%rbp)
cmpl $0x2, -0x1c(%rbp)
jge 0x265b4
movq -0x10(%rbp), %rax
movq %rax, -0xb0(%rbp)
movl $0x58, %edi
callq 0x9350
movq %rax, -0xa8(%rbp)
movb $0x1, -0x55(%rbp)
leaq -0x41(%rbp), %rdi
movq %rdi, -0xa0(%rbp)
callq 0x95c0
movq -0xa0(%rbp), %rdx
leaq 0xe28b(%rip), %rsi      # 0x347a0
leaq -0x40(%rbp), %rdi
callq 0x13550
jmp 0x26520
movq -0xa8(%rbp), %rdi
leaq -0x40(%rbp), %rsi
movl $0xa, %edx
callq 0x26100
jmp 0x26537
movq -0xa8(%rbp), %rsi
movq -0xb0(%rbp), %rdi
movb $0x0, -0x55(%rbp)
movq (%rdi), %rax
movq (%rax), %rax
callq *%rax
jmp 0x26553
leaq -0x40(%rbp), %rdi
callq 0x9658
leaq -0x41(%rbp), %rdi
callq 0x93b0
jmp 0x2668e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x2658d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x9658
leaq -0x41(%rbp), %rdi
callq 0x93b0
testb $0x1, -0x55(%rbp)
jne 0x2659e
jmp 0x265af
movq -0xa8(%rbp), %rdi
movl $0x58, %esi
callq 0x9360
jmp 0x26719
movq -0x10(%rbp), %rax
movq %rax, -0xc8(%rbp)
movl $0x58, %edi
callq 0x9350
movq %rax, -0xc0(%rbp)
movb $0x1, -0x7a(%rbp)
leaq -0x79(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
callq 0x95c0
movq -0xb8(%rbp), %rdx
leaq 0xe1ae(%rip), %rsi      # 0x347a0
leaq -0x78(%rbp), %rdi
callq 0x13550
jmp 0x265fd
movq -0xc0(%rbp), %rdi
leaq -0x78(%rbp), %rsi
movl $0xa, %edx
callq 0x26100
jmp 0x26614
movq -0xc0(%rbp), %rsi
movq -0xc8(%rbp), %rdi
movb $0x0, -0x7a(%rbp)
movq (%rdi), %rax
movq (%rax), %rax
callq *%rax
jmp 0x26630
leaq -0x78(%rbp), %rdi
callq 0x9658
leaq -0x79(%rbp), %rdi
callq 0x93b0
jmp 0x2668e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x26667
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x9658
leaq -0x79(%rbp), %rdi
callq 0x93b0
testb $0x1, -0x7a(%rbp)
jne 0x26678
jmp 0x26689
movq -0xc0(%rbp), %rdi
movl $0x58, %esi
callq 0x9360
jmp 0x26719
movl $0x0, -0x80(%rbp)
movl -0x80(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x266aa
jmp 0x2669f
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0x26695
movq -0x18(%rbp), %rdi
callq 0x143a0
movq %rax, -0xd0(%rbp)
cmpq $0x0, %rax
je 0x266e7
movq -0xd0(%rbp), %rdi
leaq 0x1c57a(%rip), %rsi     # 0x42c48
leaq 0x1e5db(%rip), %rdx     # 0x44cb0
xorl %eax, %eax
movl %eax, %ecx
callq 0x93e0
movq %rax, -0xd8(%rbp)
jmp 0x266f2
xorl %eax, %eax
movq %rax, -0xd8(%rbp)
jmp 0x266f2
movq -0xd8(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x88(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x26730
addq $0xe0, %rsp
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x95b0
nopw %cs:(%rax,%rax)