// File: dcdolson[P]nsh-sf-devkit/examples/count/main.cpp
// Function: main
int main(int argc, char** argv)
{
    try
    {
        auto interface = nshdev::NetInterfaceFactory::CreateInterfaceFromArgs(argc, argv);
        if(interface == nullptr)
        {
            std::cerr << "Failed to create interface" << std::endl;
            return 2;
        }

        nshdev::Demux demux;
        interface->SetConsumer(&demux);

        PacketCounter packetCounter;
        demux.SetConsumer(&packetCounter);

        nshdev::Scheduler scheduler(*interface);

        scheduler.SchedulePackets();

	}
    catch(const std::exception& e)
    {
        std::cerr << "Caught exception (aborting)" << std::endl << e.what() << std::endl;
    }

    return 1;  // can only get here by exception
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x18(%rbp), %rdi
leaq -0x8(%rbp), %rsi
leaq -0x10(%rbp), %rdx
callq 0x44f0
jmp 0x36fc
leaq -0x18(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3920
testb $0x1, %al
jne 0x370f
jmp 0x376f
movq 0x98d2(%rip), %rdi      # 0xcfe8
leaq 0x48e7(%rip), %rsi      # 0x8004
callq 0x3250
movq %rax, -0x80(%rbp)
jmp 0x3728
movq -0x80(%rbp), %rdi
movq 0x9855(%rip), %rsi      # 0xcf88
callq 0x3280
jmp 0x373a
movl $0x2, -0x4(%rbp)
movl $0x1, -0x28(%rbp)
jmp 0x37f3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3844
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x383b
leaq -0x40(%rbp), %rdi
callq 0x6520
jmp 0x377a
leaq -0x18(%rbp), %rdi
callq 0x3950
movq %rax, %rdi
leaq -0x40(%rbp), %rsi
callq 0x3970
jmp 0x3791
leaq -0x60(%rbp), %rdi
callq 0x39d0
jmp 0x379c
leaq -0x40(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x3a30
jmp 0x37ab
leaq -0x18(%rbp), %rdi
callq 0x3a50
movq %rax, -0x88(%rbp)
jmp 0x37bd
movq -0x88(%rbp), %rsi
leaq -0x70(%rbp), %rdi
callq 0x6b00
jmp 0x37cf
leaq -0x70(%rbp), %rdi
callq 0x6b30
jmp 0x37da
leaq -0x60(%rbp), %rdi
callq 0x3a80
leaq -0x40(%rbp), %rdi
callq 0x3aa0
movl $0x0, -0x28(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x3ae0
movl -0x28(%rbp), %eax
testl %eax, %eax
je 0x380a
jmp 0x3805
jmp 0x38f6
jmp 0x38d8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x3832
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x3a80
leaq -0x40(%rbp), %rdi
callq 0x3aa0
leaq -0x18(%rbp), %rdi
callq 0x3ae0
movl -0x24(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x3902
movq -0x20(%rbp), %rdi
callq 0x3110
movq %rax, -0x78(%rbp)
movq 0x9780(%rip), %rdi      # 0xcfe8
leaq 0x47b0(%rip), %rsi      # 0x801f
callq 0x3250
movq %rax, -0x90(%rbp)
jmp 0x387d
movq -0x90(%rbp), %rdi
movq 0x96fd(%rip), %rsi      # 0xcf88
callq 0x3280
movq %rax, -0x98(%rbp)
jmp 0x3899
movq -0x78(%rbp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
movq -0x98(%rbp), %rdi
movq %rax, %rsi
callq 0x3250
movq %rax, -0xa0(%rbp)
jmp 0x38be
movq -0xa0(%rbp), %rdi
movq 0x96bc(%rip), %rsi      # 0xcf88
callq 0x3280
jmp 0x38d3
callq 0x3370
movl $0x1, -0x4(%rbp)
jmp 0x38f6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
callq 0x3370
jmp 0x38f4
jmp 0x3902
movl -0x4(%rbp), %eax
addq $0xa0, %rsp
popq %rbp
retq
movq -0x20(%rbp), %rdi
callq 0x33d0
movq %rax, %rdi
callq 0x3b50
nopw %cs:(%rax,%rax)
nopl (%rax)