// File: /workspace/github_cpp_makefile_star2_O3/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 0x10346
movq %rax, %rbx
movl $0x28, %edi
callq 0x5290
movq %rax, %r12
leaq 0x3eee(%rip), %rsi      # 0x1b47e
movq %rax, %rdi
callq 0xfc44
movq %rbx, %rdi
movq %r12, %rsi
callq 0xf294
movl $0x10, %edi
callq 0x5290
movq %rax, %r12
movq 0x40(%r15), %rax
movq (%rax), %rsi
movq %r12, %rdi
callq 0xf844
movq %rbx, %rdi
movq %r12, %rsi
callq 0xf294
movl $0x28, %edi
callq 0x5290
movq %rax, %r12
leaq 0x3e06(%rip), %rsi      # 0x1b3e4
movq %rax, %rdi
callq 0xfc44
movl $0x20, %edi
callq 0x5290
movq %rax, %r13
movq %rax, %rdi
callq 0xff08
movl $0x10, %edi
callq 0x5290
movq %rax, %rbp
leaq 0x396b(%rip), %rsi      # 0x1af7a
movq %rax, %rdi
callq 0xfe82
movq %r13, %rdi
movq %rbp, %rsi
callq 0xff60
movl $0x10, %edi
callq 0x5290
movq %rax, %rbp
movq 0x58(%r15), %rax
movq 0x8(%rax), %rax
movl 0x30(%rax), %esi
movq %rbp, %rdi
callq 0xfe48
movq %r13, %rdi
movl $0x1, %esi
movq %rbp, %rdx
callq 0xff22
movq (%r12), %rax
movq %r12, %rdi
movq %r13, %rsi
callq *0x20(%rax)
movl $0x10, %edi
callq 0x5290
movq %rax, %r13
leaq 0x38d1(%rip), %rsi      # 0x1af44
movq %rax, %rdi
callq 0xfe82
movq (%r12), %rax
movq %r12, %rdi
movq %r13, %rsi
callq *0x20(%rax)
movq %rbx, %rdi
movq %r12, %rsi
callq 0xf294
movq 0x28(%r15), %r12
cmpq 0x30(%r15), %r12
je 0x176af
movq (%r12), %rdi
movq (%rdi), %rax
movq %r14, %rsi
callq *(%rax)
addq $0x8, %r12
jmp 0x17697
movl $0x28, %edi
callq 0x5290
movq %rax, %r14
leaq 0x3dc8(%rip), %rsi      # 0x1b48b
movq %rax, %rdi
callq 0xfc44
movq %rbx, %rdi
movq %r14, %rsi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xf294
movq %rax, %rbx
movl $0x28, %esi
movq %r14, %rdi
jmp 0x1772e
movq %rax, %rbx
movl $0x10, %esi
jmp 0x17712
jmp 0x176fd
movq %rax, %rbx
movl $0x10, %esi
movq %rbp, %rdi
jmp 0x1772e
movq %rax, %rbx
movl $0x20, %esi
movq %r13, %rdi
jmp 0x1772e
jmp 0x17723
movq %rax, %rbx
movl $0x10, %esi
jmp 0x1772b
movq %rax, %rbx
movl $0x28, %esi
movq %r12, %rdi
callq 0x52a0
movq %rbx, %rdi
callq 0x5470
nop