// File: /workspace/github_cpp_makefile_star2_O2/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 %r12
pushq %rbx
subq $0x58, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movl 0x20(%rsi), %eax
testl %eax, %eax
jle 0x2bb4
testb $0x7, %al
jne 0x2954
movq %rbx, %rdi
xorl %esi, %esi
callq 0x3046
incl 0xf8(%rbx)
movl 0x20(%r14), %eax
cmpl $0xbb8, %eax            # imm = 0xBB8
jne 0x2a8a
pushq $0x48
popq %rdi
callq 0x2170
movq %rax, %r15
leaq 0x78a1(%rip), %rsi      # 0xa212
leaq 0x38(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0x38e2
leaq 0x38(%rsp), %rdx
movq %r15, %rdi
movl $0x29a, %esi            # imm = 0x29A
callq 0x391e
leaq 0x38(%rsp), %rdi
callq 0x20a0
movq 0x68(%rbx), %rax
movq 0x20(%rax), %rax
movq 0x28(%rax), %r12
pushq $0x38
popq %rdi
callq 0x2170
leaq 0xd801(%rip), %rcx      # 0x101b8
movq (%rcx), %rdx
movq %rdx, (%rax)
incq %rdx
movq %rdx, (%rcx)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
leaq 0x4785(%rip), %rcx      # 0x7156
movq %rcx, 0x18(%rax)
andq $0x0, 0x20(%rax)
movq %r15, 0x28(%rax)
andq $0x0, 0x30(%rax)
movq (%r12), %rcx
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq *0x8(%rcx)
leaq 0x98(%rbx), %rsi
leaq 0x8(%rsp), %rdi
callq 0x39fe
pushq $0x40
popq %rdi
callq 0x2170
movq %rax, %r15
movl $0x29a, %edi            # imm = 0x29A
callq 0x5a1c
movsd %xmm0, 0x18(%rsp)
leaq 0x28(%rsp), %r12
leaq 0x8(%rsp), %rsi
movq %r12, %rdi
callq 0x39fe
pushq $0x1
popq %rsi
movq %r15, %rdi
movsd 0x18(%rsp), %xmm0
movq %r12, %rdx
callq 0x3608
leaq 0x30(%rsp), %rdi
callq 0x3978
movq %r15, 0x20(%rsp)
movl $0xe8, %edi
callq 0x2170
movq %rax, %r15
leaq 0x20(%rsp), %rsi
movq %rax, %rdi
callq 0x3650
movq %rbx, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x370c
leaq 0x10(%rsp), %rdi
callq 0x3978
movl 0x20(%r14), %eax
cmpl $0x7d0, %eax            # imm = 0x7D0
jne 0x2adb
movq 0x68(%rbx), %rax
movq (%rax), %rax
movq 0x28(%rax), %r12
pushq $0x38
popq %rdi
callq 0x2170
movq %rax, %r15
movslq 0x64(%rbx), %rcx
shlq $0x3, %rcx
addq 0x80(%rbx), %rcx
leaq 0x59cd(%rip), %rsi      # 0x848a
movq %rax, %rdi
xorl %edx, %edx
callq 0x3890
movq (%r12), %rax
movq %r12, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq *0x8(%rax)
movl 0x20(%r14), %eax
cmpl $0x3e8, %eax            # imm = 0x3E8
jne 0x2b58
pushq $0x28
popq %rdi
callq 0x2170
movq %rax, %r15
movq %rax, %rdi
callq 0x3a32
movl $0x29a, 0x20(%r15)      # imm = 0x29A
movq 0x68(%rbx), %rax
movq 0x20(%rax), %rax
movq 0x28(%rax), %r12
pushq $0x38
popq %rdi
callq 0x2170
leaq 0xd6a0(%rip), %rcx      # 0x101b8
movq (%rcx), %rdx
movq %rdx, (%rax)
incq %rdx
movq %rdx, (%rcx)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
leaq 0x5820(%rip), %rcx      # 0x8352
movq %rcx, 0x18(%rax)
andq $0x0, 0x20(%rax)
movq %r15, 0x28(%rax)
andq $0x0, 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)
pushq $0x38
popq %rdi
callq 0x2170
leaq 0xd64b(%rip), %rcx      # 0x101b8
movq (%rcx), %rdx
movq %rdx, (%rax)
incq %rdx
movq %rdx, (%rcx)
xorps %xmm0, %xmm0
movups %xmm0, 0x8(%rax)
leaq -0x267(%rip), %rcx      # 0x2920
movq %rcx, 0x18(%rax)
andq $0x0, 0x20(%rax)
movq %r14, 0x28(%rax)
andq $0x0, 0x30(%rax)
movq (%rbx), %rcx
movq %rbx, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq *0x48(%rcx)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
retq
pushq $0x28
popq %rsi
movq %r14, %rdi
callq 0x2180
pushq $0x1
popq %rsi
movq %rbx, %rdi
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
jmp 0x3046
movq %rax, %rbx
movl $0xe8, %esi
jmp 0x2bfb
movq %rax, %rbx
pushq $0x38
jmp 0x2c19
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x3978
jmp 0x2bf8
movq %rax, %rbx
pushq $0x40
popq %rsi
movq %r15, %rdi
callq 0x2180
jmp 0x2c27
movq %rax, %rbx
leaq 0x38(%rsp), %rdi
callq 0x20a0
jmp 0x2c17
movq %rax, %rbx
pushq $0x48
popq %rsi
movq %r15, %rdi
callq 0x2180
jmp 0x2c31
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x3978
movq %rbx, %rdi
callq 0x2290
nop