// File: /workspace/github_cpp_makefile_star2_O3/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 $0xa8, %rsp
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x238(%rdi), %r14
cmpq $0x0, 0x240(%rdi)
leaq 0x18(%rsp), %r12
je 0xac23
leaq 0x8(%rsp), %rdi
movq %r12, (%rdi)
leaq 0x2a596(%rip), %rsi     # 0x35130
leaq 0x2a592(%rip), %rdx     # 0x35133
callq 0xbdee
movq 0x10(%rsp), %rdx
leaq 0x2a57e(%rip), %rcx     # 0x35130
movq %r15, %rdi
xorl %esi, %esi
callq 0x73b0
movl %eax, %ebp
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0xabd5
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x72c0
testl %ebp, %ebp
je 0xac88
leaq 0x2a55a(%rip), %rsi     # 0x3513e
leaq 0x8(%rsp), %r14
movq %r14, %rdi
movq %r15, %rdx
callq 0xb692
movq %rbx, %rdi
movq %r14, %rsi
callq 0xaff2
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0xac16
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x72c0
addw $0x4, 0x290(%rbx)
jmp 0xaf14
leaq 0x8(%rsp), %rdi
movq %r12, (%rdi)
leaq 0x2a4f9(%rip), %rsi     # 0x3512b
leaq 0x2a4f6(%rip), %rdx     # 0x3512f
callq 0xbdee
movq 0x10(%rsp), %rdx
leaq 0x2a4e1(%rip), %rcx     # 0x3512b
movq %r15, %rdi
xorl %esi, %esi
callq 0x73b0
movl %eax, %ebp
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0xac6d
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x72c0
testl %ebp, %ebp
je 0xad99
cmpq $0x0, 0x240(%rbx)
jne 0xab8b
jmp 0xabdd
leaq 0x38(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x2a49c(%rip), %rsi     # 0x35134
leaq 0x2a499(%rip), %rdx     # 0x35138
leaq 0x28(%rsp), %rdi
callq 0xbdee
movq 0x30(%rsp), %rdx
leaq 0x8(%rsp), %rdi
movq %r15, %rsi
movq $-0x1, %rcx
callq 0x72f0
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0xacd9
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x72c0
leaq 0x28(%rsp), %rdi
movq %r13, (%rdi)
movq 0x238(%rbx), %rsi
movq 0x240(%rbx), %rdx
addq %rsi, %rdx
callq 0xbd58
movq 0x240(%rbx), %rdx
leaq 0x2b3ca(%rip), %rcx     # 0x360cf
movq %r14, %rdi
xorl %esi, %esi
xorl %r8d, %r8d
callq 0x7450
movq 0x10(%rsp), %rdx
cmpq 0x30(%rsp), %rdx
jne 0xad41
movq 0x28(%rsp), %r14
testq %rdx, %rdx
je 0xaee8
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x72e0
testl %eax, %eax
je 0xaee8
leaq 0x2a3f1(%rip), %rsi     # 0x35139
leaq 0x88(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0xb692
leaq 0x2a3e4(%rip), %rsi     # 0x35145
leaq 0x88(%rsp), %rdi
callq 0x7560
leaq 0x58(%rsp), %r14
movq %r14, -0x10(%r14)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xae10
movq %rdx, 0x48(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x58(%rsp)
jmp 0xae17
leaq 0x38(%rsp), %r13
movq %r13, -0x10(%r13)
leaq 0x2a3a6(%rip), %rsi     # 0x3514f
leaq 0x2a3a4(%rip), %rdx     # 0x35154
leaq 0x28(%rsp), %rdi
callq 0xbdee
movq 0x30(%rsp), %rdx
leaq 0x8(%rsp), %rdi
movq %r15, %rsi
movq $-0x1, %rcx
callq 0x72f0
leaq 0x8(%rsp), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x7370
movq (%rbx), %rdi
cmpq %r12, %rdi
je 0xadf8
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x72c0
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0xaf14
movq 0x38(%rsp), %rsi
jmp 0xaf0c
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq 0x8(%rax), %rdx
leaq 0x48(%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 0x78(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xae69
movq %rdx, 0x68(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x78(%rsp)
jmp 0xae70
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
leaq 0x68(%rsp), %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq %rbx, %rdi
callq 0xab5a
movq 0x68(%rsp), %rdi
cmpq %r15, %rdi
je 0xaeab
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x72c0
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0xaec2
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x72c0
leaq 0x98(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xaee3
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x72c0
movq 0x28(%rsp), %r14
cmpq %r13, %r14
je 0xaefd
movq 0x38(%rsp), %rsi
incq %rsi
movq %r14, %rdi
callq 0x72c0
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0xaf14
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x72c0
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xafae
jmp 0xafe6
movq %rax, %rbx
movq 0x68(%rsp), %rdi
cmpq %r15, %rdi
je 0xaf4f
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x72c0
jmp 0xaf4f
movq %rax, %rbx
movq 0x48(%rsp), %rdi
cmpq %r14, %rdi
je 0xaf6b
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x72c0
jmp 0xaf6b
movq %rax, %rbx
leaq 0x98(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0xaf93
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x72c0
jmp 0xaf93
jmp 0xaf90
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0xafcd
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x72c0
jmp 0xafcd
jmp 0xafca
movq %rax, %rbx
movq 0x28(%rsp), %rdi
cmpq %r13, %rdi
je 0xafe9
movq 0x38(%rsp), %rsi
jmp 0xafdc
jmp 0xafe6
jmp 0xafca
jmp 0xafe6
jmp 0xafca
movq %rax, %rbx
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0xafe9
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x72c0
jmp 0xafe9
movq %rax, %rbx
movq %rbx, %rdi
callq 0x74f0
nop