// File: /workspace/github_cpp_makefile_star2_O2/jandoerntlein[P]wire/src/main.cpp
// Function: main
int main( int argc, char** argv )
{
    std::cout << "--- Wire Test ---" << std::endl;

    Button B;
    Light  L1;
    Light  L2;

    B.toggle.connect( &Light::Toggle, &L1 );
    B.toggle.connect( &Light::Toggle, &L2 );
    B.changeColor.connect( &Light::setColor, &L1 );
    B.changeColor.connect( &Light::setColor, &L2 );
    B.range.connect( &Light::setRange, &L1 );
    B.toggle(); // toggles all connected lights
    B.changeColor( 17 );
    B.toggle();
    B.range( 17.f, 19.f );

    std::cout << "--- Disconnect Test ---" << std::endl;

    B.toggle.disconnect();
    B.toggle.connect( &Light::Toggle, &L2 );
    B.toggle();    

    std::cout << "--- DirectWire Test ---" << std::endl;

    Light  L3;
    Light  L4;
    enum { PORT0, PORT1 };

    B.direct_toggle.connect( PORT0, &Light::Toggle, &L3 );
    B.direct_toggle.connect( PORT1, &Light::Toggle, &L4 );
    B.direct_ChangeColor.connect( PORT0, &Light::setColor, &L3 );
    B.direct_ChangeColor.connect( PORT1, &Light::setColor, &L4 );
    B.direct_toggle( PORT0 ); // toggles only light connected to PORT0
    B.direct_toggle( PORT1 );
    B.direct_ChangeColor( PORT0, 1337 );
    B.direct_ChangeColor( PORT1, 42 );
    B.direct_toggle( PORT0 );
    B.direct_toggle( PORT1 );

    std::cout << "--- End Test ---" << std::endl;

    return 0;
}

