// File: /workspace/github_cpp_makefile_star2_O2/rfotino[P]consolite-compiler/src/syntax.cpp
// Function: ForStatement::output(Parser*, std::shared_ptr<FunctionToken> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void ForStatement::output(Parser *parser,
                          const std::shared_ptr<FunctionToken>& function,
                          const std::string& returnLabel,
                          const std::string&,
                          const std::string&) {
  // Evaluate the initial expressions and discard the result.
  for (auto expr : _initExprs) {
    expr->output(parser, VarLocation("L"));
  }
  // Create the start, break, and continue labels.
  std::string startLabel =
    parser->getUnusedLabel(function->name() + "_for_start");
  std::string breakLabel =
    parser->getUnusedLabel(function->name() + "_for_break");
  std::string continueLabel =
    parser->getUnusedLabel(function->name() + "_for_continue");
  // Output the start label and test the condition.
  parser->writeln(startLabel + ":");
  _condExpr->output(parser, VarLocation("L"));
  parser->writeInst("TST L L");
  parser->writeInst("JEQ " + breakLabel);
  // Output the function body followed by the continue label.
  _body->output(parser, function, returnLabel, breakLabel, continueLabel);
  parser->writeln(continueLabel + ":");
  // Output the loop expressions and jump to the start of the loop.
  for (auto expr : _loopExprs) {
    expr->output(parser, VarLocation("L"));
  }
  parser->writeInst("JMPI " + startLabel);
  // Output the break label.
  parser->writeln(breakLabel + ":");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rcx, 0xb0(%rsp)
movq %rdx, 0xc0(%rsp)
movq %rsi, %r15
movq 0x30(%rdi), %rbp
movq %rdi, 0xb8(%rsp)
movq 0x38(%rdi), %r12
leaq 0xc8(%rsp), %r14
leaq 0x90(%rsp), %r13
leaq 0x8(%rsp), %rbx
movq %rsi, 0x38(%rsp)
cmpq %r12, %rbp
je 0x1762d
leaq 0x40(%rsp), %rdi
movq %rbp, %rsi
callq 0x18f1c
movq 0x40(%rsp), %r15
movq %r14, %rdi
leaq 0x124f1(%rip), %rsi     # 0x29ad8
movq %r13, %rdx
callq 0x9502
movq %rbx, %rdi
movq %r14, %rsi
callq 0x73e0
movq %r15, %rdi
movq 0x38(%rsp), %r15
movq %r15, %rsi
movq %rbx, %rdx
callq 0x10ca6
movq %rbx, %rdi
callq 0x75c8
movq %r14, %rdi
callq 0x75c8
leaq 0x48(%rsp), %rdi
callq 0x7a34
addq $0x10, %rbp
jmp 0x175c6
movq 0xc0(%rsp), %r12
movq (%r12), %rsi
addq $0x58, %rsi
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
callq 0x73e0
leaq 0x12897(%rip), %rdx     # 0x29ee8
leaq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0x9ad4
leaq 0xc8(%rsp), %rdi
leaq 0x8(%rsp), %rdx
movq %r15, %rsi
callq 0x901a
movq 0xb8(%rsp), %r14
leaq 0x8(%rsp), %rdi
callq 0x75c8
leaq 0x40(%rsp), %rdi
callq 0x75c8
movq (%r12), %rsi
addq $0x58, %rsi
leaq 0x90(%rsp), %rdi
callq 0x73e0
leaq 0x12848(%rip), %rdx     # 0x29ef3
leaq 0x8(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x9ad4
leaq 0x40(%rsp), %rdi
leaq 0x8(%rsp), %rdx
movq %r15, %rsi
callq 0x901a
leaq 0x8(%rsp), %rdi
callq 0x75c8
leaq 0x90(%rsp), %rdi
callq 0x75c8
movq (%r12), %rsi
addq $0x58, %rsi
leaq 0x60(%rsp), %rdi
callq 0x73e0
leaq 0x127ff(%rip), %rdx     # 0x29efe
leaq 0x8(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x9ad4
leaq 0x90(%rsp), %rdi
leaq 0x8(%rsp), %rdx
movq %r15, %rsi
callq 0x901a
leaq 0x8(%rsp), %rdi
callq 0x75c8
leaq 0x60(%rsp), %rdi
callq 0x75c8
leaq 0x13ef2(%rip), %rdx     # 0x2b630
leaq 0x8(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
callq 0x99f6
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x93f2
leaq 0x8(%rsp), %rdi
callq 0x75c8
movq 0x10(%r14), %rbx
leaq 0x12366(%rip), %rsi     # 0x29ad8
leaq 0x60(%rsp), %rdi
leaq 0x80(%rsp), %rdx
callq 0x9502
leaq 0x8(%rsp), %rdi
leaq 0x60(%rsp), %rsi
callq 0x73e0
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x10ca6
leaq 0x8(%rsp), %rdi
callq 0x75c8
leaq 0x60(%rsp), %rdi
callq 0x75c8
leaq 0x12722(%rip), %rsi     # 0x29ee0
leaq 0x8(%rsp), %rdi
leaq 0x60(%rsp), %rdx
callq 0x9502
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x914a
leaq 0x8(%rsp), %rdi
callq 0x75c8
leaq 0x12048(%rip), %rsi     # 0x29833
leaq 0x8(%rsp), %rdi
leaq 0x40(%rsp), %rdx
callq 0x9980
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x914a
leaq 0x8(%rsp), %rdi
callq 0x75c8
movq 0x20(%r14), %rdi
movq (%rdi), %rax
leaq 0x40(%rsp), %r8
leaq 0x90(%rsp), %r9
movq %r15, %rsi
movq %r12, %rdx
movq 0xb0(%rsp), %rcx
callq *0x8(%rax)
leaq 0x13df3(%rip), %rdx     # 0x2b630
leaq 0x8(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x99f6
leaq 0x8(%rsp), %rsi
movq %r15, %rdi
callq 0x93f2
leaq 0x8(%rsp), %r15
movq %r15, %rdi
callq 0x75c8
movq 0x48(%r14), %r12
movq 0x50(%r14), %rbp
leaq 0x60(%rsp), %r14
leaq 0x37(%rsp), %rbx
cmpq %rbp, %r12
je 0x178e8
leaq 0x80(%rsp), %rdi
movq %r12, %rsi
callq 0x18f1c
movq 0x80(%rsp), %r13
movq %r14, %rdi
leaq 0x12236(%rip), %rsi     # 0x29ad8
movq %rbx, %rdx
callq 0x9502
movq %r15, %rdi
movq %r14, %rsi
callq 0x73e0
movq %r13, %rdi
movq 0x38(%rsp), %rsi
movq %r15, %rdx
callq 0x10ca6
movq %r15, %rdi
callq 0x75c8
movq %r14, %rdi
callq 0x75c8
leaq 0x88(%rsp), %rdi
callq 0x7a34
addq $0x10, %r12
jmp 0x1787b
leaq 0x11826(%rip), %rsi     # 0x29115
leaq 0x8(%rsp), %rdi
leaq 0xc8(%rsp), %rdx
callq 0x9980
leaq 0x8(%rsp), %rsi
movq 0x38(%rsp), %rbx
movq %rbx, %rdi
callq 0x914a
leaq 0x8(%rsp), %rdi
callq 0x75c8
leaq 0x13d0c(%rip), %rdx     # 0x2b630
leaq 0x8(%rsp), %rdi
leaq 0x40(%rsp), %rsi
callq 0x99f6
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x93f2
leaq 0x8(%rsp), %rdi
callq 0x75c8
leaq 0x90(%rsp), %rdi
callq 0x75c8
leaq 0x40(%rsp), %rdi
callq 0x75c8
leaq 0xc8(%rsp), %rdi
callq 0x75c8
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x179b1
jmp 0x179c3
jmp 0x179b1
jmp 0x179c3
jmp 0x179b1
jmp 0x179c3
jmp 0x179c3
jmp 0x179b1
jmp 0x179c3
jmp 0x179b1
jmp 0x179c3
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x75c8
jmp 0x179a8
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
jmp 0x179b9
jmp 0x179c3
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x75c8
jmp 0x17a51
movq %rax, %rbx
jmp 0x17a51
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x75c8
jmp 0x179dd
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
jmp 0x17a59
movq %rax, %rbx
jmp 0x17a5e
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x75c8
jmp 0x179fb
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
jmp 0x17a63
movq %rax, %rbx
jmp 0x17a68
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x75c8
jmp 0x17a1c
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
jmp 0x17a70
movq %rax, %rbx
jmp 0x17a44
movq %rax, %rbx
jmp 0x17a3a
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x75c8
leaq 0x60(%rsp), %rdi
callq 0x75c8
leaq 0x88(%rsp), %rdi
callq 0x7a34
leaq 0x90(%rsp), %rdi
callq 0x75c8
leaq 0x40(%rsp), %rdi
callq 0x75c8
leaq 0xc8(%rsp), %rdi
callq 0x75c8
jmp 0x17aa5
movq %rax, %rbx
jmp 0x17a9b
movq %rax, %rbx
jmp 0x17a8e
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x75c8
leaq 0xc8(%rsp), %rdi
callq 0x75c8
leaq 0x48(%rsp), %rdi
callq 0x7a34
movq %rbx, %rdi
callq 0x7510
nop