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

```asm
<packline>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %rdi,%rbp
  mov    %rsi,0x18(%rsp)
  mov    %edx,%ebx
  mov    %ecx,0x14(%rsp)
  mov    %r8d,%r13d
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  xor    %eax,%eax
  lea    0x1(%rsi),%r12
  movb   $0x0,(%rsi)
  mov    $0x0,%edx
  mov    $0x0,%esi
  mov    $0x0,%edi
  call   <intobyte@plt>
  test   %ebx,%ebx
  je     L121
  movslq %r13d,%rax
  mov    %rax,0x8(%rsp)
  jmp    L59
L119:
  mov    %ebx,%r14d
  mov    %r13d,%eax
  jmp    L198
L136:
  mov    $0x0,%esi
L197:
  add    $0x1,%esi
  add    0x8(%rsp),%rbp
  sub    $0x1,%ebx
  cmp    %r13b,0x0(%rbp)
  jne    L95
  test   %ebx,%ebx
  je     L95
  cmp    $0xf,%esi
  jne    L197
L95:
  mov    %r12,%rdx
  mov    $0x5,%edi
  call   <intobyte@plt>
  mov    %rax,%rdx
  movzbl %r13b,%esi
  mov    0x14(%rsp),%edi
  call   <intobyte@plt>
  mov    %rax,%r12
  jmp    L13
L131:
  test   %ebx,%ebx
  je     L185
  mov    $0x0,%r14d
  jmp    L97
L185:
  mov    %ebx,%r14d
  mov    %r13d,%eax
  lea    0x20(%rsp),%rdx
  jmp    L198
L121:
  mov    %r12,%rdx
  mov    $0x0,%esi
  mov    $0x8,%edi
  call   <intobyte@plt>
  mov    %rax,%rdx
  mov    0x18(%rsp),%rdi
  sub    %rdi,%rdx
  mov    %dl,(%rdi)
  mov    0x38(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L130
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L133:
  test   %ebx,%ebx
  je     L198
  cmp    $0xf,%r14d
  je     L198
L97:
  sub    $0x1,%r14d
  sub    0x8(%rsp),%rbp
  add    $0x1,%ebx
  jmp    L174
L188:
  test   %ebx,%ebx
  je     L198
  cmp    $0xf,%r14d
  jne    L174
L198:
  mov    %al,(%rdx)
L174:
  mov    %r14d,%esi
  or     $0x10,%esi
  mov    %r12,%rdx
  mov    $0x5,%edi
  call   <intobyte@plt>
  mov    %rax,%r12
  lea    0x20(%rsp),%r13
  mov    %r13,%r15
L146:
  add    $0x1,%r13
  movzbl -0x1(%r13),%esi
  mov    %r12,%rdx
  mov    0x14(%rsp),%edi
  call   <intobyte@plt>
  mov    %rax,%r12
  mov    %r15d,%eax
  sub    %r13d,%eax
  add    %r14d,%eax
  jns    L146
L13:
  test   %ebx,%ebx
  je     L121
L59:
  movzbl 0x0(%rbp),%r13d
  add    0x8(%rsp),%rbp
  sub    $0x1,%ebx
  movzbl 0x0(%rbp),%eax
  cmp    %r13b,%al
  jne    L246
  test   %ebx,%ebx
  jne    L136
L246:
  cmp    %r13b,%al
  je     L131
  mov    $0x0,%r14d
  lea    0x20(%rsp),%rdx
  test   %ebx,%ebx
  je     L119
L96:
  add    $0x1,%rdx
  mov    %r13b,-0x1(%rdx)
  add    $0x1,%r14d
  add    0x8(%rsp),%rbp
  sub    $0x1,%ebx
  movzbl 0x0(%rbp),%ecx
  cmp    %al,%cl
  je     L133
  mov    %eax,%r13d
  test   %ebx,%ebx
  je     L188
  cmp    $0xf,%r14d
  je     L188
  mov    %ecx,%eax
  jmp    L96
L130:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
unsigned char *packline(unsigned char *in, unsigned char *out, int len, int size, int dir) {
  unsigned char differ[16], *d_ptr, *out0, last;
  int counter;
  out0 = out++;
  *out0 = 0;
  intobyte(0, 0, 0);
  while (len) {
    last = *in;
    in += dir;
    --len;
    counter = 0;
    if ((last == *in) && len) {
      do {
        ++counter;
        in += dir;
        --len;
      } while (last == *in && len && counter != 15);
      out = intobyte(5, counter, out);
      out = intobyte(size, last, out);
    } else {
      d_ptr = differ;
      while (last != *in && len && counter != 15) {
        *d_ptr++ = last;
        ++counter;
        last = *in;
        in += dir;
        --len;
      }
      if (!len || counter == 15)
        *d_ptr = last;
      else if (last == *in) {
        --counter;
        in -= dir;
        ++len;
      }
      out = intobyte(5, counter | 0x10, out);
      d_ptr = differ;
      do {
        out = intobyte(size, *d_ptr++, out);
      } while (--counter >= 0);
    }
  }
  out = intobyte(8, 0, out);
  *out0 = out - out0;
  return out;
}
```