user: Demonstrate the C code that generates the assembly output below:

```asm
<hex2passwd>:
  endbr64
  push   %r15
  mov    %ecx,%eax
  push   %r14
  sar    $0x4,%eax
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    $0x4,%ebx
  sub    $0x38,%rsp
  and    $0x10,%ecx
  mov    %rdi,(%rsp)
  mov    %esi,0x8(%rsp)
  mov    %rdx,0x10(%rsp)
  mov    %r8d,0xc(%rsp)
  jne    L46
  nopl   0x0(%rax,%rax,1)
L28:
  sar    %eax
  add    $0x1,%ebx
  test   $0x1,%al
  je     L28
L46:
  mov    0x8(%rsp),%r15d
  mov    $0x1,%esi
  mov    $0x8,%r13d
  xor    %ebp,%ebp
  sub    %ebx,%r13d
  lea    0x0(,%r15,8),%eax
  cltd
  idiv   %ebx
  lea    0x1(%rax),%edi
  mov    %eax,0x2c(%rsp)
  call   <calloc@plt>
  mov    %ebx,%r8d
  mov    %rax,0x18(%rsp)
  mov    %rax,%r12
  test   %r15d,%r15d
  jg     L39
  jmp    L36
  nopw   0x0(%rax,%rax,1)
L38:
  mov    0xc(%rsp),%r10d
  test   %r10d,%r10d
  jne    L76
  movzbl (%r14),%eax
  mov    %r13d,%ecx
  mov    0x10(%rsp),%rdi
  add    %ebx,%r8d
  sar    %cl,%eax
  shl    %cl,%eax
  sar    %cl,%eax
  movzbl %al,%eax
  movzbl (%rdi,%rax,1),%eax
  mov    %al,(%r12)
L117:
  add    $0x1,%ebp
  sub    $0x8,%r8d
  add    $0x1,%r12
  cmp    0x8(%rsp),%ebp
  jge    L36
L39:
  mov    (%rsp),%rdi
  movslq %ebp,%rax
  lea    (%rdi,%rax,1),%r14
  movzbl (%r14),%r9d
  cmp    %r8d,%ebx
  jle    L38
  mov    (%rsp),%rdi
  mov    %ebx,%esi
  mov    $0x8,%r10d
  mov    $0x8,%r11d
  sub    %r8d,%esi
  sub    %r8d,%r11d
  lea    -0x1(%rdi,%rax,1),%r15
  mov    0xc(%rsp),%edi
  sub    %esi,%r10d
  movzbl (%r15),%edx
  test   %edi,%edi
  jne    L101
  mov    %r11d,%ecx
  mov    0x10(%rsp),%rax
  sar    %cl,%r9d
  mov    %r13d,%ecx
  shl    %cl,%r9d
  sar    %cl,%r9d
  mov    %r10d,%ecx
  shl    %cl,%edx
  mov    %r13d,%ecx
  movzbl %dl,%edx
  sar    %cl,%edx
  add    %edx,%r9d
  movzbl %r9b,%r9d
  movzbl (%rax,%r9,1),%eax
  mov    %al,(%r12)
L19:
  add    %ebx,%r8d
  cmp    $0x7,%r8d
  jg     L117
  add    $0x1,%r12
  cmp    0x8(%rsp),%ebp
  jl     L39
L36:
  mov    0x18(%rsp),%rbx
  movslq 0x2c(%rsp),%rax
  movb   $0x0,(%rbx,%rax,1)
  add    $0x38,%rsp
  mov    %rbx,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L76:
  movzbl %r9b,%edx
  movzbl %bl,%esi
  lea    D47(%rip),%rdi
  xor    %eax,%eax
  mov    %edx,%ecx
  mov    %r8d,0x20(%rsp)
  call   <printf@plt>
  movzbl (%r14),%eax
  mov    %r13d,%ecx
  mov    0x10(%rsp),%rdi
  mov    0x20(%rsp),%r8d
  sar    %cl,%eax
  shl    %cl,%eax
  sar    %cl,%eax
  mov    %eax,%esi
  movzbl %al,%eax
  movzbl (%rdi,%rax,1),%edx
  mov    %dl,(%r12)
L9:
  movzbl %sil,%esi
  mov    %edx,%ecx
  lea    D4(%rip),%rdi
  xor    %eax,%eax
  mov    %r8d,0x20(%rsp)
  call   <printf@plt>
  mov    0x20(%rsp),%r8d
  jmp    L19
  nopl   0x0(%rax,%rax,1)
L101:
  mov    %r11d,0x28(%rsp)
  sub    $0x8,%rsp
  mov    %edx,%ecx
  movzbl %sil,%esi
  mov    %r10d,0x2c(%rsp)
  lea    D2(%rip),%rdi
  xor    %eax,%eax
  push   %r9
  mov    %r8d,0x30(%rsp)
  call   <printf@plt>
  mov    0x38(%rsp),%r11d
  movzbl (%r14),%esi
  xor    %eax,%eax
  lea    D9(%rip),%rdi
  mov    %r11d,%ecx
  sar    %cl,%esi
  mov    %r13d,%ecx
  shl    %cl,%esi
  sar    %cl,%esi
  mov    %esi,%r14d
  movzbl %sil,%esi
  call   <printf@plt>
  mov    0x34(%rsp),%r10d
  movzbl (%r15),%r15d
  xor    %eax,%eax
  lea    D49(%rip),%rdi
  mov    %r10d,%ecx
  shl    %cl,%r15d
  mov    %r13d,%ecx
  movzbl %r15b,%r15d
  sar    %cl,%r15d
  mov    %r15d,%esi
  call   <printf@plt>
  mov    0x20(%rsp),%rdi
  lea    (%r14,%r15,1),%esi
  movzbl %sil,%eax
  movzbl (%rdi,%rax,1),%edx
  mov    %dl,(%r12)
  pop    %rax
  pop    %rcx
  mov    0x20(%rsp),%r8d
  jmp    L9
```

tool_calls: name: parse_data
arguments: data_tag: D47
type_infered: string
name: parse_data
arguments: data_tag: D4
type_infered: string
name: parse_data
arguments: data_tag: D2
type_infered: string
name: parse_data
arguments: data_tag: D9
type_infered: string
name: parse_data
arguments: data_tag: D49
type_infered: string

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


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


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


tool: D9: DEBUG - Intermediate value is %d


tool: D49: DEBUG - Intermediate othervalue is %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;
}
```