// File: aronszanto[P]strassen/main.cpp
// Function: main
int main(int argc, char *argv[]){
    convThreshold = 32;
    threadThresh = 512;
    if (argc == 2){
        switch (stoi(argv[1])){
            case 1:
                testStrasMult();
                return 0;
            case 2:
                testConvMult();
                return 0;
            case 3:
                testfindOptDim();
                return 0;
            case 4:
                testInitPadding();
                return 0;
            case 5:
                testRandMatrix();
                return 0;
            case 6:
                testPowers2();
                return 0;
            case 7:
                findOptimalThreadThresh();
                return 0;
            case 8:
                findOptimalconvThreshold();
                return 0;
            default:
                return -1;
        }
        return 0;

    }
    else if (argc == 3 && stoi(argv[1]) == 9){
        cout << timeRandMult(stoi(argv[2]));
    }
    else if (argc != 4)
        std::cout<<"Incorrect numargs, proper: \'0 dimension inputfile\'";
    else if (stoi(argv[1]) == 0)
    {
        int dimension = atoi(argv[2]);
        char* inputfile = argv[3];

    

        Matrix* A = FileToMatrix(inputfile, dimension, 0);
        Matrix* B = FileToMatrix(inputfile, dimension, 0);

        Matrix* C = multiply(A,B);

        printDiagonal(C, dimension);
        return 0;
    }
    
    else return -1;

}

