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

```asm
<GetXPrintUrl>:
  endbr64
  push   %r15
  lea    D38(%rip),%r15
  push   %r14
  mov    %rsi,%r14
  mov    %r15,%rsi
  push   %r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  push   %rbx
  sub    $0x148,%rsp
  mov    %rdx,0x20(%rsp)
  mov    $0x7,%edx
  mov    %rcx,0x8(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x138(%rsp)
  xor    %eax,%eax
  call   <strncmp@plt>
  mov    $0x2f,%esi
  mov    %rax,%r9
  lea    0x7(%r12),%rax
  test   %r9,%r9
  cmove  %rax,%r12
  xor    %ebx,%ebx
  mov    %r12,%rdi
  call   <strchr@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L150
  mov    %eax,%ebx
  mov    %r12,%rdi
  lea    D16(%rip),%rsi
  mov    %r12,%rbp
  sub    %r12d,%ebx
  lea    0x1(%rax),%r13
  mov    %ebx,%edx
  mov    %r13,%r12
  call   <strncmp@plt>
  test   %rax,%rax
  je     L117
L150:
  mov    %r12,%rdi
  mov    $0x4,%edx
  lea    0x30(%rsp),%r13
  lea    D20(%rip),%rsi
  call   <strncmp@plt>
  mov    0x8(%rsp),%rcx
  mov    $0x100,%esi
  mov    %r13,%rdi
  mov    %rax,%r9
  lea    0x4(%r12),%rax
  test   %r9,%r9
  cmove  %rax,%r12
  mov    %r12,%rdx
  call   <MyBestHostname@plt>
  mov    %r13,%rdi
  mov    %rax,%r12
  call   <gethostbyname@plt>
  mov    $0x2e,%esi
  mov    %r12,%rdi
  mov    (%rax),%rax
  mov    %rax,0x18(%rsp)
  call   <strchr@plt>
  test   %rax,%rax
  je     L151
  sub    %r12d,%eax
  mov    %eax,0x28(%rsp)
L166:
  mov    0x18(%rsp),%rdi
  call   <strlen@plt>
  mov    %eax,0x14(%rsp)
  test   %r14,%r14
  je     L145
  mov    %r14,%rdi
  call   <strlen@plt>
  mov    %eax,0x2c(%rsp)
  lea    0x1(%rax),%r13d
L37:
  mov    0x20(%rsp),%rax
  movl   $0x0,0x8(%rsp)
  test   %rax,%rax
  je     L62
  mov    %rax,%rdi
  call   <strlen@plt>
  add    $0x6,%eax
  mov    %eax,0x8(%rsp)
L62:
  mov    0x8(%rsp),%ecx
  lea    0x1(%rbx,%r13,1),%eax
  add    0x14(%rsp),%eax
  xor    %r13d,%r13d
  add    0x28(%rsp),%eax
  lea    0x7(%rcx,%rax,1),%edi
  call   <malloc@plt>
  test   %rax,%rax
  je     L28
  mov    %r15,%rsi
  mov    %rax,%rdi
  mov    %rax,%r13
  call   <strcpy@plt>
  mov    0x2c(%rsp),%esi
  lea    0x7(%r13),%r15
  test   %esi,%esi
  jne    L125
  test   %ebx,%ebx
  jne    L59
L211:
  mov    0x14(%rsp),%ecx
  test   %ecx,%ecx
  jne    L38
L24:
  mov    0x28(%rsp),%edx
  test   %edx,%edx
  jne    L84
L128:
  mov    0x8(%rsp),%eax
  test   %eax,%eax
  jne    L53
L43:
  movb   $0x0,(%r15)
L28:
  mov    0x138(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L236
  add    $0x148,%rsp
  mov    %r13,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L117:
  xor    %ebx,%ebx
  jmp    L150
  nop
L53:
  mov    0x20(%rsp),%rdx
  lea    D39(%rip),%rsi
  mov    %r15,%rdi
  call   <sprintf@plt>
  jmp    L28
  cs nopw 0x0(%rax,%rax,1)
L84:
  mov    0x28(%rsp),%ebx
  mov    %r15,%rdi
  mov    %r12,%rsi
  mov    %ebx,%edx
  call   <strncpy@plt>
  movslq %ebx,%rax
  add    %rax,%r15
  mov    0x8(%rsp),%eax
  test   %eax,%eax
  je     L43
  jmp    L53
  nopl   0x0(%rax)
L38:
  mov    0x18(%rsp),%rsi
  mov    %r15,%rdi
  call   <strcpy@plt>
  movslq 0x14(%rsp),%rax
  mov    0x28(%rsp),%edx
  add    %rax,%r15
  test   %edx,%edx
  je     L128
  jmp    L84
  nopl   0x0(%rax,%rax,1)
L59:
  lea    0x1(%rbx),%edx
  mov    %r15,%rdi
  mov    %rbp,%rsi
  movslq %ebx,%rbx
  call   <strncpy@plt>
  mov    0x14(%rsp),%ecx
  lea    0x1(%r15,%rbx,1),%r15
  test   %ecx,%ecx
  je     L24
  jmp    L38
  nopl   0x0(%rax)
L125:
  mov    %r15,%rdi
  mov    %r14,%rsi
  call   <strcpy@plt>
  movslq 0x2c(%rsp),%rax
  add    %r15,%rax
  movb   $0x40,(%rax)
  lea    0x1(%rax),%r15
  test   %ebx,%ebx
  je     L211
  jmp    L59
  nopl   0x0(%rax)
L145:
  movl   $0x0,0x2c(%rsp)
  mov    $0x1,%r13d
  jmp    L37
  nopl   0x0(%rax,%rax,1)
L151:
  mov    %r12,%rdi
  call   <strlen@plt>
  mov    %eax,0x28(%rsp)
  jmp    L166
L236:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: data_tag: D38
type_guessed: string
name: parse_data
arguments: data_tag: D16
type_guessed: string
name: parse_data
arguments: data_tag: D20
type_guessed: string
name: parse_data
arguments: data_tag: D39
type_guessed: string

tool: D38: xprint:

tool: D16: local

tool: D20: unix

tool: D39: ;auth=%s

assistant: ```c
char *GetXPrintUrl(char *display_name, char *printer, char *auth, char *dest_url) {
  char *dpy_name, *proto = NULL;
  char *url, *ptr;
  char *name;
  struct hostent *host;
  int len, proto_len, dpy_len, name_len, auth_len, printer_len;
  char hostname[256 + 1];
  len = 7;
  if (strncmp(display_name, "xprint:", 7) == 0)
    dpy_name = display_name + 7;
  else
    dpy_name = display_name;
  ptr = strchr(dpy_name, '/');
  if (ptr != NULL) {
    proto = dpy_name;
    proto_len = ptr - dpy_name;
    dpy_name = ptr + 1;
    if (strncmp(proto, "local", proto_len) == 0)
      proto_len = 0;
  } else
    proto_len = 0;
  if (strncmp(dpy_name, "unix", 4) == 0)
    dpy_name += 4;
  dpy_name = MyBestHostname(hostname, 256, dpy_name, dest_url);
  host = gethostbyname(hostname);
  name = host->h_name;
  ptr = strchr(dpy_name, '.');
  if (ptr != NULL)
    dpy_len = ptr - dpy_name;
  else
    dpy_len = strlen(dpy_name);
  name_len = strlen(name);
  printer_len = printer ? strlen(printer) : 0;
  auth_len = auth == NULL ? 0 : 6 + strlen(auth);
  len += printer_len + 1 + proto_len + 1 + name_len + dpy_len + auth_len;
  url = ptr = (char *)malloc(len);
  if (url == NULL)
    return NULL;
  strcpy(ptr, "xprint:");
  ptr += 7;
  if (printer_len != 0) {
    strcpy(ptr, printer);
    ptr += printer_len;
    *ptr++ = '@';
  }
  if (proto_len != 0) {
    strncpy(ptr, proto, proto_len + 1);
    ptr += proto_len + 1;
  }
  if (name_len != 0) {
    strcpy(ptr, name);
    ptr += name_len;
  }
  if (dpy_len != 0) {
    strncpy(ptr, dpy_name, dpy_len);
    ptr += dpy_len;
  }
  if (auth_len != 0)
    sprintf(ptr, ";auth=%s", auth);
  else
    *ptr = '\0';
  return url;
}
```