// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x408, %rsp            # imm = 0x408
movl %esi, 0xc(%rsp)
movq %rdi, %rbx
leaq 0x7089(%rip), %rsi      # 0xa0ee
leaq 0x38(%rsp), %rdi
leaq 0x90(%rsp), %rdx
callq 0x38e2
leaq 0x290(%rsp), %rdi
callq 0x21c0
movl 0xf8(%rbx), %esi
leaq 0x290(%rsp), %rdi
callq 0x2280
leaq 0x298(%rsp), %rsi
leaq 0x90(%rsp), %rdi
callq 0x2230
leaq 0x38(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x22d0
leaq 0x90(%rsp), %rdi
callq 0x20a0
leaq 0x7026(%rip), %rsi      # 0xa0f8
leaq 0x38(%rsp), %rdi
callq 0x22b0
leaq 0x90(%rsp), %rdi
leaq 0x38(%rsp), %rsi
pushq $0x10
popq %rdx
callq 0x22c0
leaq 0x7005(%rip), %rsi      # 0xa0fd
leaq 0x90(%rsp), %rdi
callq 0x2160
leaq 0x6ffb(%rip), %rsi      # 0xa107
leaq 0x90(%rsp), %rdi
callq 0x2160
leaq 0x7001(%rip), %rsi      # 0xa121
leaq 0x90(%rsp), %rdi
callq 0x2160
leaq 0x7007(%rip), %rsi      # 0xa13b
leaq 0x90(%rsp), %rdi
callq 0x2160
leaq 0x700d(%rip), %rsi      # 0xa155
leaq 0x90(%rsp), %rdi
callq 0x2160
leaq 0x7013(%rip), %rsi      # 0xa16f
leaq 0x90(%rsp), %rdi
callq 0x2160
leaq 0x701b(%rip), %rsi      # 0xa18b
leaq 0x90(%rsp), %rdi
callq 0x2160
leaq 0x7023(%rip), %rsi      # 0xa1a7
leaq 0x90(%rsp), %rdi
callq 0x2160
leaq 0x702e(%rip), %rsi      # 0xa1c6
leaq 0x90(%rsp), %rdi
callq 0x2160
leaq 0x7030(%rip), %rsi      # 0xa1dc
leaq 0x90(%rsp), %rdi
callq 0x2160
leaq 0x702a(%rip), %rsi      # 0xa1ea
leaq 0x90(%rsp), %rdi
callq 0x2160
leaq 0x7032(%rip), %rsi      # 0xa206
leaq 0x90(%rsp), %rdi
callq 0x2160
leaq 0x88(%rsp), %rax
movq %rax, -0x30(%rax)
movq $0x1, -0x28(%rax)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rax)
movl $0x3f800000, -0x10(%rax) # imm = 0x3F800000
movups %xmm0, -0x8(%rax)
xorl %r15d, %r15d
leaq 0xc91f(%rip), %r14      # 0xfb30
leaq 0xc928(%rip), %r12      # 0xfb40
leaq 0x10(%rsp), %r13
leaq 0x90(%rsp), %rbp
movq %rbx, (%rsp)
movslq 0x64(%rbx), %rax
leaq (%rax,%rax,2), %rcx
cmpq %rcx, %r15
jge 0x3287
movq 0xe0(%rbx), %rax
movq (%rax,%r15,8), %rbx
movq %rbx, %rdi
movq %r14, %rsi
movq %r12, %rdx
xorl %ecx, %ecx
callq 0x21a0
movl 0x8(%rbx), %edx
movsd 0xb0(%rax), %xmm0
movzbl 0xb8(%rax), %ecx
movq %r13, %rdi
callq 0x2c76
movq %rbp, %rdi
movq %r13, %rsi
callq 0x2150
movq %r13, %rdi
callq 0x20a0
incq %r15
movq (%rsp), %rbx
jmp 0x3229
xorl %ebx, %ebx
leaq 0x10(%rsp), %r15
pushq $0x2
popq %r12
leaq 0x90(%rsp), %r14
leal (%rax,%rax,2), %ecx
movslq %ecx, %rcx
cmpq %rcx, %rbx
jge 0x33f5
movq (%rsp), %rax
movq 0xe0(%rax), %rax
movq (%rax,%rbx,8), %rbp
testq %rbp, %rbp
je 0x32da
movq %rbp, %rdi
leaq 0xc869(%rip), %rsi      # 0xfb30
leaq 0xc872(%rip), %rdx      # 0xfb40
xorl %ecx, %ecx
callq 0x21a0
movq %rax, %r13
jmp 0x32dd
xorl %r13d, %r13d
movq 0xd0(%r13), %rax
testq %rax, %rax
je 0x3385
cmpb $0x0, 0xc(%rsp)
je 0x3360
movl 0x8(%rbp), %edx
movl 0x30(%rax), %ecx
movq %r15, %rdi
pushq $0x4
popq %r8
callq 0x2e20
movq %rbx, 0x30(%rsp)
movl %r12d, %r14d
leaq 0x90(%rsp), %rdi
movq %r15, %rsi
callq 0x2150
movq %r15, %rdi
callq 0x20a0
movq 0xd0(%r13), %rax
movl 0x30(%rax), %r12d
movl 0x8(%rbp), %eax
movl %eax, 0x10(%rsp)
leaq 0x58(%rsp), %rdi
movq %r15, %rbx
movq %r15, %rsi
callq 0x54aa
movl %r12d, (%rax)
movl %r14d, %r12d
leaq 0x90(%rsp), %r14
movq %rbx, %r15
movq 0x30(%rsp), %rbx
jmp 0x3385
movl 0x8(%rbp), %edx
movl 0x30(%rax), %ecx
movq %r15, %rdi
pushq $0x1
popq %r8
callq 0x2e20
movq %r14, %rdi
movq %r15, %rsi
callq 0x2150
movq %r15, %rdi
callq 0x20a0
movq 0xd8(%r13), %rax
testq %rax, %rax
je 0x33b6
movl 0x8(%rbp), %edx
movl 0x30(%rax), %ecx
movq %r15, %rdi
pushq $0x3
popq %r8
callq 0x2e20
movq %r14, %rdi
movq %r15, %rsi
callq 0x2150
movq %r15, %rdi
callq 0x20a0
movq 0xe0(%r13), %rax
testq %rax, %rax
je 0x33e6
movl 0x8(%rbp), %edx
movl 0x30(%rax), %ecx
movq %r15, %rdi
movl %r12d, %r8d
callq 0x2e20
movq %r14, %rdi
movq %r15, %rsi
callq 0x2150
movq %r15, %rdi
callq 0x20a0
incq %rbx
movq (%rsp), %rax
movl 0x64(%rax), %eax
jmp 0x329a
xorl %r15d, %r15d
leaq 0xc731(%rip), %r14      # 0xfb30
leaq 0xc73a(%rip), %r12      # 0xfb40
leaq 0x10(%rsp), %rbp
movq (%rsp), %rcx
leal (%rax,%rax,2), %eax
cltq
cmpq %rax, %r15
jge 0x34a6
movq 0xe0(%rcx), %rax
movq (%rax,%r15,8), %r13
movq %r13, %rdi
movq %r14, %rsi
movq %r12, %rdx
xorl %ecx, %ecx
callq 0x21a0
movq 0xc8(%rax), %rsi
testq %rsi, %rsi
je 0x3497
cmpb $0x0, 0xc(%rsp)
je 0x346d
movq %rax, %rbx
addq $0x30, %rsi
leaq 0x58(%rsp), %rdi
callq 0x57e2
movl 0x8(%r13), %edx
cmpl %edx, (%rax)
je 0x3497
movq 0xc8(%rbx), %rsi
jmp 0x3471
movl 0x8(%r13), %edx
movl 0x30(%rsi), %ecx
movq %rbp, %rdi
xorl %r8d, %r8d
callq 0x2e20
leaq 0x90(%rsp), %rdi
movq %rbp, %rsi
callq 0x2150
movq %rbp, %rdi
callq 0x20a0
incq %r15
movq (%rsp), %rcx
movl 0x64(%rcx), %eax
jmp 0x340f
leaq 0x6bc4(%rip), %rsi      # 0xa071
leaq 0x90(%rsp), %rdi
callq 0x2160
leaq 0x58(%rsp), %rdi
callq 0x4900
leaq 0x90(%rsp), %rdi
callq 0x2210
leaq 0x290(%rsp), %rdi
callq 0x2040
leaq 0x38(%rsp), %rdi
callq 0x20a0
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3548
jmp 0x3517
movq %rax, %rbx
leaq 0x90(%rsp), %rdi
callq 0x20a0
jmp 0x3562
jmp 0x3517
movq %rax, %rbx
jmp 0x356f
movq %rax, %rbx
jmp 0x3562
jmp 0x3548
jmp 0x3548
jmp 0x3548
jmp 0x3539
jmp 0x3548
jmp 0x3539
movq %rax, %rbx
jmp 0x3555
jmp 0x3539
jmp 0x3548
jmp 0x3539
jmp 0x3548
jmp 0x3548
jmp 0x3539
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x20a0
jmp 0x354b
movq %rax, %rbx
leaq 0x58(%rsp), %rdi
callq 0x4900
leaq 0x90(%rsp), %rdi
callq 0x2210
leaq 0x290(%rsp), %rdi
callq 0x2040
leaq 0x38(%rsp), %rdi
callq 0x20a0
movq %rbx, %rdi
callq 0x2290
nop