// Assembly:
subq $0x158, %rsp            # imm = 0x158
movl $0x0, 0x154(%rsp)
movl %edi, 0x150(%rsp)
movq %rsi, 0x148(%rsp)
movl $0x20, 0x11f7d(%rip)    # 0x1f198
movl $0x200, 0x11f6f(%rip)   # imm = 0x200
cmpl $0x2, 0x150(%rsp)
jne 0xd3d1
movq 0x148(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x68(%rsp)
leaq 0x127(%rsp), %rdi
movq %rdi, 0x70(%rsp)
callq 0x22b0
movq 0x68(%rsp), %rsi
movq 0x70(%rsp), %rdx
leaq 0x128(%rsp), %rdi
callq 0x21d0
jmp 0xd26f
xorl %eax, %eax
movl %eax, %esi
leaq 0x128(%rsp), %rdi
movl $0xa, %edx
callq 0xec20
movl %eax, 0x64(%rsp)
jmp 0xd28b
leaq 0x128(%rsp), %rdi
callq 0x2100
leaq 0x127(%rsp), %rdi
callq 0x21b0
movl 0x64(%rsp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, 0x58(%rsp)
subl $0x7, %eax
ja 0xd3c1
movq 0x58(%rsp), %rax
leaq 0xad59(%rip), %rcx      # 0x18020
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x118(%rsp)
movl %eax, 0x114(%rsp)
jmp 0xd307
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x118(%rsp)
movl %eax, 0x114(%rsp)
leaq 0x128(%rsp), %rdi
callq 0x2100
leaq 0x127(%rsp), %rdi
callq 0x21b0
jmp 0xd79f
callq 0x66a0
movl $0x0, 0x154(%rsp)
jmp 0xd790
callq 0x59a0
movl $0x0, 0x154(%rsp)
jmp 0xd790
callq 0xc480
movl $0x0, 0x154(%rsp)
jmp 0xd790
callq 0xc550
movl $0x0, 0x154(%rsp)
jmp 0xd790
callq 0x58d0
movl $0x0, 0x154(%rsp)
jmp 0xd790
callq 0xcd90
movl $0x0, 0x154(%rsp)
jmp 0xd790
callq 0x5800
movl $0x0, 0x154(%rsp)
jmp 0xd790
callq 0x54a0
movl $0x0, 0x154(%rsp)
jmp 0xd790
movl $0xffffffff, 0x154(%rsp) # imm = 0xFFFFFFFF
jmp 0xd790
movl 0x150(%rsp), %ecx
movb $0x0, 0xee(%rsp)
movb $0x0, 0xed(%rsp)
xorl %eax, %eax
cmpl $0x3, %ecx
movb %al, 0x57(%rsp)
jne 0xd469
movq 0x148(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x40(%rsp)
leaq 0xef(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x22b0
movq 0x40(%rsp), %rsi
movq 0x48(%rsp), %rdx
movb $0x1, 0xee(%rsp)
leaq 0xf0(%rsp), %rdi
callq 0x21d0
jmp 0xd437
movb $0x1, 0xed(%rsp)
xorl %eax, %eax
movl %eax, %esi
leaq 0xf0(%rsp), %rdi
movl $0xa, %edx
callq 0xec20
movl %eax, 0x3c(%rsp)
jmp 0xd45b
movl 0x3c(%rsp), %eax
cmpl $0x9, %eax
sete %al
movb %al, 0x57(%rsp)
movb 0x57(%rsp), %al
movb %al, 0x3b(%rsp)
testb $0x1, 0xed(%rsp)
jne 0xd47d
jmp 0xd48a
leaq 0xf0(%rsp), %rdi
callq 0x2100
testb $0x1, 0xee(%rsp)
jne 0xd496
jmp 0xd4a3
leaq 0xef(%rsp), %rdi
callq 0x21b0
movb 0x3b(%rsp), %al
testb $0x1, %al
jne 0xd4b0
jmp 0xd5f8
movq 0x148(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x28(%rsp)
leaq 0xc7(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0x22b0
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
leaq 0xc8(%rsp), %rdi
callq 0x21d0
jmp 0xd4ec
xorl %eax, %eax
movl %eax, %esi
leaq 0xc8(%rsp), %rdi
movl $0xa, %edx
callq 0xec20
movl %eax, 0x24(%rsp)
jmp 0xd508
movl 0x24(%rsp), %edi
callq 0x56a0
movsd %xmm0, 0x18(%rsp)
jmp 0xd519
movsd 0x18(%rsp), %xmm0
movq 0x11aaa(%rip), %rdi     # 0x1efd0
callq 0x22d0
jmp 0xd52d
leaq 0xc8(%rsp), %rdi
callq 0x2100
leaq 0xc7(%rsp), %rdi
callq 0x21b0
jmp 0xd78e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x118(%rsp)
movl %eax, 0x114(%rsp)
jmp 0xd591
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x118(%rsp)
movl %eax, 0x114(%rsp)
testb $0x1, 0xed(%rsp)
jne 0xd582
jmp 0xd58f
leaq 0xf0(%rsp), %rdi
callq 0x2100
jmp 0xd591
testb $0x1, 0xee(%rsp)
jne 0xd59d
jmp 0xd5aa
leaq 0xef(%rsp), %rdi
callq 0x21b0
jmp 0xd79f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x118(%rsp)
movl %eax, 0x114(%rsp)
jmp 0xd5e6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x118(%rsp)
movl %eax, 0x114(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x2100
leaq 0xc7(%rsp), %rdi
callq 0x21b0
jmp 0xd79f
cmpl $0x4, 0x150(%rsp)
je 0xd61a
movq 0x119c7(%rip), %rdi     # 0x1efd0
leaq 0xb7d5(%rip), %rsi      # 0x18de5
callq 0x2180
jmp 0xd78c
movq 0x148(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x8(%rsp)
leaq 0x9f(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x22b0
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
leaq 0xa0(%rsp), %rdi
callq 0x21d0
jmp 0xd656
xorl %eax, %eax
movl %eax, %esi
leaq 0xa0(%rsp), %rdi
movl $0xa, %edx
callq 0xec20
movl %eax, 0x4(%rsp)
jmp 0xd672
leaq 0xa0(%rsp), %rdi
callq 0x2100
leaq 0x9f(%rsp), %rdi
callq 0x21b0
movl 0x4(%rsp), %eax
cmpl $0x0, %eax
jne 0xd77f
movq 0x148(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x2230
movl %eax, 0x98(%rsp)
movq 0x148(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x90(%rsp)
movq 0x90(%rsp), %rdi
movl 0x98(%rsp), %esi
xorl %edx, %edx
callq 0xcf80
movq %rax, 0x88(%rsp)
movq 0x90(%rsp), %rdi
movl 0x98(%rsp), %esi
xorl %edx, %edx
callq 0xcf80
movq %rax, 0x80(%rsp)
movq 0x88(%rsp), %rdi
movq 0x80(%rsp), %rsi
callq 0x5220
movq %rax, 0x78(%rsp)
movq 0x78(%rsp), %rdi
movl 0x98(%rsp), %esi
callq 0xd180
movl $0x0, 0x154(%rsp)
jmp 0xd790
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x118(%rsp)
movl %eax, 0x114(%rsp)
jmp 0xd770
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x118(%rsp)
movl %eax, 0x114(%rsp)
leaq 0xa0(%rsp), %rdi
callq 0x2100
leaq 0x9f(%rsp), %rdi
callq 0x21b0
jmp 0xd79f
movl $0xffffffff, 0x154(%rsp) # imm = 0xFFFFFFFF
jmp 0xd790
jmp 0xd78e
jmp 0xd790
movl 0x154(%rsp), %eax
addq $0x158, %rsp            # imm = 0x158
retq
movq 0x118(%rsp), %rdi
callq 0x22a0
nopl (%rax)