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

```asm
<aaip_encode_comp>:
  endbr64
  push   %r15
  mov    %rdi,%r15
  push   %r14
  push   %r13
  mov    %rsi,%r13
  push   %r12
  mov    %edx,%r12d
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rcx,0x8(%rsp)
  mov    %r8,0x10(%rsp)
  test   %r8,%r8
  jne    L39
  test   %edx,%edx
  jle    L51
L39:
  movslq 0x10(%rsp),%rax
  mov    0x8(%rsp),%rbx
  mov    %rax,%rcx
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  test   %rcx,%rcx
  jle    L65
  nop
L14:
  xor    %ebp,%ebp
  test   %r12d,%r12d
  mov    %r13,%rsi
  mov    %r15,%rdi
  setg   %bpl
  xor    %edx,%edx
  sub    %rax,%rbp
  add    0x10(%rsp),%rbp
  cmp    $0xff,%rbp
  seta   %dl
  call   <aaip_encode_byte@plt>
  mov    $0xff,%eax
  mov    %r13,%rsi
  mov    %r15,%rdi
  cmp    %rax,%rbp
  cmova  %rax,%rbp
  mov    %ebp,%edx
  mov    %ebp,%r14d
  call   <aaip_encode_byte@plt>
  mov    %r12d,0x4(%rsp)
  test   %r12d,%r12d
  jle    L74
  movzbl %r12b,%edx
  mov    %r13,%rsi
  lea    -0x1(%rbp),%r14d
  mov    %r15,%rdi
  call   <aaip_encode_byte@plt>
  movl   $0x0,0x4(%rsp)
L74:
  movslq %r14d,%rbp
  test   %r14d,%r14d
  jle    L81
  mov    %rbx,%r14
  nopl   0x0(%rax)
L42:
  movzbl (%r14),%edx
  mov    %r13,%rsi
  mov    %r15,%rdi
  add    $0x1,%r14
  call   <aaip_encode_byte@plt>
  mov    %r14,%rax
  sub    %rbx,%rax
  cmp    %rbp,%rax
  jl     L42
  mov    %r14,%rbx
L81:
  mov    %rbx,%rax
  sub    0x8(%rsp),%rax
  cmp    0x18(%rsp),%rax
  jge    L65
  test   %r12d,%r12d
  jle    L120
  mov    0x4(%rsp),%r12d
  jmp    L14
  nopl   0x0(%rax,%rax,1)
L2:
  mov    %rbp,%rbx
L25:
  mov    %rbx,%rax
  sub    0x8(%rsp),%rax
  cmp    %rax,0x18(%rsp)
  jle    L65
L120:
  mov    0x10(%rsp),%rbp
  xor    %edx,%edx
  mov    %r13,%rsi
  mov    %r15,%rdi
  mov    $0xff,%r12d
  sub    %rax,%rbp
  cmp    $0xff,%rbp
  seta   %dl
  call   <aaip_encode_byte@plt>
  cmp    %r12,%rbp
  mov    %r13,%rsi
  mov    %r15,%rdi
  cmovbe %rbp,%r12
  mov    %r12d,%edx
  call   <aaip_encode_byte@plt>
  test   %rbp,%rbp
  je     L25
  mov    %rbx,%rbp
  nopl   0x0(%rax)
L34:
  movzbl 0x0(%rbp),%edx
  mov    %r13,%rsi
  mov    %r15,%rdi
  add    $0x1,%rbp
  call   <aaip_encode_byte@plt>
  mov    %rbp,%rax
  sub    %rbx,%rax
  cmp    %rax,%r12
  jg     L34
  jmp    L2
L51:
  xor    %edx,%edx
  call   <aaip_encode_byte@plt>
  xor    %edx,%edx
  mov    %r13,%rsi
  mov    %r15,%rdi
  call   <aaip_encode_byte@plt>
L65:
  add    $0x28,%rsp
  mov    $0x1,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
int aaip_encode_comp(unsigned char *result, size_t *result_fill, int prefix, char *data, size_t l, int flag) {
  size_t todo;
  char *rpt, *comp_start;
  if (l == 0 && prefix <= 0) {
    aaip_encode_byte(result, result_fill, 0);
    aaip_encode_byte(result, result_fill, 0);
    return (1);
  }
  for (rpt = data; rpt - data < (ssize_t)l;) {
    todo = l - (rpt - data) + (prefix > 0);
    aaip_encode_byte(result, result_fill, (todo > 255));
    if (todo > 255)
      todo = 255;
    aaip_encode_byte(result, result_fill, todo);
    if (prefix > 0) {
      aaip_encode_byte(result, result_fill, prefix);
      todo--;
      prefix = 0;
    }
    for (comp_start = rpt; rpt - comp_start < (ssize_t)todo; rpt++)
      aaip_encode_byte(result, result_fill, *((unsigned char *)rpt));
  }
  return (1);
}
```