user: Please show me the C implementation that matches the assembly code listed below:

```asm
<int2key>:
  endbr64
  push   %r13
  push   %rbp
  push   %rbx
  cmp    $0x5,%ecx
  ja     10e0 <int2key.cold>
  mov    %rsi,%r13
  mov    %ecx,%ecx
  lea    D8(%rip),%rsi
  mov    %rdi,%rbp
  movslq (%rsi,%rcx,4),%rax
  add    %rsi,%rax
  notrack jmp *%rax
  nopw   0x0(%rax,%rax,1)
  xor    %eax,%eax
  call   <rc4rand@plt>
  mov    $0x10,%edx
  cmp    %rdx,%r13
  mov    %rdx,%rdi
  cltq
  cmovbe %r13,%rdi
  xor    %edx,%edx
  div    %rdi
  mov    %rdx,%r13
  test   %rdx,%rdx
  je     L26
  lea    -0x1(%rdx),%eax
  lea    0x1(%rbp,%rax,1),%rbx
  nopl   (%rax)
L52:
  xor    %eax,%eax
  add    $0x1,%rbp
  call   <rc4rand@plt>
  cltd
  shr    $0x1e,%edx
  add    %edx,%eax
  and    $0x3,%eax
  sub    %edx,%eax
  add    $0x41,%eax
  mov    %al,-0x1(%rbp)
  cmp    %rbx,%rbp
  jne    L52
  mov    %r13,%rax
  pop    %rbx
  pop    %rbp
  pop    %r13
  ret
  nopl   0x0(%rax)
  cmp    %r13,%rdx
  mov    $0x41,%esi
  cmovbe %rdx,%r13
  mov    %r13,%rdx
  call   <memset@plt>
L26:
  mov    %r13,%rax
  pop    %rbx
  pop    %rbp
  pop    %r13
  ret
  nopl   0x0(%rax)
  pop    %rbx
  mov    %rdx,%rcx
  mov    %r13,%rsi
  pop    %rbp
  lea    D16(%rip),%rdx
  pop    %r13
  jmp    10a0 <snprintf@plt>
  cs nopw 0x0(%rax,%rax,1)
  mov    %rdx,%rdi
  call   <int2int@plt>
  mov    $0x10,%esi
  pop    %rbx
  mov    %rbp,%rdi
  cmp    %rsi,%r13
  pop    %rbp
  mov    %rax,%rdx
  cmovbe %r13,%rsi
  pop    %r13
  jmp    10d0 <int2alphakey@plt>
  nopl   0x0(%rax,%rax,1)
  xor    %eax,%eax
  call   <rc4rand@plt>
  mov    $0x10,%edx
  cmp    %rdx,%r13
  mov    %rdx,%rdi
  cltq
  cmovbe %r13,%rdi
  xor    %edx,%edx
  div    %rdi
  mov    %rdx,%r13
  test   %rdx,%rdx
  je     L26
  lea    -0x1(%rdx),%eax
  lea    0x1(%rbp,%rax,1),%rbx
  nopl   (%rax)
L47:
  xor    %eax,%eax
  add    $0x1,%rbp
  call   <rc4rand@plt>
  mov    %al,-0x1(%rbp)
  cmp    %rbp,%rbx
  jne    L47
  mov    %r13,%rax
  pop    %rbx
  pop    %rbp
  pop    %r13
  ret
  nopl   0x0(%rax,%rax,1)
  xor    %eax,%eax
  call   <rc4rand@plt>
  mov    $0x10,%edx
  cmp    %rdx,%r13
  mov    %rdx,%rbx
  cltq
  cmovbe %r13,%rbx
  xor    %edx,%edx
  div    %rbx
  mov    %rdx,%r13
  test   %rdx,%rdx
  je     L26
  lea    -0x1(%rdx),%eax
  lea    0x1(%rbp,%rax,1),%rbx
  nopl   0x0(%rax)
L46:
  xor    %eax,%eax
  add    $0x1,%rbp
  call   <rc4rand@plt>
  movslq %eax,%rcx
  cltd
  imul   $0xffffffff8d3dcb09,%rcx,%rcx
  shr    $0x20,%rcx
  add    %eax,%ecx
  sar    $0x5,%ecx
  sub    %edx,%ecx
  imul   $0x3a,%ecx,%ecx
  sub    %ecx,%eax
  add    $0x41,%eax
  mov    %al,-0x1(%rbp)
  cmp    %rbx,%rbp
  jne    L46
  mov    %r13,%rax
  pop    %rbx
  pop    %rbp
  pop    %r13
  ret
```

tool_calls: name: unpack_data
arguments: data_tag: D16
type_infered: string

tool: D16: %lu

assistant: ```c
size_t int2key(char *s, size_t maxlen, uint32_t i, int mode) {
  if (mode == 0) {
    return snprintf(s, maxlen, "%lu", (unsigned long)i);
  } else if (mode == 1) {
    if (maxlen > 16)
      maxlen = 16;
    i = int2int(i);
    return int2alphakey(s, maxlen, i);
  } else if (mode == 2) {
    if (maxlen > 16)
      maxlen = 16;
    int r = rc4rand() % maxlen;
    for (int i = 0; i < r; i++)
      s[i] = rc4rand() & 0xff;
    return r;
  } else if (mode == 3) {
    if (maxlen > 16)
      maxlen = 16;
    int r = rc4rand() % maxlen;
    for (int i = 0; i < r; i++)
      s[i] = 'A' + rc4rand() % ('z' - 'A' + 1);
    return r;
  } else if (mode == 4) {
    if (maxlen > 16)
      maxlen = 16;
    int r = rc4rand() % maxlen;
    for (int i = 0; i < r; i++)
      s[i] = 'A' + rc4rand() % 4;
    return r;
  } else if (mode == 5) {
    if (i > maxlen)
      i = maxlen;
    memset(s, 'A', i);
    return i;
  } else {
    return 0;
  }
}
```