// File: kiudee[P]VAHD-Projekt/Supervisor.cpp
// Function: Supervisor::printGraph(bool)
void Supervisor::printGraph(bool lastPass)
{
    std::string graphname("gfx/graph");
    std::ostringstream s;
    s << printcount;
    graphname += s.str();
    graphname += ".gdl";
    std::ofstream out(graphname);
    out << "graph: {\n";

    // Colors:
    out << "colorentry 32: 60 236 93\n"; //left edges: bright green
    out << "colorentry 33: 31 130 13\n"; //right edges: darker green
    out << "colorentry 34: 56 89 255\n"; //edge 0: bright blue
    out << "colorentry 35: 30 48 138\n"; //edge 1: darker blue
    out << "colorentry 36: 114 165 255\n"; //node real: light purple
    out << "colorentry 37: 255 210 114\n"; //node virtual: light sepia

    // Graph Options:
    out << "layoutalgorithm: maxdepthslow\n"; //Use slow algorithm which yields good quality
    out << "manhattan_edges: yes\n"; //Orthogonal lines
    out << "splines: yes\n"; //Slightly bended lines
    out << "orientation: bottom_to_top\n"; //Edges above nodes
    out << "yspace: 30\n"; //Edges above nodes

    std::unordered_map<int, int> alreadyLinked;

    // Print all nodes:
    for (int i = 0; i < (total * 3); i++) {
        auto node = dynamic_cast<Node *>(Subjects[i]);
        out << Node2GDL(Subjects[i]->_debugID, node->num, node->isReal);
    }

    // Print all edges, but no LEFT edges:
    for (int i = 0; i < (total * 3); i++) {
        auto node = dynamic_cast<Node *>(Subjects[i]);
        auto subject = Subjects[i];
        if (node->right != NULL) {
            if (lastPass) {
                out << Edge2GDL(subject->_debugID, node->right->debugID, LEFTRIGHT);
                alreadyLinked[subject->_debugID] = node->right->debugID;
            } else {
                out << Edge2GDL(subject->_debugID, node->right->debugID, RIGHT);
            }
        }
        if (node->node0 != NULL) {
            out << Edge2GDL(subject->_debugID, node->node0->debugID, EDGE0);
        }
        if (node->node1 != NULL) {
            out << Edge2GDL(subject->_debugID, node->node1->debugID, EDGE1);
        }
    }

    // Print LEFT edges, if nodes are not connected by a RIGHT edge:
    for (int i = 0; i < (total * 3); i++) {
        auto node = dynamic_cast<Node *>(Subjects[i]);
        auto subject = Subjects[i];
        if (node->left != NULL) {
            if (!lastPass || alreadyLinked[node->left->debugID] != static_cast<int>(subject->_debugID)) {
                out << Edge2GDL(subject->_debugID, node->left->debugID, LEFT);
            }
        }
    }
    out << "}\n";
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x580, %rsp            # imm = 0x580
movb %sil, %al
movq %rdi, -0x8(%rbp)
andb $0x1, %al
movb %al, -0x9(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x530(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0x528(%rbp)
callq 0x3340
movq -0x528(%rbp), %rdx
leaq 0x12556(%rip), %rsi     # 0x170d6
leaq -0x30(%rbp), %rdi
callq 0x5c60
jmp 0x4b8b
leaq -0x31(%rbp), %rdi
callq 0x3200
leaq -0x1c0(%rbp), %rdi
callq 0x3280
jmp 0x4ba2
movq -0x530(%rbp), %rax
movl 0xf8(%rax), %esi
leaq -0x1c0(%rbp), %rdi
callq 0x3320
jmp 0x4bbd
leaq -0x1e0(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
callq 0x31e0
jmp 0x4bd2
leaq -0x30(%rbp), %rdi
leaq -0x1e0(%rbp), %rsi
callq 0x3260
jmp 0x4be4
leaq -0x1e0(%rbp), %rdi
callq 0x3100
leaq 0x124e9(%rip), %rsi     # 0x170e0
leaq -0x30(%rbp), %rdi
callq 0x31a0
jmp 0x4c02
leaq -0x3e0(%rbp), %rdi
leaq -0x30(%rbp), %rsi
movl $0x10, %edx
callq 0x3380
jmp 0x4c19
leaq 0x124c5(%rip), %rsi     # 0x170e5
leaq -0x3e0(%rbp), %rdi
callq 0x31b0
jmp 0x4c2e
leaq 0x124ba(%rip), %rsi     # 0x170ef
leaq -0x3e0(%rbp), %rdi
callq 0x31b0
jmp 0x4c43
leaq 0x124bf(%rip), %rsi     # 0x17109
leaq -0x3e0(%rbp), %rdi
callq 0x31b0
jmp 0x4c58
leaq 0x124c4(%rip), %rsi     # 0x17123
leaq -0x3e0(%rbp), %rdi
callq 0x31b0
jmp 0x4c6d
leaq 0x124c9(%rip), %rsi     # 0x1713d
leaq -0x3e0(%rbp), %rdi
callq 0x31b0
jmp 0x4c82
leaq 0x124ce(%rip), %rsi     # 0x17157
leaq -0x3e0(%rbp), %rdi
callq 0x31b0
jmp 0x4c97
leaq 0x124d5(%rip), %rsi     # 0x17173
leaq -0x3e0(%rbp), %rdi
callq 0x31b0
jmp 0x4cac
leaq 0x124dc(%rip), %rsi     # 0x1718f
leaq -0x3e0(%rbp), %rdi
callq 0x31b0
jmp 0x4cc1
leaq 0x124e6(%rip), %rsi     # 0x171ae
leaq -0x3e0(%rbp), %rdi
callq 0x31b0
jmp 0x4cd6
leaq 0x124e7(%rip), %rsi     # 0x171c4
leaq -0x3e0(%rbp), %rdi
callq 0x31b0
jmp 0x4ceb
leaq 0x124e0(%rip), %rsi     # 0x171d2
leaq -0x3e0(%rbp), %rdi
callq 0x31b0
jmp 0x4d00
leaq 0x124e7(%rip), %rsi     # 0x171ee
leaq -0x3e0(%rbp), %rdi
callq 0x31b0
jmp 0x4d15
leaq -0x418(%rbp), %rdi
callq 0x5d10
movl $0x0, -0x41c(%rbp)
movq -0x530(%rbp), %rcx
movl -0x41c(%rbp), %eax
imull $0x3, 0x64(%rcx), %ecx
cmpl %ecx, %eax
jge 0x4ecd
movq -0x530(%rbp), %rdi
addq $0xe0, %rdi
movslq -0x41c(%rbp), %rsi
callq 0x5d30
movq (%rax), %rax
movq %rax, -0x538(%rbp)
cmpq $0x0, %rax
je 0x4e03
movq -0x538(%rbp), %rdi
leaq 0x1bd78(%rip), %rsi     # 0x20af8
leaq 0x1bd81(%rip), %rdx     # 0x20b08
xorl %eax, %eax
movl %eax, %ecx
callq 0x3240
movq %rax, -0x540(%rbp)
jmp 0x4e0e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x31(%rbp), %rdi
callq 0x3200
jmp 0x540f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x5406
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x53fa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x1e0(%rbp), %rdi
callq 0x3100
jmp 0x53fa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x53ee
xorl %eax, %eax
movq %rax, -0x540(%rbp)
jmp 0x4e0e
movq -0x530(%rbp), %rdi
movq -0x540(%rbp), %rax
movq %rax, -0x428(%rbp)
addq $0xe0, %rdi
movslq -0x41c(%rbp), %rsi
callq 0x5d30
movq -0x530(%rbp), %rsi
movq (%rax), %rax
movl 0x8(%rax), %edx
movq -0x428(%rbp), %rax
movsd 0xb0(%rax), %xmm0
movzbl 0xb8(%rax), %ecx
andl $0x1, %ecx
leaq -0x448(%rbp), %rdi
callq 0x44f0
jmp 0x4e6a
leaq -0x3e0(%rbp), %rdi
leaq -0x448(%rbp), %rsi
callq 0x3190
jmp 0x4e7f
leaq -0x448(%rbp), %rdi
callq 0x3100
movl -0x41c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x41c(%rbp)
jmp 0x4d2b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x53e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x448(%rbp), %rdi
callq 0x3100
jmp 0x53e2
movl $0x0, -0x44c(%rbp)
movq -0x530(%rbp), %rcx
movl -0x44c(%rbp), %eax
imull $0x3, 0x64(%rcx), %ecx
cmpl %ecx, %eax
jge 0x5204
movq -0x530(%rbp), %rdi
addq $0xe0, %rdi
movslq -0x44c(%rbp), %rsi
callq 0x5d30
movq (%rax), %rax
movq %rax, -0x548(%rbp)
cmpq $0x0, %rax
je 0x4f41
movq -0x548(%rbp), %rdi
leaq 0x1bbd0(%rip), %rsi     # 0x20af8
leaq 0x1bbd9(%rip), %rdx     # 0x20b08
xorl %eax, %eax
movl %eax, %ecx
callq 0x3240
movq %rax, -0x550(%rbp)
jmp 0x4f4c
xorl %eax, %eax
movq %rax, -0x550(%rbp)
jmp 0x4f4c
movq -0x530(%rbp), %rdi
movq -0x550(%rbp), %rax
movq %rax, -0x458(%rbp)
addq $0xe0, %rdi
movslq -0x44c(%rbp), %rsi
callq 0x5d30
movq (%rax), %rax
movq %rax, -0x460(%rbp)
movq -0x458(%rbp), %rax
cmpq $0x0, 0xd0(%rax)
je 0x50e0
testb $0x1, -0x9(%rbp)
je 0x5068
movq -0x530(%rbp), %rsi
movq -0x460(%rbp), %rax
movl 0x8(%rax), %edx
movq -0x458(%rbp), %rax
movq 0xd0(%rax), %rax
movl 0x30(%rax), %ecx
leaq -0x480(%rbp), %rdi
movl $0x4, %r8d
callq 0x47b0
jmp 0x4fd3
leaq -0x3e0(%rbp), %rdi
leaq -0x480(%rbp), %rsi
callq 0x3190
jmp 0x4fe8
leaq -0x480(%rbp), %rdi
callq 0x3100
movq -0x458(%rbp), %rax
movq 0xd0(%rax), %rax
movl 0x30(%rax), %eax
movl %eax, -0x55c(%rbp)
movq -0x460(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, -0x484(%rbp)
leaq -0x418(%rbp), %rdi
leaq -0x484(%rbp), %rsi
callq 0x5d50
movq %rax, -0x558(%rbp)
jmp 0x5037
movq -0x558(%rbp), %rax
movl -0x55c(%rbp), %ecx
movl %ecx, (%rax)
jmp 0x50de
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x480(%rbp), %rdi
callq 0x3100
jmp 0x53e2
movq -0x530(%rbp), %rsi
movq -0x460(%rbp), %rax
movl 0x8(%rax), %edx
movq -0x458(%rbp), %rax
movq 0xd0(%rax), %rax
movl 0x30(%rax), %ecx
leaq -0x4a8(%rbp), %rdi
movl $0x1, %r8d
callq 0x47b0
jmp 0x509e
leaq -0x3e0(%rbp), %rdi
leaq -0x4a8(%rbp), %rsi
callq 0x3190
jmp 0x50b3
leaq -0x4a8(%rbp), %rdi
callq 0x3100
jmp 0x50de
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x4a8(%rbp), %rdi
callq 0x3100
jmp 0x53e2
jmp 0x50e0
movq -0x458(%rbp), %rax
cmpq $0x0, 0xd8(%rax)
je 0x5167
movq -0x530(%rbp), %rsi
movq -0x460(%rbp), %rax
movl 0x8(%rax), %edx
movq -0x458(%rbp), %rax
movq 0xd8(%rax), %rax
movl 0x30(%rax), %ecx
leaq -0x4c8(%rbp), %rdi
movl $0x3, %r8d
callq 0x47b0
jmp 0x5127
leaq -0x3e0(%rbp), %rdi
leaq -0x4c8(%rbp), %rsi
callq 0x3190
jmp 0x513c
leaq -0x4c8(%rbp), %rdi
callq 0x3100
jmp 0x5167
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x4c8(%rbp), %rdi
callq 0x3100
jmp 0x53e2
movq -0x458(%rbp), %rax
cmpq $0x0, 0xe0(%rax)
je 0x51ee
movq -0x530(%rbp), %rsi
movq -0x460(%rbp), %rax
movl 0x8(%rax), %edx
movq -0x458(%rbp), %rax
movq 0xe0(%rax), %rax
movl 0x30(%rax), %ecx
leaq -0x4e8(%rbp), %rdi
movl $0x2, %r8d
callq 0x47b0
jmp 0x51ae
leaq -0x3e0(%rbp), %rdi
leaq -0x4e8(%rbp), %rsi
callq 0x3190
jmp 0x51c3
leaq -0x4e8(%rbp), %rdi
callq 0x3100
jmp 0x51ee
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x4e8(%rbp), %rdi
callq 0x3100
jmp 0x53e2
jmp 0x51f0
movl -0x44c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44c(%rbp)
jmp 0x4ed7
movl $0x0, -0x4ec(%rbp)
movq -0x530(%rbp), %rcx
movl -0x4ec(%rbp), %eax
imull $0x3, 0x64(%rcx), %ecx
cmpl %ecx, %eax
jge 0x5397
movq -0x530(%rbp), %rdi
addq $0xe0, %rdi
movslq -0x4ec(%rbp), %rsi
callq 0x5d30
movq (%rax), %rax
movq %rax, -0x568(%rbp)
cmpq $0x0, %rax
je 0x5278
movq -0x568(%rbp), %rdi
leaq 0x1b899(%rip), %rsi     # 0x20af8
leaq 0x1b8a2(%rip), %rdx     # 0x20b08
xorl %eax, %eax
movl %eax, %ecx
callq 0x3240
movq %rax, -0x570(%rbp)
jmp 0x5283
xorl %eax, %eax
movq %rax, -0x570(%rbp)
jmp 0x5283
movq -0x530(%rbp), %rdi
movq -0x570(%rbp), %rax
movq %rax, -0x4f8(%rbp)
addq $0xe0, %rdi
movslq -0x4ec(%rbp), %rsi
callq 0x5d30
movq (%rax), %rax
movq %rax, -0x500(%rbp)
movq -0x4f8(%rbp), %rax
cmpq $0x0, 0xc8(%rax)
je 0x5381
testb $0x1, -0x9(%rbp)
je 0x530f
movq -0x4f8(%rbp), %rax
movq 0xc8(%rax), %rsi
addq $0x30, %rsi
leaq -0x418(%rbp), %rdi
callq 0x5d80
movq %rax, -0x578(%rbp)
jmp 0x52f7
movq -0x578(%rbp), %rax
movl (%rax), %eax
movq -0x500(%rbp), %rcx
movq 0x8(%rcx), %rcx
cmpl %ecx, %eax
je 0x537f
movq -0x530(%rbp), %rsi
movq -0x500(%rbp), %rax
movl 0x8(%rax), %edx
movq -0x4f8(%rbp), %rax
movq 0xc8(%rax), %rax
movl 0x30(%rax), %ecx
leaq -0x520(%rbp), %rdi
xorl %r8d, %r8d
callq 0x47b0
jmp 0x5342
leaq -0x3e0(%rbp), %rdi
leaq -0x520(%rbp), %rsi
callq 0x3190
jmp 0x5357
leaq -0x520(%rbp), %rdi
callq 0x3100
jmp 0x537f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x520(%rbp), %rdi
callq 0x3100
jmp 0x53e2
jmp 0x5381
jmp 0x5383
movl -0x4ec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4ec(%rbp)
jmp 0x520e
leaq 0x11cbb(%rip), %rsi     # 0x17059
leaq -0x3e0(%rbp), %rdi
callq 0x31b0
jmp 0x53ac
leaq -0x418(%rbp), %rdi
callq 0x5db0
leaq -0x3e0(%rbp), %rdi
callq 0x32d0
leaq -0x1c0(%rbp), %rdi
callq 0x3070
leaq -0x30(%rbp), %rdi
callq 0x3100
addq $0x580, %rsp            # imm = 0x580
popq %rbp
retq
leaq -0x418(%rbp), %rdi
callq 0x5db0
leaq -0x3e0(%rbp), %rdi
callq 0x32d0
leaq -0x1c0(%rbp), %rdi
callq 0x3070
leaq -0x30(%rbp), %rdi
callq 0x3100
movq -0x40(%rbp), %rdi
callq 0x3330
nopl (%rax,%rax)