user: What would the C source look like for the assembly code provided here?

```asm
<ts_ip>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0xf8,%rsp
  mov    %edi,0xc(%rsp)
  mov    %rsi,%r15
  mov    %edx,%ebx
  mov    %rcx,0x10(%rsp)
  mov    %r8,%r14
  mov    %fs:0x28,%rdx
  mov    %rdx,0xe8(%rsp)
  xor    %edx,%edx
  lea    0xc(%rsi),%rdx
  movslq %ebx,%rsi
  add    %r15,%rsi
  movzbl 0x8(%rsp),%eax
  jmp    L642
L460:
  movzbl %cl,%ecx
  lea    0x1(%rdx,%rcx,1),%rdx
  cmp    %rsi,%rdx
  ja     L77
L642:
  movzbl (%rdx),%ecx
  test   %cl,%cl
  je     L646
  test   $0xc0,%cl
  je     L460
  mov    %al,0x8(%rsp)
  add    $0x1,%rdx
L409:
  movslq %ebx,%r13
  lea    0x3(%rdx),%rsi
  sub    %r15,%rsi
  mov    $0x0,%ecx
  cmp    %r13,%rsi
  jg     L608
  mov    $0x0,%ebp
  mov    0x1(%rdx),%bpl
  mov    %ebp,%ecx
  movzbl 0x2(%rdx),%eax
  mov    %al,%ch
  mov    %ecx,%ebp
  lea    0x5(%rdx),%rsi
  mov    %rsi,%rdi
  sub    %r15,%rdi
  mov    $0x0,%ecx
  cmp    %rdi,%r13
  jl     L608
  mov    %bp,0x1e(%rsp)
  mov    0x3(%rdx),%bpl
  mov    %ebp,%eax
  movzbl 0x4(%rdx),%edx
  mov    %dl,%ah
  mov    $0x0,%edi
  mov    $0x0,%r12d
  movb   $0x0,0x1d(%rsp)
  movb   $0x0,0x1b(%rsp)
  movb   $0x0,0x1c(%rsp)
  mov    %r13,%rbx
  add    %r15,%rbx
  movzbl 0x8(%rsp),%ebp
L550:
  mov    %edi,%r8d
  cmp    %rsi,%rbx
  jbe    L389
  mov    %rsi,%rdx
  jmp    L755
L646:
  mov    %al,0x8(%rsp)
  jmp    L409
L226:
  movzbl %cl,%ecx
  lea    0x1(%rdx,%rcx,1),%rdx
  cmp    %rbx,%rdx
  ja     L177
L755:
  movzbl (%rdx),%ecx
  test   %cl,%cl
  je     L454
  test   $0xc0,%cl
  je     L226
  add    $0x1,%rdx
L454:
  lea    0x3(%rdx),%rcx
  sub    %r15,%rcx
  cmp    %rcx,%r13
  jl     L141
  mov    0x1(%rdx),%al
  movzbl 0x2(%rdx),%ecx
  mov    %cl,%ah
  cmp    $0x21,%ax
  jne    L502
  lea    0x5(%rdx),%rcx
  sub    %r15,%rcx
  cmp    %rcx,%r13
  jl     L855
  mov    0x3(%rdx),%al
  movzbl 0x4(%rdx),%ecx
  mov    %cl,%ah
  cmp    $0x1,%ax
  jne    L427
  lea    0x9(%rdx),%rcx
  sub    %r15,%rcx
  cmp    %rcx,%r13
  jl     L711
  movzbl 0x5(%rdx),%r11d
  movzbl 0x6(%rdx),%r10d
  movzbl 0x7(%rdx),%ebp
  movzbl 0x8(%rdx),%r9d
  lea    0xb(%rdx),%r12
  mov    %r12,%rcx
  sub    %r15,%rcx
  cmp    %rcx,%r13
  jl     L342
  mov    0x9(%rdx),%al
  movzbl 0xa(%rdx),%ecx
  mov    %cl,%ah
  movzwl %ax,%r8d
  lea    (%r12,%r8,1),%rcx
  sub    %r15,%rcx
  cmp    %rcx,%r13
  jl     L676
  lea    0xd(%rdx),%rcx
  sub    %r15,%rcx
  cmp    %rcx,%r13
  jl     L936
  mov    0xb(%rdx),%al
  movzbl 0xc(%rdx),%ecx
  mov    %cl,%ah
  mov    %ax,0x50(%rsp,%rdi,2)
  lea    0xf(%rdx),%rcx
  sub    %r15,%rcx
  cmp    %rcx,%r13
  jl     L668
  mov    0xd(%rdx),%al
  movzbl 0xe(%rdx),%ecx
  mov    %cl,%ah
  mov    %ax,0x70(%rsp,%rdi,2)
  lea    0x11(%rdx),%rcx
  mov    %rcx,%r8
  sub    %r15,%r8
  cmp    %r8,%r13
  jl     L240
  mov    0xf(%rdx),%al
  movzbl 0x10(%rdx),%edx
  mov    %dl,%ah
  mov    %ax,0x30(%rsp,%rdi,2)
  mov    %rcx,0x90(%rsp,%rdi,8)
  jmp    L329
L502:
  mov    %bpl,0x8(%rsp)
  mov    %eax,%ebp
  mov    0x20(%rsp),%rcx
  movzbl %r9b,%edx
  shl    $0x18,%rdx
  test   %r12b,%r12b
  mov    %rcx,%rdi
  cmovne %rdx,%rdi
  mov    %rdi,0x20(%rsp)
  cmpb   $0x0,0x1d(%rsp)
  je     L760
  movzbl 0x8(%rsp),%eax
  shl    $0x10,%rax
  and    $0xffffffffff00ffff,%rdi
  mov    %rdi,%rdx
  or     %rax,%rdx
  mov    %rdx,0x20(%rsp)
L760:
  mov    0x20(%rsp),%rdx
  movzbl %dh,%eax
  cmpb   $0x0,0x1b(%rsp)
  cmovne %r10,%rax
  mov    %al,%dh
  mov    %rdx,0x20(%rsp)
  cmpb   $0x0,0x1c(%rsp)
  je     L416
  mov    %r11b,%dl
  mov    %rdx,0x20(%rsp)
  jmp    L416
L427:
  mov    %bpl,0x8(%rsp)
  mov    %eax,%ebp
  mov    0x20(%rsp),%rcx
  movzbl %r9b,%edx
  shl    $0x18,%rdx
  test   %r12b,%r12b
  mov    %rcx,%rdi
  cmovne %rdx,%rdi
  mov    %rdi,0x20(%rsp)
  cmpb   $0x0,0x1d(%rsp)
  je     L309
  movzbl 0x8(%rsp),%eax
  shl    $0x10,%rax
  and    $0xffffffffff00ffff,%rdi
  mov    %rdi,%rdx
  or     %rax,%rdx
  mov    %rdx,0x20(%rsp)
L309:
  mov    0x20(%rsp),%rdx
  movzbl %dh,%eax
  cmpb   $0x0,0x1b(%rsp)
  cmovne %r10,%rax
  mov    %al,%dh
  mov    %rdx,0x20(%rsp)
  cmpb   $0x0,0x1c(%rsp)
  je     L416
  mov    %r11b,%dl
  mov    %rdx,0x20(%rsp)
  jmp    L416
L215:
  movzbl %dl,%edx
  lea    0x1(%rcx,%rdx,1),%rcx
  cmp    %rbx,%rcx
  ja     L80
L329:
  movzbl (%rcx),%edx
  test   %dl,%dl
  je     L105
  test   $0xc0,%dl
  je     L215
  add    $0x1,%rcx
L105:
  add    $0x1,%rcx
  add    $0x1,%rdi
  mov    %rsi,0x28(%rsp)
  movb   $0x1,0x1c(%rsp)
  movb   $0x1,0x1b(%rsp)
  movb   $0x1,0x1d(%rsp)
  mov    $0x1,%r12d
  cmp    $0xa,%rdi
  je     L602
  mov    %rcx,%rsi
  jmp    L550
L602:
  mov    %ebp,%edi
  mov    %eax,%ebp
  movzbl %r9b,%edx
  movzbl %dil,%eax
  shl    $0x10,%rax
  shl    $0x18,%rdx
  or     %rax,%rdx
  mov    %rdx,%rax
  mov    %r10,%rdx
  mov    %dl,%ah
  mov    %r11b,%al
  mov    %rax,0x20(%rsp)
  mov    $0xa,%r8d
  cmpw   $0x1,0x1e(%rsp)
  je     L552
  mov    $0xa,%r8d
  jmp    L172
L389:
  mov    %ebp,%esi
  mov    %eax,%ebp
  mov    0x20(%rsp),%rcx
  movzbl %r9b,%edx
  shl    $0x18,%rdx
  test   %r12b,%r12b
  mov    %rcx,%rdi
  cmovne %rdx,%rdi
  mov    %rdi,0x20(%rsp)
  cmpb   $0x0,0x1d(%rsp)
  je     L678
  movzbl %sil,%eax
  shl    $0x10,%rax
  and    $0xffffffffff00ffff,%rdi
  mov    %rdi,%rdx
  or     %rax,%rdx
  mov    %rdx,0x20(%rsp)
L678:
  mov    0x20(%rsp),%rdx
  movzbl %dh,%eax
  cmpb   $0x0,0x1b(%rsp)
  cmovne %r10,%rax
  mov    %al,%dh
  mov    %rdx,0x20(%rsp)
  cmpb   $0x0,0x1c(%rsp)
  je     L262
  mov    %r11b,%dl
  mov    %rdx,0x20(%rsp)
L262:
  mov    0x28(%rsp),%rsi
L416:
  cmpw   $0x1,0x1e(%rsp)
  je     L548
L172:
  test   %r8d,%r8d
  je     L92
  cmp    %r8d,0xc(%rsp)
  jge    L92
  mov    $0x0,%r12d
  cmp    $0x1,%r8d
  jle    L824
L552:
  mov    $0x0,%r12d
  lea    0x70(%rsp),%r9
  mov    0xc(%rsp),%r10d
  jmp    L938
L2:
  movslq %r12d,%rdx
  movzwl (%r9,%rax,2),%ecx
  cmp    %cx,0x70(%rsp,%rdx,2)
  cmovle %eax,%r12d
L573:
  add    $0x1,%rax
  cmp    %eax,%r8d
  jle    L216
L111:
  movslq %r12d,%rdx
  movzwl 0x50(%rsp,%rdx,2),%ecx
  movzwl 0x50(%rsp,%rax,2),%edx
  cmp    %dx,%cx
  jg     L573
  je     L2
  mov    %eax,%r12d
  jmp    L573
L216:
  test   %r10d,%r10d
  je     L193
  movslq %r12d,%rax
  movw   $0xffff,0x70(%rsp,%rax,2)
  movw   $0xffff,0x50(%rsp,%rax,2)
  sub    $0x1,%r10d
L938:
  mov    $0x0,%eax
  jmp    L111
L193:
  mov    %r10d,0xc(%rsp)
  cmpw   $0x1,0x1e(%rsp)
  je     L652
L824:
  movslq %r12d,%rax
  movswl 0x30(%rsp,%rax,2),%eax
  mov    %eax,(%r14)
L652:
  mov    %r12d,0x8(%rsp)
  mov    0x20(%rsp),%r12
  jmp    L102
L635:
  movzbl %al,%eax
  lea    0x1(%r14,%rax,1),%r14
  cmp    %r14,%rbx
  jb     L909
L570:
  movzbl (%r14),%eax
  test   %al,%al
  je     L472
  test   $0xc0,%al
  je     L635
  add    $0x1,%r14
L472:
  cmpw   $0x1,0x1e(%rsp)
  jne    L616
  mov    0xc(%rsp),%edi
  test   %edi,%edi
  sete   %al
  movzbl %al,%eax
  lea    -0x1(%rdi),%edi
  mov    %edi,0xc(%rsp)
L93:
  lea    0x3(%r14),%rdx
  sub    %r15,%rdx
  cmp    %rdx,%r13
  jl     L325
  mov    0x1(%r14),%bpl
  mov    %ebp,%edx
  movzbl 0x2(%r14),%ecx
  mov    %cl,%dh
  mov    %edx,%ebp
  cmp    $0x1,%eax
  jne    L707
  cmp    $0x5,%dx
  je     L525
L707:
  cmp    $0x1,%dx
  mov    $0x0,%edx
  cmovne %edx,%eax
  lea    0x5(%r14),%rdx
  sub    %r15,%rdx
  cmp    %rdx,%r13
  jl     L874
  mov    0x3(%r14),%bpl
  mov    %ebp,%edx
  movzbl 0x4(%r14),%ecx
  mov    %cl,%dh
  mov    %edx,%ebp
  cmp    $0x1,%dx
  mov    $0x0,%edx
  cmovne %edx,%eax
  lea    0x9(%r14),%rdx
  sub    %r15,%rdx
  cmp    %rdx,%r13
  jl     L22
  mov    0x5(%r14),%r12b
  mov    %r12,%rdx
  movzbl 0x6(%r14),%ecx
  mov    %cl,%dh
  mov    %rdx,%r12
  movzbl 0x7(%r14),%edx
  shl    $0x10,%rdx
  and    $0xffffffffff00ffff,%r12
  or     %rdx,%r12
  movzbl 0x8(%r14),%edx
  shl    $0x18,%rdx
  movabs $0xffffffff00ffffff,%rdi
  and    %rdi,%r12
  or     %rdx,%r12
  lea    0xb(%r14),%rsi
  mov    %rsi,%rdx
  sub    %r15,%rdx
  cmp    %rdx,%r13
  jl     L680
  mov    0x9(%r14),%bpl
  mov    %ebp,%edx
  movzbl 0xa(%r14),%ecx
  mov    %cl,%dh
  mov    %edx,%ebp
  movzwl %dx,%edx
  add    %rdx,%rsi
  mov    %rsi,%rdx
  sub    %r15,%rdx
  cmp    %rdx,%r13
  jl     L511
  test   %eax,%eax
  jne    L506
L102:
  cmp    %rsi,%rbx
  jbe    L735
  mov    %rsi,%r14
  jmp    L570
L616:
  movslq 0x8(%rsp),%rax
  mov    0x90(%rsp,%rax,8),%rax
  mov    %rsi,%rdx
  mov    %rax,%rsi
  mov    %r15,%rdi
  call   <_ts_lmatch@plt>
  jmp    L93
L525:
  lea    0x5(%r14),%rax
  sub    %r15,%rax
  cmp    %rax,%r13
  jl     L630
  mov    %edx,%eax
  movzbl 0x4(%r14),%ebx
  mov    %bl,%ah
  mov    %eax,%ebp
  lea    0x9(%r14),%rax
  sub    %r15,%rax
  cmp    %rax,%r13
  jl     L191
  lea    0xb(%r14),%rsi
  mov    %rsi,%rax
  sub    %r15,%rax
  cmp    %rax,%r13
  jl     L251
  mov    0x9(%r14),%bpl
  mov    %ebp,%eax
  movzbl 0xa(%r14),%ebx
  mov    %bl,%ah
  movzwl %ax,%eax
  add    %rsi,%rax
  sub    %r15,%rax
  mov    $0x0,%ecx
  cmp    %rax,%r13
  jl     L608
  mov    0x10(%rsp),%rdx
  mov    %r15,%rdi
  call   <_ts_lcopy@plt>
  mov    $0x0,%ecx
  jmp    L608
L506:
  mov    %r12,%rbx
  lea    0xf(%r14),%rax
  sub    %r15,%rax
  mov    $0x0,%ecx
  cmp    %rax,%r13
  jl     L608
  mov    0xb(%r14),%bl
  movzbl 0xc(%r14),%eax
  mov    %al,%bh
  movzbl 0xd(%r14),%eax
  shl    $0x10,%rax
  and    $0xffffffffff00ffff,%rbx
  mov    %rbx,%rcx
  or     %rax,%rcx
  movzbl 0xe(%r14),%eax
  shl    $0x18,%rax
  and    %rdi,%rcx
  or     %rax,%rcx
  jmp    L608
L735:
  mov    0x8(%rsp),%r12d
  movslq %r12d,%r12
  mov    0x90(%rsp,%r12,8),%rsi
  mov    0x10(%rsp),%rdx
  mov    %r15,%rdi
  call   <_ts_lcopy@plt>
  mov    $0x0,%ecx
  jmp    L608
L77:
  mov    $0x0,%ecx
L608:
  mov    0xe8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L109
  mov    %rcx,%rax
  add    $0xf8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L177:
  mov    $0x0,%ecx
  jmp    L608
L141:
  mov    $0x0,%ecx
  jmp    L608
L855:
  mov    $0x0,%ecx
  jmp    L608
L711:
  mov    $0x0,%ecx
  jmp    L608
L342:
  mov    $0x0,%ecx
  jmp    L608
L676:
  mov    $0x0,%ecx
  jmp    L608
L936:
  mov    $0x0,%ecx
  jmp    L608
L668:
  mov    $0x0,%ecx
  jmp    L608
L240:
  mov    $0x0,%ecx
  jmp    L608
L80:
  mov    $0x0,%ecx
  jmp    L608
L92:
  mov    $0x0,%ecx
  jmp    L608
L909:
  mov    $0x0,%ecx
  jmp    L608
L325:
  mov    $0x0,%ecx
  jmp    L608
L630:
  mov    $0x0,%ecx
  jmp    L608
L191:
  mov    $0x0,%ecx
  jmp    L608
L251:
  mov    $0x0,%ecx
  jmp    L608
L874:
  mov    $0x0,%ecx
  jmp    L608
L22:
  mov    $0x0,%ecx
  jmp    L608
L680:
  mov    $0x0,%ecx
  jmp    L608
L511:
  mov    $0x0,%ecx
  jmp    L608
L548:
  mov    $0x0,%r12d
  cmp    $0x1,%r8d
  jg     L552
  jmp    L652
L109:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
unsigned long int ts_ip(int which, unsigned char *a, int len, char *host, int *port) {
  unsigned char *rr, *srv_target[10], *buf = a;
  unsigned short int i;
  unsigned long int l;
  int srv = 0, srvs = 0, aflag = 0;
  short int srv_port[10], srv_pri[10], srv_weight[10];
  buf += 12;
  for (; *buf != 0 && !(*buf & 0xc0 && buf++); buf += *buf + 1)
    if ((buf + *buf + 1) > (a + len))
      return 0;
  buf++;
  ;
  if ((buf + 2) - a > len)
    return 0;
  ;
  ((char *)&i)[0] = *buf++;
  ((char *)&i)[1] = *buf++;
  ;
  if (i == 1)
    aflag = 1;
  if ((buf + 2) - a > len)
    return 0;
  ;
  ((char *)&i)[0] = *buf++;
  ((char *)&i)[1] = *buf++;
  ;
  while (buf < (a + len)) {
    rr = buf;
    for (; *buf != 0 && !(*buf & 0xc0 && buf++); buf += *buf + 1)
      if ((buf + *buf + 1) > (a + len))
        return 0;
    buf++;
    ;
    if ((buf + 2) - a > len)
      return 0;
    ;
    ((char *)&i)[0] = *buf++;
    ((char *)&i)[1] = *buf++;
    ;
    if (i != 33)
      break;
    if ((buf + 2) - a > len)
      return 0;
    ;
    ((char *)&i)[0] = *buf++;
    ((char *)&i)[1] = *buf++;
    ;
    if (i != 1)
      break;
    if ((buf + 4) - a > len)
      return 0;
    ;
    ((char *)&l)[0] = *buf++;
    ((char *)&l)[1] = *buf++;
    ((char *)&l)[2] = *buf++;
    ((char *)&l)[3] = *buf++;
    ;
    if ((buf + 2) - a > len)
      return 0;
    ;
    ((char *)&i)[0] = *buf++;
    ((char *)&i)[1] = *buf++;
    ;
    if ((buf + i) - a > len)
      return 0;
    ;
    if ((buf + 2) - a > len)
      return 0;
    ;
    ((char *)&i)[0] = *buf++;
    ((char *)&i)[1] = *buf++;
    ;
    srv_pri[srvs] = i;
    if ((buf + 2) - a > len)
      return 0;
    ;
    ((char *)&i)[0] = *buf++;
    ((char *)&i)[1] = *buf++;
    ;
    srv_weight[srvs] = i;
    if ((buf + 2) - a > len)
      return 0;
    ;
    ((char *)&i)[0] = *buf++;
    ((char *)&i)[1] = *buf++;
    ;
    srv_port[srvs] = i;
    srv_target[srvs] = buf;
    for (; *buf != 0 && !(*buf & 0xc0 && buf++); buf += *buf + 1)
      if ((buf + *buf + 1) > (a + len))
        return 0;
    buf++;
    ;
    srvs++;
    if (srvs == 10)
      break;
  }
  if (!aflag && (srvs == 0 || which >= srvs))
    return 0;
  buf = rr;
  while (srvs > 1) {
    int cur;
    for (cur = 0; cur < srvs; cur++) {
      if (srv_pri[srv] > srv_pri[cur] || (srv_pri[srv] == srv_pri[cur] && srv_weight[srv] > srv_weight[cur]))
        continue;
      srv = cur;
    }
    if (which == 0)
      break;
    srv_pri[srv] = srv_weight[srv] = -1;
    which--;
  }
  if (!aflag)
    *port = srv_port[srv];
  while (buf < (a + len)) {
    int match = 0;
    rr = buf;
    for (; *buf != 0 && !(*buf & 0xc0 && buf++); buf += *buf + 1)
      if ((buf + *buf + 1) > (a + len))
        return 0;
    buf++;
    ;
    if (aflag)
      match = (which-- == 0) ? 1 : 0;
    else
      match = _ts_lmatch(a, srv_target[srv], rr);
    if ((buf + 2) - a > len)
      return 0;
    ;
    ((char *)&i)[0] = *buf++;
    ((char *)&i)[1] = *buf++;
    ;
    if (i == 5 && match == 1) {
      if ((buf + 2) - a > len)
        return 0;
      ;
      ((char *)&i)[0] = *buf++;
      ((char *)&i)[1] = *buf++;
      ;
      if ((buf + 4) - a > len)
        return 0;
      ;
      ((char *)&l)[0] = *buf++;
      ((char *)&l)[1] = *buf++;
      ((char *)&l)[2] = *buf++;
      ((char *)&l)[3] = *buf++;
      ;
      if ((buf + 2) - a > len)
        return 0;
      ;
      ((char *)&i)[0] = *buf++;
      ((char *)&i)[1] = *buf++;
      ;
      if ((buf + i) - a > len)
        return 0;
      ;
      _ts_lcopy(a, buf, host);
      return 0;
    }
    if (i != 1)
      match = 0;
    if ((buf + 2) - a > len)
      return 0;
    ;
    ((char *)&i)[0] = *buf++;
    ((char *)&i)[1] = *buf++;
    ;
    if (i != 1)
      match = 0;
    if ((buf + 4) - a > len)
      return 0;
    ;
    ((char *)&l)[0] = *buf++;
    ((char *)&l)[1] = *buf++;
    ((char *)&l)[2] = *buf++;
    ((char *)&l)[3] = *buf++;
    ;
    if ((buf + 2) - a > len)
      return 0;
    ;
    ((char *)&i)[0] = *buf++;
    ((char *)&i)[1] = *buf++;
    ;
    if ((buf + i) - a > len)
      return 0;
    ;
    if (match) {
      if ((buf + 4) - a > len)
        return 0;
      ;
      ((char *)&l)[0] = *buf++;
      ((char *)&l)[1] = *buf++;
      ((char *)&l)[2] = *buf++;
      ((char *)&l)[3] = *buf++;
      return l;
    }
    buf += i;
  }
  _ts_lcopy(a, srv_target[srv], host);
  return 0;
}
```