user: What would the C source look like for the assembly code provided here:

```asm
<hex2passwd>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %esi,-0x2c(%rbp)
  mov    %rdx,-0x38(%rbp)
  mov    %ecx,-0x30(%rbp)
  mov    %r8d,-0x3c(%rbp)
  movl   $0x0,-0x1c(%rbp)
  movl   $0x0,-0x18(%rbp)
  movl   $0x4,-0x14(%rbp)
  mov    -0x30(%rbp),%eax
  sar    $0x4,%eax
  mov    %eax,-0x10(%rbp)
  movb   $0x0,-0x1e(%rbp)
  movb   $0x0,-0x1d(%rbp)
  movl   $0x0,-0xc(%rbp)
  jmp    L50
L23:
  sarl   -0x10(%rbp)
  addl   $0x1,-0x14(%rbp)
L50:
  mov    -0x10(%rbp),%eax
  and    $0x1,%eax
  test   %eax,%eax
  je     L23
  mov    -0x14(%rbp),%eax
  mov    %eax,-0x18(%rbp)
  mov    -0x2c(%rbp),%eax
  shl    $0x3,%eax
  cltd
  idivl  -0x14(%rbp)
  add    $0x1,%eax
  mov    $0x1,%esi
  mov    %eax,%edi
  call   <calloc@plt>
  mov    %rax,-0x8(%rbp)
  jmp    L96
L76:
  mov    -0x18(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jl     L10
  cmpl   $0x0,-0x3c(%rbp)
  je     L80
  mov    -0x1c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%ecx
  mov    -0x1c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x14(%rbp),%eax
  movzbl %al,%eax
  mov    %eax,%esi
  lea    D26(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L80:
  mov    -0x1c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    $0x8,%eax
  sub    -0x14(%rbp),%eax
  mov    %eax,%ecx
  sar    %cl,%edx
  mov    %edx,%eax
  mov    %al,-0x1e(%rbp)
  movzbl -0x1e(%rbp),%edx
  mov    $0x8,%eax
  sub    -0x14(%rbp),%eax
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    $0x8,%eax
  sub    -0x14(%rbp),%eax
  mov    %eax,%ecx
  sar    %cl,%edx
  mov    %edx,%eax
  mov    %al,-0x1e(%rbp)
  jmp    L49
L10:
  cmpl   $0x0,-0x3c(%rbp)
  je     L97
  mov    -0x1c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%esi
  mov    -0x1c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%r8d
  mov    -0x1c(%rbp),%eax
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%ecx
  mov    -0x1c(%rbp),%eax
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x14(%rbp),%eax
  mov    %eax,%edi
  mov    -0x18(%rbp),%eax
  mov    %eax,%r9d
  mov    %edi,%eax
  sub    %r9d,%eax
  movzbl %al,%eax
  mov    -0x18(%rbp),%edi
  sub    $0x8,%rsp
  push   %rsi
  mov    %r8d,%r9d
  mov    %edi,%r8d
  mov    %eax,%esi
  lea    D13(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  add    $0x10,%rsp
L97:
  mov    -0x1c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    $0x8,%eax
  sub    -0x18(%rbp),%eax
  mov    %eax,%ecx
  sar    %cl,%edx
  mov    %edx,%eax
  mov    %al,-0x1e(%rbp)
  movzbl -0x1e(%rbp),%edx
  mov    $0x8,%eax
  sub    -0x14(%rbp),%eax
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    $0x8,%eax
  sub    -0x14(%rbp),%eax
  mov    %eax,%ecx
  sar    %cl,%edx
  mov    %edx,%eax
  mov    %al,-0x1e(%rbp)
  cmpl   $0x0,-0x3c(%rbp)
  je     L0
  movzbl -0x1e(%rbp),%eax
  mov    %eax,%esi
  lea    D3(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L0:
  mov    -0x1c(%rbp),%eax
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x14(%rbp),%eax
  sub    -0x18(%rbp),%eax
  mov    %eax,%ecx
  mov    $0x8,%eax
  sub    %ecx,%eax
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    %edx,%eax
  mov    %al,-0x1d(%rbp)
  movzbl -0x1d(%rbp),%edx
  mov    $0x8,%eax
  sub    -0x14(%rbp),%eax
  mov    %eax,%ecx
  sar    %cl,%edx
  mov    %edx,%eax
  mov    %al,-0x1d(%rbp)
  cmpl   $0x0,-0x3c(%rbp)
  je     L107
  movzbl -0x1d(%rbp),%eax
  mov    %eax,%esi
  lea    D36(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L107:
  movzbl -0x1d(%rbp),%eax
  add    %al,-0x1e(%rbp)
L49:
  movzbl -0x1e(%rbp),%edx
  mov    -0x38(%rbp),%rax
  add    %rdx,%rax
  mov    -0xc(%rbp),%edx
  movslq %edx,%rcx
  mov    -0x8(%rbp),%rdx
  add    %rcx,%rdx
  movzbl (%rax),%eax
  mov    %al,(%rdx)
  cmpl   $0x0,-0x3c(%rbp)
  je     L26
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%ecx
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  movzbl -0x1e(%rbp),%eax
  mov    %eax,%esi
  lea    D25(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L26:
  mov    -0x14(%rbp),%eax
  add    %eax,-0x18(%rbp)
  cmpl   $0x7,-0x18(%rbp)
  jle    L79
  addl   $0x1,-0x1c(%rbp)
  subl   $0x8,-0x18(%rbp)
L79:
  addl   $0x1,-0xc(%rbp)
L96:
  mov    -0x1c(%rbp),%eax
  cmp    -0x2c(%rbp),%eax
  jl     L76
  mov    -0x2c(%rbp),%eax
  shl    $0x3,%eax
  cltd
  idivl  -0x14(%rbp)
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x8(%rbp),%rax
  leave
  ret
```

