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

```asm
<decrypt>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %rdi,%r12
  mov    %esi,0xc(%rsp)
  mov    %rdx,0x10(%rsp)
  mov    %ecx,%ebx
  mov    %r8,0x18(%rsp)
  mov    %r9,%r15
  mov    0x70(%rsp),%r14
  mov    0x78(%rsp),%r13
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  movl   $0x0,0x24(%rsp)
  call   <EVP_CIPHER_CTX_new@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L166
L15:
  mov    $0x0,%eax
  call   <EVP_aes_256_gcm@plt>
  mov    %rax,%rsi
  mov    $0x0,%r8d
  mov    $0x0,%ecx
  mov    $0x0,%edx
  mov    %rbp,%rdi
  call   <EVP_DecryptInit_ex@plt>
  test   %eax,%eax
  je     L75
L83:
  mov    $0x0,%ecx
  mov    $0x10,%edx
  mov    D8(%rip),%rax
  mov    (%rax),%esi
  mov    %rbp,%rdi
  call   <EVP_CIPHER_CTX_ctrl@plt>
  test   %eax,%eax
  je     L90
L122:
  mov    %r14,%r8
  mov    %r15,%rcx
  mov    $0x0,%edx
  mov    $0x0,%esi
  mov    %rbp,%rdi
  call   <EVP_DecryptInit_ex@plt>
  test   %eax,%eax
  je     L159
L201:
  lea    0x24(%rsp),%rdx
  mov    %ebx,%r8d
  mov    0x10(%rsp),%rcx
  mov    $0x0,%esi
  mov    %rbp,%rdi
  call   <EVP_DecryptUpdate@plt>
  test   %eax,%eax
  je     L6
L21:
  mov    0xc(%rsp),%eax
  lea    -0xf(%rax),%r14d
  test   %r14d,%r14d
  jle    L69
  mov    $0x0,%ebx
  lea    0x24(%rsp),%r15
  jmp    L150
L166:
  mov    $0x0,%eax
  call   <handleErrors@plt>
  jmp    L15
L75:
  call   <handleErrors@plt>
  jmp    L83
L90:
  call   <handleErrors@plt>
  jmp    L122
L159:
  call   <handleErrors@plt>
  jmp    L201
L6:
  call   <handleErrors@plt>
  jmp    L21
L179:
  mov    %ebx,%eax
  add    0x24(%rsp),%eax
  mov    %eax,%ebx
  cmp    %r14d,%eax
  jge    L29
L150:
  movslq %ebx,%rsi
  lea    (%r12,%rsi,1),%rcx
  add    %r13,%rsi
  mov    $0x10,%r8d
  mov    %r15,%rdx
  mov    %rbp,%rdi
  call   <EVP_DecryptUpdate@plt>
  cmp    $0x1,%eax
  je     L179
  mov    $0x0,%eax
  call   <handleErrors@plt>
  jmp    L179
L69:
  mov    $0x0,%ebx
L29:
  movslq %ebx,%rsi
  lea    (%r12,%rsi,1),%rcx
  lea    0x24(%rsp),%rdx
  add    %r13,%rsi
  mov    0xc(%rsp),%r8d
  sub    %ebx,%r8d
  mov    %rbp,%rdi
  call   <EVP_DecryptUpdate@plt>
  cmp    $0x1,%eax
  jne    L182
L197:
  add    0x24(%rsp),%ebx
  mov    0x18(%rsp),%rcx
  mov    $0x10,%edx
  mov    D4(%rip),%rax
  mov    (%rax),%esi
  mov    %rbp,%rdi
  call   <EVP_CIPHER_CTX_ctrl@plt>
  test   %eax,%eax
  je     L43
L92:
  lea    0x24(%rsp),%rdx
  movslq %ebx,%rax
  lea    0x0(%r13,%rax,1),%rsi
  mov    %rbp,%rdi
  call   <EVP_DecryptFinal_ex@plt>
  mov    %eax,%r12d
  mov    %rbp,%rdi
  call   <EVP_CIPHER_CTX_free@plt>
  test   %r12d,%r12d
  jle    L147
  add    0x24(%rsp),%ebx
L70:
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L73
  mov    %ebx,%eax
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L182:
  mov    $0x0,%eax
  call   <handleErrors@plt>
  jmp    L197
L43:
  call   <handleErrors@plt>
  jmp    L92
L147:
  mov    $0xffffffff,%ebx
  jmp    L70
L73:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int decrypt(unsigned char *ciphertext, int ciphertext_len, unsigned char *aad, int aad_len, unsigned char *tag, unsigned char *key, unsigned char *iv, unsigned char *plaintext) {
  EVP_CIPHER_CTX *ctx;
  int len = 0, plaintext_len = 0, ret;
  if (!(ctx = EVP_CIPHER_CTX_new()))
    handleErrors();
  if (!EVP_DecryptInit_ex(ctx, EVP_aes_256_gcm(), NULL, NULL, NULL))
    handleErrors();
  if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_IVLEN, 16, NULL))
    handleErrors();
  if (!EVP_DecryptInit_ex(ctx, NULL, NULL, key, iv))
    handleErrors();
  if (!EVP_DecryptUpdate(ctx, NULL, &len, aad, aad_len))
    handleErrors();
  while (plaintext_len <= ciphertext_len - 16) {
    if (1 != EVP_DecryptUpdate(ctx, plaintext + plaintext_len, &len, ciphertext + plaintext_len, 16))
      handleErrors();
    plaintext_len += len;
  }
  if (1 != EVP_DecryptUpdate(ctx, plaintext + plaintext_len, &len, ciphertext + plaintext_len, ciphertext_len - plaintext_len))
    handleErrors();
  plaintext_len += len;
  if (!EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_GCM_SET_TAG, 16, tag))
    handleErrors();
  ret = EVP_DecryptFinal_ex(ctx, plaintext + plaintext_len, &len);
  EVP_CIPHER_CTX_free(ctx);
  if (ret > 0) {
    plaintext_len += len;
    return plaintext_len;
  } else {
    return -1;
  }
}
```