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

```asm
<scale>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x68,%rsp
  mov    %edi,-0x54(%rbp)
  mov    %esi,-0x58(%rbp)
  mov    %rdx,-0x60(%rbp)
  mov    %rcx,-0x68(%rbp)
  movl   $0x0,-0x44(%rbp)
  movl   $0x1,-0x40(%rbp)
  mov    -0x68(%rbp),%rax
  movl   $0x0,(%rax)
  mov    -0x54(%rbp),%eax
  cmp    -0x58(%rbp),%eax
  je     L244
  mov    -0x60(%rbp),%rax
  lea    D1(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L328
L244:
  mov    -0x60(%rbp),%rax
  jmp    L281
L328:
  cmpl   $0x1,-0x54(%rbp)
  jle    L199
  cmpl   $0x40,-0x54(%rbp)
  jg     L199
  cmpl   $0x1,-0x58(%rbp)
  jle    L199
  cmpl   $0x40,-0x58(%rbp)
  jle    L292
L199:
  mov    $0x0,%eax
  jmp    L281
L292:
  mov    -0x60(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x2d,%al
  jne    L247
  movl   $0x0,-0x40(%rbp)
  addq   $0x1,-0x60(%rbp)
L247:
  movq   $0x0,-0x38(%rbp)
  movq   $0x1,-0x30(%rbp)
  movq   $0x0,-0x18(%rbp)
  mov    -0x60(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x60(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x28(%rbp)
  jmp    L195
L168:
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  mov    %al,-0x45(%rbp)
  cmpb   $0x2f,-0x45(%rbp)
  jle    L151
  cmpb   $0x39,-0x45(%rbp)
  jg     L151
  movzbl -0x45(%rbp),%eax
  sub    $0x30,%eax
  mov    %al,-0x45(%rbp)
  jmp    L312
L151:
  cmpb   $0x40,-0x45(%rbp)
  jle    L73
  cmpb   $0x5b,-0x45(%rbp)
  jg     L73
  movzbl -0x45(%rbp),%eax
  sub    $0x37,%eax
  mov    %al,-0x45(%rbp)
  jmp    L312
L73:
  cmpb   $0x60,-0x45(%rbp)
  jle    L20
  cmpb   $0x7a,-0x45(%rbp)
  jg     L20
  movzbl -0x45(%rbp),%eax
  sub    $0x3d,%eax
  mov    %al,-0x45(%rbp)
  jmp    L312
L20:
  cmpb   $0x40,-0x45(%rbp)
  jne    L321
  movb   $0x3e,-0x45(%rbp)
  jmp    L312
L321:
  cmpb   $0x5f,-0x45(%rbp)
  jne    L312
  movb   $0x3f,-0x45(%rbp)
L312:
  movsbl -0x45(%rbp),%eax
  cmp    %eax,-0x54(%rbp)
  jge    L240
  mov    $0x0,%eax
  jmp    L281
L240:
  movsbq -0x45(%rbp),%rax
  imul   -0x30(%rbp),%rax
  add    %rax,-0x38(%rbp)
  mov    -0x54(%rbp),%eax
  cltq
  mov    -0x30(%rbp),%rdx
  imul   %rdx,%rax
  mov    %rax,-0x30(%rbp)
  subq   $0x1,-0x28(%rbp)
L195:
  mov    -0x28(%rbp),%rax
  cmp    -0x60(%rbp),%rax
  jae    L168
  mov    -0x38(%rbp),%rax
  mov    %eax,%edi
  call   <log@plt>
  mov    %eax,%ebx
  mov    -0x58(%rbp),%eax
  mov    %eax,%edi
  call   <log@plt>
  mov    %eax,%ecx
  mov    %ebx,%eax
  cltd
  idiv   %ecx
  add    $0x1,%eax
  mov    %eax,-0x3c(%rbp)
  mov    -0x3c(%rbp),%eax
  add    $0x1,%eax
  mov    $0x1,%esi
  mov    %eax,%edi
  call   <calloc@plt>
  mov    %rax,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  mov    %rax,-0x20(%rbp)
  mov    -0x3c(%rbp),%eax
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x20(%rbp)
L241:
  mov    -0x58(%rbp),%eax
  movslq %eax,%rcx
  mov    -0x38(%rbp),%rax
  cqto
  idiv   %rcx
  mov    %rdx,%rax
  mov    %al,-0x45(%rbp)
  mov    -0x58(%rbp),%eax
  movslq %eax,%rbx
  mov    -0x38(%rbp),%rax
  cqto
  idiv   %rbx
  mov    %rax,-0x38(%rbp)
  cmpb   $0x9,-0x45(%rbp)
  jg     L37
  movzbl -0x45(%rbp),%eax
  add    $0x30,%eax
  mov    %al,-0x45(%rbp)
  jmp    L163
L37:
  cmpb   $0x23,-0x45(%rbp)
  jg     L133
  movzbl -0x45(%rbp),%eax
  add    $0x37,%eax
  mov    %al,-0x45(%rbp)
  jmp    L163
L133:
  cmpb   $0x3d,-0x45(%rbp)
  jg     L1
  movzbl -0x45(%rbp),%eax
  add    $0x3d,%eax
  mov    %al,-0x45(%rbp)
  jmp    L163
L1:
  cmpb   $0x3e,-0x45(%rbp)
  jne    L207
  movb   $0x40,-0x45(%rbp)
  jmp    L163
L207:
  cmpb   $0x3f,-0x45(%rbp)
  jne    L163
  movb   $0x5f,-0x45(%rbp)
L163:
  mov    -0x20(%rbp),%rax
  movzbl -0x45(%rbp),%edx
  mov    %dl,(%rax)
  subq   $0x1,-0x20(%rbp)
  cmpq   $0x0,-0x38(%rbp)
  jg     L241
  mov    -0x18(%rbp),%rax
L281:
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

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

tool: D1: 0

assistant: ```c
char *scale(int cur, int res, char *num, bool *freeable) {
  bool caps = false, posi = true;
  *freeable = false;
  if (cur == res || strcmp(num, "0") == 0)
    return num;
  if (cur < 2 || cur > 64 || res < 2 || res > 64)
    return NULL;
  if (num[0] == '-') {
    posi = false;
    num++;
  }
  long iresult = 0, unit = 1;
  char *sresult = NULL, value;
  for (char *i = num + strlen(num) - 1; i >= num; i--) {
    value = *i;
    if (value > 47 && value < 58)
      value -= 48;
    else if (value > 64 && value < 92)
      value -= 55;
    else if (value > 96 && value < 123)
      value -= 61;
    else if (value == 64)
      value = 62;
    else if (value == 95)
      value = 63;
    if (value > cur)
      return NULL;
    iresult += value * unit;
    unit *= cur;
  }
  int len = (int)(log(iresult) / log(res)) + 1;
  sresult = calloc(len + 1, sizeof(char));
  char *ptr = sresult;
  ptr = len + sresult - 1;
  do {
    value = iresult % res;
    iresult /= res;
    if (value < 10)
      value += 48;
    else if (value < 36)
      value += 55;
    else if (value < 62)
      value += 61;
    else if (value == 62)
      value = 64;
    else if (value == 63)
      value = 95;
    *ptr = value;
    ptr--;
  } while (iresult > 0);
  return sresult;
}
```