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

```asm
<__cl_printf>:
  endbr64
  push   %r15
  mov    %rdi,%rsi
  push   %r14
  lea    D34(%rip),%r14
  push   %r13
  lea    D14(%rip),%r13
  push   %r12
  lea    D27(%rip),%r12
  push   %rbp
  lea    D46(%rip),%rbp
  push   %rbx
  mov    %rdi,%rbx
  xor    %edi,%edi
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  call   <va_start@plt>
  movzbl (%rbx),%eax
  mov    %al,0xf(%rsp)
  test   %al,%al
  jne    L137
  jmp    L135
  nopl   0x0(%rax,%rax,1)
L77:
  movzbl 0x1(%rbx),%eax
  mov    %al,0xf(%rsp)
  cmp    $0x25,%al
  je     L54
  cmp    $0x66,%al
  je     L152
  jg     L158
  cmp    $0x63,%al
  je     L55
  cmp    $0x64,%al
  jne    L167
  lea    0x10(%rsp),%r15
  xor    %edi,%edi
  mov    $0x1,%edx
  mov    %r15,%rsi
  call   <__cl_va_arg@plt>
  mov    %r15,%rsi
  mov    %r12,%rdi
  call   <vprintf@plt>
L62:
  movzbl 0x2(%rbx),%eax
  add    $0x2,%rbx
L39:
  mov    %al,0xf(%rsp)
  test   %al,%al
  je     L135
L137:
  cmp    $0x25,%al
  je     L77
  lea    0xf(%rsp),%rsi
  mov    %rbp,%rdi
  add    $0x1,%rbx
  call   <vprintf@plt>
  movzbl (%rbx),%eax
  mov    %al,0xf(%rsp)
  test   %al,%al
  jne    L137
L135:
  xor    %edi,%edi
  call   <va_end@plt>
  xor    %eax,%eax
  jmp    L126
  nopw   0x0(%rax,%rax,1)
L158:
  cmp    $0x73,%al
  jne    L167
  lea    0x10(%rsp),%r15
  xor    %edi,%edi
  mov    $0x2,%edx
  mov    %r15,%rsi
  call   <__cl_va_arg@plt>
  mov    %r15,%rsi
  mov    %r13,%rdi
  call   <vprintf@plt>
  jmp    L62
  nopl   (%rax)
L54:
  lea    0x10(%rsp),%rsi
  lea    D48(%rip),%rdi
  add    $0x2,%rbx
  call   <vprintf@plt>
  movzbl (%rbx),%eax
  jmp    L39
  nopl   (%rax)
L152:
  lea    0x10(%rsp),%r15
  xor    %edi,%edi
  mov    $0x2,%edx
  mov    %r15,%rsi
  call   <__cl_va_arg@plt>
  mov    %r15,%rsi
  mov    %r14,%rdi
  call   <vprintf@plt>
  jmp    L62
  nopl   0x0(%rax)
L167:
  xor    %edi,%edi
  call   <va_end@plt>
  lea    0xf(%rsp),%rsi
  lea    D54(%rip),%rdi
  call   <vprintf@plt>
  mov    $0xffffffff,%eax
L126:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L57
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L55:
  lea    0x10(%rsp),%r15
  xor    %edi,%edi
  mov    $0x1,%edx
  mov    %r15,%rsi
  call   <__cl_va_arg@plt>
  mov    %r15,%rsi
  mov    %rbp,%rdi
  call   <vprintf@plt>
  jmp    L62
L57:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D34
type: string
name: extract_symbolic_data
arguments: data_label: D14
type: string
name: extract_symbolic_data
arguments: data_label: D27
type: string
name: extract_symbolic_data
arguments: data_label: D46
type: string
name: extract_symbolic_data
arguments: data_label: D48
type: string
name: extract_symbolic_data
arguments: data_label: D54
type: string

tool: D34: %lf

tool: D14: %s

tool: D27: %d

tool: D46: %c

tool: D48: %%

tool: D54: (printf format string error)

assistant: ```c
int __cl_printf(__attribute__((address_space(4))) char *restrict format, ...) {
  char arg_data[8];
  va_list ap;
  va_start(ap, format);
  char ch = *format;
  while (ch) {
    if (ch == '%') {
      ch = *++format;
      if (ch == '%') {
        vprintf("%%", arg_data);
        ch = *++format;
      } else {
        switch (ch) {
        case 'c': {
          __cl_va_arg(ap, arg_data, 1);
          vprintf("%c", arg_data);
          break;
        }
        case 'd': {
          __cl_va_arg(ap, arg_data, 1);
          vprintf("%d", arg_data);
          break;
        }
        case 'f': {
          __cl_va_arg(ap, arg_data, 2);
          vprintf("%lf", arg_data);
          break;
        }
        case 's': {
          __cl_va_arg(ap, arg_data, 2);
          vprintf("%s", arg_data);
          break;
        }
        default:
          goto error;
        }
        ch = *++format;
      }
    } else {
      vprintf("%c", &ch);
      ch = *++format;
    }
  }
  va_end(ap);
  return 0;
error:
  va_end(ap);
  vprintf("(printf format string error)", &ch);
  return -1;
}
```