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

```asm
<urlencode>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x838,%rsp
  mov    %rsi,0x8(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x828(%rsp)
  xor    %eax,%eax
  cmp    $0x2,%ecx
  jg     L36
  mov    %edx,%r14d
  test   %edx,%edx
  je     L131
  mov    %rdi,%r15
  xor    %ebx,%ebx
  lea    D8(%rip),%r13
  xor    %ebp,%ebp
  jmp    L53
  nopl   0x0(%rax)
L32:
  lea    -0x5b(%rdx),%eax
  cmp    $0x5,%al
  jbe    L93
  lea    -0x7b(%rdx),%eax
  cmp    $0x4,%al
  jbe    L93
  mov    %dl,0x20(%rsp,%rbx,1)
  mov    %r12d,%ebx
L50:
  add    $0x1,%ebp
  cmp    %ebp,%r14d
  jbe    L181
L56:
  cmp    $0x7fe,%ebx
  ja     L39
L53:
  mov    %ebp,%eax
  lea    0x1(%rbx),%r12d
  movzbl (%r15,%rax,1),%edx
  lea    -0x3a(%rdx),%eax
  cmp    $0x6,%al
  jbe    L2
  cmp    $0x2f,%dl
  ja     L32
L2:
  cmp    $0x2,%ecx
  jne    L93
  cmp    $0x20,%dl
  jne    L93
  add    $0x1,%ebp
  movb   $0x2b,0x20(%rsp,%rbx,1)
  mov    %r12d,%ebx
  cmp    %ebp,%r14d
  ja     L56
L181:
  cmp    $0x7fe,%ebx
  ja     L39
L185:
  movb   $0x0,0x20(%rsp,%rbx,1)
  jmp    L44
  nopl   0x0(%rax)
L93:
  lea    0x1c(%rsp),%rdi
  mov    %r13,%rsi
  mov    %ecx,0x4(%rsp)
  call   <sprintf@plt>
  movzbl 0x1c(%rsp),%edx
  mov    %ebx,%eax
  mov    0x4(%rsp),%ecx
  mov    %dl,0x20(%rsp,%rax,1)
  movzbl 0x1d(%rsp),%eax
  movzbl 0x1e(%rsp),%edx
  mov    %al,0x20(%rsp,%r12,1)
  lea    0x2(%rbx),%eax
  add    $0x3,%ebx
  mov    %dl,0x20(%rsp,%rax,1)
  jmp    L50
  cs nopw 0x0(%rax,%rax,1)
L39:
  lea    -0x1(%rbx),%eax
  movb   $0x0,0x20(%rsp,%rax,1)
L44:
  lea    0x20(%rsp),%rbp
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    0x8(%rsp),%rbx
  lea    0x1(%rax),%rsi
  mov    (%rbx),%rdi
  call   <realloc@plt>
  mov    %rax,(%rbx)
  mov    %rax,%rdi
  test   %rax,%rax
  je     L16
L0:
  mov    %rbp,%rsi
  call   <strcpy@plt>
L36:
  mov    0x828(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L37
  add    $0x838,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  xchg   %ax,%ax
L16:
  lea    D14(%rip),%rdi
  call   <printf@plt>
  xor    %edi,%edi
  call   <exit@plt>
  mov    0x8(%rsp),%rax
  mov    (%rax),%rdi
  jmp    L0
  nopl   (%rax)
L131:
  xor    %ebx,%ebx
  jmp    L185
L37:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D8
type: string
name: extract_symbolic_data
arguments: data_label: D14
type: string

tool: D8: %%%2x

tool: D14: 
 Realloc failed 


assistant: ```c
void urlencode(char *src, char **dst, unsigned int size, int type) {
  unsigned int i, j = 0;
  unsigned char c;
  char newchar[4];
  char newdst[2048];
  if (type > 2)
    return;
  for (i = 0; i < size && j < (2048 - 1); i++) {
    c = src[i];
    if ((c < 48) || (c > 57 && c < 65) || (c > 90 && c < 97) || (c > 122 && c < 128)) {
      if (type == 2 && c == 32) {
        newdst[j++] = '+';
      } else {
        sprintf(newchar, "\%%%2x", c);
        newdst[j] = newchar[0];
        newdst[j + 1] = newchar[1];
        newdst[j + 2] = newchar[2];
        j = j + 3;
      }
    } else {
      newdst[j] = c;
      j++;
    }
  }
  if (j < (2048 - 1))
    newdst[j] = '\0';
  else
    newdst[j - 1] = '\0';
  *dst = realloc(*dst, strlen(newdst) + 1);
  if (*dst == NULL) {
    printf("\n Realloc failed \n");
    exit(0);
  }
  strcpy(*dst, newdst);
}
```