// File: 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
movq %rsp, %rbp
subq $0x210, %rsp            # imm = 0x210
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x1b0(%rbp)
addq $0x238, %rdi            # imm = 0x238
callq 0x8690
movb %al, %cl
movb $0x0, -0x32(%rbp)
movb $0x0, -0x45(%rbp)
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x1a1(%rbp)
jne 0xc643
jmp 0xc6bd
movq -0x10(%rbp), %rax
movq %rax, -0x1c0(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0x1b8(%rbp)
callq 0x8760
movq -0x1b8(%rbp), %rdx
movb $0x1, -0x32(%rbp)
leaq 0x62aaf(%rip), %rsi     # 0x6f11f
leaq -0x30(%rbp), %rdi
callq 0xced0
jmp 0xc67b
movb $0x1, -0x45(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x8300
movq -0x1c0(%rbp), %rdi
movq %rax, %rdx
leaq 0x62a86(%rip), %rcx     # 0x6f11f
xorl %eax, %eax
movl %eax, %esi
callq 0x8560
movl %eax, -0x1c4(%rbp)
jmp 0xc6aa
movl -0x1c4(%rbp), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
sete %al
movb %al, -0x1a1(%rbp)
movb -0x1a1(%rbp), %al
movb %al, -0x1c5(%rbp)
testb $0x1, -0x45(%rbp)
jne 0xc6d1
jmp 0xc6da
leaq -0x30(%rbp), %rdi
callq 0x8848
testb $0x1, -0x32(%rbp)
jne 0xc6e2
jmp 0xc6eb
leaq -0x31(%rbp), %rdi
callq 0x8460
movb -0x1c5(%rbp), %al
testb $0x1, %al
jne 0xc6fa
jmp 0xc813
movq -0x10(%rbp), %rax
movq %rax, -0x1d8(%rbp)
leaq -0x89(%rbp), %rdi
movq %rdi, -0x1d0(%rbp)
callq 0x8760
movq -0x1d0(%rbp), %rdx
leaq 0x62a1d(%rip), %rsi     # 0x6f143
leaq -0x88(%rbp), %rdi
callq 0xced0
jmp 0xc734
leaq -0x88(%rbp), %rdi
callq 0x8300
movq -0x1d8(%rbp), %rsi
movq %rax, %rdx
leaq -0x68(%rbp), %rdi
movq $-0x1, %rcx
callq 0x8410
jmp 0xc75c
movq -0x1b0(%rbp), %rdi
addq $0x238, %rdi            # imm = 0x238
leaq -0x68(%rbp), %rsi
callq 0x84e0
leaq -0x68(%rbp), %rdi
callq 0x8848
leaq -0x88(%rbp), %rdi
callq 0x8848
leaq -0x89(%rbp), %rdi
callq 0x8460
jmp 0xcbfc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xc7c6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
testb $0x1, -0x45(%rbp)
jne 0xc7bb
jmp 0xc7c4
leaq -0x30(%rbp), %rdi
callq 0x8848
jmp 0xc7c6
testb $0x1, -0x32(%rbp)
jne 0xc7ce
jmp 0xc7d7
leaq -0x31(%rbp), %rdi
callq 0x8460
jmp 0xcc1d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xc802
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x8848
leaq -0x89(%rbp), %rdi
callq 0x8460
jmp 0xcc1d
movq -0x1b0(%rbp), %rdi
addq $0x238, %rdi            # imm = 0x238
callq 0x8690
movb %al, %cl
movb $0x0, -0xb2(%rbp)
movb $0x0, -0xb3(%rbp)
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x1d9(%rbp)
jne 0xc8d0
movq -0x10(%rbp), %rax
movq %rax, -0x1f0(%rbp)
leaq -0xb1(%rbp), %rdi
movq %rdi, -0x1e8(%rbp)
callq 0x8760
movq -0x1e8(%rbp), %rdx
movb $0x1, -0xb2(%rbp)
leaq 0x628aa(%rip), %rsi     # 0x6f124
leaq -0xb0(%rbp), %rdi
callq 0xced0
jmp 0xc888
movb $0x1, -0xb3(%rbp)
leaq -0xb0(%rbp), %rdi
callq 0x8300
movq -0x1f0(%rbp), %rdi
movq %rax, %rdx
leaq 0x62878(%rip), %rcx     # 0x6f124
xorl %eax, %eax
movl %eax, %esi
callq 0x8560
movl %eax, -0x1f4(%rbp)
jmp 0xc8bd
movl -0x1f4(%rbp), %ecx
xorl %eax, %eax
cmpl %ecx, %eax
sete %al
movb %al, -0x1d9(%rbp)
movb -0x1d9(%rbp), %al
movb %al, -0x1f5(%rbp)
testb $0x1, -0xb3(%rbp)
jne 0xc8e7
jmp 0xc8f3
leaq -0xb0(%rbp), %rdi
callq 0x8848
testb $0x1, -0xb2(%rbp)
jne 0xc8fe
jmp 0xc90a
leaq -0xb1(%rbp), %rdi
callq 0x8460
movb -0x1f5(%rbp), %al
testb $0x1, %al
jne 0xc919
jmp 0xcba3
movq -0x10(%rbp), %rax
movq %rax, -0x208(%rbp)
leaq -0xf9(%rbp), %rdi
movq %rdi, -0x200(%rbp)
callq 0x8760
movq -0x200(%rbp), %rdx
leaq 0x627e3(%rip), %rsi     # 0x6f128
leaq -0xf8(%rbp), %rdi
callq 0xced0
jmp 0xc953
leaq -0xf8(%rbp), %rdi
callq 0x8300
movq -0x208(%rbp), %rsi
movq %rax, %rdx
leaq -0xd8(%rbp), %rdi
movq $-0x1, %rcx
callq 0x8410
jmp 0xc97e
leaq -0xf8(%rbp), %rdi
callq 0x8848
leaq -0xf9(%rbp), %rdi
callq 0x8460
movq -0x1b0(%rbp), %rsi
addq $0x238, %rsi            # imm = 0x238
leaq -0x120(%rbp), %rdi
callq 0x81b0
jmp 0xc9b2
movq -0x1b0(%rbp), %rdi
addq $0x238, %rdi            # imm = 0x238
leaq 0x63798(%rip), %rsi     # 0x7015f
callq 0x8580
jmp 0xc9ce
leaq -0xd8(%rbp), %rdi
leaq -0x120(%rbp), %rsi
callq 0xdfa0
testb $0x1, %al
jne 0xc9ea
jmp 0xcb6f
leaq 0x6273c(%rip), %rsi     # 0x6f12d
leaq -0x180(%rbp), %rdi
leaq -0xd8(%rbp), %rdx
callq 0xdc30
jmp 0xca06
leaq 0x6272c(%rip), %rdx     # 0x6f139
leaq -0x160(%rbp), %rdi
leaq -0x180(%rbp), %rsi
callq 0xe020
jmp 0xca22
leaq -0x140(%rbp), %rdi
leaq -0x160(%rbp), %rsi
leaq -0x120(%rbp), %rdx
callq 0xdfd0
jmp 0xca3e
movq -0x1b0(%rbp), %rdi
leaq -0x140(%rbp), %rsi
callq 0xc600
jmp 0xca53
leaq -0x140(%rbp), %rdi
callq 0x8848
leaq -0x160(%rbp), %rdi
callq 0x8848
leaq -0x180(%rbp), %rdi
callq 0x8848
jmp 0xcb6f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xcaaf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
testb $0x1, -0xb3(%rbp)
jne 0xcaa1
jmp 0xcaad
leaq -0xb0(%rbp), %rdi
callq 0x8848
jmp 0xcaaf
testb $0x1, -0xb2(%rbp)
jne 0xcaba
jmp 0xcac6
leaq -0xb1(%rbp), %rdi
callq 0x8460
jmp 0xcc1d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xcaf1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0xf8(%rbp), %rdi
callq 0x8848
leaq -0xf9(%rbp), %rdi
callq 0x8460
jmp 0xcc1d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xcb95
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xcb89
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xcb61
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0xcb55
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x140(%rbp), %rdi
callq 0x8848
leaq -0x160(%rbp), %rdi
callq 0x8848
leaq -0x180(%rbp), %rdi
callq 0x8848
jmp 0xcb89
leaq -0x120(%rbp), %rdi
callq 0x8848
leaq -0xd8(%rbp), %rdi
callq 0x8848
jmp 0xcbfc
leaq -0x120(%rbp), %rdi
callq 0x8848
leaq -0xd8(%rbp), %rdi
callq 0x8848
jmp 0xcc1d
jmp 0xcba5
movq -0x10(%rbp), %rdx
leaq 0x62582(%rip), %rsi     # 0x6f132
leaq -0x1a0(%rbp), %rdi
movq %rdi, -0x210(%rbp)
callq 0xdc30
movq -0x1b0(%rbp), %rdi
movq -0x210(%rbp), %rsi
callq 0xcc30
jmp 0xcbd8
leaq -0x1a0(%rbp), %rdi
callq 0x8848
movq -0x1b0(%rbp), %rax
movzwl 0x290(%rax), %ecx
addl $0x4, %ecx
movw %cx, 0x290(%rax)
addq $0x210, %rsp            # imm = 0x210
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0x8848
movq -0x40(%rbp), %rdi
callq 0x8750
nopw %cs:(%rax,%rax)