user: Please show me the C implementation that matches the assembly code listed below:

```asm
<solve_congruence>:
  endbr64
  push   %r15
  xor    %eax,%eax
  push   %r14
  mov    %rsi,%r14
  push   %r13
  push   %r12
  mov    %rdx,%r12
  push   %rbp
  push   %rbx
  mov    %edi,%ebx
  mov    %rdx,%rdi
  sub    $0x38,%rsp
  call   <prime_factors@plt>
  mov    $0x8,%esi
  cltq
  mov    (%rax),%rbp
  mov    %rax,0x28(%rsp)
  mov    %rbp,%rdi
  call   <calloc@plt>
  mov    $0x8,%esi
  mov    %rbp,%rdi
  mov    %rax,0x8(%rsp)
  call   <calloc@plt>
  mov    $0x8,%esi
  mov    %rbp,%rdi
  mov    %rax,0x20(%rsp)
  mov    %rax,%r15
  call   <calloc@plt>
  mov    %rax,0x10(%rsp)
  test   %rbp,%rbp
  jle    L13
  mov    0x28(%rsp),%rax
  mov    %r15,%rsi
  mov    %r15,%r13
  xor    %r15d,%r15d
  add    $0x8,%rax
  sub    %rsi,%rax
  mov    %ebx,%esi
  mov    %r13,%rbx
  mov    %rax,0x18(%rsp)
  mov    %r12,%rax
  mov    %esi,%r13d
  mov    %r15,%r12
  mov    %rax,%r15
  nopl   0x0(%rax,%rax,1)
L3:
  mov    0x18(%rsp),%rax
  mov    $0x1,%r8d
  lea    (%rax,%rbx,1),%rdi
  mov    %r15,%rax
  mov    (%rdi),%r11
  cqto
  mov    %r11,%rcx
  mov    %r11,(%rbx)
  imul   %r11,%rcx
  idiv   %rcx
  test   %rdx,%rdx
  jne    L51
  nopl   0x0(%rax)
L15:
  mov    %rcx,(%rbx)
  mov    (%rdi),%r11
  mov    %r15,%rax
  add    $0x1,%r8d
  cqto
  imul   %r11,%rcx
  idiv   %rcx
  test   %rdx,%rdx
  je     L15
L51:
  mov    %r11,%rdx
  mov    %r14,%rsi
  mov    %r8d,%ecx
  mov    %r13d,%edi
  xor    %eax,%eax
  add    $0x8,%rbx
  call   <solve_prime_power_congruence@plt>
  mov    0x8(%rsp),%rsi
  cltq
  lea    0x8(%rax),%rdx
  mov    (%rax),%rax
  mov    %rdx,(%rsi,%r12,8)
  mov    0x10(%rsp),%rsi
  mov    %eax,(%rsi,%r12,4)
  add    $0x1,%r12
  cmp    %r12,%rbp
  jne    L3
  mov    0x8(%rsp),%rbx
  mov    0x20(%rsp),%rcx
  mov    %rbp,%rdi
  xor    %eax,%eax
  mov    %rbx,%rdx
  mov    %rbx,%r15
  lea    (%rbx,%rbp,8),%rbx
  call   <solve_system_of_order_1_congruence_sets@plt>
  movslq %eax,%r14
  nopl   0x0(%rax,%rax,1)
L49:
  mov    (%r15),%rax
  add    $0x8,%r15
  lea    -0x8(%rax),%rdi
  call   <free@plt>
  cmp    %r15,%rbx
  jne    L49
L17:
  mov    0x10(%rsp),%rdi
  call   <free@plt>
  mov    0x8(%rsp),%rdi
  call   <free@plt>
  mov    0x20(%rsp),%rdi
  call   <free@plt>
  mov    0x28(%rsp),%rdi
  call   <free@plt>
  add    $0x38,%rsp
  mov    %r14,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L13:
  mov    0x20(%rsp),%rcx
  mov    0x8(%rsp),%rdx
  mov    %rax,%rsi
  mov    %rbp,%rdi
  xor    %eax,%eax
  call   <solve_system_of_order_1_congruence_sets@plt>
  movslq %eax,%r14
  jmp    L17
```

assistant: ```c
long *solve_congruence(int funcDegree, long funcCoeffs[], long mod) {
  long *solutionList;
  long *modFactorList = prime_factors(mod);
  long numOfModFactors = *modFactorList;
  long *modFactors = modFactorList + 1;
  long **primePowerSolutions = calloc(numOfModFactors, sizeof(long *));
  long *primePowers = calloc(numOfModFactors, sizeof(long));
  int *primePowerSolutionLengths = calloc(numOfModFactors, sizeof(int *));
  int power;
  int i, j, k;
  for (i = 0; i < numOfModFactors; i++) {
    primePowers[i] = modFactors[i];
    power = 1;
    while (mod % (primePowers[i] * modFactors[i]) == 0) {
      primePowers[i] *= modFactors[i];
      power++;
    }
    primePowerSolutions[i] = solve_prime_power_congruence(funcDegree, funcCoeffs, modFactors[i], power);
    primePowerSolutionLengths[i] = *(primePowerSolutions[i]++);
  }
  solutionList = solve_system_of_order_1_congruence_sets(numOfModFactors, primePowerSolutionLengths, primePowerSolutions, primePowers);
  for (i = 0; i < numOfModFactors; i++) {
    free(primePowerSolutions[i] - 1);
  }
  free(primePowerSolutionLengths);
  free(primePowerSolutions);
  free(primePowers);
  free(modFactorList);
  return solutionList;
}
```