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

```asm
<bi_bi2str>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x3f0,%rsp
  mov    %rdi,%rbp
  mov    %esi,%r12d
  mov    %fs:0x28,%rax
  mov    %rax,0x3e8(%rsp)
  xor    %eax,%eax
  cmp    $0xa,%ecx
  je     L155
  cmp    $0x10,%ecx
  jne    L136
  mov    %esi,%eax
  sub    $0x1,%eax
  js     L168
  cltq
  shl    $0x3,%rax
  lea    (%rdx,%rax,1),%r8
  lea    -0x8(%rdx,%rax,1),%r10
  lea    -0x1(%rsi),%eax
  shl    $0x3,%rax
  sub    %rax,%r10
  mov    $0x0,%esi
  mov    $0x0,%ebx
  mov    $0x1,%r9d
  jmp    L178
L155:
  test   %esi,%esi
  jle    L6
  mov    %esi,%esi
L77:
  mov    (%rdx,%rax,8),%rcx
  mov    %rcx,(%rsp,%rax,8)
  add    $0x1,%rax
  cmp    %rax,%rsi
  jne    L77
  mov    %rbp,%r13
  mov    $0x0,%ebx
  mov    %rsp,%r14
L130:
  lea    -0x1(%r12),%eax
  cltq
  cmpq   $0x0,(%rsp,%rax,8)
  je     L128
  mov    $0xa,%edx
  mov    %r14,%rsi
  mov    %r12d,%edi
  call   <bi_mod1@plt>
  add    $0x30,%eax
  mov    %al,0x0(%r13)
  mov    $0xa,%edx
  mov    %r14,%rsi
  mov    %r12d,%edi
  call   <bi_div1@plt>
  mov    %eax,%r12d
  add    $0x1,%ebx
  add    $0x1,%r13
  test   %eax,%eax
  jg     L130
  jmp    L128
L82:
  mov    %r9d,%esi
L154:
  lea    0x30(%rax),%edi
  lea    0x57(%rax),%edx
  cmp    $0x9,%rax
  mov    %edi,%eax
  cmova  %edx,%eax
  movslq %ebx,%rdx
  mov    %al,0x0(%rbp,%rdx,1)
  add    $0x1,%ebx
L74:
  sub    $0x4,%ecx
  cmp    $0xfffffffc,%ecx
  je     L144
L134:
  mov    (%r8),%rax
  shr    %cl,%rax
  and    $0xf,%eax
  test   %esi,%esi
  jne    L40
  test   %rax,%rax
  jne    L82
L40:
  test   %esi,%esi
  jne    L154
  jmp    L74
L144:
  sub    $0x8,%r8
  cmp    %r10,%r8
  je     L128
L178:
  mov    $0x1c,%ecx
  jmp    L134
L136:
  mov    %ecx,%esi
  lea    D6(%rip),%rdi
  call   <printf@plt>
  mov    $0xffffffff,%edi
  call   <exit@plt>
L128:
  movslq %ebx,%rax
  movb   $0x0,0x0(%rbp,%rax,1)
  mov    0x3e8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L114
  mov    %ebx,%eax
  add    $0x3f0,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L6:
  mov    $0x0,%ebx
  jmp    L128
L168:
  mov    $0x0,%ebx
  jmp    L128
L114:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: tag: D6
type_infered: string

tool: D6: Error: invalid system: %d, quit


assistant: ```c
int bi_bi2str(char *str, int a_len, unsigned long *a_data, const unsigned int system) {
  unsigned long data[125];
  int i;
  char ch;
  if (system == 10) {
    for (i = 0; i < a_len; i++)
      data[i] = a_data[i];
    i = 0;
    while (a_len > 0 && data[a_len - 1] > 0) {
      ch = (char)bi_mod1(a_len, data, system) + 48;
      str[i] = ch;
      a_len = bi_div1(a_len, data, system);
      i++;
    }
  } else if (system == 16) {
    int j, k;
    int start = 0;
    unsigned long d;
    i = 0;
    for (k = a_len - 1; k >= 0; k--) {
      for (j = 7; j >= 0; j--) {
        d = (a_data[k] >> (j * 4)) & 0xf;
        if (!start && d != 0)
          start = 1;
        if (!start)
          continue;
        if (d < 10)
          ch = d + 48;
        else
          ch = d - 10 + 97;
        str[i] = ch;
        i++;
      }
    }
  } else {
    printf("Error: invalid system: %d, quit\n", system);
    exit(-1);
  }
  str[i] = 0;
  return i;
}
```