// File: /workspace/github_c_makefile_star2_O0/millimat[P]Soft-Heap/run-tests.c
// Function: coprime_test
static void coprime_test(int elems[], int results[][2]) {
  printf("----------COPRIME TEST----------\n");
  printf("Inserting integers (%d * i) mod %d into a soft heap for i = 0 to %d...\n",
         MAGIC_PRIME_ONE, MAGIC_PRIME_TWO, N_ELEMENTS - 1);

  softheap *P = makeheap_empty(EPSILON);
  for(int i = 0; i < N_ELEMENTS; i++) {
    int num = (MAGIC_PRIME_ONE * i) % MAGIC_PRIME_TWO;
    elems[i] = num;
    insert(P, num);
  }

  printf("Sorting correctness array...\n");
  qsort(elems, N_ELEMENTS, sizeof(int), intcmp);
  
  
  int ckey_corruptions = 0, pos_corruptions = 0;
  printf("Extracting elements with ckeys...\n");
  for(int i = 0; i < N_ELEMENTS; i++) {
    results[i][0] = extract_min_with_ckey(P, &results[i][1]);
    if(results[i][0] < results[i][1]) ckey_corruptions++;
    if(results[i][0] != elems[i]) pos_corruptions++;
  }
  
  report_corruptions(ckey_corruptions, pos_corruptions, N_ELEMENTS);  
  free(P);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq 0x1c84(%rip), %rdi      # 0x317b
movb $0x0, %al
callq 0x1050
leaq 0x1c98(%rip), %rdi      # 0x319d
movl $0x577, %esi            # imm = 0x577
movl $0x445, %edx            # imm = 0x445
movl $0xfffff, %ecx          # imm = 0xFFFFF
movb $0x0, %al
callq 0x1050
movsd 0x1ae5(%rip), %xmm0     # 0x3008
callq 0x19d0
movq %rax, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
cmpl $0x100000, -0x1c(%rbp)  # imm = 0x100000
jge 0x1573
imull $0x577, -0x1c(%rbp), %eax # imm = 0x577
movl $0x445, %ecx            # imm = 0x445
cltd
idivl %ecx
movl %edx, -0x20(%rbp)
movl -0x20(%rbp), %edx
movq -0x8(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x18(%rbp), %rdi
movl -0x20(%rbp), %esi
callq 0x1c40
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x1533
leaq 0x1c6b(%rip), %rdi      # 0x31e5
movb $0x0, %al
callq 0x1050
movq -0x8(%rbp), %rdi
movl $0x100000, %esi         # imm = 0x100000
movl $0x4, %edx
leaq 0x2ca(%rip), %rcx       # 0x1860
callq 0x1040
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
leaq 0x1abb(%rip), %rdi      # 0x306b
movb $0x0, %al
callq 0x1050
movl $0x0, -0x2c(%rbp)
cmpl $0x100000, -0x2c(%rbp)  # imm = 0x100000
jge 0x1643
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rsi
movslq -0x2c(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
addq $0x4, %rsi
callq 0x2080
movl %eax, %edx
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movl %edx, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movl (%rax,%rcx,8), %eax
movq -0x10(%rbp), %rcx
movslq -0x2c(%rbp), %rdx
cmpl 0x4(%rcx,%rdx,8), %eax
jge 0x1612
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
movq -0x10(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movl (%rax,%rcx,8), %eax
movq -0x8(%rbp), %rcx
movslq -0x2c(%rbp), %rdx
cmpl (%rcx,%rdx,4), %eax
je 0x1633
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x1635
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x15be
movl -0x24(%rbp), %edi
movl -0x28(%rbp), %esi
movl $0x100000, %edx         # imm = 0x100000
callq 0x17f0
movq -0x18(%rbp), %rdi
callq 0x1030
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)