// File: /workspace/github_cpp_makefile_star2_O1/kiudee[P]VAHD-Projekt/Supervisor.cpp
// Function: Supervisor::Wakeup(NumObj*)
Action Supervisor::Wakeup(NumObj *numo)
{
    if (numo->num > 0) {
        if (numo->num % 8 == 0) {
            printGraph(false);
            printcount++;
        }

        /////////////////////////////////////////////////////
        //////// BEGIN TESTCASE INSERT LEAVE LOOKUP /////////
        //Description: Insert, remove the responsible node, and fire a lookup
        if (false) { //activate testcase
            if (numo->num == 6000) {
                DateObj *dob = new DateObj(89, "me lov subjectz. lolz.");
                Nodes[0]->out->call(Node::Insert, dob);
                //0, 0
            }

            if (numo->num == 2000) {
                //Nodes[54]->out->call(Node::Leave, NONE);
                Nodes[88]->out->call(Node::Leave, NONE);
                //subjects[h(89)]->call(Node::Leave, NONE);
            }

            if (numo->num == 1000) {
                NumObj *numo2 = new NumObj(89);
                Nodes[4]->out->call(Node::LookUp, numo2);
            }
        }

        //////////////////////////////////////////////////
        //////// END TESTCASE INSERT LEAVE LOOKUP ////////
        //////////////////////////////////////////////////


        /////////////////////////////////////////////////////
        //////// BEGIN TESTCASE INSERT JOIN LOOKUP /////////
        //Description: Insert, join a new responsible node, and fire a lookup

        if (true) {
            if (numo->num == 3000) {
                DateObj *dob = new DateObj(666, "some more data.");
                Nodes[4]->out->call(Node::Insert, dob);
                std::shared_ptr<std::ofstream> tmpfile(csvFile);
                InitObj *tempObj = new InitObj(h(666), true, tmpfile);
                new(Node, tempObj);
            }

            if (numo->num == 2000) {

                Nodes[0]->out->call(Node::Join, StartID[total]);
            }

            if (numo->num == 1000) {
                NumObj *numo2 = new NumObj(666);
                Nodes[4]->out->call(Node::LookUp, numo2);
            }
        }


        //////////////////////////////////////////////////
        //////// END TESTCASE INSERT JOIN LOOKUP /////////
        //////////////////////////////////////////////////


        /////////////////////////////////////////////////////
        //////// BEGIN TESTCASE INSERT LOOKUP DELETE /////////
        //Test Insert / Lookup / Delete
        if (false) {
            if (numo->num == 5000) {
                DateObj *dob = new DateObj(14, "me lov subjectz. lolz.");
                Nodes[7]->out->call(Node::Insert, dob);
            }
            if (numo->num == 4000) {
                NumObj *numo2 = new NumObj(14);
                Nodes[5]->out->call(Node::LookUp, numo2);

            }
            if (numo->num == 2000) {
                NumObj *numo3 = new NumObj(14);
                Nodes[0]->out->call(Node::Delete, numo3);
            }
        }

        //////////////////////////////////////////////////
        //////// END TESTCASE INSERT LOOKUP DELETE /////////
        //////////////////////////////////////////////////

        //////////////////////////////////////////////
        /// BEGIN TESTCASE CONTINUOUS LOOKUPS ////////
        // Description: Insert a few data elements and then
        // periodically ask random nodes to Lookup one of
        // these items.
        // Used for csv-file data gathering.
        // Simulationrounds: 15000

        if (false) {
            if (numo->num == 12000) {
                std::uniform_int_distribution<int> distribution(0, total - 1);
                std::mt19937 engine(numo->num);
                auto generator = std::bind(distribution, engine);
                for (int i = 0; i < 10; i++) {
                    DateObj *dob = new DateObj(i, "JustOneTestElement");
                    Nodes[generator()]->out->call(Node::Insert, dob);
                }
            }
            if (numo->num < 12000 && numo->num % 20 == 0) {
                std::uniform_int_distribution<int> nodedist(0, total - 1);
                std::uniform_int_distribution<int> datedist(0, 9);
                std::mt19937 engine(numo->num);
                auto randNode = std::bind(nodedist, engine);
                auto randDate = std::bind(datedist, engine);
                auto numo = new NumObj(randDate());
                Nodes[randNode()]->out->call(Node::LookUp, numo);
            }
        }


        /////////////////////////////////////////////
        /// END TESTCASE CONTINUOUS LOOKUPS  ////////
        ////////////////////////////////////////////


        /////////////////////////////////////////////////////////
        /// BEGIN TESTCASE RETURN SORTED LIST WITH n=100 ////////
        // Description: Routes from left to right. Node 88 is the
        //smallest real node.
        // Simulationrounds: 15000
        if (false) {
            if (numo->num == 1000) {
                NumObj *numo2 = new NumObj(1);
                Nodes[88]->out->call(Node::_DebugRouteFromLeftToRight, numo2);//n=100
                //Nodes[4]->out->call(Node::_DebugRouteFromLeftToRight, numo2);//n=10
            }
        }

        ///////////////////////////////////////////////////////
        /// END TESTCASE RETURN SORTED LIST WITH n=100 ////////
        ///////////////////////////////////////////////////////

        numo->num--;
        call(Supervisor::Wakeup, numo);
    } else {
        delete numo;
        printGraph(true);
    }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x40, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movl 0x20(%rsi), %eax
testl %eax, %eax
jle 0x3c4c
testb $0x7, %al
jne 0x3b68
movq %rbx, %rdi
xorl %esi, %esi
callq 0x44e6
incl 0xf8(%rbx)
cmpl $0xbb8, 0x20(%r14)      # imm = 0xBB8
jne 0x3d29
movl $0x48, %edi
callq 0x3160
movq %rax, %r15
leaq 0x30(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x967e(%rip), %rsi      # 0xd212
leaq 0x9686(%rip), %rdx      # 0xd221
leaq 0x20(%rsp), %rdi
callq 0x6328
leaq 0x20(%rsp), %rdx
movq %r15, %rdi
movl $0x29a, %esi            # imm = 0x29A
callq 0x4faa
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x3bce
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3170
movq 0x68(%rbx), %rax
movq 0x20(%rax), %rax
movq 0x28(%rax), %r12
movl $0x38, %edi
callq 0x3160
leaq 0xe5bd(%rip), %rcx      # 0x121a8
movq (%rcx), %rdx
movq %rdx, (%rax)
incq %rdx
movq %rdx, (%rcx)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
leaq 0x59e1(%rip), %rcx      # 0x95e6
movq %rcx, 0x18(%rax)
xorl %ecx, %ecx
movq %rcx, 0x20(%rax)
movq %r15, 0x28(%rax)
movq %rcx, 0x30(%rax)
movq (%r12), %rcx
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq *0x8(%rcx)
movq 0x98(%rbx), %r13
movq 0xa0(%rbx), %r15
testq %r15, %r15
je 0x3c7d
movq 0xe387(%rip), %rax      # 0x11fc8
cmpb $0x0, (%rax)
je 0x3c78
incl 0x8(%r15)
jmp 0x3c7d
testq %r14, %r14
je 0x3c5e
movl $0x28, %esi
movq %r14, %rdi
callq 0x3170
movq %rbx, %rdi
movl $0x1, %esi
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x44e6
lock
incl 0x8(%r15)
movl $0x40, %edi
callq 0x3160
movq %rax, %r12
movl $0x29a, %edi            # imm = 0x29A
callq 0x71bc
movq %r13, 0x8(%rsp)
movq %r15, 0x10(%rsp)
testq %r15, %r15
je 0x3cba
movq 0xe31e(%rip), %rax      # 0x11fc8
cmpb $0x0, (%rax)
je 0x3cb5
incl 0x8(%r15)
jmp 0x3cba
lock
incl 0x8(%r15)
leaq 0x8(%rsp), %rdx
movq %r12, %rdi
movl $0x1, %esi
callq 0x4c46
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3cdb
callq 0x503a
movq %r12, 0x18(%rsp)
movl $0xe8, %edi
callq 0x3160
movq %rax, %r12
leaq 0x18(%rsp), %rsi
movq %rax, %rdi
callq 0x4ca0
leaq 0xe49f(%rip), %rax      # 0x121a0
movq %rbx, (%rax)
movl $0x60, %edi
callq 0x3160
movq %rax, %r13
movq %rax, %rdi
movq %r12, %rsi
callq 0x60d2
testq %r15, %r15
je 0x3d29
movq %r15, %rdi
callq 0x503a
cmpl $0x7d0, 0x20(%r14)      # imm = 0x7D0
jne 0x3d9d
movq 0x68(%rbx), %rax
movq (%rax), %rax
movq 0x28(%rax), %r15
movl $0x38, %edi
callq 0x3160
movslq 0x64(%rbx), %rcx
movq 0x80(%rbx), %rdx
leaq 0xe44e(%rip), %rsi      # 0x121a8
movq (%rsi), %rdi
movq %rdi, (%rax)
incq %rdi
movq %rdi, (%rsi)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
leaq 0x72f6(%rip), %rsi      # 0xb06a
movq %rsi, 0x18(%rax)
xorl %esi, %esi
movq %rsi, 0x20(%rax)
movq (%rdx,%rcx,8), %rdi
movq %rdi, 0x28(%rax)
movq %rsi, 0x30(%rax)
movq %rsi, (%rdx,%rcx,8)
movq (%r15), %rcx
movq %r15, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq *0x8(%rcx)
cmpl $0x3e8, 0x20(%r14)      # imm = 0x3E8
jne 0x3e55
movl $0x28, %edi
callq 0x3160
movq %rax, %r15
leaq 0xe3c9(%rip), %rax      # 0x12188
movq (%rax), %rcx
movq %rcx, (%r15)
incq %rcx
movq %rcx, (%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%r15)
movq $0x0, 0x18(%r15)
leaq 0xe3be(%rip), %rax      # 0x121a0
movq (%rax), %rax
testq %rax, %rax
je 0x3df4
movq %r15, %rcx
addq $0x8, %rcx
movq %rax, (%rcx)
movl $0x29a, 0x20(%r15)      # imm = 0x29A
movq 0x68(%rbx), %rax
movq 0x20(%rax), %rax
movq 0x28(%rax), %r12
movl $0x38, %edi
callq 0x3160
leaq 0xe38f(%rip), %rcx      # 0x121a8
movq (%rcx), %rdx
movq %rdx, (%rax)
incq %rdx
movq %rdx, (%rcx)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
leaq 0x6fb9(%rip), %rcx      # 0xadec
movq %rcx, 0x18(%rax)
xorl %ecx, %ecx
movq %rcx, 0x20(%rax)
movq %r15, 0x28(%rax)
movq %rcx, 0x30(%rax)
movq (%r12), %rcx
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq *0x8(%rcx)
decl 0x20(%r14)
movl $0x38, %edi
callq 0x3160
leaq 0xe33e(%rip), %rcx      # 0x121a8
movq (%rcx), %rdx
movq %rdx, (%rax)
incq %rdx
movq %rdx, (%rcx)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
leaq -0x34e(%rip), %rcx      # 0x3b36
movq %rcx, 0x18(%rax)
xorl %ecx, %ecx
movq %rcx, 0x20(%rax)
movq %r14, 0x28(%rax)
movq %rcx, 0x30(%rax)
movq (%rbx), %rcx
movq %rbx, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq *0x48(%rcx)
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq
movq %rax, %rbx
movl $0x60, %esi
movq %r13, %rdi
jmp 0x3ee9
movq %rax, %rbx
movl $0xe8, %esi
jmp 0x3ee6
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x3ee1
callq 0x503a
jmp 0x3ee1
movq %rax, %rbx
movl $0x40, %esi
movq %r12, %rdi
callq 0x3170
jmp 0x3f21
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x3f0f
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x3170
jmp 0x3f0f
movq %rax, %rbx
movl $0x48, %esi
movq %r15, %rdi
callq 0x3170
jmp 0x3f2e
movq %rax, %rbx
testq %r15, %r15
je 0x3f2e
movq %r15, %rdi
callq 0x503a
movq %rbx, %rdi
callq 0x3280