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

```asm
<serpent_convert_from_string>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  mov    %edi,%ebx
  mov    %rsi,%rdi
  lea    0x6(%rbx),%r12d
  sub    $0x48,%rsp
  mov    %rdx,0x10(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  xor    %eax,%eax
  call   <strlen@plt>
  mov    %ebx,%edx
  add    $0x3,%edx
  cmovns %edx,%r12d
  sar    $0x2,%r12d
  cmp    %r12d,%eax
  jl     L82
L39:
  test   %ebx,%ebx
  js     L137
  lea    0x0(,%r12,4),%eax
  cmp    %ebx,%eax
  jl     L137
  sub    $0x3,%eax
  cmp    %ebx,%eax
  jg     L137
  test   %r12d,%r12d
  jle    L154
  lea    -0x1(%r12),%eax
  mov    %rbp,%rcx
  lea    0x1(%rbp,%rax,1),%rsi
  nopl   0x0(%rax,%rax,1)
L34:
  movzbl (%rcx),%eax
  mov    %eax,%edx
  and    $0xffffffdf,%edx
  sub    $0x41,%edx
  cmp    $0x5,%dl
  jbe    L1
  sub    $0x30,%eax
  cmp    $0x9,%al
  jbe    L1
L137:
  mov    $0xffffffff,%r12d
L178:
  mov    0x38(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L167
  add    $0x48,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L1:
  add    $0x1,%rcx
  cmp    %rcx,%rsi
  jne    L34
  xor    %r13d,%r13d
  cmp    $0x7,%r12d
  jle    L2
  movslq %r12d,%rax
  mov    0x10(%rsp),%rdi
  lea    0x20(%rsp),%r13
  lea    -0x8(%rbp,%rax,1),%r14
  lea    -0x8(%r12),%eax
  mov    %eax,0x1c(%rsp)
  shr    $0x3,%eax
  mov    %rdi,%r15
  lea    D1(%rip),%r12
  mov    %eax,0x18(%rsp)
  lea    0x8(%rdi,%rax,8),%rax
  mov    %rax,0x8(%rsp)
  nopl   0x0(%rax)
L67:
  mov    %r14,%rdi
  mov    %r13,%rdx
  mov    %r12,%rsi
  sub    $0x8,%r14
  call   <sscanf@plt>
  mov    0x20(%rsp),%rax
  add    $0x8,%r15
  mov    %rax,-0x8(%r15)
  cmp    %r15,0x8(%rsp)
  jne    L67
  mov    0x18(%rsp),%edi
  mov    0x1c(%rsp),%esi
  mov    %edi,%eax
  add    $0x1,%edi
  neg    %eax
  mov    %edi,%r13d
  lea    (%rsi,%rax,8),%r12d
L87:
  test   %r12d,%r12d
  jne    L2
L171:
  lea    0x1f(%rbx),%r12d
  sar    $0x5,%r12d
  cmp    %r12d,%r13d
  jge    L36
  lea    -0x1(%r12),%eax
  xor    %esi,%esi
  sub    %r13d,%eax
  movslq %r13d,%r13
  lea    0x8(,%rax,8),%rdx
  mov    0x10(%rsp),%rax
  lea    (%rax,%r13,8),%rdi
  call   <memset@plt>
  jmp    L178
  nopw   0x0(%rax,%rax,1)
L2:
  lea    0x2e(%rsp),%r14
  mov    %r12d,%edx
  mov    %rbp,%rsi
  movslq %r12d,%r12
  mov    %r14,%rdi
  call   <strncpy@plt>
  lea    0x20(%rsp),%rdx
  mov    %r14,%rdi
  lea    D1(%rip),%rsi
  movb   $0x0,0x2e(%rsp,%r12,1)
  call   <sscanf@plt>
  mov    0x20(%rsp),%rdx
  mov    0x10(%rsp),%rdi
  movslq %r13d,%rax
  add    $0x1,%r13d
  mov    %rdx,(%rdi,%rax,8)
  jmp    L171
  nopw   0x0(%rax,%rax,1)
L82:
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %eax,%r12d
  jmp    L39
L36:
  mov    %r13d,%r12d
  jmp    L178
L154:
  xor    %r13d,%r13d
  jmp    L87
L167:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: tag: D1
type_guessed: string

tool: D1: %08lX

assistant: ```c
int serpent_convert_from_string(int len, char *str, unsigned long *val) {
  int is, iv;
  int slen = (((strlen(str)) < ((len + 3) / 4)) ? (strlen(str)) : ((len + 3) / 4));
  if (len < 0)
    return -1;
  if (len > slen * 4 || len < slen * 4 - 3)
    return -1;
  for (is = 0; is < slen; is++)
    if (((str[is] < '0') || (str[is] > '9')) && ((str[is] < 'A') || (str[is] > 'F')) && ((str[is] < 'a') || (str[is] > 'f')))
      return -1;
  for (is = slen, iv = 0; is >= 8; is -= 8, iv++) {
    unsigned long t;
    sscanf(&str[is - 8], "%08lX", &t);
    val[iv] = t;
  }
  if (is > 0) {
    char tmp[10];
    unsigned long t;
    strncpy(tmp, str, is);
    tmp[is] = 0;
    sscanf(tmp, "%08lX", &t);
    val[iv++] = t;
  }
  for (; iv < (len + 31) / 32; iv++)
    val[iv] = 0;
  return iv;
}
```