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

```asm
<aim_interpolate_variables>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %rdi,%r12
  mov    %rsi,%r14
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  xor    %eax,%eax
  mov    $0x0,%edi
  call   <time@plt>
  mov    %eax,0x14(%rsp)
  lea    0x14(%rsp),%rdi
  call   <localtime@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L28
  mov    (%rax),%edx
  cmp    $0xc,%edx
  jle    L153
  sub    $0xc,%edx
  lea    D61(%rip),%r9
L242:
  mov    0x4(%rbx),%ecx
  lea    0x29(%rsp),%rbp
  mov    0x8(%rbx),%r8d
  lea    D47(%rip),%rsi
  mov    %rbp,%rdi
  call   <sprintf@plt>
  mov    0x14(%rbx),%eax
  mov    0xc(%rbx),%esi
  lea    0x1(%rsi),%ecx
  lea    0x1a(%rsp),%r13
  lea    0x76c(%rax),%r9d
  mov    0x10(%rbx),%r8d
  lea    D59(%rip),%rdx
  mov    $0xf,%esi
  mov    %r13,%rdi
  call   <snprintf@plt>
  mov    %r14,%rdi
  call   <strlen@plt>
  mov    %rax,(%rsp)
  mov    %r13,%rdi
  call   <strlen@plt>
  mov    %rax,0x8(%rsp)
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %rax,%r15
  mov    %r12,%rdi
  call   <strlen@plt>
  test   %rax,%rax
  je     L74
  mov    %r12,%rbx
  add    %rax,%r12
  mov    $0x0,%edx
  mov    $0x0,%ebp
  lea    D71(%rip),%r13
  jmp    L226
L153:
  test   %edx,%edx
  jne    L4
  mov    $0xc,%edx
  lea    D43(%rip),%r9
  jmp    L242
L4:
  cmp    $0xc,%edx
  lea    D43(%rip),%r9
  lea    D61(%rip),%rax
  cmovge %rax,%r9
  jmp    L242
L165:
  cmp    $0x74,%al
  jne    L23
  cmp    $0x1,%edx
  je     L125
  movslq %ebp,%rax
  movb   $0x74,0x0(%r13,%rax,1)
  lea    0x1(%rbp),%ebp
  jmp    L257
L63:
  cmp    $0x1,%edx
  je     L261
  mov    $0x1,%edx
  jmp    L257
L261:
  lea    0x1(%rbp),%eax
  movslq %ebp,%rdx
  movb   $0x25,0x0(%r13,%rdx,1)
  add    $0x2,%ebp
  cltq
  movb   $0x25,0x0(%r13,%rax,1)
  mov    $0x0,%edx
  jmp    L257
L279:
  cmp    $0x1,%edx
  je     L195
  movslq %ebp,%rax
  movb   $0x6e,0x0(%r13,%rax,1)
  lea    0x1(%rbp),%ebp
  jmp    L257
L195:
  movslq %ebp,%rdi
  add    %r13,%rdi
  mov    (%rsp),%rdx
  mov    %r14,%rsi
  call   <memcpy@plt>
  add    (%rsp),%ebp
  mov    $0x0,%edx
  jmp    L257
L265:
  lea    0x1a(%rsp),%rsi
  movslq %ebp,%rdi
  add    %r13,%rdi
  mov    0x8(%rsp),%rdx
  call   <memcpy@plt>
  add    0x8(%rsp),%ebp
  mov    $0x0,%edx
  jmp    L257
L125:
  lea    0x29(%rsp),%rsi
  movslq %ebp,%rdi
  add    %r13,%rdi
  mov    %r15,%rdx
  call   <memcpy@plt>
  add    %r15d,%ebp
  mov    $0x0,%edx
  jmp    L257
L23:
  cmp    $0x1,%edx
  je     L217
L119:
  movzbl (%rcx),%edx
  movslq %ebp,%rax
  mov    %dl,0x0(%r13,%rax,1)
  lea    0x1(%rbp),%ebp
  mov    $0x0,%edx
L257:
  add    $0x1,%rbx
  cmp    %r12,%rbx
  je     L81
L226:
  mov    %rbx,%rcx
  movzbl (%rbx),%eax
  cmp    $0x6e,%al
  je     L279
  jg     L165
  cmp    $0x25,%al
  je     L63
  cmp    $0x64,%al
  jne    L23
  cmp    $0x1,%edx
  je     L265
  movslq %ebp,%rax
  movb   $0x64,0x0(%r13,%rax,1)
  lea    0x1(%rbp),%ebp
  jmp    L257
L217:
  movslq %ebp,%rax
  movb   $0x25,0x0(%r13,%rax,1)
  lea    0x1(%rbp),%ebp
  jmp    L119
L74:
  mov    $0x0,%ebp
L81:
  lea    D71(%rip),%rbx
  movslq %ebp,%rbp
  movb   $0x0,(%rbx,%rbp,1)
L28:
  mov    0x38(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L102
  mov    %rbx,%rax
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L102:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: tag: D61
type: string
name: parse_data
arguments: tag: D47
type: string
name: parse_data
arguments: tag: D59
type: string
name: parse_data
arguments: tag: D43
type: string

tool: D61: PM

tool: D47: %d:%02d:%02d %s

tool: D59: %d/%d/%d

tool: D43: AM

assistant: ```c
char *aim_interpolate_variables(const char *const input, const char *const nickname) {
  static char output[16384];
  int o = 0, gotpercent = 0;
  size_t nl, dl, tl, l, i;
  char date[15], tim[15];
  {
    int hour;
    int am = 1;
    struct tm *t;
    time_t b;
    b = time(NULL);
    t = localtime(&b);
    if (t == NULL)
      return (NULL);
    hour = t->tm_hour;
    if (hour >= 12)
      am = 0;
    if (hour > 12)
      hour -= 12;
    if (hour == 0)
      hour = 12;
    sprintf(tim, "%d:%02d:%02d %s", hour, t->tm_min, t->tm_sec, am == 1 ? "AM" : "PM");
    snprintf(date, 15, "%d/%d/%d", t->tm_mon + 1, t->tm_mday, t->tm_year + 1900);
  }
  nl = strlen(nickname);
  dl = strlen(date);
  tl = strlen(tim);
  l = strlen(input);
  for (i = 0; i < l; i++)
    switch (input[i]) {
    case '%':
      if (gotpercent == 1) {
        gotpercent = 0;
        output[o++] = '%';
        output[o++] = '%';
      } else
        gotpercent = 1;
      break;
    case 'n':
      if (gotpercent == 1) {
        gotpercent = 0;
        memcpy(&output[o], nickname, nl);
        o += nl;
      } else
        output[o++] = 'n';
      break;
    case 'd':
      if (gotpercent == 1) {
        gotpercent = 0;
        memcpy(&output[o], date, dl);
        o += dl;
      } else
        output[o++] = 'd';
      break;
    case 't':
      if (gotpercent == 1) {
        gotpercent = 0;
        memcpy(&output[o], tim, tl);
        o += tl;
      } else
        output[o++] = 't';
      break;
    default:
      if (gotpercent == 1) {
        gotpercent = 0;
        output[o++] = '%';
      }
      output[o++] = input[i];
    }
  output[o] = 0;
  return (output);
}
```