// File: /workspace/github_cpp_makefile_star2_O2/arturb-dev[P]CPP-Dynamic-Class-Loading/main.cpp
// Function: main
int main(void) {

    auto dlTriangle = new DLClass<Polygon>("./triangle.so");
    auto dlSquare = new DLClass<Polygon>("./square.so");
    
    int x = 5;
    std::shared_ptr<Polygon> triangle = dlTriangle->make_obj(3);
    std::shared_ptr<Polygon> square = dlSquare->make_obj(x);
    delete dlTriangle;
    delete dlSquare;
    
    if(!triangle) {
        std::cerr << "Failed to instantiate a triangle." << std::endl;
        return 1;
    }

    std::cout << "Triangle area: " << triangle->area() << std::endl;
    triangle = std::shared_ptr<Polygon>(NULL);
    
    if(!square) {
        std::cerr << "Failed to instantiate a triangle." << std::endl;
        return 1;
    }

    std::cout << "Square area: " << square->area() << std::endl;
    square = std::shared_ptr<Polygon>(NULL);

    
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x78, %rsp
pushq $0x30
popq %rdi
callq 0x2100
movq %rax, %rbx
leaq 0xd19(%rip), %rsi       # 0x3004
leaq -0x90(%rbp), %rdi
leaq -0x28(%rbp), %rdx
callq 0x2050
leaq -0x90(%rbp), %rsi
movq %rbx, %rdi
callq 0x24ca
leaq -0x90(%rbp), %rdi
callq 0x2070
pushq $0x30
popq %rdi
callq 0x2100
movq %rax, %r14
leaq 0xcea(%rip), %rsi       # 0x3012
leaq -0x70(%rbp), %rdi
leaq -0x28(%rbp), %rdx
callq 0x2050
leaq -0x70(%rbp), %rsi
movq %r14, %rdi
callq 0x24ca
leaq -0x70(%rbp), %rdi
callq 0x2070
leaq -0x28(%rbp), %rdi
pushq $0x3
popq %rdx
movq %rbx, %rsi
callq 0x252c
leaq -0x38(%rbp), %rdi
pushq $0x5
popq %rdx
movq %r14, %rsi
callq 0x252c
movq %rbx, %rdi
callq 0x261a
movq %rbx, %rdi
callq 0x20e0
movq %r14, %rdi
callq 0x261a
movq %r14, %rdi
callq 0x20e0
cmpq $0x0, -0x28(%rbp)
je 0x2436
movq 0x2c36(%rip), %rdi      # 0x4fd0
leaq 0xc9f(%rip), %rsi       # 0x3040
callq 0x20f0
movq %rax, %rbx
movq -0x28(%rbp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
movq %rbx, %rdi
callq 0x2160
movq %rax, %rdi
callq 0x2080
xorps %xmm0, %xmm0
leaq -0x50(%rbp), %rsi
movaps %xmm0, (%rsi)
leaq -0x28(%rbp), %rdi
callq 0x2d20
leaq -0x48(%rbp), %rdi
callq 0x263a
cmpq $0x0, -0x38(%rbp)
je 0x2436
movq 0x2be3(%rip), %rdi      # 0x4fd0
leaq 0xc5c(%rip), %rsi       # 0x3050
callq 0x20f0
movq %rax, %rbx
movq -0x38(%rbp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
movq %rbx, %rdi
callq 0x2160
movq %rax, %rdi
callq 0x2080
xorps %xmm0, %xmm0
leaq -0x50(%rbp), %rsi
movaps %xmm0, (%rsi)
leaq -0x38(%rbp), %rdi
callq 0x2d20
leaq -0x48(%rbp), %rdi
callq 0x263a
xorl %ebx, %ebx
jmp 0x2454
movq 0x2bb3(%rip), %rdi      # 0x4ff0
leaq 0xbda(%rip), %rsi       # 0x301e
callq 0x20f0
movq %rax, %rdi
callq 0x2080
pushq $0x1
popq %rbx
leaq -0x30(%rbp), %rdi
callq 0x263a
leaq -0x20(%rbp), %rdi
callq 0x263a
movl %ebx, %eax
addq $0x78, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r15
jmp 0x24b8
movq %rax, %r15
leaq -0x70(%rbp), %rdi
callq 0x2070
jmp 0x2489
movq %rax, %r15
movq %r14, %rdi
jmp 0x24a5
movq %rax, %r15
leaq -0x90(%rbp), %rdi
callq 0x2070
jmp 0x24a2
movq %rax, %r15
movq %rbx, %rdi
callq 0x20e0
jmp 0x24c1
movq %rax, %r15
leaq -0x30(%rbp), %rdi
callq 0x263a
leaq -0x20(%rbp), %rdi
callq 0x263a
movq %r15, %rdi
callq 0x2180
nop