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

```asm
<urlencode_put>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,%r14
  mov    %rsi,%r13
  mov    %rdx,%rbx
  mov    %rdx,(%rsp)
  mov    %rcx,0x8(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  test   %rdi,%rdi
  setne  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  test   %rbx,%rbx
  setne  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    $0x0,%edx
  mov    $0x0,%esi
  mov    $0x0,%edi
  call   <mbtowc@plt>
  mov    $0x0,%r12d
  mov    $0x0,%ebx
  mov    $0x0,%ebp
  mov    D3(%rip),%r15
  jmp    L78
L16:
  add    $0x1,%ebx
  movb   $0x2b,(%r14,%rax,1)
  jmp    L113
L100:
  mov    %ebx,%eax
  cmp    %r13,%rax
  jae    L50
  add    $0x1,%ebx
  movzbl 0x17(%rsp),%edx
  mov    %dl,(%r14,%rax,1)
L113:
  lea    0x1(%rbp),%edx
  mov    %ebp,%ebp
  cmp    0x8(%rsp),%rbp
  jae    L151
  mov    %ebx,%eax
  cmp    %r13,%rax
  jae    L151
  mov    %edx,%ebp
L78:
  mov    %r12d,%esi
  add    (%rsp),%rsi
  lea    0x17(%rsp),%rdi
  mov    (%r15),%edx
  call   <mbtowc@plt>
  add    %eax,%r12d
  movzbl 0x17(%rsp),%edi
  test   %dil,%dil
  je     L151
  cmp    $0x20,%dil
  jne    L187
  mov    %ebx,%eax
  cmp    %r13,%rax
  jb     L16
L187:
  movsbl %dil,%edi
  call   <iswalnum@plt>
  test   %rax,%rax
  jne    L100
  movzbl 0x17(%rsp),%eax
  lea    -0x2d(%rax),%edx
  cmp    $0x1,%dl
  jbe    L100
  cmp    $0x7e,%al
  je     L100
L50:
  movsbl 0x17(%rsp),%edi
  call   <isASCIIcompat_char@plt>
  test   %rax,%rax
  je     L49
  mov    %ebx,%eax
  cmp    %r13,%rax
  jb     L89
L49:
  cmpb   $0x7f,0x17(%rsp)
  je     L79
L53:
  mov    %ebx,%eax
  cmp    %r13,%rax
  jb     L83
L151:
  mov    %ebx,%eax
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L143
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L89:
  add    $0x1,%ebx
  movb   $0x25,(%r14,%rax,1)
  movzbl 0x17(%rsp),%esi
  mov    %ebx,%edi
  add    %r14,%rdi
  call   <hexadecimal@plt>
  add    %eax,%ebx
  jmp    L113
L79:
  lea    0x2(%rbx),%eax
  cmp    %r13,%rax
  jae    L53
  lea    0x1(%rbx),%eax
  mov    %ebx,%ebx
  movb   $0x25,(%r14,%rbx,1)
  mov    %eax,%ebx
  mov    %eax,%edi
  add    %r14,%rdi
  mov    $0x7f,%esi
  call   <hexadecimal@plt>
  add    %eax,%ebx
  jmp    L113
L83:
  add    $0x1,%ebx
  movb   $0x2a,(%r14,%rax,1)
  jmp    L151
L143:
  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;
}
```