// File: /workspace/github_cpp_makefile_star2_O1/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
movl $0x2, %esi
callq 0x102f0
movq %rax, %rbx
movl $0x28, %edi
callq 0x5290
movq %rax, %r12
leaq 0x3c84(%rip), %rsi      # 0x1b41e
movq %rax, %rdi
callq 0xfc18
movq %rbx, %rdi
movq %r12, %rsi
callq 0xf258
movl $0x10, %edi
callq 0x5290
movq %rax, %r12
movq 0x40(%r15), %rax
movq (%rax), %rsi
movq %r12, %rdi
callq 0xf81c
movq %rbx, %rdi
movq %r12, %rsi
callq 0xf258
movl $0x28, %edi
callq 0x5290
movq %rax, %r12
leaq 0x3b9c(%rip), %rsi      # 0x1b384
movq %rax, %rdi
callq 0xfc18
movl $0x20, %edi
callq 0x5290
movq %rax, %r13
movq %rax, %rdi
callq 0xfed4
movl $0x10, %edi
callq 0x5290
movq %rax, %rbp
leaq 0x3701(%rip), %rsi      # 0x1af1a
movq %rax, %rdi
callq 0xfe4e
movq %r13, %rdi
movq %rbp, %rsi
callq 0xff2c
movl $0x10, %edi
callq 0x5290
movq %rax, %rbp
movq 0x58(%r15), %rax
movq 0x8(%rax), %rax
movl 0x30(%rax), %esi
movq %rbp, %rdi
callq 0xfe14
movq %r13, %rdi
movl $0x1, %esi
movq %rbp, %rdx
callq 0xfeee
movq (%r12), %rax
movq %r12, %rdi
movq %r13, %rsi
callq *0x20(%rax)
movl $0x10, %edi
callq 0x5290
movq %rax, %r13
leaq 0x3667(%rip), %rsi      # 0x1aee4
movq %rax, %rdi
callq 0xfe4e
movq (%r12), %rax
movq %r12, %rdi
movq %r13, %rsi
callq *0x20(%rax)
movq %rbx, %rdi
movq %r12, %rsi
callq 0xf258
movq 0x28(%r15), %r12
cmpq 0x30(%r15), %r12
je 0x178b9
movq (%r12), %rdi
movq (%rdi), %rax
movq %r14, %rsi
callq *(%rax)
addq $0x8, %r12
jmp 0x178a1
movl $0x28, %edi
callq 0x5290
movq %rax, %r14
leaq 0x3b5e(%rip), %rsi      # 0x1b42b
movq %rax, %rdi
callq 0xfc18
movq %rbx, %rdi
movq %r14, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xf258
movq %rax, %rbx
movl $0x28, %esi
movq %r14, %rdi
jmp 0x17938
movq %rax, %rbx
movl $0x10, %esi
jmp 0x1791c
jmp 0x17907
movq %rax, %rbx
movl $0x10, %esi
movq %rbp, %rdi
jmp 0x17938
movq %rax, %rbx
movl $0x20, %esi
movq %r13, %rdi
jmp 0x17938
jmp 0x1792d
movq %rax, %rbx
movl $0x10, %esi
jmp 0x17935
movq %rax, %rbx
movl $0x28, %esi
movq %r12, %rdi
callq 0x52a0
movq %rbx, %rdi
callq 0x5470
nop