user: Converte this assembly snippet into its equivalent C code:

```asm
<ASN1_TIME_adj_internal>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x20,%rsp
  mov    %rdi,%r12
  mov    %esi,0xc(%rsp)
  mov    %edx,%r13d
  mov    %rcx,%r14
  mov    %r8d,%ebp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  lea    0x14(%rsp),%rsi
  lea    0xc(%rsp),%rdi
  call   <gmtime_r@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L131
  test   %r13d,%r13d
  jne    L166
  test   %r14,%r14
  jne    L166
L88:
  cmp    $0x80,%ebp
  je     L23
  cmp    $0x81,%ebp
  je     L106
  mov    $0x0,%ebx
  test   %ebp,%ebp
  je     L80
L131:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L73
  mov    %rbx,%rax
  add    $0x20,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L166:
  lea    0x14(%rsp),%rdi
  mov    %r14,%rdx
  mov    %r13d,%esi
  call   <OPENSSL_gmtime_adj@plt>
  test   %eax,%eax
  jne    L88
  mov    $0x0,%ebx
  jmp    L131
L23:
  lea    0x14(%rsp),%rdi
  call   <utctime_string_from_tm@plt>
  mov    %rax,%rbp
L81:
  test   %rbp,%rbp
  je     L55
  test   %r12,%r12
  je     L119
  mov    %rbp,%rdi
  call   <strlen@plt>
  cmp    $0xd,%rax
  je     L201
  cmp    $0xf,%rax
  jne    L82
L86:
  movl   $0x81,(%r12)
  mov    %r12,%rbx
  mov    $0xf,%r12d
L129:
  mov    0x8(%rbx),%rdi
  call   <free@plt>
  mov    %rbp,0x8(%rbx)
  mov    %r12,0x10(%rbx)
  jmp    L131
L106:
  lea    0x14(%rsp),%rdi
  call   <gentime_string_from_tm@plt>
  mov    %rax,%rbp
  jmp    L81
L80:
  lea    0x14(%rsp),%rdi
  call   <rfc5280_string_from_tm@plt>
  mov    %rax,%rbp
  jmp    L81
L55:
  mov    D4(%rip),%rax
  mov    (%rax),%edi
  call   <ASN1error@plt>
  mov    %rbp,%rbx
  jmp    L131
L119:
  mov    $0x0,%eax
  call   <ASN1_TIME_new@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L229
  mov    %rbp,%rdi
  call   <strlen@plt>
  cmp    $0xd,%rax
  je     L201
  cmp    $0xf,%rax
  je     L86
  mov    %r12,%rdi
  call   <ASN1_TIME_free@plt>
L82:
  mov    %rbp,%rdi
  call   <free@plt>
  mov    $0x0,%ebx
  jmp    L131
L201:
  movl   $0x80,(%r12)
  mov    %r12,%rbx
  mov    $0xd,%r12d
  jmp    L129
L229:
  mov    %rax,%rbx
  jmp    L131
L73:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
ASN1_TIME *ASN1_TIME_adj_internal(ASN1_TIME *s, time_t t, int offset_day, long offset_sec, int mode) {
  int allocated = 0;
  struct tm tm;
  size_t len;
  char *p;
  if (gmtime_r(&t, &tm) == NULL)
    return (NULL);
  if (offset_day || offset_sec) {
    if (!OPENSSL_gmtime_adj(&tm, offset_day, offset_sec))
      return (NULL);
  }
  switch (mode) {
  case V_ASN1_UTCTIME:
    p = utctime_string_from_tm(&tm);
    break;
  case V_ASN1_GENERALIZEDTIME:
    p = gentime_string_from_tm(&tm);
    break;
  case 0:
    p = rfc5280_string_from_tm(&tm);
    break;
  default:
    return (NULL);
  }
  if (p == NULL) {
    ASN1error(ASN1_R_ILLEGAL_TIME_VALUE);
    return (NULL);
  }
  if (s == NULL) {
    if ((s = ASN1_TIME_new()) == NULL)
      return (NULL);
    allocated = 1;
  }
  len = strlen(p);
  switch (len) {
  case 15:
    s->type = V_ASN1_GENERALIZEDTIME;
    break;
  case 13:
    s->type = V_ASN1_UTCTIME;
    break;
  default:
    if (allocated)
      ASN1_TIME_free(s);
    free(p);
    return (NULL);
  }
  free(s->data);
  s->data = p;
  s->length = len;
  return (s);
}
```