// File: Manca[P]algorithms1/./assignment4.hpp
// Function: assignment4::testCase2()
void testCase2()
    {
        Graph g;
        g[1] = {2};
        g[2] = {3, 5, 6};
        g[3] = {4, 7};
        g[4] = {3, 8};
        g[5] = {1, 6};
        g[6] = {7};
        g[7] = {6, 8};
        g[8] = {8};
        
        Graph gRev;
        gRev[1] = {5};
        gRev[2] = {1};
        gRev[3] = {2, 4};
        gRev[4] = {3};
        gRev[5] = {2};
        gRev[6] = {2, 5, 7};
        gRev[7] = {3, 6};
        gRev[8] = {4, 7, 8};
        
        // initialize global var
        _seen       = seenList(g.size() + 1, 0);
        _times      = timesList(g.size() + 1, 0);
        _leaders    = leadersList(g.size() + 1, 0);
        
        DFSLoop(gRev);
        Graph newGraph = constructNewGraph(g, _times);
        DFSLoop(newGraph);
        
        sort(begin(_leaders), end(_leaders));
        std::vector<SCC> SCCs;
        int el = _leaders[1];
        int elCnt = 1;
        for (size_t i = 2; i < _leaders.size(); i++)
        {
            if (_leaders[i] == el)
                elCnt++;
            else
            {
                SCC scc;
                scc.leader = el;
                scc.numNodes = elCnt;
                SCCs.push_back(scc);
                
                el = _leaders[i];
                elCnt = 1;
            }
        }
        // last SCC
        SCC scc;
        scc.leader = el;
        scc.numNodes = elCnt;
        SCCs.push_back(scc);
        
        // there are 4 SCCs in the given graph
        assert(SCCs.size() == 4);
        for (SCC sccc : SCCs)
        {
            cout << "SCC with leader " << sccc.leader << " has " << sccc.numNodes << " nodes." << endl;
        }
    }