tool_calls: name: parse_data
arguments: label: D26
datatype: string
name: parse_data
arguments: label: D13
datatype: string
name: parse_data
arguments: label: D3
datatype: string
name: parse_data
arguments: label: D36
datatype: string
name: parse_data
arguments: label: D25
datatype: string

tool: D26: DEBUG - Value is first %d bits of '%c' (%d)


tool: D13: DEBUG - Value is last %d bits of '%c' (%d) and first %d bits of '%c' (%d)


tool: D3: DEBUG - Intermediate value is %d


tool: D36: DEBUG - Intermediate othervalue is %d


tool: D25: DEBUG - Value %d maps to character '%c' (%d)


assistant: ```c
unsigned char *hex2passwd(unsigned char *hex, int len, unsigned char *mapping, int mappinglength, int dflag) {
  int charpos = 0;
  int bitpos = 0;
  int numbits = 4;
  int length = mappinglength >> 4;
  unsigned char value = 0;
  unsigned char othervalue = 0;
  int outpos = 0;
  while ((length & 0x01) == 0x00) {
    length >>= 1;
    numbits++;
  }
  bitpos = numbits;
  unsigned char *out = calloc(len * 8 / numbits + 1, sizeof(char));
  while (charpos < len) {
    if (bitpos >= numbits) {
      if (dflag)
        printf("DEBUG - Value is first %d bits of '%c' (%d)\n", numbits, hex[charpos], hex[charpos]);
      value = (hex[charpos] >> (8 - numbits));
      value = (value << (8 - numbits)) >> (8 - numbits);
    } else {
      if (dflag)
        printf("DEBUG - Value is last %d bits of '%c' (%d) and first %d bits of '%c' (%d)\n", numbits - bitpos, hex[charpos - 1], hex[charpos - 1], bitpos, hex[charpos], hex[charpos]);
      value = (hex[charpos] >> (8 - bitpos));
      value = (value << (8 - numbits)) >> (8 - numbits);
      if (dflag)
        printf("DEBUG - Intermediate value is %d\n", value);
      othervalue = hex[charpos - 1] << (8 - (numbits - bitpos));
      othervalue = othervalue >> (8 - numbits);
      if (dflag)
        printf("DEBUG - Intermediate othervalue is %d\n", othervalue);
      value = value + othervalue;
    }
    out[outpos] = mapping[value];
    if (dflag)
      printf("DEBUG - Value %d maps to character '%c' (%d)\n", value, out[outpos], out[outpos]);
    bitpos += numbits;
    if (bitpos >= 8) {
      charpos++;
      bitpos -= 8;
    }
    outpos++;
  };
  out[len * 8 / numbits] = 0x00;
  return out;
}
```