user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<urlencode>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x840,%rsp
  mov    %rdi,-0x828(%rbp)
  mov    %rsi,-0x830(%rbp)
  mov    %edx,-0x834(%rbp)
  mov    %ecx,-0x838(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x0,-0x818(%rbp)
  cmpl   $0x2,-0x838(%rbp)
  jg     L0
  movl   $0x0,-0x81c(%rbp)
  jmp    L111
L96:
  mov    -0x81c(%rbp),%edx
  mov    -0x828(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  mov    %al,-0x81d(%rbp)
  cmpb   $0x2f,-0x81d(%rbp)
  jbe    L58
  cmpb   $0x39,-0x81d(%rbp)
  jbe    L90
  cmpb   $0x40,-0x81d(%rbp)
  jbe    L58
L90:
  cmpb   $0x5a,-0x81d(%rbp)
  jbe    L134
  cmpb   $0x60,-0x81d(%rbp)
  jbe    L58
L134:
  cmpb   $0x7a,-0x81d(%rbp)
  jbe    L91
  movzbl -0x81d(%rbp),%eax
  test   %al,%al
  js     L91
L58:
  cmpl   $0x2,-0x838(%rbp)
  jne    L171
  cmpb   $0x20,-0x81d(%rbp)
  jne    L171
  mov    -0x818(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x818(%rbp)
  mov    %eax,%eax
  movb   $0x2b,-0x810(%rbp,%rax,1)
  jmp    L74
L171:
  movzbl -0x81d(%rbp),%edx
  lea    -0x814(%rbp),%rax
  lea    D12(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  movzbl -0x814(%rbp),%edx
  mov    -0x818(%rbp),%eax
  mov    %dl,-0x810(%rbp,%rax,1)
  mov    -0x818(%rbp),%eax
  lea    0x1(%rax),%edx
  movzbl -0x813(%rbp),%eax
  mov    %edx,%edx
  mov    %al,-0x810(%rbp,%rdx,1)
  mov    -0x818(%rbp),%eax
  lea    0x2(%rax),%edx
  movzbl -0x812(%rbp),%eax
  mov    %edx,%edx
  mov    %al,-0x810(%rbp,%rdx,1)
  addl   $0x3,-0x818(%rbp)
  jmp    L74
L91:
  movzbl -0x81d(%rbp),%edx
  mov    -0x818(%rbp),%eax
  mov    %dl,-0x810(%rbp,%rax,1)
  addl   $0x1,-0x818(%rbp)
L74:
  addl   $0x1,-0x81c(%rbp)
L111:
  mov    -0x81c(%rbp),%eax
  cmp    -0x834(%rbp),%eax
  jae    L186
  cmpl   $0x7fe,-0x818(%rbp)
  jbe    L96
L186:
  cmpl   $0x7fe,-0x818(%rbp)
  ja     L190
  mov    -0x818(%rbp),%eax
  movb   $0x0,-0x810(%rbp,%rax,1)
  jmp    L169
L190:
  mov    -0x818(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,%eax
  movb   $0x0,-0x810(%rbp,%rax,1)
L169:
  lea    -0x810(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  lea    0x1(%rax),%rdx
  mov    -0x830(%rbp),%rax
  mov    (%rax),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <realloc@plt>
  mov    -0x830(%rbp),%rdx
  mov    %rax,(%rdx)
  mov    -0x830(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  jne    L17
  lea    D18(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    $0x0,%edi
  call   <exit@plt>
L17:
  mov    -0x830(%rbp),%rax
  mov    (%rax),%rax
  lea    -0x810(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  jmp    L193
L0:
  nop
L193:
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L172
  call   <__stack_chk_fail@plt>
L172:
  leave
  ret
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D12
type: string
name: extract_symbolic_data
arguments: data_label: D18
type: string

tool: D12: %%%2x

tool: D18: 
 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);
}
```