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

```asm
<test_mod_exp_sizes>:
  endbr64
  push   %r15
  mov    %rsi,%rdi
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  sub    $0x18,%rsp
  call   <BN_CTX_start@plt>
  mov    %rbp,%rdi
  call   <BN_CTX_get@plt>
  mov    %rbp,%rdi
  mov    %rax,%r15
  call   <BN_CTX_get@plt>
  mov    %rbp,%rdi
  mov    %rax,%rbx
  call   <BN_CTX_get@plt>
  mov    %rbp,%rdi
  mov    %rax,%r12
  call   <BN_CTX_get@plt>
  mov    %rbp,%rdi
  mov    %rax,(%rsp)
  call   <BN_CTX_get@plt>
  mov    %rax,%r14
  xor    %eax,%eax
  call   <BN_MONT_CTX_new@plt>
  mov    %rax,0x8(%rsp)
  test   %r14,%r14
  je     L21
  mov    %rax,%r13
  test   %rax,%rax
  je     L21
  xor    %r9d,%r9d
  xor    %r8d,%r8d
  xor    %ecx,%ecx
  xor    %edx,%edx
  mov    $0x20,%esi
  mov    %r15,%rdi
  call   <BN_generate_prime_ex@plt>
  test   %eax,%eax
  je     L21
  mov    %rbp,%rdx
  mov    %r15,%rsi
  mov    %r13,%rdi
  call   <BN_MONT_CTX_set@plt>
  test   %eax,%eax
  je     L21
  mov    $0x20,%r13d
  jmp    L94
  nopl   0x0(%rax,%rax,1)
L20:
  xor    %ecx,%ecx
  mov    $0xffffffff,%edx
  mov    %r13d,%esi
  mov    %r12,%rdi
  call   <BN_rand@plt>
  test   %eax,%eax
  je     L21
  mov    0x8(%rsp),%r9
  mov    (%rsp),%rdi
  mov    %rbp,%r8
  mov    %r15,%rcx
  mov    %r12,%rdx
  mov    %rbx,%rsi
  call   <BN_mod_exp_mont_consttime@plt>
  test   %eax,%eax
  je     L21
  mov    %rbp,%r8
  mov    %r15,%rcx
  mov    %r12,%rdx
  mov    %rbx,%rsi
  mov    %r14,%rdi
  call   <BN_mod_exp@plt>
  test   %eax,%eax
  je     L21
  mov    (%rsp),%rdi
  mov    %r14,%rsi
  call   <BN_cmp@plt>
  test   %rax,%rax
  jne    L110
  add    $0x8,%r13d
  cmp    $0x400,%r13d
  je     L106
L94:
  xor    %ecx,%ecx
  mov    $0xffffffff,%edx
  mov    %r13d,%esi
  mov    %rbx,%rdi
  call   <BN_rand@plt>
  test   %eax,%eax
  jne    L20
L21:
  xor    %r12d,%r12d
L87:
  mov    0x8(%rsp),%rdi
  call   <BN_MONT_CTX_free@plt>
  mov    %rbp,%rdi
  call   <BN_CTX_end@plt>
  add    $0x18,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L110:
  mov    (%rsp),%rdi
  call   <BN_bn2hex@plt>
  mov    %r14,%rdi
  mov    %rax,%r15
  call   <BN_bn2hex@plt>
  mov    %r15,%rdx
  mov    %r13d,%esi
  lea    D4(%rip),%rdi
  mov    %rax,%rcx
  mov    %rax,%r12
  call   <printf@plt>
  mov    %r15,%rdi
  call   <free@plt>
  mov    %r12,%rdi
  xor    %r12d,%r12d
  call   <free@plt>
  jmp    L87
  nopl   0x0(%rax)
L106:
  mov    $0x1,%r12d
  jmp    L87
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D4
type_infered: string

tool: D4: 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;
}
```