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

```asm
<sqlite_encode_binary>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x450,%rsp
  mov    %rdi,-0x438(%rbp)
  mov    %esi,-0x43c(%rbp)
  mov    %rdx,-0x448(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  cmpl   $0x0,-0x43c(%rbp)
  jg     L10
  cmpq   $0x0,-0x448(%rbp)
  je     L82
  mov    -0x448(%rbp),%rax
  movb   $0x78,(%rax)
  mov    -0x448(%rbp),%rax
  add    $0x1,%rax
  movb   $0x0,(%rax)
L82:
  mov    $0x1,%eax
  jmp    L71
L10:
  lea    -0x410(%rbp),%rax
  mov    $0x400,%edx
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  mov    -0x43c(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x424(%rbp)
  jmp    L151
L133:
  mov    -0x424(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x438(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%eax
  movslq %eax,%rdx
  mov    -0x410(%rbp,%rdx,4),%edx
  add    $0x1,%edx
  cltq
  mov    %edx,-0x410(%rbp,%rax,4)
  subl   $0x1,-0x424(%rbp)
L151:
  cmpl   $0x0,-0x424(%rbp)
  jns    L133
  mov    -0x43c(%rbp),%eax
  mov    %eax,-0x418(%rbp)
  movl   $0x1,-0x424(%rbp)
  jmp    L30
L168:
  cmpl   $0x27,-0x424(%rbp)
  je     L192
  mov    -0x424(%rbp),%eax
  cltq
  mov    -0x410(%rbp,%rax,4),%edx
  mov    -0x424(%rbp),%eax
  add    $0x1,%eax
  movzbl %al,%eax
  cltq
  mov    -0x410(%rbp,%rax,4),%eax
  add    %eax,%edx
  mov    -0x424(%rbp),%eax
  add    $0x27,%eax
  movzbl %al,%eax
  cltq
  mov    -0x410(%rbp,%rax,4),%eax
  add    %edx,%eax
  mov    %eax,-0x414(%rbp)
  mov    -0x414(%rbp),%eax
  cmp    -0x418(%rbp),%eax
  jge    L4
  mov    -0x414(%rbp),%eax
  mov    %eax,-0x418(%rbp)
  mov    -0x424(%rbp),%eax
  mov    %eax,-0x41c(%rbp)
  cmpl   $0x0,-0x418(%rbp)
  je     L83
  jmp    L4
L192:
  nop
L4:
  addl   $0x1,-0x424(%rbp)
L30:
  cmpl   $0xff,-0x424(%rbp)
  jle    L168
  jmp    L117
L83:
  nop
L117:
  cmpq   $0x0,-0x448(%rbp)
  jne    L66
  mov    -0x43c(%rbp),%edx
  mov    -0x418(%rbp),%eax
  add    %edx,%eax
  add    $0x1,%eax
  jmp    L71
L66:
  mov    -0x41c(%rbp),%eax
  mov    %eax,%edx
  mov    -0x448(%rbp),%rax
  mov    %dl,(%rax)
  movl   $0x1,-0x420(%rbp)
  movl   $0x0,-0x424(%rbp)
  jmp    L163
L5:
  mov    -0x424(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x438(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  mov    -0x41c(%rbp),%edx
  sub    %edx,%eax
  mov    %al,-0x425(%rbp)
  cmpb   $0x0,-0x425(%rbp)
  je     L53
  cmpb   $0x1,-0x425(%rbp)
  je     L53
  cmpb   $0x27,-0x425(%rbp)
  jne    L49
L53:
  mov    -0x420(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x420(%rbp)
  movslq %eax,%rdx
  mov    -0x448(%rbp),%rax
  add    %rdx,%rax
  movb   $0x1,(%rax)
  movzbl -0x425(%rbp),%eax
  add    $0x1,%eax
  mov    %al,-0x425(%rbp)
L49:
  mov    -0x420(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x420(%rbp)
  movslq %eax,%rdx
  mov    -0x448(%rbp),%rax
  add    %rax,%rdx
  movzbl -0x425(%rbp),%eax
  mov    %al,(%rdx)
  addl   $0x1,-0x424(%rbp)
L163:
  mov    -0x424(%rbp),%eax
  cmp    -0x43c(%rbp),%eax
  jl     L5
  mov    -0x420(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x448(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x43c(%rbp),%edx
  mov    -0x418(%rbp),%eax
  add    %edx,%eax
  add    $0x1,%eax
  cmp    %eax,-0x420(%rbp)
  sete   %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  mov    -0x420(%rbp),%eax
L71:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L37
  call   <__stack_chk_fail@plt>
L37:
  leave
  ret
```

assistant: ```c
int sqlite_encode_binary(const unsigned char *in, int n, unsigned char *out) {
  int i, j, e, m;
  unsigned char x;
  int cnt[256];
  if (n <= 0) {
    if (out) {
      out[0] = 'x';
      out[1] = 0;
    }
    return 1;
  }
  memset(cnt, 0, sizeof(cnt));
  for (i = n - 1; i >= 0; i--) {
    cnt[in[i]]++;
  }
  m = n;
  for (i = 1; i < 256; i++) {
    int sum;
    if (i == '\'')
      continue;
    sum = cnt[i] + cnt[(i + 1) & 0xff] + cnt[(i + '\'') & 0xff];
    if (sum < m) {
      m = sum;
      e = i;
      if (m == 0)
        break;
    }
  }
  if (out == 0) {
    return n + m + 1;
  }
  out[0] = e;
  j = 1;
  for (i = 0; i < n; i++) {
    x = in[i] - e;
    if (x == 0 || x == 1 || x == '\'') {
      out[j++] = 1;
      x++;
    }
    out[j++] = x;
  }
  out[j] = 0;
  assert(j == n + m + 1);
  return j;
}
```