// File: /workspace/github_cpp_makefile_star2_O3/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 0x2c3b
testb $0x7, %al
jne 0x2b5a
movq %rbx, %rdi
xorl %esi, %esi
callq 0x34d6
incl 0xf8(%rbx)
movl 0x20(%r14), %eax
cmpl $0xbb8, %eax            # imm = 0xBB8
jne 0x2d13
movl $0x48, %edi
callq 0x2160
movq %rax, %r15
leaq 0x30(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0x968f(%rip), %rsi      # 0xc212
leaq 0x9697(%rip), %rdx      # 0xc221
leaq 0x20(%rsp), %rdi
callq 0x5268
leaq 0x20(%rsp), %rdx
movq %r15, %rdi
movl $0x29a, %esi            # imm = 0x29A
callq 0x3f6a
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x2bbd
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2170
movq 0x68(%rbx), %rax
movq 0x20(%rax), %rax
movq 0x28(%rax), %r12
movl $0x38, %edi
callq 0x2160
leaq 0xe5ce(%rip), %rcx      # 0x111a8
movq (%rcx), %rdx
movq %rdx, (%rax)
incq %rdx
movq %rdx, (%rcx)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
leaq 0x5a3c(%rip), %rcx      # 0x8630
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 0x2c67
movq 0xe398(%rip), %rax      # 0x10fc8
cmpb $0x0, (%rax)
je 0x2c62
incl 0x8(%r15)
jmp 0x2c67
movl $0x28, %esi
movq %r14, %rdi
callq 0x2170
movq %rbx, %rdi
movl $0x1, %esi
addq $0x40, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
jmp 0x34d6
lock
incl 0x8(%r15)
movl $0x40, %edi
callq 0x2160
movq %rax, %r12
movl $0x29a, %edi            # imm = 0x29A
callq 0x60d4
movq %r13, 0x8(%rsp)
movq %r15, 0x10(%rsp)
testq %r15, %r15
je 0x2ca4
movq 0xe334(%rip), %rax      # 0x10fc8
cmpb $0x0, (%rax)
je 0x2c9f
incl 0x8(%r15)
jmp 0x2ca4
lock
incl 0x8(%r15)
leaq 0x8(%rsp), %rdx
movq %r12, %rdi
movl $0x1, %esi
callq 0x3c1e
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2cc5
callq 0x4002
movq %r12, 0x18(%rsp)
movl $0xe8, %edi
callq 0x2160
movq %rax, %r12
leaq 0x18(%rsp), %rsi
movq %rax, %rdi
callq 0x3c7a
leaq 0xe4b5(%rip), %rax      # 0x111a0
movq %rbx, (%rax)
movl $0x60, %edi
callq 0x2160
movq %rax, %r13
movq %rax, %rdi
movq %r12, %rsi
callq 0x500a
testq %r15, %r15
je 0x2d13
movq %r15, %rdi
callq 0x4002
movl 0x20(%r14), %eax
cmpl $0x7d0, %eax            # imm = 0x7D0
jne 0x2d8c
movq 0x68(%rbx), %rax
movq (%rax), %rax
movq 0x28(%rax), %r15
movl $0x38, %edi
callq 0x2160
movslq 0x64(%rbx), %rcx
movq 0x80(%rbx), %rdx
leaq 0xe463(%rip), %rsi      # 0x111a8
movq (%rsi), %rdi
movq %rdi, (%rax)
incq %rdi
movq %rdi, (%rsi)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
leaq 0x73c3(%rip), %rsi      # 0xa122
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)
movl 0x20(%r14), %eax
cmpl $0x3e8, %eax            # imm = 0x3E8
jne 0x2e45
movl $0x28, %edi
callq 0x2160
movq %rax, %r15
leaq 0xe3dd(%rip), %rax      # 0x11188
movq (%rax), %rcx
movq %rcx, (%r15)
incq %rcx
movq %rcx, (%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%r15)
movq $0x0, 0x18(%r15)
leaq 0xe3d2(%rip), %rax      # 0x111a0
movq (%rax), %rax
testq %rax, %rax
je 0x2de0
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 0x2160
leaq 0xe3a3(%rip), %rcx      # 0x111a8
movq (%rcx), %rdx
movq %rdx, (%rax)
incq %rdx
movq %rdx, (%rcx)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
leaq 0x7073(%rip), %rcx      # 0x9e92
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)
movl 0x20(%r14), %eax
decl %eax
movl %eax, 0x20(%r14)
movl $0x38, %edi
callq 0x2160
leaq 0xe34c(%rip), %rcx      # 0x111a8
movq (%rcx), %rdx
movq %rdx, (%rax)
incq %rdx
movq %rdx, (%rcx)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
leaq -0x352(%rip), %rcx      # 0x2b24
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 0x2edb
movq %rax, %rbx
movl $0xe8, %esi
jmp 0x2ed8
movq %rax, %rbx
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2ed3
callq 0x4002
jmp 0x2ed3
movq %rax, %rbx
movl $0x40, %esi
movq %r12, %rdi
callq 0x2170
jmp 0x2f13
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r12, %rdi
je 0x2f01
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x2170
jmp 0x2f01
movq %rax, %rbx
movl $0x48, %esi
movq %r15, %rdi
callq 0x2170
jmp 0x2f20
movq %rax, %rbx
testq %r15, %r15
je 0x2f20
movq %r15, %rdi
callq 0x4002
movq %rbx, %rdi
callq 0x2280