// File: /workspace/github_cpp_makefile_star2_O2/bendem[P]DiskGraph/src/main.cpp
// Function: main
int main(int argc, char** argv) {
    bool all = false;
    if(argc == 2) {
        string arg(argv[1]);
        if("-v" == arg) {
            cout << " Disk graphs by bendem, v" << VERSION << endl;
            return 0;
        }
        if("-h" == arg) {
            cout
                << " -h to get help" << endl
                << " -a to print all mounted partitions" << endl
                << " -v to get version" << endl
                ;
            return 0;
        }
        if("-a" == arg) {
            all = true;
        }
    }
    vector<string> output(exec("df --portability"));
    Table t(4);
    vector<unsigned> percents;
    bool first = true;

    // Parsing output and preparing formatting
    for(string line : output) {
        if(first) {
            // Ignoring header line
            first = false;
            continue;
        }

        vector<string> fields = split(line, ' ', 6);
        if(!all && fields[0].substr(0, 5) != "/dev/") {
            continue;
        }

        percents.push_back(parseInt(fields[4].substr(0, fields[4].length()-1)));
        unsigned usedBytes = parseInt(fields[2]);
        unsigned availBytes = parseInt(fields[3]);
        auto used = humanReadable(usedBytes);
        auto total = humanReadable(availBytes + usedBytes);
        t.addLine({
            toString(used.first) + toString(used.second),
            "/",
            toString(total.first) + toString(total.second),
            fields[5]
        });
    }

    cout << ' ' << percents.size() << " disks:" << endl;

    const unsigned width = t.getTotalWidth();
    const TermSize ts = termSize();
    if(ts.width < width) {
        cout << "Terminal too small" << endl;
        return 0;
    }
    const unsigned graphWidth = ts.width - width - 2;
    for(unsigned i = 0; i < percents.size(); ++i) {
        cout << ' ' << displayGraph(percents[i], graphWidth, GRAPH_CHAR) << t.getLine(i) << endl;
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2b8, %rsp            # imm = 0x2B8
cmpl $0x2, %edi
jne 0x302f
movq 0x8(%rsi), %rsi
leaq -0x108(%rbp), %rdi
leaq -0x180(%rbp), %rdx
callq 0x2090
leaq 0x205e(%rip), %rdi      # 0x5061
leaq -0x108(%rbp), %rsi
callq 0x37d3
testb %al, %al
je 0x303b
movq 0x4f9e(%rip), %rdi      # 0x7fb8
leaq 0x2043(%rip), %rsi      # 0x5064
callq 0x2160
leaq 0x2051(%rip), %rsi      # 0x507e
jmp 0x308b
movl $0x0, -0x2c(%rbp)
jmp 0x30d2
leaq 0x2040(%rip), %rdi      # 0x5082
leaq -0x108(%rbp), %rsi
callq 0x37d3
testb %al, %al
je 0x30a6
movq 0x4f5f(%rip), %rdi      # 0x7fb8
leaq 0x2025(%rip), %rsi      # 0x5085
callq 0x2160
movq %rax, %rdi
callq 0x20c0
leaq 0x2021(%rip), %rsi      # 0x5095
movq %rax, %rdi
callq 0x2160
movq %rax, %rdi
callq 0x20c0
leaq 0x202e(%rip), %rsi      # 0x50b9
movq %rax, %rdi
callq 0x2160
movq %rax, %rdi
callq 0x20c0
xorl %ebx, %ebx
movl $0x0, -0x2c(%rbp)
jmp 0x30be
leaq 0x201f(%rip), %rdi      # 0x50cc
leaq -0x108(%rbp), %rsi
callq 0x37d3
movl %eax, -0x2c(%rbp)
movb $0x1, %bl
leaq -0x108(%rbp), %rdi
callq 0x22e8
testb %bl, %bl
je 0x34aa
leaq 0x1ff6(%rip), %rsi      # 0x50cf
leaq -0x108(%rbp), %rdi
leaq -0x180(%rbp), %rdx
callq 0x2090
leaq -0x120(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x3cf0
leaq -0x108(%rbp), %rdi
callq 0x22e8
leaq -0x180(%rbp), %rdi
pushq $0x4
popq %rsi
callq 0x4414
xorps %xmm0, %xmm0
leaq -0x50(%rbp), %rax
movaps %xmm0, (%rax)
andq $0x0, 0x10(%rax)
movq -0x120(%rbp), %rsi
movq -0x118(%rbp), %rax
movq %rax, -0x80(%rbp)
leaq -0xe8(%rbp), %r12
leaq -0xc8(%rbp), %rax
movq %rax, -0x60(%rbp)
movb $0x1, %bl
leaq -0xa8(%rbp), %rax
movq %rax, -0x58(%rbp)
leaq -0x2e0(%rbp), %r13
cmpq -0x80(%rbp), %rsi
je 0x3418
movq %r13, %rdi
movq %rsi, -0x88(%rbp)
callq 0x21c0
testb $0x1, %bl
jne 0x33fe
leaq -0x2c0(%rbp), %rbx
movq %rbx, %rdi
movq %r13, %rsi
callq 0x21c0
leaq -0x78(%rbp), %rdi
movq %rbx, %rsi
pushq $0x20
popq %rdx
pushq $0x6
popq %rcx
callq 0x40b3
movq %rbx, %rdi
callq 0x22e8
cmpb $0x0, -0x2c(%rbp)
jne 0x31ee
movq -0x78(%rbp), %rsi
leaq -0x108(%rbp), %r15
movq %r15, %rdi
xorl %edx, %edx
pushq $0x5
popq %rcx
callq 0x2180
movq %r15, %rdi
leaq 0x1f09(%rip), %rsi      # 0x50e0
callq 0x37ec
movl %eax, %ebx
movq %r15, %rdi
callq 0x22e8
testb %bl, %bl
jne 0x33f5
movq -0x78(%rbp), %rsi
movq 0x88(%rsi), %rcx
subq $-0x80, %rsi
decq %rcx
leaq -0x248(%rbp), %rbx
movq %rbx, %rdi
xorl %edx, %edx
callq 0x2180
movq %rbx, %rdi
callq 0x4038
movl %eax, -0x108(%rbp)
leaq -0x50(%rbp), %rdi
leaq -0x108(%rbp), %rsi
callq 0x3b78
leaq -0x248(%rbp), %rdi
callq 0x22e8
movq -0x78(%rbp), %rsi
addq $0x40, %rsi
leaq -0x2a0(%rbp), %r15
movq %r15, %rdi
callq 0x21c0
movq %r15, %rdi
callq 0x4038
movl %eax, %ebx
movq %r15, %rdi
callq 0x22e8
movq -0x78(%rbp), %rsi
addq $0x60, %rsi
leaq -0x280(%rbp), %r14
movq %r14, %rdi
callq 0x21c0
movq %r14, %rdi
callq 0x4038
movl %eax, %r15d
movq %r14, %rdi
callq 0x22e8
leaq -0x148(%rbp), %rdi
movl %ebx, %esi
callq 0x3fa4
addl %ebx, %r15d
leaq -0x1e8(%rbp), %rbx
movq %rbx, %rdi
movl %r15d, %esi
callq 0x3fa4
leaq -0x1c0(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0x386a
leaq -0x228(%rbp), %r15
movq %r15, %rdi
leaq -0x140(%rbp), %rsi
callq 0x38df
leaq -0x108(%rbp), %rdi
leaq -0x1c0(%rbp), %rsi
movq %r15, %rdx
callq 0x37f9
movq %r12, %rdi
leaq 0x1dea(%rip), %rsi      # 0x50e4
leaq -0x2e(%rbp), %rdx
callq 0x2090
leaq -0x1a0(%rbp), %rdi
movq %rbx, %rsi
callq 0x386a
leaq -0x208(%rbp), %rbx
movq %rbx, %rdi
leaq -0x1e0(%rbp), %rsi
callq 0x38df
leaq -0xc8(%rbp), %rdi
movq %rdi, %r15
leaq -0x1a0(%rbp), %rsi
movq %rbx, %rdx
callq 0x37f9
movq -0x78(%rbp), %rsi
movl $0xa0, %eax
addq %rax, %rsi
leaq -0xa8(%rbp), %rdi
movq %rdi, %r15
callq 0x21c0
leaq -0x260(%rbp), %rbx
movq %rbx, %rdi
leaq -0x108(%rbp), %rsi
pushq $0x4
popq %rdx
leaq -0x2d(%rbp), %rcx
callq 0x376e
leaq -0x180(%rbp), %rdi
movq %rbx, %rsi
callq 0x449e
movq %rbx, %rdi
callq 0x37a8
pushq $0x60
popq %rbx
leaq (%rbx,%rbp), %rdi
addq $-0x108, %rdi           # imm = 0xFEF8
callq 0x22e8
addq $-0x20, %rbx
cmpq $-0x20, %rbx
jne 0x3393
leaq -0x208(%rbp), %rdi
callq 0x22e8
leaq -0x1a0(%rbp), %rdi
callq 0x22e8
leaq -0x228(%rbp), %rdi
callq 0x22e8
leaq -0x1c0(%rbp), %rdi
callq 0x22e8
leaq -0x1e0(%rbp), %rdi
callq 0x22e8
leaq -0x140(%rbp), %rdi
callq 0x22e8
leaq -0x78(%rbp), %rdi
callq 0x37a8
movq %r13, %rdi
callq 0x22e8
movq -0x88(%rbp), %rsi
addq $0x20, %rsi
xorl %ebx, %ebx
jmp 0x3161
movq 0x4b99(%rip), %rdi      # 0x7fb8
pushq $0x20
popq %rsi
callq 0x2190
movq -0x48(%rbp), %rsi
subq -0x50(%rbp), %rsi
sarq $0x2, %rsi
movq %rax, %rdi
callq 0x20f0
leaq 0x1ca4(%rip), %rsi      # 0x50e6
movq %rax, %rdi
callq 0x2160
movq %rax, %rdi
callq 0x20c0
leaq -0x180(%rbp), %rdi
callq 0x454e
movl %eax, %r14d
callq 0x3e04
movq %rax, %rbx
subl %r14d, %ebx
jae 0x34be
movq 0x4b43(%rip), %rdi      # 0x7fb8
leaq 0x1c72(%rip), %rsi      # 0x50ee
callq 0x2160
movq %rax, %rdi
callq 0x20c0
leaq -0x50(%rbp), %rdi
callq 0x3b54
leaq -0x180(%rbp), %rdi
callq 0x3952
leaq -0x120(%rbp), %rdi
callq 0x37a8
xorl %eax, %eax
addq $0x2b8, %rsp            # imm = 0x2B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addl $-0x2, %ebx
xorl %r14d, %r14d
leaq -0x108(%rbp), %r13
leaq -0x148(%rbp), %r12
movl %r14d, %r14d
movq -0x48(%rbp), %rax
subq -0x50(%rbp), %rax
sarq $0x2, %rax
cmpq %r14, %rax
jbe 0x3489
movq 0x4acb(%rip), %rdi      # 0x7fb8
pushq $0x20
popq %rsi
callq 0x2190
movq %rax, %r15
movq -0x50(%rbp), %rax
movl (%rax,%r14,4), %esi
movq %r13, %rdi
movl %ebx, %edx
pushq $0x3d
popq %rcx
callq 0x3e38
movq %r15, %rdi
movq %r13, %rsi
callq 0x2140
movq %rax, %r15
movq %r12, %rdi
leaq -0x180(%rbp), %rsi
movl %r14d, %edx
callq 0x456e
movq %r15, %rdi
movq %r12, %rsi
callq 0x2140
movq %rax, %rdi
callq 0x20c0
movq %r12, %rdi
callq 0x22e8
movq %r13, %rdi
callq 0x22e8
incl %r14d
jmp 0x34d2
jmp 0x3569
jmp 0x3768
movq %rax, %r14
jmp 0x373c
jmp 0x3576
movq %rax, %r14
jmp 0x3748
jmp 0x3768
movq %rax, %r14
leaq -0x108(%rbp), %rdi
callq 0x22e8
jmp 0x3748
jmp 0x3768
jmp 0x35ea
movq %rax, %r14
leaq -0x108(%rbp), %rdi
jmp 0x370d
movq %rax, %r14
jmp 0x3601
movq %rax, %r14
xorl %ebx, %ebx
jmp 0x36b1
movq %rax, %r14
jmp 0x36fa
jmp 0x35ea
movq %rax, %r14
jmp 0x35e1
movq %rax, %r14
jmp 0x3706
movq %rax, %r14
leaq -0x2a0(%rbp), %rdi
jmp 0x370d
jmp 0x35ea
movq %rax, %r14
leaq -0x108(%rbp), %r12
xorl %ebx, %ebx
jmp 0x36b5
jmp 0x35ea
movq %rax, %r14
jmp 0x3712
movq %rax, %r14
leaq -0x260(%rbp), %rdi
callq 0x37a8
pushq $0x60
popq %rbx
leaq (%rbx,%rbp), %rdi
addq $-0x108, %rdi           # imm = 0xFEF8
callq 0x22e8
addq $-0x20, %rbx
cmpq $-0x20, %rbx
jne 0x3604
movb $0x1, %bl
jmp 0x3691
movq %rax, %r14
xorl %ebx, %ebx
jmp 0x36a5
movq %rax, %r14
xorl %ebx, %ebx
leaq -0x108(%rbp), %r12
jmp 0x36c1
movq %rax, %r14
leaq -0x280(%rbp), %rdi
jmp 0x370d
jmp 0x364b
movq %rax, %r14
jmp 0x375f
jmp 0x3768
jmp 0x3768
movq %rax, %r14
leaq -0x2c0(%rbp), %rdi
callq 0x22e8
jmp 0x371b
movq %rax, %r14
jmp 0x371b
movq %rax, %r14
leaq -0x248(%rbp), %rdi
jmp 0x370d
movq %rax, %r14
xorl %ebx, %ebx
movq %r15, -0x58(%rbp)
leaq -0x208(%rbp), %rdi
callq 0x22e8
movq -0x58(%rbp), %rax
movq %rax, -0x60(%rbp)
leaq -0x1a0(%rbp), %rdi
callq 0x22e8
movq -0x60(%rbp), %r12
leaq -0x228(%rbp), %rdi
callq 0x22e8
leaq -0x1c0(%rbp), %rdi
callq 0x22e8
leaq -0x108(%rbp), %rax
cmpq %r12, %rax
sete %al
testb %bl, %bl
jne 0x36fa
testb %al, %al
jne 0x36fa
leaq -0x108(%rbp), %rbx
addq $-0x20, %r12
movq %r12, %rdi
callq 0x22e8
cmpq %rbx, %r12
jne 0x36e9
leaq -0x1e0(%rbp), %rdi
callq 0x22e8
leaq -0x140(%rbp), %rdi
callq 0x22e8
leaq -0x78(%rbp), %rdi
callq 0x37a8
leaq -0x2e0(%rbp), %rdi
callq 0x22e8
leaq -0x50(%rbp), %rdi
callq 0x3b54
leaq -0x180(%rbp), %rdi
callq 0x3952
leaq -0x120(%rbp), %rdi
callq 0x37a8
movq %r14, %rdi
callq 0x2290
movq %rax, %r14
leaq -0x148(%rbp), %rdi
callq 0x22e8
leaq -0x108(%rbp), %rdi
jmp 0x3722
movq %rax, %r14
jmp 0x3727
nop