// File: /workspace/github_cpp_makefile_star2_O1/Davidc2525[P]Leaf/compiler/backend/x86_64_linux/generator.cpp
// Function: x86_64_linux_generator_visitor::init(LEAF::AST::NODEU*)
void x86_64_linux_generator_visitor::init(ASTU start)
{
    cout << "x86_64 linux visitor" << endl;
    if (start == nullptr)
        return;
    assembly->get_program()->section(Sections::global)->add(new DInstruccion("global main"));
    assembly->get_program()->section(Sections::_extern)->add(new DInstruccion("extern printf"));
    assembly->get_program()->section(Sections::_extern)->add(new DInstruccion("extern puts"));

    reg = rp->reserve();
    start->accept(this);

    //3 espacio para firmar el archivo
    *out_file << endl;
    *out_file << endl;
    *out_file << endl;

    *out_file << "%include \"feactures/exceptions/linux64.asm\"" << endl;
    assembly->get_program()->write(*out_file);
    cout << "visits: " << visits_ins << endl;
}

// Assembly:
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r14
movq %rdi, %rbx
movq 0xffcd(%rip), %r15      # 0x25fd8
leaq 0x5301(%rip), %rsi      # 0x1b313
movl $0x14, %edx
movq %r15, %rdi
callq 0x5300
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x5260
movsbl %al, %esi
movq %r15, %rdi
callq 0x5050
movq %rax, %rdi
callq 0x51a0
testq %r14, %r14
je 0x16244
movq 0x10(%rbx), %rax
movq (%rax), %rdi
movl $0x4, %esi
callq 0x102f0
movq %rax, %r12
movl $0x28, %edi
callq 0x5290
movq %rax, %r15
leaq 0x51a7(%rip), %rsi      # 0x1b21e
movq %rax, %rdi
callq 0xfc18
movq %r12, %rdi
movq %r15, %rsi
callq 0xf258
movq 0x10(%rbx), %rax
movq (%rax), %rdi
movl $0x3, %esi
callq 0x102f0
movq %rax, %r12
movl $0x28, %edi
callq 0x5290
movq %rax, %r15
leaq 0x5178(%rip), %rsi      # 0x1b22a
movq %rax, %rdi
callq 0xfc18
movq %r12, %rdi
movq %r15, %rsi
callq 0xf258
movq 0x10(%rbx), %rax
movq (%rax), %rdi
movl $0x3, %esi
callq 0x102f0
movq %rax, %r12
movl $0x28, %edi
callq 0x5290
movq %rax, %r15
leaq 0x523b(%rip), %rsi      # 0x1b328
movq %rax, %rdi
callq 0xfc18
movq %r12, %rdi
movq %r15, %rsi
callq 0xf258
movq 0x30(%rbx), %rdi
movq (%rdi), %rax
callq *0x50(%rax)
movq %rax, 0x20(%rbx)
movq (%r14), %rax
movq %r14, %rdi
movq %rbx, %rsi
callq *(%rax)
movq 0x18(%rbx), %r14
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x5260
movsbl %al, %esi
movq %r14, %rdi
callq 0x5050
movq %rax, %rdi
callq 0x51a0
movq 0x18(%rbx), %r14
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x5260
movsbl %al, %esi
movq %r14, %rdi
callq 0x5050
movq %rax, %rdi
callq 0x51a0
movq 0x18(%rbx), %r14
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x5260
movsbl %al, %esi
movq %r14, %rdi
callq 0x5050
movq %rax, %rdi
callq 0x51a0
movq 0x18(%rbx), %r14
leaq 0x518f(%rip), %rsi      # 0x1b334
movl $0x2b, %edx
movq %r14, %rdi
callq 0x5300
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x5260
movsbl %al, %esi
movq %r14, %rdi
callq 0x5050
movq %rax, %rdi
callq 0x51a0
movq 0x10(%rbx), %rax
movq 0x18(%rbx), %rsi
movq (%rax), %rdi
callq 0x102aa
movq 0xfde8(%rip), %r14      # 0x25fd8
leaq 0x5169(%rip), %rsi      # 0x1b360
movl $0x8, %edx
movq %r14, %rdi
callq 0x5300
movl 0x8(%rbx), %esi
movq %r14, %rdi
callq 0x5460
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x5260
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5050
movq %rax, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x51a0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
jmp 0x16254
jmp 0x16254
movq %rax, %rbx
movl $0x28, %esi
movq %r15, %rdi
callq 0x52a0
movq %rbx, %rdi
callq 0x5470