// File: /workspace/github_cpp_makefile_star2_O1/rfotino[P]consolite-compiler/src/parser.cpp
// Function: Parser::writeInst(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
void Parser::writeInst(const std::string& inst) {
  // We want to optimize a PUSH followed by a POP by either
  // removing it entirely or by turning it into a single MOV
  // instruction.
  if (_pendingPushReg.empty() &&
      0 == inst.compare(0, std::string("PUSH").size(), "PUSH")) {
    // It is a PUSH instruction and there are no pending push instructions.
    // We need to save the register and write nothing, because the next
    // instruction could be a POP.
    _pendingPushReg = inst.substr(std::string("PUSH ").size());
    return;
  } else if (!_pendingPushReg.empty() &&
             0 == inst.compare(0, std::string("POP").size(), "POP")) {
    // It is a POP instruction and the previous instruction was a PUSH.
    // We can optimize this into nothing or a MOV instruction.
    std::string popReg = inst.substr(std::string("POP ").size());
    std::string pushReg = _pendingPushReg;
    _pendingPushReg = "";
    if (popReg != pushReg) {
      this->writeInst("MOV " + popReg + " " + pushReg);
    }
    return;
  }
  this->writeln("        " + inst);
  _bytePos += INST_SIZE;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xe8, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq 0x240(%rdi), %r15
testq %r15, %r15
je 0xadd9
xorl %ebp, %ebp
jmp 0xae20
leaq 0xb8(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x2b33e(%rip), %rsi     # 0x3612b
leaq 0x2b33b(%rip), %rdx     # 0x3612f
leaq 0xa8(%rsp), %rdi
callq 0xc0a4
movq 0xb0(%rsp), %rdx
leaq 0x2b31b(%rip), %rcx     # 0x3612b
movq %r14, %rdi
xorl %esi, %esi
callq 0x73b0
testl %eax, %eax
sete %bpl
testq %r15, %r15
jne 0xae46
leaq 0xb8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xae46
movq 0xb8(%rsp), %rsi
incq %rsi
callq 0x72c0
leaq 0x238(%rbx), %r15
testb %bpl, %bpl
je 0xaeca
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x2b2ec(%rip), %rsi     # 0x3614f
leaq 0x2b2ea(%rip), %rdx     # 0x36154
leaq 0x8(%rsp), %rdi
callq 0xc0a4
movq 0x10(%rsp), %rdx
leaq 0x48(%rsp), %rdi
movq %r14, %rsi
movq $-0x1, %rcx
callq 0x72f0
leaq 0x48(%rsp), %rbx
movq %r15, %rdi
movq %rbx, %rsi
callq 0x7370
movq (%rbx), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0xaeb7
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x72c0
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
jne 0xb19f
jmp 0xb1ac
movq 0x240(%rbx), %r12
testq %r12, %r12
je 0xaf15
leaq 0x58(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x2b24a(%rip), %rsi     # 0x36130
leaq 0x2b246(%rip), %rdx     # 0x36133
leaq 0x48(%rsp), %rdi
callq 0xc0a4
movq 0x50(%rsp), %rdx
leaq 0x2b22d(%rip), %rcx     # 0x36130
movq %r14, %rdi
xorl %esi, %esi
callq 0x73b0
testl %eax, %eax
sete %bpl
jmp 0xaf17
xorl %ebp, %ebp
testq %r12, %r12
je 0xaf37
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xaf37
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x72c0
testb %bpl, %bpl
je 0xb04b
leaq 0x38(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x2b1e3(%rip), %rsi     # 0x36134
leaq 0x2b1e0(%rip), %rdx     # 0x36138
leaq 0x28(%rsp), %rdi
callq 0xc0a4
movq 0x30(%rsp), %rdx
leaq 0x8(%rsp), %rdi
movq %r14, %rsi
movq $-0x1, %rcx
callq 0x72f0
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0xaf92
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x72c0
leaq 0x28(%rsp), %rdi
movq %r12, (%rdi)
movq 0x238(%rbx), %rsi
movq 0x240(%rbx), %rdx
addq %rsi, %rdx
callq 0xc014
movq 0x240(%rbx), %rdx
leaq 0x2c111(%rip), %rcx     # 0x370cf
movq %r15, %rdi
xorl %esi, %esi
xorl %r8d, %r8d
callq 0x7450
movq 0x10(%rsp), %rdx
cmpq 0x30(%rsp), %rdx
jne 0xaff7
testq %rdx, %rdx
je 0xb17a
movq 0x28(%rsp), %rsi
movq 0x8(%rsp), %rdi
callq 0x72e0
testl %eax, %eax
je 0xb17a
leaq 0x2b13b(%rip), %rsi     # 0x36139
leaq 0xc8(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0xb963
leaq 0x2b12e(%rip), %rsi     # 0x36145
leaq 0xc8(%rsp), %rdi
callq 0x7560
leaq 0x78(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xb095
movq %rdx, 0x68(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x78(%rsp)
jmp 0xb09c
leaq 0x2b0ec(%rip), %rsi     # 0x3613e
leaq 0x8(%rsp), %r15
movq %r15, %rdi
movq %r14, %rdx
callq 0xb963
movq %rbx, %rdi
movq %r15, %rsi
callq 0xb2c4
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb088
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x72c0
addw $0x4, 0x290(%rbx)
jmp 0xb1ac
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq 0x8(%rax), %rdx
leaq 0x68(%rsp), %rdi
movq %rdx, 0x8(%rdi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
callq 0x70d0
leaq 0x98(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xb0f7
movq %rdx, 0x88(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x98(%rsp)
jmp 0xb0fe
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
leaq 0x88(%rsp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %rbx, %rdi
callq 0xadb2
movq 0x88(%rsp), %rdi
cmpq %r15, %rdi
je 0xb142
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x72c0
movq 0x68(%rsp), %rdi
cmpq %r14, %rdi
je 0xb159
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x72c0
leaq 0xd8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb17a
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x72c0
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0xb191
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x72c0
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb1ac
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x72c0
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x88(%rsp), %rdi
cmpq %r15, %rdi
je 0xb1e3
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x72c0
jmp 0xb1e3
movq %rax, %rbx
movq 0x68(%rsp), %rdi
cmpq %r14, %rdi
je 0xb1ff
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x72c0
jmp 0xb1ff
movq %rax, %rbx
leaq 0xd8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xb227
movq 0xd8(%rsp), %rsi
incq %rsi
callq 0x72c0
jmp 0xb227
jmp 0xb224
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0xb259
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x72c0
jmp 0xb259
jmp 0xb256
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r12, %rdi
je 0xb2bc
movq 0x38(%rsp), %rsi
jmp 0xb2af
movq %rax, %rbx
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
jne 0xb2aa
jmp 0xb2bc
jmp 0xb2b9
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r13, %rdi
je 0xb2bc
movq 0x58(%rsp), %rsi
jmp 0xb2af
jmp 0xb2b9
movq %rax, %rbx
movq 0xa8(%rsp), %rdi
cmpq %r12, %rdi
je 0xb2bc
movq 0xb8(%rsp), %rsi
jmp 0xb2af
jmp 0xb2b9
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0xb2bc
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x72c0
jmp 0xb2bc
movq %rax, %rbx
movq %rbx, %rdi
callq 0x74f0