// File: toxaart[P]hierarchical_block_sparse_lib/test_source/test_matrix_alloc_problem.cc
// Function: main
int main(int argc, const char* argv[]) {
  if(argc != 6) {
    std::cerr << "Please give 5 args: N blockSize nMat nRep nonzeroFraction" << std::endl;
    return -1;
  }
  int N = atoi(argv[1]);
  int blockSize = atoi(argv[2]);
  int nMat = atoi(argv[3]);
  int nRep = atoi(argv[4]);
  double nonzeroFraction = atof(argv[5]);
  std::cout << "N = " << N << std::endl;
  std::cout << "blockSize = " << blockSize << std::endl;
  std::cout << "nMat = " << nMat << std::endl;
  std::cout << "nRep = " << nRep << std::endl;
  std::cout << "nonzeroFraction = " << nonzeroFraction << std::endl;
  if(N < 7) {
    std::cerr << "Error: N must be 7 or greater." << std::endl;
    return -1;
  }
  if(nonzeroFraction < 0 || nonzeroFraction > 1) {
    std::cerr << "Error: nonzeroFraction must be between 0 and 1." << std::endl;
    return -1;
  }
  double nElementsPerMatrix = N*N*nonzeroFraction;
  double nBytesPerMatrix = nElementsPerMatrix * sizeof(double);
  double nBytesForAllMatrices = nBytesPerMatrix * nMat;
  double memUsageForAllMatricesInGB = nBytesForAllMatrices / ( 1000*1000*1000 );

  double startTime = get_wall_seconds();
  int resultCode = test_creation<hbsm::HierarchicalBlockSparseMatrix<double> >(N, blockSize, nonzeroFraction, nMat, nRep);
  double secondsTaken = get_wall_seconds() - startTime;
  printf("secondsTaken = %12.3f wall seconds\n", secondsTaken);
  return resultCode;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x6, -0x8(%rbp)
je 0x250a
movq 0xfb05(%rip), %rdi      # 0x11fe8
leaq 0x9b66(%rip), %rsi      # 0xc050
callq 0x2170
movq %rax, %rdi
movq 0xfaaf(%rip), %rsi      # 0x11fa8
callq 0x21a0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2759
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x2270
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x2270
movl %eax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x2270
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x2270
movl %eax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x2200
movsd %xmm0, -0x28(%rbp)
movq 0xfa65(%rip), %rdi      # 0x11fc8
leaq 0x9b20(%rip), %rsi      # 0xc08a
callq 0x2170
movq %rax, %rdi
movl -0x14(%rbp), %esi
callq 0x22c0
movq %rax, %rdi
movq 0xfa24(%rip), %rsi      # 0x11fa8
callq 0x21a0
movq 0xfa38(%rip), %rdi      # 0x11fc8
leaq 0x9af8(%rip), %rsi      # 0xc08f
callq 0x2170
movq %rax, %rdi
movl -0x18(%rbp), %esi
callq 0x22c0
movq %rax, %rdi
movq 0xf9f7(%rip), %rsi      # 0x11fa8
callq 0x21a0
movq 0xfa0b(%rip), %rdi      # 0x11fc8
leaq 0x9ad8(%rip), %rsi      # 0xc09c
callq 0x2170
movq %rax, %rdi
movl -0x1c(%rbp), %esi
callq 0x22c0
movq %rax, %rdi
movq 0xf9ca(%rip), %rsi      # 0x11fa8
callq 0x21a0
movq 0xf9de(%rip), %rdi      # 0x11fc8
leaq 0x9ab3(%rip), %rsi      # 0xc0a4
callq 0x2170
movq %rax, %rdi
movl -0x20(%rbp), %esi
callq 0x22c0
movq %rax, %rdi
movq 0xf99d(%rip), %rsi      # 0x11fa8
callq 0x21a0
movq 0xf9b1(%rip), %rdi      # 0x11fc8
leaq 0x9a8e(%rip), %rsi      # 0xc0ac
callq 0x2170
movq %rax, %rdi
movsd -0x28(%rbp), %xmm0
callq 0x2300
movq %rax, %rdi
movq 0xf96e(%rip), %rsi      # 0x11fa8
callq 0x21a0
cmpl $0x7, -0x14(%rbp)
jge 0x2673
movq 0xf99c(%rip), %rdi      # 0x11fe8
leaq 0x9a6c(%rip), %rsi      # 0xc0bf
callq 0x2170
movq %rax, %rdi
movq 0xf946(%rip), %rsi      # 0x11fa8
callq 0x21a0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2759
xorps %xmm0, %xmm0
ucomisd -0x28(%rbp), %xmm0
ja 0x2690
movsd -0x28(%rbp), %xmm0
movsd 0x997e(%rip), %xmm1     # 0xc008
ucomisd %xmm1, %xmm0
jbe 0x26be
movq 0xf951(%rip), %rdi      # 0x11fe8
leaq 0x9a40(%rip), %rsi      # 0xc0de
callq 0x2170
movq %rax, %rdi
movq 0xf8fb(%rip), %rsi      # 0x11fa8
callq 0x21a0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x2759
movl -0x14(%rbp), %eax
imull -0x14(%rbp), %eax
cvtsi2sd %eax, %xmm0
mulsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x30(%rbp)
movsd 0x993d(%rip), %xmm0     # 0xc018
mulsd -0x30(%rbp), %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x38(%rbp), %xmm0
cvtsi2sdl -0x1c(%rbp), %xmm1
mulsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x40(%rbp), %xmm0
movsd 0x990b(%rip), %xmm1     # 0xc010
divsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
callq 0x2770
movsd %xmm0, -0x50(%rbp)
movl -0x14(%rbp), %edi
movl -0x18(%rbp), %esi
movsd -0x28(%rbp), %xmm0
movl -0x1c(%rbp), %edx
movl -0x20(%rbp), %ecx
callq 0x2810
movl %eax, -0x54(%rbp)
callq 0x2770
subsd -0x50(%rbp), %xmm0
movsd %xmm0, -0x60(%rbp)
movsd -0x60(%rbp), %xmm0
leaq 0x99c2(%rip), %rdi      # 0xc10e
movb $0x1, %al
callq 0x2030
movl -0x54(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)