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

```asm
<calc_padding_ccc>:
  endbr64
  test   %edi,%edi
  lea    0x7(%rdi),%eax
  mov    %edx,%r9d
  mov    %rsi,%r8
  cmovns %edi,%eax
  and    $0x7,%edi
  sar    $0x3,%eax
  cmp    $0x1,%edi
  sbb    $0xffffffff,%eax
  movslq %eax,%rdx
  mov    %eax,%esi
  imul   $0x2aaaaaab,%rdx,%rdx
  sar    $0x1f,%esi
  shr    $0x20,%rdx
  sub    %esi,%edx
  lea    (%rdx,%rdx,4),%esi
  lea    (%rdx,%rdx,2),%edx
  add    %edx,%edx
  sub    %edx,%eax
  add    %esi,%eax
  cmp    $0x500,%eax
  jle    L54
  movl   $0x7,(%rcx)
  mov    $0x100,%edi
L98:
  sub    $0x3e,%r9d
  lea    0x3(%rdi,%rax,1),%esi
  movslq %r9d,%rcx
  sar    $0x1f,%r9d
  imul   $0x78787879,%rcx,%rcx
  sar    $0x23,%rcx
  sub    %r9d,%ecx
  nopw   0x0(%rax,%rax,1)
L107:
  mov    %esi,%eax
  add    $0x1,%ecx
  cltd
  idiv   %ecx
  cmp    $0x5a,%eax
  jg     L107
  cmp    $0x1,%edx
  mov    %ecx,(%r8)
  sbb    $0xffffffff,%eax
  imul   %eax,%ecx
  xor    %eax,%eax
  cmp    $0x3a0,%ecx
  jg     L6
  sub    %edi,%ecx
  sub    $0x3,%ecx
  movslq %ecx,%rax
  mov    %ecx,%edx
  imul   $0x66666667,%rax,%rax
  sar    $0x1f,%edx
  sar    $0x21,%rax
  sub    %edx,%eax
  lea    (%rax,%rax,2),%edx
  lea    (%rax,%rax,4),%eax
  sub    %eax,%ecx
  lea    (%rcx,%rdx,2),%eax
  shl    $0x3,%eax
  ret
  nopl   0x0(%rax)
L6:
  ret
  nopl   0x0(%rax)
L54:
  cmp    $0x280,%eax
  jg     L48
  cmp    $0x140,%eax
  jg     L104
  cmp    $0xa0,%eax
  jg     L40
  cmp    $0x28,%eax
  jg     L86
  mov    $0x4,%edi
  movl   $0x2,(%rcx)
  add    %edi,%edi
  jmp    L98
L48:
  mov    $0x6,%esi
L127:
  movq   D0(%rip),%xmm0
  mov    %esi,(%rcx)
  add    $0x1,%esi
  mov    $0x3,%ecx
L113:
  movd   %xmm0,%edx
  pshufd $0xe5,%xmm0,%xmm1
  movd   %xmm1,%edi
  imul   %edx,%edi
  lea    (%rcx,%rcx,1),%edx
  cmp    %edx,%esi
  je     L98
  add    %edi,%edi
  jmp    L98
L86:
  mov    $0x3,%esi
L121:
  movq   D4(%rip),%xmm0
  mov    %esi,(%rcx)
  add    $0x1,%esi
  mov    $0x2,%ecx
  jmp    L113
L40:
  mov    $0x4,%esi
  jmp    L121
L104:
  mov    $0x5,%esi
  jmp    L127
```

tool_calls: name: retrieve_data
arguments: data_tag: D0
type_infered: byte[8]
name: retrieve_data
arguments: data_tag: D4
type_infered: byte[8]

tool: {"D0": [0x08,0x00,0x00,0x00,0x08,0x00,0x00,0x00]}

tool: {"D4": [0x04,0x00,0x00,0x00,0x04,0x00,0x00,0x00]}

assistant: ```c
int calc_padding_ccc(int binary_length, int *cc_width, int lin_width, int *ecc) {
  int target_bitsize = 0;
  int byte_length, codewords_used, ecc_level, ecc_codewords, rows;
  int codewords_total, target_codewords, target_bytesize;
  int i;
  byte_length = binary_length / 8;
  if (binary_length % 8 != 0) {
    byte_length++;
  }
  codewords_used = (byte_length / 6) * 5;
  codewords_used += byte_length % 6;
  ecc_level = 7;
  if (codewords_used <= 1280) {
    ecc_level = 6;
  }
  if (codewords_used <= 640) {
    ecc_level = 5;
  }
  if (codewords_used <= 320) {
    ecc_level = 4;
  }
  if (codewords_used <= 160) {
    ecc_level = 3;
  }
  if (codewords_used <= 40) {
    ecc_level = 2;
  }
  *(ecc) = ecc_level;
  ecc_codewords = 1;
  for (i = 1; i <= (ecc_level + 1); i++) {
    ecc_codewords *= 2;
  }
  codewords_used += ecc_codewords;
  codewords_used += 3;
  *(cc_width) = (lin_width - 62) / 17;
  do {
    *(cc_width) = *(cc_width) + 1;
    rows = codewords_used / *(cc_width);
  } while (rows > 90);
  if (codewords_used % *(cc_width) != 0) {
    rows++;
  }
  codewords_total = *(cc_width)*rows;
  if (codewords_total > 928) {
    return 0;
  }
  target_codewords = codewords_total - ecc_codewords;
  target_codewords -= 3;
  target_bytesize = 6 * (target_codewords / 5);
  target_bytesize += target_codewords % 5;
  target_bitsize = 8 * target_bytesize;
  return target_bitsize;
}
```