user: 请从给定的汇编指令推导出C源代码:

```asm
<urlencode_put>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  push   %rbx
  mov    %rdx,%rbx
  sub    $0x38,%rsp
  mov    %rdx,(%rsp)
  mov    %rcx,0x18(%rsp)
  mov    %rdi,0x10(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  test   %rdi,%rdi
  setne  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  xor    %edi,%edi
  test   %rbx,%rbx
  setne  %dil
  xor    %ebp,%ebp
  xor    %r13d,%r13d
  xor    %ebx,%ebx
  call   <assert@plt>
  xor    %edx,%edx
  xor    %esi,%esi
  xor    %edi,%edi
  call   <mbtowc@plt>
  lea    0x27(%rsp),%rax
  xor    %r15d,%r15d
  mov    %rax,0x8(%rsp)
  jmp    L76
  nopl   (%rax)
L159:
  mov    0x10(%rsp),%rax
  add    $0x1,%r13d
  mov    %dil,(%rax,%r15,1)
L195:
  mov    %r13d,%r15d
  lea    0x1(%rbx),%eax
  mov    %r15,%r14
  cmp    0x18(%rsp),%rbx
  jae    L13
  cmp    %r15,%r12
  jbe    L13
  mov    %eax,%ebx
L76:
  mov    D1(%rip),%rax
  mov    0x8(%rsp),%rdi
  mov    %ebp,%esi
  mov    %r15,%r14
  add    (%rsp),%rsi
  mov    (%rax),%edx
  call   <mbtowc@plt>
  movsbl 0x27(%rsp),%edi
  add    %eax,%ebp
  test   %dil,%dil
  je     L13
  cmp    $0x20,%dil
  jne    L80
  cmp    %r15,%r12
  ja     L57
L80:
  call   <iswalnum@plt>
  movsbl 0x27(%rsp),%edi
  test   %rax,%rax
  jne    L51
  lea    -0x2d(%rdi),%eax
  cmp    $0x1,%al
  jbe    L51
  cmp    $0x7e,%dil
  jne    L90
L51:
  cmp    %r15,%r12
  ja     L159
  call   <isASCIIcompat_char@plt>
L0:
  cmpb   $0x7f,0x27(%rsp)
  je     L84
L52:
  cmp    %r15,%r12
  ja     L131
L13:
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L85
  add    $0x38,%rsp
  mov    %r14,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nop
L57:
  mov    0x10(%rsp),%rax
  add    $0x1,%r13d
  movb   $0x2b,(%rax,%r15,1)
  jmp    L195
  nopl   0x0(%rax,%rax,1)
L84:
  lea    0x2(%r13),%eax
  cmp    %r12,%rax
  jae    L52
  mov    0x10(%rsp),%rax
  lea    0x1(%r13),%edi
  mov    $0x7f,%esi
  mov    %rdi,%r13
  movb   $0x25,(%rax,%r15,1)
  add    %rax,%rdi
  call   <hexadecimal@plt>
  add    %eax,%r13d
  jmp    L195
  nopw   0x0(%rax,%rax,1)
L90:
  call   <isASCIIcompat_char@plt>
  test   %rax,%rax
  je     L0
  cmp    %r15,%r12
  jbe    L0
  mov    0x10(%rsp),%rax
  lea    0x1(%r13),%edi
  movzbl 0x27(%rsp),%esi
  mov    %rdi,%r13
  movb   $0x25,(%rax,%r15,1)
  add    %rax,%rdi
  call   <hexadecimal@plt>
  add    %eax,%r13d
  jmp    L195
L131:
  mov    0x10(%rsp),%rax
  lea    0x1(%r13),%r14d
  movb   $0x2a,(%rax,%r15,1)
  jmp    L13
L85:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
size_t urlencode_put(char *result, size_t result_max, const char *multibyte_input, size_t input_len) {
  assert(NULL != result);
  assert(NULL != multibyte_input);
  unsigned int i = 0;
  unsigned int r = 0;
  unsigned int offset = 0;
  wchar_t current;
  mbtowc(NULL, NULL, 0);
  do {
    offset += mbtowc(&current, (multibyte_input) + (offset), MB_CUR_MAX);
    if (current == 0) {
      break;
    } else if (current == ' ' && r < result_max) {
      result[r++] = '+';
      continue;
    } else if ((iswalnum(current) || current == '-' || current == '.' || current == '~') && r < result_max) {
      result[r++] = current;
    } else if (isASCIIcompat_char(current) && r < result_max) {
      result[r++] = '%';
      r += hexadecimal(result + r, (unsigned int)(current & 0xFF));
    } else if (current >= 0x7F && current <= 0x7FFFFFFF && (r + 2) < result_max) {
      result[r++] = '%';
      r += hexadecimal(result + r, (unsigned int)current);
    } else if (result_max > r) {
      result[r++] = '*';
      break;
    }
  } while ((i++) < input_len && (r < result_max));
  return r;
}
```