// File: /workspace/github_cpp_makefile_star2_O1/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 %r12
pushq %rbx
subq $0x60, %rsp
movl $0x30, %edi
callq 0x2100
movq %rax, %rbx
leaq -0x70(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0xd09(%rip), %rsi       # 0x3020
leaq 0xd0f(%rip), %rdx       # 0x302d
leaq -0x80(%rbp), %rdi
callq 0x2840
leaq -0x80(%rbp), %rsi
movq %rbx, %rdi
callq 0x2598
movq -0x80(%rbp), %rdi
cmpq %r14, %rdi
je 0x2341
callq 0x20e0
movl $0x30, %edi
callq 0x2100
movq %rax, %r14
leaq -0x50(%rbp), %r12
movq %r12, -0x10(%r12)
leaq 0xcd0(%rip), %rsi       # 0x302e
leaq 0xcd4(%rip), %rdx       # 0x3039
leaq -0x60(%rbp), %rdi
callq 0x2840
leaq -0x60(%rbp), %rsi
movq %r14, %rdi
callq 0x2598
movq -0x60(%rbp), %rdi
cmpq %r12, %rdi
je 0x2388
callq 0x20e0
leaq -0x40(%rbp), %rdi
movq %rbx, %rsi
movl $0x3, %edx
callq 0x264a
leaq -0x30(%rbp), %rdi
movq %r14, %rsi
movl $0x5, %edx
callq 0x264a
movq %rbx, %rdi
callq 0x2794
movq %rbx, %rdi
callq 0x20e0
movq %r14, %rdi
callq 0x2794
movq %r14, %rdi
callq 0x20e0
cmpq $0x0, -0x40(%rbp)
je 0x24ba
movq 0x2bf4(%rip), %rdi      # 0x4fd0
leaq 0xc79(%rip), %rsi       # 0x305c
movl $0xf, %edx
callq 0x2110
movq -0x40(%rbp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
movq 0x2bd2(%rip), %rdi      # 0x4fd0
callq 0x2160
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x20f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2070
xorps %xmm0, %xmm0
movq -0x38(%rbp), %rdi
movups %xmm0, -0x40(%rbp)
testq %rdi, %rdi
je 0x2442
callq 0x27c6
cmpq $0x0, -0x30(%rbp)
je 0x24ba
movq 0x2b80(%rip), %rdi      # 0x4fd0
leaq 0xc15(%rip), %rsi       # 0x306c
movl $0xd, %edx
callq 0x2110
movq -0x30(%rbp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
movq 0x2b5e(%rip), %rdi      # 0x4fd0
callq 0x2160
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x20f0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2070
xorps %xmm0, %xmm0
movq -0x28(%rbp), %rdi
movups %xmm0, -0x30(%rbp)
xorl %ebx, %ebx
testq %rdi, %rdi
je 0x2505
callq 0x27c6
jmp 0x2505
movq 0x2b2f(%rip), %rbx      # 0x4ff0
leaq 0xb72(%rip), %rsi       # 0x303a
movl $0x21, %edx
movq %rbx, %rdi
callq 0x2110
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x20f0
movsbl %al, %esi
movq 0x2afd(%rip), %rdi      # 0x4ff0
callq 0x2030
movl $0x1, %ebx
movq %rax, %rdi
callq 0x2070
movq -0x28(%rbp), %rdi
testq %rdi, %rdi
je 0x2513
callq 0x27c6
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
je 0x2521
callq 0x27c6
movl %ebx, %eax
addq $0x60, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r15
jmp 0x2581
movq %rax, %r15
movq -0x60(%rbp), %rdi
cmpq %r12, %rdi
je 0x254b
callq 0x20e0
jmp 0x254b
movq %rax, %r15
movq %r14, %rdi
jmp 0x2569
movq %rax, %r15
movq -0x80(%rbp), %rdi
cmpq %r14, %rdi
je 0x2566
callq 0x20e0
jmp 0x2566
movq %rax, %r15
movq %rbx, %rdi
callq 0x20e0
jmp 0x258f
movq %rax, %r15
movq -0x28(%rbp), %rdi
testq %rdi, %rdi
je 0x2581
callq 0x27c6
movq -0x38(%rbp), %rdi
testq %rdi, %rdi
je 0x258f
callq 0x27c6
movq %r15, %rdi
callq 0x2190
nop