user: Converte this assembly snippet into its equivalent C code:

```asm
<generate_filename>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  add    $0xffffffffffffff80,%rsp
  mov    %rdi,-0x58(%rbp)
  mov    %rsi,-0x60(%rbp)
  mov    %edx,-0x64(%rbp)
  mov    %ecx,-0x68(%rbp)
  mov    %r8d,-0x6c(%rbp)
  mov    %r9,-0x78(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x60(%rbp),%rax
  add    $0xffa,%rax
  mov    %rax,-0x18(%rbp)
  mov    -0x58(%rbp),%rax
  sub    $0x1,%rax
  mov    %rax,-0x40(%rbp)
  mov    -0x60(%rbp),%rax
  sub    $0x1,%rax
  mov    %rax,-0x48(%rbp)
  jmp    L294
L39:
  mov    -0x48(%rbp),%rax
  cmp    -0x18(%rbp),%rax
  jae    L377
  mov    -0x40(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x25,%al
  jne    L294
  mov    -0x40(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  cmp    $0x79,%eax
  je     L34
  cmp    $0x79,%eax
  jg     L10
  cmp    $0x78,%eax
  je     L381
  cmp    $0x78,%eax
  jg     L10
  cmp    $0x65,%eax
  je     L399
  cmp    $0x65,%eax
  jg     L10
  cmp    $0x25,%eax
  je     L380
  cmp    $0x63,%eax
  je     L40
  jmp    L10
L381:
  subq   $0x1,-0x48(%rbp)
  cmpl   $0x0,-0x6c(%rbp)
  je     L186
  lea    -0x10(%rbp),%rax
  sub    $0x1,%rax
  mov    %rax,-0x38(%rbp)
  mov    -0x64(%rbp),%edx
  lea    -0x10(%rbp),%rax
  lea    D3(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  jmp    L244
L9:
  mov    -0x48(%rbp),%rax
  cmp    -0x18(%rbp),%rax
  jae    L259
L244:
  addq   $0x1,-0x38(%rbp)
  addq   $0x1,-0x48(%rbp)
  mov    -0x38(%rbp),%rax
  movzbl (%rax),%edx
  mov    -0x48(%rbp),%rax
  mov    %dl,(%rax)
  mov    -0x48(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L9
  jmp    L356
L259:
  nop
L356:
  subq   $0x1,-0x48(%rbp)
L186:
  addq   $0x1,-0x40(%rbp)
  jmp    L10
L34:
  subq   $0x1,-0x48(%rbp)
  cmpl   $0x0,-0x6c(%rbp)
  je     L366
  lea    -0x10(%rbp),%rax
  sub    $0x1,%rax
  mov    %rax,-0x30(%rbp)
  mov    -0x68(%rbp),%edx
  lea    -0x10(%rbp),%rax
  lea    D3(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  jmp    L345
L6:
  mov    -0x48(%rbp),%rax
  cmp    -0x18(%rbp),%rax
  jae    L211
L345:
  addq   $0x1,-0x30(%rbp)
  addq   $0x1,-0x48(%rbp)
  mov    -0x30(%rbp),%rax
  movzbl (%rax),%edx
  mov    -0x48(%rbp),%rax
  mov    %dl,(%rax)
  mov    -0x48(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L6
  jmp    L246
L211:
  nop
L246:
  subq   $0x1,-0x48(%rbp)
L366:
  addq   $0x1,-0x40(%rbp)
  jmp    L10
L40:
  subq   $0x1,-0x48(%rbp)
  cmpl   $0x0,-0x6c(%rbp)
  je     L174
  lea    -0x10(%rbp),%rax
  sub    $0x1,%rax
  mov    %rax,-0x28(%rbp)
  mov    -0x68(%rbp),%ecx
  mov    -0x64(%rbp),%edx
  lea    -0x10(%rbp),%rax
  lea    D0(%rip),%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <sprintf@plt>
  jmp    L215
L369:
  mov    -0x48(%rbp),%rax
  cmp    -0x18(%rbp),%rax
  jae    L278
L215:
  addq   $0x1,-0x28(%rbp)
  addq   $0x1,-0x48(%rbp)
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%edx
  mov    -0x48(%rbp),%rax
  mov    %dl,(%rax)
  mov    -0x48(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L369
  jmp    L51
L278:
  nop
L51:
  subq   $0x1,-0x48(%rbp)
L174:
  addq   $0x1,-0x40(%rbp)
  jmp    L10
L399:
  subq   $0x1,-0x48(%rbp)
  mov    -0x78(%rbp),%rax
  sub    $0x1,%rax
  mov    %rax,-0x20(%rbp)
  jmp    L250
L160:
  mov    -0x48(%rbp),%rax
  cmp    -0x18(%rbp),%rax
  jae    L154
L250:
  addq   $0x1,-0x20(%rbp)
  addq   $0x1,-0x48(%rbp)
  mov    -0x20(%rbp),%rax
  movzbl (%rax),%edx
  mov    -0x48(%rbp),%rax
  mov    %dl,(%rax)
  mov    -0x48(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L160
  jmp    L362
L154:
  nop
L362:
  subq   $0x1,-0x48(%rbp)
  addq   $0x1,-0x40(%rbp)
  jmp    L10
L380:
  subq   $0x1,-0x48(%rbp)
  addq   $0x1,-0x40(%rbp)
  nop
L10:
  mov    -0x40(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L134
L294:
  addq   $0x1,-0x40(%rbp)
  addq   $0x1,-0x48(%rbp)
  mov    -0x40(%rbp),%rax
  movzbl (%rax),%edx
  mov    -0x48(%rbp),%rax
  mov    %dl,(%rax)
  mov    -0x48(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L39
  jmp    L60
L377:
  nop
  jmp    L60
L134:
  nop
L60:
  mov    -0x48(%rbp),%rax
  movb   $0x0,(%rax)
  mov    -0x60(%rbp),%rax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L310
  call   <__stack_chk_fail@plt>
L310:
  leave
  ret
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D3
type_infered: string
name: extract_symbolic_data
arguments: data_tag: D0
type_infered: string

tool: D3: %i

tool: D0: _%i_%i

assistant: ```c
char *generate_filename(const char *template, char *result, int x, int y, int pages, const char *extension) {
  char *a;
  const char *b;
  char *end = result + 4090;
  b = template - 1, a = result - 1;
  while ((*++a = *++b)) {
    if (a >= end)
      break;
    if (*b == '%') {
      switch (b[1]) {
      case 'x':
        a--;
        if (pages) {
          char text[8];
          char *e = text - 1;
          sprintf(text, "%i", x);
          while ((*++a = *++e))
            if (a >= end)
              break;
          a--;
        }
        b++;
        break;
      case 'y':
        a--;
        if (pages) {
          char text[8];
          char *e = text - 1;
          sprintf(text, "%i", y);
          while ((*++a = *++e))
            if (a >= end)
              break;
          a--;
        }
        b++;
        break;
      case 'c':
        a--;
        if (pages) {
          char text[8];
          char *e = text - 1;
          sprintf(text, "_%i_%i", x, y);
          while ((*++a = *++e))
            if (a >= end)
              break;
          a--;
        }
        b++;
        break;
      case 'e':
        a--;
        {
          const char *e = extension - 1;
          while ((*++a = *++e))
            if (a >= end)
              break;
          a--;
        }
        b++;
        break;
      case '%':
        a--;
        b++;
        break;
      }
      if (!*b)
        break;
    }
  }
  *a = 0;
  return result;
}
```