// File: aronszanto[P]strassen/main.cpp
// Function: findOptimalconvThreshold()
void findOptimalconvThreshold() {

    for (convThreshold = 8; convThreshold <= 256; convThreshold*=2){
    //for (convThreshold = 2; convThreshold <= 64; convThreshold++){    

        
        
        double total = 0;
        //cout << "multiplying matrices, n = " << i << endl;
        for (int j = 0; j < 5; j ++){
            Matrix* m1 = new Matrix();
            Matrix* m2 = new Matrix();
            initMatrix(m1, 256);
            initMatrix(m2, 256);
            //cout << "populating m1" << endl;
            populateRandomMatrix(m1, 0, 1);
            //cout << "populating m2" << endl;
            populateRandomMatrix(m2, 0, 1);
            clock_t start;
            start = clock();
            
            Matrix* m3 = multiply(m1, m2);
            total += (std::clock() - start) / (double)(CLOCKS_PER_SEC);
            delete(m1);
            delete(m2);
            delete(m3);
        }

        cout << convThreshold << "\t" << total / 5 << endl;

        //cout << "finished multiplying.\n" << endl;
        
    }
}

// Assembly:
subq $0x58, %rsp
movl $0x8, 0x19cea(%rip)     # 0x1f198
cmpl $0x100, 0x19ce0(%rip)   # imm = 0x100
jg 0x569b
xorps %xmm0, %xmm0
movsd %xmm0, 0x50(%rsp)
movl $0x0, 0x4c(%rsp)
cmpl $0x5, 0x4c(%rsp)
jge 0x563e
movl $0x20, %edi
callq 0x2190
movq %rax, %rdi
movq %rdi, 0x10(%rsp)
xorl %esi, %esi
movl $0x20, %edx
callq 0x20e0
movq 0x10(%rsp), %rdi
callq 0xd950
movq 0x10(%rsp), %rax
movq %rax, 0x40(%rsp)
movl $0x20, %edi
callq 0x2190
movq %rax, %rdi
movq %rdi, 0x18(%rsp)
xorl %esi, %esi
movl $0x20, %edx
callq 0x20e0
movq 0x18(%rsp), %rdi
callq 0xd950
movq 0x18(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0x40(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x2440
movq 0x38(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x2440
movq 0x40(%rsp), %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0x5360
movq 0x38(%rsp), %rdi
xorl %esi, %esi
movl $0x1, %edx
callq 0x5360
callq 0x2120
movq %rax, 0x30(%rsp)
movq 0x40(%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0x5220
movq %rax, 0x28(%rsp)
callq 0x2120
subq 0x30(%rsp), %rax
cvtsi2sd %rax, %xmm0
movsd 0x12a5d(%rip), %xmm1    # 0x18010
divsd %xmm1, %xmm0
addsd 0x50(%rsp), %xmm0
movsd %xmm0, 0x50(%rsp)
movq 0x40(%rsp), %rax
movq %rax, 0x20(%rsp)
cmpq $0x0, %rax
je 0x55e7
movq 0x20(%rsp), %rdi
callq 0xd970
movq 0x20(%rsp), %rdi
callq 0x2170
movq 0x38(%rsp), %rax
movq %rax, 0x8(%rsp)
cmpq $0x0, %rax
je 0x560b
movq 0x8(%rsp), %rdi
callq 0xd970
movq 0x8(%rsp), %rdi
callq 0x2170
movq 0x28(%rsp), %rax
movq %rax, (%rsp)
cmpq $0x0, %rax
je 0x562c
movq (%rsp), %rdi
callq 0xd970
movq (%rsp), %rdi
callq 0x2170
jmp 0x562e
movl 0x4c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4c(%rsp)
jmp 0x54cf
movl 0x19b54(%rip), %esi     # 0x1f198
movq 0x19985(%rip), %rdi     # 0x1efd0
callq 0x2280
movq %rax, %rdi
leaq 0x13616(%rip), %rsi     # 0x18c70
callq 0x2180
movq %rax, %rdi
movsd 0x50(%rsp), %xmm0
movsd 0x12998(%rip), %xmm1    # 0x18008
divsd %xmm1, %xmm0
callq 0x22d0
movq %rax, %rdi
movq 0x19935(%rip), %rsi     # 0x1efb8
callq 0x21a0
movl 0x19b0a(%rip), %eax     # 0x1f198
shll %eax
movl %eax, 0x19b02(%rip)     # 0x1f198
jmp 0x54ae
addq $0x58, %rsp
retq