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

```asm
<test_mod_exp_sizes>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x60,%rsp
  mov    %rdi,-0x58(%rbp)
  mov    %rsi,-0x60(%rbp)
  movl   $0x0,-0x44(%rbp)
  mov    -0x60(%rbp),%rax
  mov    %rax,%rdi
  call   <BN_CTX_start@plt>
  mov    -0x60(%rbp),%rax
  mov    %rax,%rdi
  call   <BN_CTX_get@plt>
  mov    %rax,-0x40(%rbp)
  mov    -0x60(%rbp),%rax
  mov    %rax,%rdi
  call   <BN_CTX_get@plt>
  mov    %rax,-0x38(%rbp)
  mov    -0x60(%rbp),%rax
  mov    %rax,%rdi
  call   <BN_CTX_get@plt>
  mov    %rax,-0x30(%rbp)
  mov    -0x60(%rbp),%rax
  mov    %rax,%rdi
  call   <BN_CTX_get@plt>
  mov    %rax,-0x28(%rbp)
  mov    -0x60(%rbp),%rax
  mov    %rax,%rdi
  call   <BN_CTX_get@plt>
  mov    %rax,-0x20(%rbp)
  mov    $0x0,%eax
  call   <BN_MONT_CTX_new@plt>
  mov    %rax,-0x18(%rbp)
  cmpq   $0x0,-0x20(%rbp)
  je     L35
  cmpq   $0x0,-0x18(%rbp)
  je     L35
  mov    -0x40(%rbp),%rax
  mov    $0x0,%r9d
  mov    $0x0,%r8d
  mov    $0x0,%ecx
  mov    $0x0,%edx
  mov    $0x20,%esi
  mov    %rax,%rdi
  call   <BN_generate_prime_ex@plt>
  test   %eax,%eax
  je     L101
  mov    -0x60(%rbp),%rdx
  mov    -0x40(%rbp),%rcx
  mov    -0x18(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <BN_MONT_CTX_set@plt>
  test   %eax,%eax
  je     L101
  movl   $0x20,-0x48(%rbp)
  jmp    L102
L80:
  mov    -0x48(%rbp),%esi
  mov    -0x38(%rbp),%rax
  mov    $0x0,%ecx
  mov    $0xffffffff,%edx
  mov    %rax,%rdi
  call   <BN_rand@plt>
  test   %eax,%eax
  je     L64
  mov    -0x48(%rbp),%esi
  mov    -0x30(%rbp),%rax
  mov    $0x0,%ecx
  mov    $0xffffffff,%edx
  mov    %rax,%rdi
  call   <BN_rand@plt>
  test   %eax,%eax
  je     L64
  mov    -0x18(%rbp),%r8
  mov    -0x60(%rbp),%rdi
  mov    -0x40(%rbp),%rcx
  mov    -0x30(%rbp),%rdx
  mov    -0x38(%rbp),%rsi
  mov    -0x28(%rbp),%rax
  mov    %r8,%r9
  mov    %rdi,%r8
  mov    %rax,%rdi
  call   <BN_mod_exp_mont_consttime@plt>
  test   %eax,%eax
  je     L64
  mov    -0x60(%rbp),%rdi
  mov    -0x40(%rbp),%rcx
  mov    -0x30(%rbp),%rdx
  mov    -0x38(%rbp),%rsi
  mov    -0x20(%rbp),%rax
  mov    %rdi,%r8
  mov    %rax,%rdi
  call   <BN_mod_exp@plt>
  test   %eax,%eax
  je     L64
  mov    -0x20(%rbp),%rdx
  mov    -0x28(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <BN_cmp@plt>
  test   %rax,%rax
  je     L107
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <BN_bn2hex@plt>
  mov    %rax,-0x10(%rbp)
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <BN_bn2hex@plt>
  mov    %rax,-0x8(%rbp)
  mov    -0x8(%rbp),%rcx
  mov    -0x10(%rbp),%rdx
  mov    -0x48(%rbp),%eax
  mov    %eax,%esi
  lea    D6(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  jmp    L111
L107:
  addl   $0x8,-0x48(%rbp)
L102:
  cmpl   $0x3ff,-0x48(%rbp)
  jle    L80
  movl   $0x1,-0x44(%rbp)
  jmp    L111
L35:
  nop
  jmp    L111
L101:
  nop
  jmp    L111
L64:
  nop
L111:
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <BN_MONT_CTX_free@plt>
  mov    -0x60(%rbp),%rax
  mov    %rax,%rdi
  call   <BN_CTX_end@plt>
  mov    -0x44(%rbp),%eax
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: label: D6
type_infered: string

tool: D6: Incorrect answer at size %d: %s vs %s


assistant: ```c
int test_mod_exp_sizes(BIO *bp, BN_CTX *ctx) {
  BN_MONT_CTX *mont_ctx;
  BIGNUM *p, *x, *y, *r, *r2;
  int size;
  int ok = 0;
  BN_CTX_start(ctx);
  p = BN_CTX_get(ctx);
  x = BN_CTX_get(ctx);
  y = BN_CTX_get(ctx);
  r = BN_CTX_get(ctx);
  r2 = BN_CTX_get(ctx);
  mont_ctx = BN_MONT_CTX_new();
  if (r2 == NULL || mont_ctx == NULL)
    goto err;
  if (!BN_generate_prime_ex(p, 32, 0, NULL, NULL, NULL) || !BN_MONT_CTX_set(mont_ctx, p, ctx))
    goto err;
  for (size = 32; size < 1024; size += 8) {
    if (!BN_rand(x, size, -1, 0) || !BN_rand(y, size, -1, 0) || !BN_mod_exp_mont_consttime(r, x, y, p, ctx, mont_ctx) || !BN_mod_exp(r2, x, y, p, ctx))
      goto err;
    if (BN_cmp(r, r2) != 0) {
      char *r_str = BN_bn2hex(r);
      char *r2_str = BN_bn2hex(r2);
      printf("Incorrect answer at size %d: %s vs %s\n", size, r_str, r2_str);
      free(r_str);
      free(r2_str);
      goto err;
    }
  }
  ok = 1;
err:
  BN_MONT_CTX_free(mont_ctx);
  BN_CTX_end(ctx);
  return ok;
}
```