// Assembly:
subq $0x448, %rsp            # imm = 0x448
leaq 0x418(%rsp), %rdi
movq %rdi, 0x108(%rsp)
callq 0x8760
movq 0x108(%rsp), %rdi
movl $0x2, 0x404(%rsp)
leaq 0x404(%rsp), %rax
movq %rax, 0x408(%rsp)
movq $0x1, 0x410(%rsp)
movl $0x1, 0x400(%rsp)
leaq 0x400(%rsp), %rsi
callq 0x8770
movq %rax, 0x110(%rsp)
jmp 0x441d
movq 0x110(%rsp), %rdi
movq 0x408(%rsp), %rsi
movq 0x410(%rsp), %rdx
callq 0x8870
jmp 0x443c
movl $0x3, 0x3d4(%rsp)
movl $0x5, 0x3d8(%rsp)
movl $0x6, 0x3dc(%rsp)
leaq 0x3d4(%rsp), %rax
movq %rax, 0x3e0(%rsp)
movq $0x3, 0x3e8(%rsp)
movl $0x2, 0x3d0(%rsp)
leaq 0x418(%rsp), %rdi
leaq 0x3d0(%rsp), %rsi
callq 0x8770
movq %rax, 0x100(%rsp)
jmp 0x44a3
movq 0x100(%rsp), %rdi
movq 0x3e0(%rsp), %rsi
movq 0x3e8(%rsp), %rdx
callq 0x8870
jmp 0x44c2
movl $0x4, 0x3b8(%rsp)
movl $0x7, 0x3bc(%rsp)
leaq 0x3b8(%rsp), %rax
movq %rax, 0x3c0(%rsp)
movq $0x2, 0x3c8(%rsp)
movl $0x3, 0x3b4(%rsp)
leaq 0x418(%rsp), %rdi
leaq 0x3b4(%rsp), %rsi
callq 0x8770
movq %rax, 0xf8(%rsp)
jmp 0x451e
movq 0xf8(%rsp), %rdi
movq 0x3c0(%rsp), %rsi
movq 0x3c8(%rsp), %rdx
callq 0x8870
jmp 0x453d
movl $0x3, 0x398(%rsp)
movl $0x8, 0x39c(%rsp)
leaq 0x398(%rsp), %rax
movq %rax, 0x3a0(%rsp)
movq $0x2, 0x3a8(%rsp)
movl $0x4, 0x394(%rsp)
leaq 0x418(%rsp), %rdi
leaq 0x394(%rsp), %rsi
callq 0x8770
movq %rax, 0xf0(%rsp)
jmp 0x4599
movq 0xf0(%rsp), %rdi
movq 0x3a0(%rsp), %rsi
movq 0x3a8(%rsp), %rdx
callq 0x8870
jmp 0x45b8
movl $0x1, 0x378(%rsp)
movl $0x6, 0x37c(%rsp)
leaq 0x378(%rsp), %rax
movq %rax, 0x380(%rsp)
movq $0x2, 0x388(%rsp)
movl $0x5, 0x374(%rsp)
leaq 0x418(%rsp), %rdi
leaq 0x374(%rsp), %rsi
callq 0x8770
movq %rax, 0xe8(%rsp)
jmp 0x4614
movq 0xe8(%rsp), %rdi
movq 0x380(%rsp), %rsi
movq 0x388(%rsp), %rdx
callq 0x8870
jmp 0x4633
movl $0x7, 0x35c(%rsp)
leaq 0x35c(%rsp), %rax
movq %rax, 0x360(%rsp)
movq $0x1, 0x368(%rsp)
movl $0x6, 0x358(%rsp)
leaq 0x418(%rsp), %rdi
leaq 0x358(%rsp), %rsi
callq 0x8770
movq %rax, 0xe0(%rsp)
jmp 0x4684
movq 0xe0(%rsp), %rdi
movq 0x360(%rsp), %rsi
movq 0x368(%rsp), %rdx
callq 0x8870
jmp 0x46a3
movl $0x6, 0x340(%rsp)
movl $0x8, 0x344(%rsp)
leaq 0x340(%rsp), %rax
movq %rax, 0x348(%rsp)
movq $0x2, 0x350(%rsp)
movl $0x7, 0x33c(%rsp)
leaq 0x418(%rsp), %rdi
leaq 0x33c(%rsp), %rsi
callq 0x8770
movq %rax, 0xd8(%rsp)
jmp 0x46ff
movq 0xd8(%rsp), %rdi
movq 0x348(%rsp), %rsi
movq 0x350(%rsp), %rdx
callq 0x8870
jmp 0x471e
movl $0x8, 0x324(%rsp)
leaq 0x324(%rsp), %rax
movq %rax, 0x328(%rsp)
movq $0x1, 0x330(%rsp)
movl $0x8, 0x320(%rsp)
leaq 0x418(%rsp), %rdi
leaq 0x320(%rsp), %rsi
callq 0x8770
movq %rax, 0xd0(%rsp)
jmp 0x476f
movq 0xd0(%rsp), %rdi
movq 0x328(%rsp), %rsi
movq 0x330(%rsp), %rdx
callq 0x8870
jmp 0x478e
leaq 0x2f0(%rsp), %rdi
movq %rdi, 0xc0(%rsp)
callq 0x8760
movq 0xc0(%rsp), %rdi
movl $0x5, 0x2dc(%rsp)
leaq 0x2dc(%rsp), %rax
movq %rax, 0x2e0(%rsp)
movq $0x1, 0x2e8(%rsp)
movl $0x1, 0x2d8(%rsp)
leaq 0x2d8(%rsp), %rsi
callq 0x8770
movq %rax, 0xc8(%rsp)
jmp 0x47f4
movq 0xc8(%rsp), %rdi
movq 0x2e0(%rsp), %rsi
movq 0x2e8(%rsp), %rdx
callq 0x8870
jmp 0x4813
movl $0x1, 0x2c4(%rsp)
leaq 0x2c4(%rsp), %rax
movq %rax, 0x2c8(%rsp)
movq $0x1, 0x2d0(%rsp)
movl $0x2, 0x2c0(%rsp)
leaq 0x2f0(%rsp), %rdi
leaq 0x2c0(%rsp), %rsi
callq 0x8770
movq %rax, 0xb8(%rsp)
jmp 0x4864
movq 0xb8(%rsp), %rdi
movq 0x2c8(%rsp), %rsi
movq 0x2d0(%rsp), %rdx
callq 0x8870
jmp 0x4883
movl $0x2, 0x2a8(%rsp)
movl $0x4, 0x2ac(%rsp)
leaq 0x2a8(%rsp), %rax
movq %rax, 0x2b0(%rsp)
movq $0x2, 0x2b8(%rsp)
movl $0x3, 0x2a4(%rsp)
leaq 0x2f0(%rsp), %rdi
leaq 0x2a4(%rsp), %rsi
callq 0x8770
movq %rax, 0xb0(%rsp)
jmp 0x48df
movq 0xb0(%rsp), %rdi
movq 0x2b0(%rsp), %rsi
movq 0x2b8(%rsp), %rdx
callq 0x8870
jmp 0x48fe
movl $0x3, 0x28c(%rsp)
leaq 0x28c(%rsp), %rax
movq %rax, 0x290(%rsp)
movq $0x1, 0x298(%rsp)
movl $0x4, 0x288(%rsp)
leaq 0x2f0(%rsp), %rdi
leaq 0x288(%rsp), %rsi
callq 0x8770
movq %rax, 0xa8(%rsp)
jmp 0x494f
movq 0xa8(%rsp), %rdi
movq 0x290(%rsp), %rsi
movq 0x298(%rsp), %rdx
callq 0x8870
jmp 0x496e
movl $0x2, 0x274(%rsp)
leaq 0x274(%rsp), %rax
movq %rax, 0x278(%rsp)
movq $0x1, 0x280(%rsp)
movl $0x5, 0x270(%rsp)
leaq 0x2f0(%rsp), %rdi
leaq 0x270(%rsp), %rsi
callq 0x8770
movq %rax, 0xa0(%rsp)
jmp 0x49bf
movq 0xa0(%rsp), %rdi
movq 0x278(%rsp), %rsi
movq 0x280(%rsp), %rdx
callq 0x8870
jmp 0x49de
movl $0x2, 0x254(%rsp)
movl $0x5, 0x258(%rsp)
movl $0x7, 0x25c(%rsp)
leaq 0x254(%rsp), %rax
movq %rax, 0x260(%rsp)
movq $0x3, 0x268(%rsp)
movl $0x6, 0x250(%rsp)
leaq 0x2f0(%rsp), %rdi
leaq 0x250(%rsp), %rsi
callq 0x8770
movq %rax, 0x98(%rsp)
jmp 0x4a45
movq 0x98(%rsp), %rdi
movq 0x260(%rsp), %rsi
movq 0x268(%rsp), %rdx
callq 0x8870
jmp 0x4a64
movl $0x3, 0x238(%rsp)
movl $0x6, 0x23c(%rsp)
leaq 0x238(%rsp), %rax
movq %rax, 0x240(%rsp)
movq $0x2, 0x248(%rsp)
movl $0x7, 0x234(%rsp)
leaq 0x2f0(%rsp), %rdi
leaq 0x234(%rsp), %rsi
callq 0x8770
movq %rax, 0x90(%rsp)
jmp 0x4ac0
movq 0x90(%rsp), %rdi
movq 0x240(%rsp), %rsi
movq 0x248(%rsp), %rdx
callq 0x8870
jmp 0x4adf
movl $0x4, 0x214(%rsp)
movl $0x7, 0x218(%rsp)
movl $0x8, 0x21c(%rsp)
leaq 0x214(%rsp), %rax
movq %rax, 0x220(%rsp)
movq $0x3, 0x228(%rsp)
movl $0x8, 0x210(%rsp)
leaq 0x2f0(%rsp), %rdi
leaq 0x210(%rsp), %rsi
callq 0x8770
movq %rax, 0x88(%rsp)
jmp 0x4b46
movq 0x88(%rsp), %rdi
movq 0x220(%rsp), %rsi
movq 0x228(%rsp), %rdx
callq 0x8870
jmp 0x4b65
leaq 0x418(%rsp), %rdi
callq 0x8690
incq %rax
movq %rax, 0x78(%rsp)
movl $0x0, 0x1f4(%rsp)
leaq 0x1f3(%rsp), %rdi
movq %rdi, 0x80(%rsp)
callq 0x83d0
movq 0x78(%rsp), %rsi
movq 0x80(%rsp), %rcx
leaq 0x1f8(%rsp), %rdi
leaq 0x1f4(%rsp), %rdx
callq 0x86a0
jmp 0x4bbe
leaq 0x1f643(%rip), %rdi     # 0x24208
leaq 0x1f8(%rsp), %rsi
movq %rsi, 0x60(%rsp)
callq 0x8720
movq 0x60(%rsp), %rdi
callq 0x8300
leaq 0x1f3(%rsp), %rdi
callq 0x8470
leaq 0x418(%rsp), %rdi
callq 0x8690
incq %rax
movq %rax, 0x68(%rsp)
movl $0x0, 0x1d4(%rsp)
leaq 0x1d3(%rsp), %rdi
movq %rdi, 0x70(%rsp)
callq 0x83d0
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rcx
leaq 0x1d8(%rsp), %rdi
leaq 0x1d4(%rsp), %rdx
callq 0x86a0
jmp 0x4c41
leaq 0x1f5a8(%rip), %rdi     # 0x241f0
leaq 0x1d8(%rsp), %rsi
movq %rsi, 0x48(%rsp)
callq 0x8720
movq 0x48(%rsp), %rdi
callq 0x8300
leaq 0x1d3(%rsp), %rdi
callq 0x8470
leaq 0x418(%rsp), %rdi
callq 0x8690
incq %rax
movq %rax, 0x50(%rsp)
movl $0x0, 0x1b4(%rsp)
leaq 0x1b3(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x83d0
movq 0x50(%rsp), %rsi
movq 0x58(%rsp), %rcx
leaq 0x1b8(%rsp), %rdi
leaq 0x1b4(%rsp), %rdx
callq 0x86a0
jmp 0x4cc4
leaq 0x1f555(%rip), %rdi     # 0x24220
leaq 0x1b8(%rsp), %rsi
movq %rsi, 0x40(%rsp)
callq 0x8720
movq 0x40(%rsp), %rdi
callq 0x8300
leaq 0x1b3(%rsp), %rdi
callq 0x8470
leaq 0x2f0(%rsp), %rdi
callq 0x3160
jmp 0x4d03
leaq 0x1f4e6(%rip), %rdx     # 0x241f0
leaq 0x180(%rsp), %rdi
leaq 0x418(%rsp), %rsi
callq 0x3270
jmp 0x4d21
leaq 0x180(%rsp), %rdi
callq 0x3160
jmp 0x4d30
leaq 0x1f4e9(%rip), %rdi     # 0x24220
callq 0x8910
movq %rax, 0x38(%rsp)
jmp 0x4d43
movq 0x38(%rsp), %rax
movq %rax, 0x178(%rsp)
leaq 0x1f4c9(%rip), %rdi     # 0x24220
callq 0x8940
movq %rax, 0x30(%rsp)
jmp 0x4d63
movq 0x30(%rsp), %rax
movq %rax, 0x170(%rsp)
movq 0x178(%rsp), %rdi
movq 0x170(%rsp), %rsi
callq 0x88d0
jmp 0x4d87
leaq 0x158(%rsp), %rdi
callq 0x8970
leaq 0x1f485(%rip), %rdi     # 0x24220
movl $0x1, %esi
callq 0x84b0
movl (%rax), %eax
movl %eax, 0x154(%rsp)
movl $0x1, 0x150(%rsp)
movq $0x2, 0x148(%rsp)
movq 0x148(%rsp), %rax
movq %rax, 0x28(%rsp)
leaq 0x1f447(%rip), %rdi     # 0x24220
callq 0x7f90
movq %rax, %rcx
movq 0x28(%rsp), %rax
cmpq %rcx, %rax
jae 0x4f83
movq 0x148(%rsp), %rsi
leaq 0x1f422(%rip), %rdi     # 0x24220
callq 0x84b0
movl (%rax), %eax
cmpl 0x154(%rsp), %eax
jne 0x4ee5
movl 0x150(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x150(%rsp)
jmp 0x4f68
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3f8(%rsp)
movl %eax, 0x3f4(%rsp)
jmp 0x514f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3f8(%rsp)
movl %eax, 0x3f4(%rsp)
jmp 0x5142
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3f8(%rsp)
movl %eax, 0x3f4(%rsp)
leaq 0x1f3(%rsp), %rdi
callq 0x8470
jmp 0x5142
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3f8(%rsp)
movl %eax, 0x3f4(%rsp)
leaq 0x1d3(%rsp), %rdi
callq 0x8470
jmp 0x5142
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3f8(%rsp)
movl %eax, 0x3f4(%rsp)
leaq 0x1b3(%rsp), %rdi
callq 0x8470
jmp 0x5142
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3f8(%rsp)
movl %eax, 0x3f4(%rsp)
jmp 0x5135
movl 0x154(%rsp), %eax
movl %eax, 0x140(%rsp)
movl 0x150(%rsp), %eax
movl %eax, 0x144(%rsp)
leaq 0x158(%rsp), %rdi
leaq 0x140(%rsp), %rsi
callq 0x8980
jmp 0x4f18
movq 0x148(%rsp), %rsi
leaq 0x1f2f9(%rip), %rdi     # 0x24220
callq 0x84b0
movl (%rax), %eax
movl %eax, 0x154(%rsp)
movl $0x1, 0x150(%rsp)
jmp 0x4f68
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x3f8(%rsp)
movl %eax, 0x3f4(%rsp)
leaq 0x158(%rsp), %rdi
callq 0x8ae0
jmp 0x5135
jmp 0x4f6a
movq 0x148(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x148(%rsp)
jmp 0x4dc5
movl 0x154(%rsp), %eax
movl %eax, 0x138(%rsp)
movl 0x150(%rsp), %eax
movl %eax, 0x13c(%rsp)
leaq 0x158(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0x8980
jmp 0x4fb6
leaq 0x158(%rsp), %rdi
callq 0x89f0
cmpq $0x4, %rax
jne 0x4fcb
jmp 0x4fea
leaq 0x15147(%rip), %rdi     # 0x1a119
leaq 0x1504e(%rip), %rsi     # 0x1a027
movl $0x114, %edx            # imm = 0x114
leaq 0x15145(%rip), %rcx     # 0x1a12a
callq 0x2140
leaq 0x158(%rsp), %rax
movq %rax, 0x130(%rsp)
movq 0x130(%rsp), %rdi
callq 0x8a10
movq %rax, 0x128(%rsp)
movq 0x130(%rsp), %rdi
callq 0x8a40
movq %rax, 0x120(%rsp)
leaq 0x128(%rsp), %rdi
leaq 0x120(%rsp), %rsi
callq 0x8a70
testb $0x1, %al
jne 0x5042
jmp 0x50f9
leaq 0x128(%rsp), %rdi
callq 0x8ab0
movq (%rax), %rax
movq %rax, 0x118(%rsp)
movq 0x1ef77(%rip), %rdi     # 0x23fd8
leaq 0x15092(%rip), %rsi     # 0x1a0fa
callq 0x21a0
movq %rax, 0x20(%rsp)
jmp 0x5074
movq 0x20(%rsp), %rdi
movl 0x118(%rsp), %esi
callq 0x2320
movq %rax, 0x18(%rsp)
jmp 0x508c
movq 0x18(%rsp), %rdi
leaq 0x15073(%rip), %rsi     # 0x1a10b
callq 0x21a0
movq %rax, 0x10(%rsp)
jmp 0x50a4
movq 0x10(%rsp), %rdi
movl 0x11c(%rsp), %esi
callq 0x2320
movq %rax, 0x8(%rsp)
jmp 0x50bc
movq 0x8(%rsp), %rdi
leaq 0x15049(%rip), %rsi     # 0x1a111
callq 0x21a0
movq %rax, (%rsp)
jmp 0x50d3
movq (%rsp), %rdi
movq 0x1eeea(%rip), %rsi     # 0x23fc8
callq 0x21d0
jmp 0x50e5
jmp 0x50e7
leaq 0x128(%rsp), %rdi
callq 0x8ac0
jmp 0x5024
leaq 0x158(%rsp), %rdi
callq 0x8ae0
leaq 0x180(%rsp), %rdi
callq 0x8860
leaq 0x2f0(%rsp), %rdi
callq 0x8860
leaq 0x418(%rsp), %rdi
callq 0x8860
addq $0x448, %rsp            # imm = 0x448
retq
leaq 0x180(%rsp), %rdi
callq 0x8860
leaq 0x2f0(%rsp), %rdi
callq 0x8860
leaq 0x418(%rsp), %rdi
callq 0x8860
movq 0x3f8(%rsp), %rdi
callq 0x2330
nopl (%rax)