// File: /workspace/github_cpp_makefile_star2_O2/Davidc2525[P]Leaf/compiler/backend/x86_64_linux/generator.cpp
// Function: x86_64_linux_generator_visitor::visit(LEAF::AST::CatchStatementNode*)
void x86_64_linux_generator_visitor::visit(CatchStatementNode *_catch_)
{

    UPDATE_STATICS
    Section *st = assembly->get_program()->section(Sections::text);
    DInstruccion *i = new DInstruccion(";start catch");
    st->add(i);

    Label *try_label = new Label((char *)_catch_->start_label->c_str());
    st->add(try_label);

    i = new DInstruccion("mov");
    MemoryOperand *var_ex = new MemoryOperand();
    var_ex->add_operand(new RegisterOperand("rbp"));
    var_ex->add_operand(load_mod::sub, new InmediateIntOperand(_catch_->ex_var->obj->adr));
    i->add_operand(var_ex);
    i->add_operand(new RegisterOperand("rax"));
    st->add(i);

    vector<ASTU>::iterator x = _catch_->nodos.begin();
    for (; x != _catch_->nodos.end(); x++)
    {
        (*x)->accept(this);
    }

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
incl 0x8(%rdi)
movq %rsi, %r15
movq 0x10(%rdi), %rax
movq (%rax), %rdi
pushq $0x2
popq %rsi
callq 0xe61c
movq %rax, %rbx
pushq $0x28
popq %rdi
callq 0x5260
movq %rax, %r12
leaq 0x38bc(%rip), %rsi      # 0x1849e
movq %rax, %rdi
callq 0xdf60
movq %rbx, %rdi
movq %r12, %rsi
callq 0xd750
pushq $0x10
popq %rdi
callq 0x5260
movq %rax, %r12
movq 0x40(%r15), %rax
movq (%rax), %rsi
movq %r12, %rdi
callq 0xdc40
movq %rbx, %rdi
movq %r12, %rsi
callq 0xd750
pushq $0x28
popq %rdi
callq 0x5260
movq %rax, %r12
leaq 0x37d8(%rip), %rsi      # 0x18404
movq %rax, %rdi
callq 0xdf60
pushq $0x20
popq %rdi
callq 0x5260
movq %rax, %r13
movq %rax, %rdi
callq 0xe234
pushq $0x10
popq %rdi
callq 0x5260
movq %rax, %rbp
leaq 0x3341(%rip), %rsi      # 0x17f9a
movq %rax, %rdi
callq 0xe1b2
movq %r13, %rdi
movq %rbp, %rsi
callq 0xe288
pushq $0x10
popq %rdi
callq 0x5260
movq %rax, %rbp
movq 0x58(%r15), %rax
movq 0x8(%rax), %rax
movl 0x30(%rax), %esi
movq %rbp, %rdi
callq 0xe17c
pushq $0x1
popq %rsi
movq %r13, %rdi
movq %rbp, %rdx
callq 0xe24c
movq (%r12), %rax
movq %r12, %rdi
movq %r13, %rsi
callq *0x20(%rax)
pushq $0x10
popq %rdi
callq 0x5260
movq %rax, %r13
leaq 0x32ad(%rip), %rsi      # 0x17f64
movq %rax, %rdi
callq 0xe1b2
movq (%r12), %rax
movq %r12, %rdi
movq %r13, %rsi
callq *0x20(%rax)
movq %rbx, %rdi
movq %r12, %rsi
callq 0xd750
movq 0x28(%r15), %r12
cmpq 0x30(%r15), %r12
je 0x14cf3
movq (%r12), %rdi
movq (%rdi), %rax
movq %r14, %rsi
callq *(%rax)
addq $0x8, %r12
jmp 0x14cdb
pushq $0x28
popq %rdi
callq 0x5260
movq %rax, %r14
leaq 0x37a6(%rip), %rsi      # 0x184ab
movq %rax, %rdi
callq 0xdf60
movq %rbx, %rdi
movq %r14, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xd750
movq %rax, %rbx
pushq $0x28
popq %rsi
movq %r14, %rdi
jmp 0x14d62
movq %rax, %rbx
pushq $0x10
jmp 0x14d4a
jmp 0x14d3a
movq %rax, %rbx
pushq $0x10
popq %rsi
movq %rbp, %rdi
jmp 0x14d62
movq %rax, %rbx
pushq $0x20
popq %rsi
movq %r13, %rdi
jmp 0x14d62
jmp 0x14d59
movq %rax, %rbx
pushq $0x10
jmp 0x14d5e
movq %rax, %rbx
pushq $0x28
popq %rsi
movq %r12, %rdi
callq 0x5270
movq %rbx, %rdi
callq 0x5420
nop