user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<beta_RSA_padding_add_PKCS1_OAEP_mgf1>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x58,%rsp
  mov    %rdi,-0x50(%rbp)
  mov    %rdx,-0x60(%rbp)
  mov    %ecx,-0x44(%rbp)
  mov    %r8,-0x58(%rbp)
  mov    %r9d,-0x48(%rbp)
  mov    0x10(%rbp),%r14
  mov    0x18(%rbp),%r12
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  lea    -0x1(%rsi),%ebx
  mov    D3(%rip),%rax
  movslq (%rax),%rax
  add    $0xf,%rax
  mov    %rax,%rcx
  and    $0xfffffffffffffff0,%rcx
  and    $0xfffffffffffff000,%rax
  mov    %rsp,%rdx
  sub    %rax,%rdx
L172:
  cmp    %rdx,%rsp
  je     L75
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L172
L75:
  mov    %rcx,%rax
  and    $0xfff,%eax
  sub    %rax,%rsp
  test   %rax,%rax
  je     L45
  orq    $0x0,-0x8(%rsp,%rax,1)
L45:
  mov    %rsp,-0x80(%rbp)
  test   %r14,%r14
  je     L32
L76:
  test   %r12,%r12
  cmove  %r14,%r12
  mov    %r14,%rdi
  call   <EVP_MD_size@plt>
  mov    %eax,%r15d
  lea    (%rax,%rax,1),%r13d
  mov    %ebx,%eax
  sub    %r13d,%eax
  cmp    %ebx,%r13d
  jge    L145
  mov    %eax,-0x64(%rbp)
  mov    -0x44(%rbp),%edx
  cmp    %edx,%eax
  jg     L55
L145:
  mov    $0x0,%eax
L149:
  mov    -0x38(%rbp),%rdx
  sub    %fs:0x28,%rdx
  jne    L104
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L32:
  mov    $0x0,%eax
  call   <EVP_sha1@plt>
  mov    %rax,%r14
  jmp    L76
L55:
  mov    -0x50(%rbp),%rdi
  movb   $0x0,(%rdi)
  movslq %r15d,%rsi
  mov    %rsi,-0x70(%rbp)
  lea    0x1(%rdi,%rsi,1),%rsi
  mov    $0x0,%r9d
  mov    %r14,%r8
  mov    $0x0,%ecx
  mov    %rsi,-0x78(%rbp)
  mov    %rsi,%rdx
  mov    -0x48(%rbp),%esi
  mov    -0x58(%rbp),%rdi
  call   <EVP_Digest@plt>
  test   %eax,%eax
  je     L149
  mov    -0x50(%rbp),%rdi
  add    $0x1,%rdi
  mov    %rdi,-0x58(%rbp)
  mov    %ebx,%r14d
  sub    -0x44(%rbp),%r14d
  sub    %r13d,%r14d
  lea    -0x1(%r14),%edx
  mov    -0x78(%rbp),%r13
  mov    %r13,%rdi
  add    -0x70(%rbp),%rdi
  mov    $0x0,%esi
  call   <memset@plt>
  add    %r15d,%r14d
  movslq %r14d,%r14
  movb   $0x1,-0x1(%r13,%r14,1)
  movslq %ebx,%rdi
  mov    -0x44(%rbp),%edx
  movslq %edx,%rax
  sub    %rax,%rdi
  sub    -0x70(%rbp),%rdi
  mov    %r13,%r14
  add    %r13,%rdi
  mov    -0x60(%rbp),%rsi
  call   <memcpy@plt>
  mov    %r15d,%esi
  mov    -0x58(%rbp),%rdi
  call   <RAND_bytes@plt>
  mov    %rax,%rdx
  mov    $0x0,%eax
  test   %rdx,%rdx
  jle    L149
  mov    -0x64(%rbp),%ebx
  add    %r15d,%ebx
  mov    %ebx,%edi
  call   <OPENSSL_malloc@plt>
  mov    %rax,%r13
  mov    $0x0,%eax
  test   %r13,%r13
  je     L149
  mov    %r12,%r8
  mov    %r15d,%ecx
  mov    -0x58(%rbp),%rdx
  mov    %ebx,%esi
  mov    %r13,%rdi
  call   <beta_PKCS1_MGF1@plt>
  mov    %rax,%rdx
  mov    $0x0,%eax
  test   %rdx,%rdx
  js     L149
  test   %ebx,%ebx
  jle    L94
  mov    %ebx,%ecx
  mov    $0x0,%eax
  mov    %r14,%rdx
L141:
  movzbl 0x0(%r13,%rax,1),%esi
  xor    %sil,(%rdx,%rax,1)
  add    $0x1,%rax
  cmp    %rcx,%rax
  jne    L141
L94:
  mov    %r12,%r8
  mov    %ebx,%ecx
  mov    -0x78(%rbp),%rdx
  mov    %r15d,%esi
  mov    -0x80(%rbp),%rbx
  mov    %rbx,%rdi
  call   <beta_PKCS1_MGF1@plt>
  mov    %rax,%rdx
  mov    $0x0,%eax
  test   %rdx,%rdx
  js     L149
  test   %r15d,%r15d
  jle    L67
  lea    0x1(%r15),%ecx
  mov    $0x1,%eax
  mov    %rbx,%rdi
  mov    -0x50(%rbp),%rdx
L91:
  movzbl -0x1(%rdi,%rax,1),%esi
  xor    %sil,(%rdx,%rax,1)
  add    $0x1,%rax
  cmp    %rax,%rcx
  jne    L91
L67:
  mov    %r13,%rdi
  call   <OPENSSL_free@plt>
  mov    $0x1,%eax
  jmp    L149
L104:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int beta_RSA_padding_add_PKCS1_OAEP_mgf1(unsigned char *to, int tlen, const unsigned char *from, int flen, const unsigned char *param, int plen, const EVP_MD *md, const EVP_MD *mgf1md) {
  int i, emlen = tlen - 1;
  unsigned char *db, *seed;
  unsigned char *dbmask, seedmask[EVP_MAX_MD_SIZE];
  int mdlen;
  if (md == NULL)
    md = EVP_sha1();
  if (mgf1md == NULL)
    mgf1md = md;
  mdlen = EVP_MD_size(md);
  if (flen > emlen - 2 * mdlen - 1) {
    return 0;
  }
  if (emlen < 2 * mdlen + 1) {
    return 0;
  }
  to[0] = 0;
  seed = to + 1;
  db = to + mdlen + 1;
  if (!EVP_Digest((void *)param, plen, db, NULL, md, NULL))
    return 0;
  memset(db + mdlen, 0, emlen - flen - 2 * mdlen - 1);
  db[emlen - flen - mdlen - 1] = 0x01;
  memcpy(db + emlen - flen - mdlen, from, (unsigned int)flen);
  if (RAND_bytes(seed, mdlen) <= 0)
    return 0;
  dbmask = OPENSSL_malloc(emlen - mdlen);
  if (dbmask == NULL) {
    return 0;
  }
  if (beta_PKCS1_MGF1(dbmask, emlen - mdlen, seed, mdlen, mgf1md) < 0)
    return 0;
  for (i = 0; i < emlen - mdlen; i++)
    db[i] ^= dbmask[i];
  if (beta_PKCS1_MGF1(seedmask, mdlen, db, emlen - mdlen, mgf1md) < 0)
    return 0;
  for (i = 0; i < mdlen; i++)
    seed[i] ^= seedmask[i];
  OPENSSL_free(dbmask);
  return 1;
}
```