user: 请将以下的汇编代码转换成C语言代码：

```asm
<residue_idx>:
  endbr64
  push   %r15
  push   %r14
  mov    %rdx,%r14
  xor    %edx,%edx
  push   %r13
  mov    %r8,%r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rsi,0x8(%rsp)
  mov    %rdi,%rsi
  mov    $0x1,%edi
  mov    %rcx,(%rsp)
  mov    $0xc,%ecx
  mov    %r9,0x10(%rsp)
  call   <cmatrix@plt>
  mov    %r12,%rsi
  mov    $0x1,%edi
  mov    %rax,%r15
  call   <lvector@plt>
  mov    %rax,%rbp
  test   %r12,%r12
  jle    L45
  mov    $0x1,%r11d
  lea    D1(%rip),%rbx
  test   %r14,%r14
  je     L69
  mov    %rax,0x18(%rsp)
  mov    %r13,%rax
  mov    %r11,%rbp
  mov    %r14,%r13
  mov    %rax,%r14
L2:
  mov    0x0(%r13,%rbp,8),%rax
  mov    (%rsp),%rcx
  mov    %rbx,%rsi
  mov    (%r14,%rbp,8),%rdx
  mov    (%r15,%rbp,8),%rdi
  movsbl 0x2(%rax),%r9d
  mov    0x8(%rsp),%rax
  movsbl (%rcx,%rbp,1),%ecx
  mov    (%rax,%rbp,8),%r8
  add    $0x1,%rbp
  call   <sprintf@plt>
  cmp    %rbp,%r12
  jge    L2
L74:
  mov    0x18(%rsp),%rbp
  lea    0x0(%rbp,%r12,8),%r13
  cmp    $0x1,%r12
  je     L88
  mov    $0x1,%ebx
  nopl   0x0(%rax)
L24:
  mov    (%r15,%rbx,8),%rsi
  mov    0x8(%r15,%rbx,8),%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  setne  %al
  movzbl %al,%eax
  mov    %rax,0x0(%rbp,%rbx,8)
  add    $0x1,%rbx
  cmp    %rbx,%r12
  jne    L24
L88:
  movq   $0x1,0x0(%r13)
  xor    %esi,%esi
  mov    $0x1,%eax
  nopl   0x0(%rax)
L46:
  cmpq   $0x1,0x0(%rbp,%rax,8)
  sbb    $0xffffffffffffffff,%rsi
  add    $0x1,%rax
  cmp    %rax,%r12
  jge    L46
  mov    $0x2,%ecx
  mov    $0x1,%edx
  mov    $0x1,%edi
  call   <lmatrix@plt>
  xor    %esi,%esi
  mov    %rax,%r13
  mov    $0x1,%eax
  nopl   0x0(%rax)
L105:
  cmpq   $0x0,0x0(%rbp,%rax,8)
  je     L26
  add    $0x1,%rsi
  mov    0x0(%r13,%rsi,8),%rdx
  mov    %rax,0x10(%rdx)
L26:
  add    $0x1,%rax
  cmp    %rax,%r12
  jge    L105
  cmp    $0x1,%rsi
  jle    L41
  lea    0x8(%r13),%rax
  lea    0x0(%r13,%rsi,8),%rdi
  nopl   (%rax)
L71:
  mov    (%rax),%rdx
  mov    0x8(%rax),%rcx
  add    $0x8,%rax
  mov    0x10(%rdx),%rdx
  add    $0x1,%rdx
  mov    %rdx,0x8(%rcx)
  cmp    %rax,%rdi
  jne    L71
L41:
  mov    0x8(%r13),%rax
  mov    %r12,%rdx
  mov    %r15,%rdi
  mov    $0xc,%r8d
  xor    %ecx,%ecx
  movq   $0x1,0x8(%rax)
  mov    0x10(%rsp),%rax
  mov    %rsi,(%rax)
  mov    $0x1,%esi
  call   <free_cmatrix@plt>
  mov    %r12,%rdx
  mov    %rbp,%rdi
  mov    $0x1,%esi
  call   <free_lvector@plt>
  add    $0x28,%rsp
  mov    %r13,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L69:
  mov    %rax,0x18(%rsp)
  mov    %r13,%rbp
  mov    0x8(%rsp),%r13
  mov    $0x1,%r14d
  nopl   0x0(%rax,%rax,1)
L18:
  mov    (%rsp),%rax
  mov    0x0(%rbp,%r14,8),%rdx
  mov    %rbx,%rsi
  mov    $0x20,%r9d
  mov    (%r15,%r14,8),%rdi
  mov    0x0(%r13,%r14,8),%r8
  movsbl (%rax,%r14,1),%ecx
  add    $0x1,%r14
  call   <sprintf@plt>
  cmp    %r14,%r12
  jge    L18
  jmp    L74
  nopl   0x0(%rax,%rax,1)
L45:
  movq   $0x1,(%rax,%r12,8)
  xor    %esi,%esi
  mov    $0x2,%ecx
  mov    $0x1,%edx
  mov    $0x1,%edi
  call   <lmatrix@plt>
  xor    %esi,%esi
  mov    %rax,%r13
  jmp    L41
```

tool_calls: name: retrieve_data
arguments: label: D1
data_type: string

tool: D1: %3s%c%4ld%c

assistant: ```c
long **residue_idx(long num, long *ResSeq, char **Miscs, char *ChainID, char **ResName, long *num_residue) {
  char iCode;
  char **bidx;
  long i, n, **seidx, *temp;
  bidx = cmatrix(1, num, 0, 12);
  temp = lvector(1, num);
  for (i = 1; i <= num; i++) {
    iCode = (Miscs == NULL) ? ' ' : Miscs[i][2];
    sprintf(bidx[i], "%3s%c%4ld%c", ResName[i], ChainID[i], ResSeq[i], iCode);
  }
  for (i = 1; i < num; i++)
    temp[i] = strcmp(bidx[i + 1], bidx[i]) ? 1 : 0;
  temp[num] = 1;
  n = 0;
  for (i = 1; i <= num; i++)
    if (temp[i])
      ++n;
  seidx = lmatrix(1, n, 1, 2);
  n = 0;
  for (i = 1; i <= num; i++)
    if (temp[i])
      seidx[++n][2] = i;
  for (i = 2; i <= n; i++)
    seidx[i][1] = seidx[i - 1][2] + 1;
  seidx[1][1] = 1;
  *num_residue = n;
  free_cmatrix(bidx, 1, num, 0, 12);
  free_lvector(temp, 1, num);
  return seidx;
}
```