// File: Davidc2525[P]Leaf/compiler/backend/x86_64_linux/generator.cpp
// Function: x86_64_linux_generator_visitor::visit(LEAF::AST::ThrowStatementNode*)
void x86_64_linux_generator_visitor::visit(ThrowStatementNode *_t_)
{
    UPDATE_STATICS
    Section *st = assembly->get_program()->section(Sections::text);
    DInstruccion *i = new DInstruccion(";throw");
    st->add(i);

    i = new DInstruccion("_pop_");
    st->add(i);

    i = new DInstruccion("mov");
    i->add_operand(new RegisterOperand("rcx"));
    i->add_operand(new RegisterOperand("rax"));
    st->add(i);

    i = new DInstruccion("list_find_h_by_type");
    i->add_operand(new RegisterOperand("rax"));
    i->add_operand(new InmediateIntOperand(symbol_table::get_id(_t_->child->obj->type, 0)));
    st->add(i);

    i = new DInstruccion("mov");
    i->add_operand(new RegisterOperand("rbx"));
    i->add_operand(new RegisterOperand("rax"));
    st->add(i);

    ax = Load;
    _t_->child->accept(this);
    ;

    i = new DInstruccion("mov");
    i->add_operand(new RegisterOperand("rax"));
    i->add_operand(new RegisterOperand(reg->getName()));
    st->add(i);

    i = new DInstruccion("mov");
    i->add_operand(new RegisterOperand("rbp"));
    MemoryOperand *m = new MemoryOperand();
    m->add_operand(new RegisterOperand("rcx"));
    m->add_operand(load_mod::add, new InmediateIntOperand(8));
    i->add_operand(m);
    st->add(i);

    i = new DInstruccion("mov");
    i->add_operand(new RegisterOperand("rsp"));
    m = new MemoryOperand();
    m->add_operand(new RegisterOperand("rcx"));
    m->add_operand(load_mod::add, new InmediateIntOperand(16));
    i->add_operand(m);
    st->add(i);

    i = new DInstruccion("J_H_RUTINE");
    i->add_operand(new RegisterOperand("rbx"));
    //i->add_operand(new RegisterOperand("rcx"));
    st->add(i);

    i = new DInstruccion(";end throw");
    st->add(i);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x48(%rbp)
movl 0x8(%rax), %ecx
incl %ecx
movl %ecx, 0x8(%rax)
movq 0x10(%rax), %rdi
callq 0xb010
movq %rax, %rdi
movl $0x2, %esi
callq 0x1c3c0
movq %rax, -0x18(%rbp)
movl $0x28, %edi
callq 0x62e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x40(%rbp)
leaq 0x4fb3(%rip), %rsi      # 0x3623b
callq 0x1a4e0
jmp 0x3128f
movq -0x40(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x18670
movl $0x28, %edi
callq 0x62e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x50(%rbp)
leaq 0x4f5e(%rip), %rsi      # 0x3621d
callq 0x1a4e0
jmp 0x312c6
movq -0x50(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x18670
movl $0x28, %edi
callq 0x62e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x58(%rbp)
leaq 0x4e93(%rip), %rsi      # 0x36189
callq 0x1a4e0
jmp 0x312fd
movq -0x58(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x68(%rbp)
movl $0x10, %edi
callq 0x62e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x60(%rbp)
leaq 0x49e4(%rip), %rsi      # 0x35d0c
callq 0x1b1e0
jmp 0x3132f
movq -0x60(%rbp), %rsi
movq -0x68(%rbp), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
callq *%rax
movq -0x20(%rbp), %rax
movq %rax, -0x78(%rbp)
movl $0x10, %edi
callq 0x62e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x70(%rbp)
leaq 0x49a1(%rip), %rsi      # 0x35d04
callq 0x1b1e0
jmp 0x3136a
movq -0x70(%rbp), %rsi
movq -0x78(%rbp), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
callq *%rax
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x18670
movl $0x28, %edi
callq 0x62e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x80(%rbp)
leaq 0x4e9f(%rip), %rsi      # 0x36242
callq 0x1a4e0
jmp 0x313aa
movq -0x80(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x90(%rbp)
movl $0x10, %edi
callq 0x62e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x88(%rbp)
leaq 0x4929(%rip), %rsi      # 0x35d04
callq 0x1b1e0
jmp 0x313e2
movq -0x88(%rbp), %rsi
movq -0x90(%rbp), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
callq *%rax
movq -0x20(%rbp), %rax
movq %rax, -0xa8(%rbp)
movl $0x10, %edi
callq 0x62e0
movq %rax, -0xa0(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x8(%rax), %rax
movq 0x18(%rax), %rdi
xorl %esi, %esi
callq 0x1fe70
movl %eax, -0x94(%rbp)
jmp 0x31434
movl -0x94(%rbp), %esi
movq -0xa0(%rbp), %rdi
callq 0x1b0f0
jmp 0x31448
movq -0xa0(%rbp), %rsi
movq -0xa8(%rbp), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
callq *%rax
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x18670
movl $0x28, %edi
callq 0x62e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xb0(%rbp)
leaq 0x4cff(%rip), %rsi      # 0x36189
callq 0x1a4e0
jmp 0x31491
movq -0xb0(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xc0(%rbp)
movl $0x10, %edi
callq 0x62e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xb8(%rbp)
leaq 0x4843(%rip), %rsi      # 0x35d08
callq 0x1b1e0
jmp 0x314cc
movq -0xb8(%rbp), %rsi
movq -0xc0(%rbp), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
callq *%rax
movq -0x20(%rbp), %rax
movq %rax, -0xd0(%rbp)
movl $0x10, %edi
callq 0x62e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xc8(%rbp)
leaq 0x47f8(%rip), %rsi      # 0x35d04
callq 0x1b1e0
jmp 0x31513
movq -0xc8(%rbp), %rsi
movq -0xd0(%rbp), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
callq *%rax
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x18670
movq -0x48(%rbp), %rsi
movl $0x1, 0x38(%rsi)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
movq (%rdi), %rax
movq (%rax), %rax
callq *%rax
movl $0x28, %edi
callq 0x62e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xd8(%rbp)
leaq 0x4c19(%rip), %rsi      # 0x36189
callq 0x1a4e0
jmp 0x31577
movq -0xd8(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xe8(%rbp)
movl $0x10, %edi
callq 0x62e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xe0(%rbp)
leaq 0x4759(%rip), %rsi      # 0x35d04
callq 0x1b1e0
jmp 0x315b2
movq -0xe0(%rbp), %rsi
movq -0xe8(%rbp), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
callq *%rax
movq -0x20(%rbp), %rax
movq %rax, -0x100(%rbp)
movl $0x10, %edi
callq 0x62e0
movq %rax, %rcx
movq -0x48(%rbp), %rax
movq %rcx, -0xf8(%rbp)
movq 0x20(%rax), %rdi
callq 0x21350
movq %rax, -0xf0(%rbp)
jmp 0x315fe
movq -0xf0(%rbp), %rsi
movq -0xf8(%rbp), %rdi
callq 0x1b1e0
jmp 0x31613
movq -0xf8(%rbp), %rsi
movq -0x100(%rbp), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
callq *%rax
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x18670
movl $0x28, %edi
callq 0x62e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x108(%rbp)
leaq 0x4b34(%rip), %rsi      # 0x36189
callq 0x1a4e0
jmp 0x3165c
movq -0x108(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x118(%rbp)
movl $0x10, %edi
callq 0x62e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x110(%rbp)
leaq 0x46aa(%rip), %rsi      # 0x35d3a
callq 0x1b1e0
jmp 0x31697
movq -0x110(%rbp), %rsi
movq -0x118(%rbp), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
callq *%rax
movl $0x20, %edi
callq 0x62e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x120(%rbp)
callq 0x1b360
jmp 0x316cc
movq -0x120(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x130(%rbp)
movl $0x10, %edi
callq 0x62e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x128(%rbp)
leaq 0x460c(%rip), %rsi      # 0x35d0c
callq 0x1b1e0
jmp 0x31707
movq -0x128(%rbp), %rsi
movq -0x130(%rbp), %rdi
callq 0x1b420
movq -0x38(%rbp), %rax
movq %rax, -0x140(%rbp)
movl $0x10, %edi
callq 0x62e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x138(%rbp)
movl $0x8, %esi
callq 0x1b0f0
jmp 0x31748
movq -0x138(%rbp), %rdx
movq -0x140(%rbp), %rdi
xorl %esi, %esi
callq 0x1b3a0
movq -0x20(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq (%rdi), %rax
movq 0x20(%rax), %rax
callq *%rax
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x18670
movl $0x28, %edi
callq 0x62e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x148(%rbp)
leaq 0x49f0(%rip), %rsi      # 0x36189
callq 0x1a4e0
jmp 0x317a0
movq -0x148(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x158(%rbp)
movl $0x10, %edi
callq 0x62e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x150(%rbp)
leaq 0x473b(%rip), %rsi      # 0x35f0f
callq 0x1b1e0
jmp 0x317db
movq -0x150(%rbp), %rsi
movq -0x158(%rbp), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
callq *%rax
movl $0x20, %edi
callq 0x62e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x160(%rbp)
callq 0x1b360
jmp 0x31810
movq -0x160(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq %rax, -0x170(%rbp)
movl $0x10, %edi
callq 0x62e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x168(%rbp)
leaq 0x44c8(%rip), %rsi      # 0x35d0c
callq 0x1b1e0
jmp 0x3184b
movq -0x168(%rbp), %rsi
movq -0x170(%rbp), %rdi
callq 0x1b420
movq -0x38(%rbp), %rax
movq %rax, -0x180(%rbp)
movl $0x10, %edi
callq 0x62e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x178(%rbp)
movl $0x10, %esi
callq 0x1b0f0
jmp 0x3188c
movq -0x178(%rbp), %rdx
movq -0x180(%rbp), %rdi
xorl %esi, %esi
callq 0x1b3a0
movq -0x20(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq (%rdi), %rax
movq 0x20(%rax), %rax
callq *%rax
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x18670
movl $0x28, %edi
callq 0x62e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x188(%rbp)
leaq 0x4979(%rip), %rsi      # 0x36256
callq 0x1a4e0
jmp 0x318e4
movq -0x188(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x198(%rbp)
movl $0x10, %edi
callq 0x62e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x190(%rbp)
leaq 0x43f0(%rip), %rsi      # 0x35d08
callq 0x1b1e0
jmp 0x3191f
movq -0x190(%rbp), %rsi
movq -0x198(%rbp), %rdi
movq (%rdi), %rax
movq 0x20(%rax), %rax
callq *%rax
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x18670
movl $0x28, %edi
callq 0x62e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x1a0(%rbp)
leaq 0x4900(%rip), %rsi      # 0x36261
callq 0x1a4e0
jmp 0x31968
movq -0x1a0(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x18670
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
movq -0x40(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x28, %esi
callq 0x62f0
jmp 0x31cfc
movq -0x50(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x28, %esi
callq 0x62f0
jmp 0x31cfc
movq -0x58(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x28, %esi
callq 0x62f0
jmp 0x31cfc
movq -0x60(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x10, %esi
callq 0x62f0
jmp 0x31cfc
movq -0x70(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x10, %esi
callq 0x62f0
jmp 0x31cfc
movq -0x80(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x28, %esi
callq 0x62f0
jmp 0x31cfc
movq -0x88(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x10, %esi
callq 0x62f0
jmp 0x31cfc
movq -0xa0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x10, %esi
callq 0x62f0
jmp 0x31cfc
movq -0xb0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x28, %esi
callq 0x62f0
jmp 0x31cfc
movq -0xb8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x10, %esi
callq 0x62f0
jmp 0x31cfc
movq -0xc8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x10, %esi
callq 0x62f0
jmp 0x31cfc
movq -0xd8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x28, %esi
callq 0x62f0
jmp 0x31cfc
movq -0xe0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x10, %esi
callq 0x62f0
jmp 0x31cfc
movq -0xf8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x10, %esi
callq 0x62f0
jmp 0x31cfc
movq -0x108(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x28, %esi
callq 0x62f0
jmp 0x31cfc
movq -0x110(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x10, %esi
callq 0x62f0
jmp 0x31cfc
movq -0x120(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x20, %esi
callq 0x62f0
jmp 0x31cfc
movq -0x128(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x10, %esi
callq 0x62f0
jmp 0x31cfc
movq -0x138(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x10, %esi
callq 0x62f0
jmp 0x31cfc
movq -0x148(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x28, %esi
callq 0x62f0
jmp 0x31cfc
movq -0x150(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x10, %esi
callq 0x62f0
jmp 0x31cfc
movq -0x160(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x20, %esi
callq 0x62f0
jmp 0x31cfc
movq -0x168(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x10, %esi
callq 0x62f0
jmp 0x31cfc
movq -0x178(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x10, %esi
callq 0x62f0
jmp 0x31cfc
movq -0x188(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x28, %esi
callq 0x62f0
jmp 0x31cfc
movq -0x190(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x10, %esi
callq 0x62f0
jmp 0x31cfc
movq -0x1a0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
movl $0x28, %esi
callq 0x62f0
movq -0x28(%rbp), %rdi
callq 0x64f0
nopw %cs:(%rax,%rax)
nop