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

```asm
<nysiis>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %rdi,-0x48(%rbp)
  mov    -0x48(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %rax,-0x28(%rbp)
  mov    -0x48(%rbp),%rax
  mov    %rax,%rdi
  call   <strdup@plt>
  mov    %rax,-0x20(%rbp)
  cmpq   $0x0,-0x20(%rbp)
  jne    L62
  mov    $0x0,%eax
  jmp    L564
L62:
  mov    -0x20(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L667
  mov    -0x20(%rbp),%rax
  jmp    L564
L667:
  mov    -0x28(%rbp),%rax
  add    $0x1,%rax
  mov    %rax,%rdi
  call   <malloc@plt>
  mov    %rax,-0x18(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  jne    L551
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    $0x0,%eax
  jmp    L564
L551:
  mov    -0x20(%rbp),%rax
  mov    $0x3,%edx
  lea    D47(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncmp@plt>
  test   %eax,%eax
  jne    L3
  mov    -0x20(%rbp),%rax
  add    $0x1,%rax
  movb   $0x43,(%rax)
  jmp    L34
L3:
  mov    -0x20(%rbp),%rax
  mov    $0x3,%edx
  lea    D23(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncmp@plt>
  test   %eax,%eax
  jne    L636
  mov    -0x20(%rbp),%rax
  movb   $0x4e,(%rax)
  jmp    L34
L636:
  mov    -0x20(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x4b,%al
  jne    L192
  mov    -0x20(%rbp),%rax
  movb   $0x43,(%rax)
  jmp    L34
L192:
  mov    -0x20(%rbp),%rax
  mov    $0x2,%edx
  lea    D50(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncmp@plt>
  test   %eax,%eax
  jne    L599
  mov    -0x20(%rbp),%rax
  movb   $0x46,(%rax)
  mov    -0x20(%rbp),%rax
  add    $0x1,%rax
  movb   $0x46,(%rax)
  jmp    L34
L599:
  mov    -0x20(%rbp),%rax
  mov    $0x3,%edx
  lea    D59(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncmp@plt>
  test   %eax,%eax
  jne    L34
  mov    -0x20(%rbp),%rax
  add    $0x1,%rax
  movb   $0x53,(%rax)
  mov    -0x20(%rbp),%rax
  add    $0x2,%rax
  movb   $0x53,(%rax)
L34:
  mov    -0x28(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  mov    %al,-0x3b(%rbp)
  cmpb   $0x45,-0x3b(%rbp)
  jne    L193
  mov    -0x28(%rbp),%rax
  lea    -0x2(%rax),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  mov    %al,-0x3a(%rbp)
  cmpb   $0x45,-0x3a(%rbp)
  je     L332
  cmpb   $0x49,-0x3a(%rbp)
  jne    L479
L332:
  mov    -0x28(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movb   $0x20,(%rax)
  mov    -0x28(%rbp),%rax
  lea    -0x2(%rax),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movb   $0x59,(%rax)
  jmp    L479
L193:
  cmpb   $0x54,-0x3b(%rbp)
  jne    L85
  mov    -0x28(%rbp),%rax
  lea    -0x2(%rax),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  mov    %al,-0x3a(%rbp)
  cmpb   $0x44,-0x3a(%rbp)
  je     L172
  cmpb   $0x52,-0x3a(%rbp)
  je     L172
  cmpb   $0x4e,-0x3a(%rbp)
  jne    L479
L172:
  mov    -0x28(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movb   $0x20,(%rax)
  mov    -0x28(%rbp),%rax
  lea    -0x2(%rax),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movb   $0x44,(%rax)
  jmp    L479
L85:
  cmpb   $0x44,-0x3b(%rbp)
  jne    L479
  mov    -0x28(%rbp),%rax
  lea    -0x2(%rax),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  mov    %al,-0x3a(%rbp)
  cmpb   $0x52,-0x3a(%rbp)
  je     L437
  cmpb   $0x4e,-0x3a(%rbp)
  jne    L479
L437:
  mov    -0x28(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movb   $0x20,(%rax)
  mov    -0x28(%rbp),%rax
  lea    -0x2(%rax),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movb   $0x44,(%rax)
L479:
  mov    -0x18(%rbp),%rax
  mov    %rax,-0x30(%rbp)
  mov    -0x20(%rbp),%rax
  mov    %rax,-0x38(%rbp)
  mov    -0x38(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x38(%rbp)
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    -0x30(%rbp),%rbx
  lea    0x1(%rbx),%rdx
  mov    %rdx,-0x30(%rbp)
  mov    %eax,%edi
  call   <toupper@plt>
  mov    %al,(%rbx)
  jmp    L531
L697:
  cmpb   $0x20,-0x3b(%rbp)
  je     L316
  movsbl -0x3b(%rbp),%eax
  sub    $0x41,%eax
  cmp    $0x19,%eax
  ja     L400
  mov    %eax,%eax
  lea    0x0(,%rax,4),%rdx
  lea    D42(%rip),%rax
  mov    (%rdx,%rax,1),%eax
  cltq
  lea    D42(%rip),%rdx
  add    %rdx,%rax
  notrack jmp *%rax
  mov    -0x38(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <toupper@plt>
  cmp    $0x56,%al
  jne    L538
  mov    -0x30(%rbp),%rax
  movb   $0x41,(%rax)
  addq   $0x1,-0x30(%rbp)
  mov    -0x30(%rbp),%rax
  movb   $0x46,(%rax)
  jmp    L224
L538:
  mov    -0x30(%rbp),%rax
  movb   $0x41,(%rax)
  jmp    L224
  mov    -0x30(%rbp),%rax
  movb   $0x47,(%rax)
  jmp    L224
  mov    -0x30(%rbp),%rax
  movb   $0x53,(%rax)
  jmp    L224
  mov    -0x30(%rbp),%rax
  movb   $0x4e,(%rax)
  jmp    L224
  mov    -0x38(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <toupper@plt>
  cmp    $0x4e,%al
  jne    L565
  mov    -0x30(%rbp),%rax
  movb   $0x4e,(%rax)
  jmp    L224
L565:
  mov    -0x30(%rbp),%rax
  movb   $0x43,(%rax)
  jmp    L224
  mov    -0x38(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <toupper@plt>
  cmp    $0x43,%al
  jne    L50
  mov    -0x38(%rbp),%rax
  add    $0x2,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <toupper@plt>
  cmp    $0x48,%al
  jne    L50
  mov    -0x30(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x30(%rbp)
  movb   $0x53,(%rax)
  mov    -0x30(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x30(%rbp)
  movb   $0x53,(%rax)
  mov    -0x30(%rbp),%rax
  movb   $0x53,(%rax)
  jmp    L224
L50:
  mov    -0x30(%rbp),%rax
  movb   $0x53,(%rax)
  jmp    L224
  mov    -0x38(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <toupper@plt>
  cmp    $0x48,%al
  jne    L593
  mov    -0x30(%rbp),%rax
  movb   $0x46,(%rax)
  addq   $0x1,-0x30(%rbp)
  mov    -0x30(%rbp),%rax
  movb   $0x46,(%rax)
  jmp    L224
L593:
  mov    -0x30(%rbp),%rax
  movb   $0x50,(%rax)
  jmp    L224
  mov    -0x38(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <toupper@plt>
  mov    %al,-0x3a(%rbp)
  mov    -0x38(%rbp),%rax
  sub    $0x1,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <toupper@plt>
  mov    %al,-0x39(%rbp)
  cmpb   $0x41,-0x3a(%rbp)
  je     L470
  cmpb   $0x45,-0x3a(%rbp)
  je     L470
  cmpb   $0x49,-0x3a(%rbp)
  je     L470
  cmpb   $0x4f,-0x3a(%rbp)
  je     L470
  cmpb   $0x55,-0x3a(%rbp)
  jne    L461
L470:
  cmpb   $0x41,-0x39(%rbp)
  je     L46
  cmpb   $0x45,-0x39(%rbp)
  je     L46
  cmpb   $0x49,-0x39(%rbp)
  je     L46
  cmpb   $0x4f,-0x39(%rbp)
  je     L46
  cmpb   $0x55,-0x39(%rbp)
  je     L46
L461:
  mov    -0x30(%rbp),%rax
  movzbl -0x39(%rbp),%edx
  mov    %dl,(%rax)
  jmp    L224
L46:
  mov    -0x30(%rbp),%rax
  movb   $0x48,(%rax)
  jmp    L224
  mov    -0x38(%rbp),%rax
  sub    $0x1,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <toupper@plt>
  mov    %al,-0x3a(%rbp)
  cmpb   $0x41,-0x3a(%rbp)
  je     L35
  cmpb   $0x45,-0x3a(%rbp)
  je     L35
  cmpb   $0x49,-0x3a(%rbp)
  je     L35
  cmpb   $0x4f,-0x3a(%rbp)
  je     L35
  cmpb   $0x55,-0x3a(%rbp)
  jne    L495
L35:
  mov    -0x30(%rbp),%rax
  movzbl -0x3a(%rbp),%edx
  mov    %dl,(%rax)
  jmp    L224
L495:
  mov    -0x30(%rbp),%rax
  movb   $0x57,(%rax)
  jmp    L224
L400:
  movsbl -0x3b(%rbp),%eax
  mov    %eax,%edi
  call   <toupper@plt>
  mov    -0x30(%rbp),%rdx
  mov    %al,(%rdx)
L224:
  mov    -0x30(%rbp),%rax
  movzbl (%rax),%edx
  mov    -0x30(%rbp),%rax
  sub    $0x1,%rax
  movzbl (%rax),%eax
  cmp    %al,%dl
  jne    L350
  mov    -0x18(%rbp),%rax
  add    $0x1,%rax
  cmp    %rax,-0x30(%rbp)
  jne    L263
L350:
  addq   $0x1,-0x30(%rbp)
L263:
  addq   $0x1,-0x38(%rbp)
L531:
  mov    -0x38(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <toupper@plt>
  mov    %al,-0x3b(%rbp)
  cmpb   $0x0,-0x3b(%rbp)
  jne    L697
  jmp    L510
L316:
  nop
L510:
  mov    -0x30(%rbp),%rax
  movb   $0x0,(%rax)
  mov    -0x30(%rbp),%rax
  movzbl -0x1(%rax),%eax
  mov    %al,-0x3b(%rbp)
  cmpb   $0x53,-0x3b(%rbp)
  jne    L367
  subq   $0x1,-0x30(%rbp)
  mov    -0x30(%rbp),%rax
  movb   $0x0,(%rax)
  jmp    L151
L367:
  cmpb   $0x59,-0x3b(%rbp)
  jne    L151
  mov    -0x30(%rbp),%rax
  sub    $0x2,%rax
  movzbl (%rax),%eax
  cmp    $0x41,%al
  jne    L151
  subq   $0x1,-0x30(%rbp)
  mov    -0x30(%rbp),%rax
  movb   $0x0,(%rax)
  subq   $0x1,-0x30(%rbp)
  mov    -0x30(%rbp),%rax
  movb   $0x59,(%rax)
L151:
  mov    -0x30(%rbp),%rax
  sub    $0x1,%rax
  movzbl (%rax),%eax
  cmp    $0x41,%al
  jne    L639
  mov    -0x30(%rbp),%rax
  sub    $0x1,%rax
  movb   $0x0,(%rax)
L639:
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x18(%rbp),%rax
L564:
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

tool_calls: name: retrieve_data
arguments: tag: D47
datatype: string
name: retrieve_data
arguments: tag: D23
datatype: string
name: retrieve_data
arguments: tag: D50
datatype: string
name: retrieve_data
arguments: tag: D59
datatype: string

tool: D47: MAC

tool: D23: KN

tool: D50: PH

tool: D59: SCH

assistant: ```c
char *nysiis(const char *str) {
  size_t len = strlen(str);
  char c1, c2, c3;
  char *copy, *code;
  char *p, *cp;
  copy = strdup(str);
  if (!copy) {
    return NULL;
  }
  if (!*copy) {
    return copy;
  }
  code = malloc(len + 1 * sizeof(char));
  if (!code) {
    free(copy);
    return NULL;
  }
  if (!strncmp(copy, "MAC", 3)) {
    copy[1] = 'C';
  } else if (!strncmp(copy, "KN", 3)) {
    copy[0] = 'N';
  } else if (copy[0] == 'K') {
    copy[0] = 'C';
  } else if (!strncmp(copy, "PH", 2)) {
    copy[0] = 'F';
    copy[1] = 'F';
  } else if (!strncmp(copy, "SCH", 3)) {
    copy[1] = 'S';
    copy[2] = 'S';
  }
  c1 = copy[len - 1];
  if (c1 == 'E') {
    c2 = copy[len - 2];
    if (c2 == 'E' || c2 == 'I') {
      copy[len - 1] = ' ';
      copy[len - 2] = 'Y';
    }
  } else if (c1 == 'T') {
    c2 = copy[len - 2];
    if (c2 == 'D' || c2 == 'R' || c2 == 'N') {
      copy[len - 1] = ' ';
      copy[len - 2] = 'D';
    }
  } else if (c1 == 'D') {
    c2 = copy[len - 2];
    if (c2 == 'R' || c2 == 'N') {
      copy[len - 1] = ' ';
      copy[len - 2] = 'D';
    }
  }
  cp = code;
  p = copy;
  *(cp++) = toupper(*(p++));
  while ((c1 = toupper(*p))) {
    if (c1 == ' ') {
      break;
    }
    switch (c1) {
    case 'E':
      if (toupper(*(p + 1)) == 'V') {
        *cp = 'A';
        *(++cp) = 'F';
        break;
      }
    case 'A':
    case 'I':
    case 'O':
    case 'U':
      *cp = 'A';
      break;
    case 'Q':
      *cp = 'G';
      break;
    case 'Z':
      *cp = 'S';
      break;
    case 'M':
      *cp = 'N';
      break;
    case 'K':
      if (toupper(*(p + 1)) == 'N') {
        *cp = 'N';
      } else {
        *cp = 'C';
      }
      break;
    case 'S':
      if (toupper(*(p + 1)) == 'C' && toupper(*(p + 2)) == 'H') {
        *(cp++) = 'S';
        *(cp++) = 'S';
        *cp = 'S';
      } else {
        *cp = 'S';
      }
      break;
    case 'P':
      if (toupper(*(p + 1)) == 'H') {
        *cp = 'F';
        *(++cp) = 'F';
      } else {
        *cp = 'P';
      }
      break;
    case 'H':
      c2 = toupper(*(p + 1));
      c3 = toupper(*(p - 1));
      if (!((c2) == 'A' || (c2) == 'E' || (c2) == 'I' || (c2) == 'O' || (c2) == 'U') || !((c3) == 'A' || (c3) == 'E' || (c3) == 'I' || (c3) == 'O' || (c3) == 'U')) {
        *cp = c3;
      } else {
        *cp = 'H';
      }
      break;
    case 'W':
      c2 = toupper(*(p - 1));
      if (((c2) == 'A' || (c2) == 'E' || (c2) == 'I' || (c2) == 'O' || (c2) == 'U')) {
        *cp = c2;
      } else {
        *cp = 'W';
      }
      break;
    default:
      *cp = toupper(c1);
    }
    if (*cp != *(cp - 1) || cp == code + 1) {
      cp++;
    }
    p++;
  }
  *cp = '\0';
  c1 = *(cp - 1);
  if (c1 == 'S') {
    *(--cp) = '\0';
  } else if (c1 == 'Y') {
    if (*(cp - 2) == 'A') {
      *(--cp) = '\0';
      *(--cp) = 'Y';
    }
  }
  if (*(cp - 1) == 'A') {
    *(cp - 1) = '\0';
  }
  free(copy);
  return code;
}
```