user: What is the c source code of the assembly code below:

```asm
<CheckX509Hostname>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,0x8(%rsp)
  test   %rdi,%rdi
  je     L159
  mov    %rsi,%r14
  mov    %edx,%r12d
  test   %edx,%edx
  jle    L94
  test   %rsi,%rsi
  je     L45
L94:
  test   %r12d,%r12d
  js     L125
  mov    D19(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,0x4(%rsp)
  mov    D25(%rip),%rax
  mov    (%rax),%r15d
  mov    $0x0,%ecx
  mov    $0x0,%edx
  mov    D22(%rip),%rax
  mov    (%rax),%esi
  mov    0x8(%rsp),%rdi
  call   <X509_get_ext_d2i@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L161
  mov    %rax,%rdi
  call   <sk_GENERAL_NAME_num@plt>
  mov    %eax,%r13d
  test   %eax,%eax
  jle    L171
  mov    $0x0,%ebx
  movb   $0x1,0x3(%rsp)
  jmp    L82
L169:
  add    $0x1,%ebx
  cmp    %ebx,%r13d
  je     L66
L82:
  mov    %ebx,%esi
  mov    %rbp,%rdi
  call   <sk_GENERAL_NAME_value@plt>
  cmp    %r15d,(%rax)
  jne    L169
  mov    0x8(%rax),%rdi
  mov    $0x1,%ecx
  mov    %r12d,%edx
  mov    %r14,%rsi
  call   <CheckX509HostnameMatch@plt>
  test   %rax,%rax
  jne    L71
  movb   $0x0,0x3(%rsp)
  jmp    L169
L66:
  mov    %rbp,%rdi
  call   <GENERAL_NAMES_free@plt>
  cmpb   $0x0,0x3(%rsp)
  jne    L161
  mov    $0x0,%eax
L103:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L74:
  mov    $0x0,%eax
  jmp    L103
L159:
  mov    $0xfffffffe,%eax
  jmp    L103
L45:
  mov    $0xfffffffd,%eax
  jmp    L103
L125:
  mov    $0xfffffffc,%eax
  jmp    L103
L71:
  mov    %rbp,%rdi
  call   <GENERAL_NAMES_free@plt>
  mov    $0x1,%eax
  jmp    L103
L171:
  mov    %rbp,%rdi
  call   <GENERAL_NAMES_free@plt>
L161:
  mov    0x8(%rsp),%rdi
  call   <X509_get_subject_name@plt>
  mov    %rax,%rbp
  mov    $0xffffffff,%ebx
  mov    $0x0,%eax
  test   %rbp,%rbp
  je     L103
L19:
  mov    %ebx,%edx
  mov    0x4(%rsp),%esi
  mov    %rbp,%rdi
  call   <X509_NAME_get_index_by_NID@plt>
  mov    %eax,%ebx
  test   %eax,%eax
  js     L74
  mov    %ebx,%esi
  mov    %rbp,%rdi
  call   <X509_NAME_get_entry@plt>
  mov    %rax,%rdi
  call   <X509_NAME_ENTRY_get_data@plt>
  mov    %rax,%rdi
  mov    $0x0,%ecx
  mov    %r12d,%edx
  mov    %r14,%rsi
  call   <CheckX509HostnameMatch@plt>
  test   %rax,%rax
  je     L19
  mov    $0x1,%eax
  jmp    L103
```

assistant: ```c
int32_t CheckX509Hostname(X509 *x509, const char *hostname, int32_t cchHostname) {
  if (!x509)
    return -2;
  if (cchHostname > 0 && !hostname)
    return -3;
  if (cchHostname < 0)
    return -4;
  int subjectNid = NID_commonName;
  int sanGenType = GEN_DNS;
  GENERAL_NAMES *san = X509_get_ext_d2i(x509, NID_subject_alt_name, NULL, NULL);
  char readSubject = 1;
  int success = 0;
  if (san) {
    int i;
    int count = sk_GENERAL_NAME_num(san);
    for (i = 0; i < count; ++i) {
      GENERAL_NAME *sanEntry = sk_GENERAL_NAME_value(san, i);
      if (sanEntry->type != sanGenType) {
        continue;
      }
      readSubject = 0;
      if (CheckX509HostnameMatch(sanEntry->d.dNSName, hostname, cchHostname, 1)) {
        success = 1;
        break;
      }
    }
    GENERAL_NAMES_free(san);
  }
  if (readSubject && !success) {
    X509_NAME *subject = X509_get_subject_name(x509);
    if (subject) {
      int i = -1;
      while ((i = X509_NAME_get_index_by_NID(subject, subjectNid, i)) >= 0) {
        X509_NAME_ENTRY *nameEnt = X509_NAME_get_entry(subject, i);
        ASN1_STRING *cn = X509_NAME_ENTRY_get_data(nameEnt);
        if (CheckX509HostnameMatch(cn, hostname, cchHostname, 0)) {
          success = 1;
          break;
        }
      }
    }
  }
  return success;
}
```