// File: MUST-Quick-Fry[P]Process-Scheduler/scheduler.cpp
// Function: Project::Scheduler::Display(std::queue<Project::Job, std::deque<Project::Job, std::allocator<Project::Job>>>)
void Scheduler::Display(queue<Job> q)
{
    cout<<"Totally " << get_job_num() << " jobs, Time using: " << get_total_time()<<" s\n";
    cout<<"======================================================================="<<'\n';
    cout<<"Gantt Chart"<<'\n';
    cout<<"======================================================================="<<'\n';
    cout << "Time" << setfill(' ') << setw(5) << "|";
     
    for (int i = 0; i <= get_total_time()/ 10; i++)
    {
        cout << i;
        cout << setfill(' ') << setw(20);
    }   
        
    cout << '\n';
    cout << setfill(' ') << setw(9) << '|';
    for (int i = 0; i <= get_total_time() / 10; i++)
    {
        for (int j = 0; j <= 9; j++){ cout << j << ' ';}
    }
    cout << '\n';
    
    int stopindex = 0;
    
    while(!q.empty())
    {
         auto it = q.front();
         q.pop();
         
         cout<<"Job " << it.ID <<setw(4) << "|";
         int arr_time = it.get_arr_time();
         int dur_time = it.get_dur_time();
         for(int i=0; i<arr_time; ++i){ cout << " " << ' ';}
         cout << "." << ' '; // arrive
         for(int i=arr_time + 1; i<=get_total_time(); ++i){ 
             if(i <= stopindex){cout << "." << ' ';}
             else{
                 cout << "#" << ' ';
                 dur_time--;
                 if(dur_time==0){stopindex = i; break;}
             }
         }
         for(int i=stopindex + 1; i<=get_total_time(); ++i){ cout << " " << ' ';}
         cout << endl;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movq %rsi, -0xe8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq 0x16a64(%rip), %rdi     # 0x22fc0
leaq 0xcd69(%rip), %rsi      # 0x192cc
callq 0x3270
movq -0xd8(%rbp), %rdi
movq %rax, -0xe0(%rbp)
callq 0x86a0
movq -0xe0(%rbp), %rdi
movl %eax, %esi
callq 0x3440
movq %rax, %rdi
leaq 0xcd42(%rip), %rsi      # 0x192d5
callq 0x3270
movq -0xd8(%rbp), %rdi
movq %rax, -0xd0(%rbp)
callq 0x8680
movq -0xd0(%rbp), %rdi
movl %eax, %esi
callq 0x3440
movq %rax, %rdi
leaq 0xcd26(%rip), %rsi      # 0x192e9
callq 0x3270
movq 0x169f1(%rip), %rdi     # 0x22fc0
leaq 0xcd17(%rip), %rsi      # 0x192ed
callq 0x3270
movq %rax, %rdi
movl $0xa, %esi
callq 0x32c0
movq 0x169d1(%rip), %rdi     # 0x22fc0
leaq 0xcd3f(%rip), %rsi      # 0x19335
callq 0x3270
movq %rax, %rdi
movl $0xa, %esi
callq 0x32c0
movq 0x169b1(%rip), %rdi     # 0x22fc0
leaq 0xccd7(%rip), %rsi      # 0x192ed
callq 0x3270
movq %rax, %rdi
movl $0xa, %esi
callq 0x32c0
movq 0x16991(%rip), %rdi     # 0x22fc0
leaq 0xcd0b(%rip), %rsi      # 0x19341
callq 0x3270
movq %rax, -0xc8(%rbp)
movl $0x20, %edi
callq 0x6aa0
movq -0xc8(%rbp), %rdi
movb %al, -0x11(%rbp)
movzbl -0x11(%rbp), %esi
callq 0x33e0
movq %rax, -0xc0(%rbp)
movl $0x5, %edi
callq 0x6a80
movq -0xc0(%rbp), %rdi
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %esi
callq 0x32b0
movq %rax, %rdi
leaq 0xccba(%rip), %rsi      # 0x19346
callq 0x3270
movl $0x0, -0x1c(%rbp)
movq -0xd8(%rbp), %rdi
movl -0x1c(%rbp), %eax
movl %eax, -0xec(%rbp)
callq 0x8680
movl $0xa, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0xec(%rbp), %eax
cmpl %ecx, %eax
jg 0xc71e
movl -0x1c(%rbp), %esi
movq 0x168f5(%rip), %rdi     # 0x22fc0
callq 0x3440
movl $0x20, %edi
callq 0x6aa0
movb %al, -0x1d(%rbp)
movq 0x168dc(%rip), %rdi     # 0x22fc0
movzbl -0x1d(%rbp), %esi
callq 0x33e0
movq %rax, -0xf8(%rbp)
movl $0x14, %edi
callq 0x6a80
movq -0xf8(%rbp), %rdi
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %esi
callq 0x32b0
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0xc698
movq 0x1689b(%rip), %rdi     # 0x22fc0
movl $0xa, %esi
callq 0x32c0
movl $0x20, %edi
callq 0x6aa0
movb %al, -0x25(%rbp)
movq 0x1687d(%rip), %rdi     # 0x22fc0
movzbl -0x25(%rbp), %esi
callq 0x33e0
movq %rax, -0x100(%rbp)
movl $0x9, %edi
callq 0x6a80
movq -0x100(%rbp), %rdi
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %esi
callq 0x32b0
movq %rax, %rdi
movl $0x7c, %esi
callq 0x32c0
movl $0x0, -0x30(%rbp)
movq -0xd8(%rbp), %rdi
movl -0x30(%rbp), %eax
movl %eax, -0x104(%rbp)
callq 0x8680
movl $0xa, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x104(%rbp), %eax
cmpl %ecx, %eax
jg 0xc7ed
movl $0x0, -0x34(%rbp)
cmpl $0x9, -0x34(%rbp)
jg 0xc7e0
movl -0x34(%rbp), %esi
movq 0x167fd(%rip), %rdi     # 0x22fc0
callq 0x3440
movq %rax, %rdi
movl $0x20, %esi
callq 0x32c0
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0xc7b3
jmp 0xc7e2
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0xc783
movq 0x167cc(%rip), %rdi     # 0x22fc0
movl $0xa, %esi
callq 0x32c0
movl $0x0, -0x38(%rbp)
movq -0xe8(%rbp), %rdi
callq 0xf8c0
xorb $-0x1, %al
testb $0x1, %al
jne 0xc81c
jmp 0xcb28
movq -0xe8(%rbp), %rdi
callq 0xf8e0
movq %rax, %rsi
leaq -0x90(%rbp), %rdi
callq 0x5c00
movq -0xe8(%rbp), %rdi
callq 0xf900
jmp 0xc845
movq 0x16774(%rip), %rdi     # 0x22fc0
leaq 0xcaf5(%rip), %rsi      # 0x19348
callq 0x3270
movq %rax, -0x110(%rbp)
jmp 0xc861
movq -0x110(%rbp), %rdi
movl -0x64(%rbp), %esi
callq 0x3440
movq %rax, -0x118(%rbp)
jmp 0xc879
movl $0x4, %edi
callq 0x6a80
movl %eax, -0x11c(%rbp)
jmp 0xc88b
movq -0x118(%rbp), %rdi
movl -0x11c(%rbp), %eax
movl %eax, -0xa0(%rbp)
movl -0xa0(%rbp), %esi
callq 0x32b0
movq %rax, -0x128(%rbp)
jmp 0xc8b2
movq -0x128(%rbp), %rdi
leaq 0xca86(%rip), %rsi      # 0x19346
callq 0x3270
jmp 0xc8c7
leaq -0x90(%rbp), %rdi
callq 0x5b10
movl %eax, -0x12c(%rbp)
jmp 0xc8db
movl -0x12c(%rbp), %eax
movl %eax, -0xa4(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x5b30
movl %eax, -0x130(%rbp)
jmp 0xc8fb
movl -0x130(%rbp), %eax
movl %eax, -0xa8(%rbp)
movl $0x0, -0xac(%rbp)
movl -0xac(%rbp), %eax
cmpl -0xa4(%rbp), %eax
jge 0xc984
movq 0x1669a(%rip), %rdi     # 0x22fc0
leaq 0xc76f(%rip), %rsi      # 0x1909c
callq 0x3270
movq %rax, -0x138(%rbp)
jmp 0xc93b
movq -0x138(%rbp), %rdi
movl $0x20, %esi
callq 0x32c0
jmp 0xc94e
jmp 0xc950
movl -0xac(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xac(%rbp)
jmp 0xc911
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x98(%rbp)
movl %eax, -0x9c(%rbp)
leaq -0x90(%rbp), %rdi
callq 0x4190
jmp 0xcb31
movq 0x16635(%rip), %rdi     # 0x22fc0
leaq 0xc9bb(%rip), %rsi      # 0x1934d
callq 0x3270
movq %rax, -0x140(%rbp)
jmp 0xc9a0
movq -0x140(%rbp), %rdi
movl $0x20, %esi
callq 0x32c0
jmp 0xc9b3
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb0(%rbp)
movq -0xd8(%rbp), %rdi
movl -0xb0(%rbp), %eax
movl %eax, -0x144(%rbp)
callq 0x8680
movl %eax, %ecx
movl -0x144(%rbp), %eax
cmpl %ecx, %eax
jg 0xca90
movl -0xb0(%rbp), %eax
cmpl -0x38(%rbp), %eax
jg 0xca26
movq 0x165c4(%rip), %rdi     # 0x22fc0
leaq 0xc94a(%rip), %rsi      # 0x1934d
callq 0x3270
movq %rax, -0x150(%rbp)
jmp 0xca11
movq -0x150(%rbp), %rdi
movl $0x20, %esi
callq 0x32c0
jmp 0xca24
jmp 0xca7a
movq 0x16593(%rip), %rdi     # 0x22fc0
leaq 0xc91b(%rip), %rsi      # 0x1934f
callq 0x3270
movq %rax, -0x158(%rbp)
jmp 0xca42
movq -0x158(%rbp), %rdi
movl $0x20, %esi
callq 0x32c0
jmp 0xca55
movl -0xa8(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0xa8(%rbp)
cmpl $0x0, -0xa8(%rbp)
jne 0xca78
movl -0xb0(%rbp), %eax
movl %eax, -0x38(%rbp)
jmp 0xca90
jmp 0xca7a
jmp 0xca7c
movl -0xb0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb0(%rbp)
jmp 0xc9c2
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb4(%rbp)
movq -0xd8(%rbp), %rdi
movl -0xb4(%rbp), %eax
movl %eax, -0x15c(%rbp)
callq 0x8680
movl %eax, %ecx
movl -0x15c(%rbp), %eax
cmpl %ecx, %eax
jg 0xcb02
movq 0x164f9(%rip), %rdi     # 0x22fc0
leaq 0xc5ce(%rip), %rsi      # 0x1909c
callq 0x3270
movq %rax, -0x168(%rbp)
jmp 0xcadc
movq -0x168(%rbp), %rdi
movl $0x20, %esi
callq 0x32c0
jmp 0xcaef
jmp 0xcaf1
movl -0xb4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xb4(%rbp)
jmp 0xca9c
movq 0x164b7(%rip), %rdi     # 0x22fc0
movq 0x164a0(%rip), %rsi     # 0x22fb0
callq 0x3290
jmp 0xcb17
leaq -0x90(%rbp), %rdi
callq 0x4190
jmp 0xc805
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
movq -0x98(%rbp), %rdi
callq 0x3450
nopl (%rax)