// Assembly:
pushq %r14
pushq %rbx
subq $0xe8, %rsp
movq 0x6d2b(%rip), %rdi      # 0x8fd8
leaq 0x2d88(%rip), %rsi      # 0x503c
callq 0x20d0
movq %rax, %rdi
callq 0x2070
leaq 0xa8(%rsp), %rax
xorps %xmm0, %xmm0
movaps %xmm0, -0x48(%rax)
movaps %xmm0, -0x58(%rax)
movaps %xmm0, -0x68(%rax)
movaps %xmm0, -0x78(%rax)
andq $0x0, -0x38(%rax)
movq %rax, -0x30(%rax)
pushq $0x1
popq %rcx
movq %rcx, -0x28(%rax)
movups %xmm0, -0x20(%rax)
movl $0x3f800000, %edx       # imm = 0x3F800000
movl %edx, -0x10(%rax)
movaps %xmm0, -0x8(%rax)
leaq 0xe0(%rsp), %rax
movq %rax, -0x30(%rax)
movq %rcx, -0x28(%rax)
movaps %xmm0, -0x20(%rax)
movl %edx, -0x10(%rax)
movups %xmm0, -0x8(%rax)
leaq 0x18(%rsp), %rcx
andl $0x0, 0x4(%rcx)
xorl %eax, %eax
movb %al, 0x8(%rcx)
movl 0x6dad(%rip), %edx      # 0x90d8
leal 0x1(%rdx), %esi
movl %edx, (%rcx)
andl $0x0, 0x4(%rsp)
movb %al, 0x8(%rsp)
addl $0x2, %edx
movl %edx, 0x6d96(%rip)      # 0x90d8
movl %esi, (%rsp)
leaq 0x230(%rip), %rsi       # 0x257c
leaq 0x30(%rsp), %rdi
xorl %edx, %edx
callq 0x2bb0
leaq 0x21d(%rip), %rsi       # 0x257c
leaq 0x30(%rsp), %rdi
movq %rsp, %rcx
xorl %edx, %edx
callq 0x2bb0
leaq 0x48(%rsp), %rbx
leaq 0x286(%rip), %rsi       # 0x2600
leaq 0x18(%rsp), %rcx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x2fd0
leaq 0x270(%rip), %rsi       # 0x2600
movq %rsp, %rcx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x2fd0
leaq 0x60(%rsp), %r14
leaq 0x29f(%rip), %rsi       # 0x2648
leaq 0x18(%rsp), %rcx
movq %r14, %rdi
xorl %edx, %edx
callq 0x340a
leaq 0x30(%rsp), %rdi
callq 0x26d0
pushq $0x11
popq %rsi
movq %rbx, %rdi
callq 0x26f6
leaq 0x30(%rsp), %rdi
callq 0x26d0
movss 0x2c25(%rip), %xmm0     # 0x5004
movss 0x2c21(%rip), %xmm1     # 0x5008
movq %r14, %rdi
callq 0x2720
movq 0x6be2(%rip), %rdi      # 0x8fd8
leaq 0x2c51(%rip), %rsi      # 0x504e
callq 0x20d0
movq %rax, %rdi
callq 0x2070
leaq 0x30(%rsp), %rbx
movq %rbx, %rdi
callq 0x38ac
leaq 0x15e(%rip), %rsi       # 0x257c
movq %rsp, %rcx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x2bb0
leaq 0x30(%rsp), %rdi
callq 0x26d0
movq 0x6b9c(%rip), %rdi      # 0x8fd8
leaq 0x2c23(%rip), %rsi      # 0x5066
callq 0x20d0
movq %rax, %rdi
callq 0x2070
leaq 0x78(%rsp), %rbx
leaq 0x24(%rsp), %r8
andl $0x0, 0x4(%r8)
xorl %eax, %eax
movb %al, 0x8(%r8)
movl 0x6c6d(%rip), %ecx      # 0x90d8
leal 0x1(%rcx), %edx
movl %ecx, (%r8)
andl $0x0, 0x10(%rsp)
movb %al, 0x14(%rsp)
addl $0x2, %ecx
movl %ecx, 0x6c55(%rip)      # 0x90d8
movl %edx, 0xc(%rsp)
leaq 0xee(%rip), %rdx        # 0x257c
movq %rbx, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x275c
leaq 0xdb(%rip), %rdx        # 0x257c
pushq $0x1
popq %rsi
leaq 0xc(%rsp), %r8
movq %rbx, %rdi
xorl %ecx, %ecx
callq 0x275c
leaq 0xb0(%rsp), %r14
leaq 0x13e(%rip), %rdx       # 0x2600
leaq 0x24(%rsp), %r8
movq %r14, %rdi
xorl %esi, %esi
xorl %ecx, %ecx
callq 0x27a6
leaq 0x126(%rip), %rdx       # 0x2600
pushq $0x1
popq %rsi
leaq 0xc(%rsp), %r8
movq %r14, %rdi
xorl %ecx, %ecx
callq 0x27a6
movq %rbx, %rdi
xorl %esi, %esi
callq 0x27f0
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x27f0
movq %r14, %rdi
xorl %esi, %esi
movl $0x539, %edx            # imm = 0x539
callq 0x2828
pushq $0x1
popq %rsi
pushq $0x2a
popq %rdx
movq %r14, %rdi
callq 0x2828
movq %rbx, %rdi
xorl %esi, %esi
callq 0x27f0
pushq $0x1
popq %rsi
movq %rbx, %rdi
callq 0x27f0
movq 0x6a9e(%rip), %rdi      # 0x8fd8
leaq 0x2b3d(%rip), %rsi      # 0x507e
callq 0x20d0
movq %rax, %rdi
callq 0x2070
leaq 0x30(%rsp), %rdi
callq 0x2864
xorl %eax, %eax
addq $0xe8, %rsp
popq %rbx
popq %r14
retq
jmp 0x2567
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x2864
movq %rbx, %rdi
callq 0x2160