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

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  lea    -0x4000(%rsp),%r11
L179:
  sub    $0x1000,%rsp
  orq    $0x0,(%rsp)
  cmp    %r11,%rsp
  jne    L179
  sub    $0xe58,%rsp
  lea    D21(%rip),%rdi
  mov    %fs:0x28,%rax
  mov    %rax,0x4e48(%rsp)
  xor    %eax,%eax
  lea    0x1c(%rsp),%rsi
  call   <scanf@plt>
  mov    0x1c(%rsp),%eax
  test   %eax,%eax
  jle    L67
  xor    %r12d,%r12d
  lea    0x1b(%rsp),%rbp
  lea    0x20(%rsp),%r13
  lea    D9(%rip),%rbx
  jmp    L49
  nopl   0x0(%rax)
L265:
  cmp    $0xa,%al
  jne    L28
L49:
  xor    %eax,%eax
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  call   <scanf@plt>
  test   %rax,%rax
  movsbl 0x1b(%rsp),%eax
  jne    L265
L28:
  sub    $0x30,%eax
  mov    0x1c(%rsp),%edi
  mov    %eax,0x0(%r13,%r12,4)
  add    $0x1,%r12
  cmp    %r12d,%edi
  jg     L49
  test   %edi,%edi
  jle    L67
  xor    %esi,%esi
  mov    $0x1,%r9d
  xor    %r10d,%r10d
  nopl   0x0(%rax,%rax,1)
L41:
  movslq %esi,%rax
  lea    0x1(%rsi),%edx
  mov    $0x1,%ecx
  mov    0x20(%rsp,%rax,4),%r8d
  movslq %edx,%rax
  cmp    0x20(%rsp,%rax,4),%r8d
  je     L337
  jmp    L279
  nop
L29:
  cmp    %esi,%edx
  je     L199
L337:
  lea    0x1(%rdx),%eax
  add    $0x1,%ecx
  cltd
  idiv   %edi
  movslq %edx,%rax
  cmp    %r8d,0x20(%rsp,%rax,4)
  je     L29
L199:
  cmp    %r9d,%ecx
  jl     L347
  jle    L145
  mov    %ecx,%r9d
  mov    $0x1,%r10d
  xor    %eax,%eax
L19:
  mov    %esi,0x2f00(%rsp,%rax,8)
L347:
  add    %ecx,%esi
  cmp    %esi,%edi
  jg     L41
  movslq %r10d,%rdx
  mov    %r10d,0x4(%rsp)
  xor    %eax,%eax
  lea    0xfc0(%rsp),%r11
  test   %edx,%edx
  je     L326
L342:
  mov    %eax,(%r11,%rax,4)
  add    $0x1,%rax
  cmp    %rax,%rdx
  jne    L342
L326:
  movl   $0x0,0x1f60(%rsp)
  cmp    $0x1,%edi
  jle    L9
  cmpl   $0x1,0x4(%rsp)
  je     L9
  lea    0x1f60(%rsp),%rax
  xor    %r10d,%r10d
  cmpl   $0x1,0x4(%rsp)
  mov    $0x1,%ebp
  mov    %rax,0x8(%rsp)
  mov    $0xa,%r12d
  jle    L334
  nopw   0x0(%rax,%rax,1)
L131:
  mov    $0x4,%r8d
  mov    $0x1,%ebx
  mov    $0x1,%r13d
  jmp    L154
  nopl   0x0(%rax,%rax,1)
L297:
  mov    0x8(%rsp),%rdx
  mov    %r9d,(%rdx)
  cmp    %eax,0x4(%rsp)
  jle    L349
  mov    $0x1,%r13d
  movslq %ebx,%r10
L144:
  add    $0x4,%r8
  mov    %eax,%ebx
L154:
  movslq (%r11,%r10,4),%rax
  lea    0x0(,%r10,4),%r14
  movslq 0x2f00(%rsp,%rax,8),%rcx
  lea    (%rcx,%rbp,1),%eax
  cltd
  idiv   %edi
  mov    %r12d,%eax
  sub    0x20(%rsp,%rcx,4),%eax
  movslq %eax,%rcx
  mov    %eax,%esi
  imul   $0x66666667,%rcx,%rcx
  sar    $0x1f,%esi
  sar    $0x22,%rcx
  sub    %esi,%ecx
  lea    (%rcx,%rcx,4),%ecx
  add    %ecx,%ecx
  sub    %ecx,%eax
  movslq %edx,%rdx
  add    0x20(%rsp,%rdx,4),%eax
  movslq %eax,%rcx
  cltd
  imul   $0x66666667,%rcx,%rcx
  sar    $0x22,%rcx
  sub    %edx,%ecx
  lea    (%rcx,%rcx,4),%edx
  add    %edx,%edx
  sub    %edx,%eax
  mov    %eax,%ecx
  movslq (%r11,%r8,1),%rax
  movslq 0x2f00(%rsp,%rax,8),%rsi
  mov    %rax,%r9
  lea    (%rsi,%rbp,1),%eax
  cltd
  idiv   %edi
  mov    %r12d,%eax
  sub    0x20(%rsp,%rsi,4),%eax
  movslq %eax,%rsi
  mov    %eax,%r15d
  imul   $0x66666667,%rsi,%rsi
  sar    $0x1f,%r15d
  sar    $0x22,%rsi
  sub    %r15d,%esi
  lea    (%rsi,%rsi,4),%esi
  add    %esi,%esi
  sub    %esi,%eax
  movslq %edx,%rdx
  add    0x20(%rsp,%rdx,4),%eax
  movslq %eax,%rdx
  mov    %eax,%esi
  imul   $0x66666667,%rdx,%rdx
  sar    $0x1f,%esi
  sar    $0x22,%rdx
  sub    %esi,%edx
  lea    (%rdx,%rdx,4),%esi
  add    %esi,%esi
  sub    %esi,%eax
  mov    %eax,%edx
  lea    0x1(%rbx),%eax
  cmp    %edx,%ecx
  jg     L297
  jne    L136
  mov    0x8(%rsp),%rbx
  movslq %r13d,%rdx
  add    $0x1,%r13d
  mov    %r9d,(%rbx,%rdx,4)
L136:
  cmp    %eax,0x4(%rsp)
  jg     L144
  mov    0x8(%rsp),%rbx
  add    $0x1,%ebp
  mov    (%rbx,%r14,1),%eax
  mov    %eax,(%r11)
  cmp    %ebp,%edi
  jle    L195
  cmp    $0x1,%r13d
  je     L195
  mov    %r11,%rax
  mov    %r13d,0x4(%rsp)
  cmpl   $0x1,0x4(%rsp)
  mov    %rbx,%r11
  mov    %rax,0x8(%rsp)
  jg     L131
L334:
  mov    0x8(%rsp),%rax
  mov    (%rax,%r10,4),%eax
  mov    %eax,(%r11)
L195:
  mov    0x8(%rsp),%rax
  movslq (%rax),%rax
  movslq 0x2f00(%rsp,%rax,8),%rax
  mov    0x20(%rsp,%rax,4),%esi
  mov    %rax,%rbp
  mov    $0xa,%eax
  sub    %esi,%eax
  movslq %eax,%rbx
  cltd
  imul   $0x66666667,%rbx,%rbx
  sar    $0x22,%rbx
  sub    %edx,%ebx
  lea    (%rbx,%rbx,4),%edx
  add    %edx,%edx
  sub    %edx,%eax
  mov    %eax,%ebx
L98:
  xor    %r12d,%r12d
  jmp    L247
  nopl   0x0(%rax,%rax,1)
L163:
  movslq %edx,%rax
  mov    0x20(%rsp,%rax,4),%esi
L247:
  add    %ebx,%esi
  lea    D21(%rip),%rdi
  add    $0x1,%r12d
  movslq %esi,%rcx
  mov    %esi,%eax
  imul   $0x66666667,%rcx,%rcx
  sar    $0x1f,%eax
  sar    $0x22,%rcx
  sub    %eax,%ecx
  lea    (%rcx,%rcx,4),%eax
  add    %eax,%eax
  sub    %eax,%esi
  xor    %eax,%eax
  call   <printf@plt>
  lea    0x1(%rbp),%eax
  mov    0x1c(%rsp),%ecx
  cltd
  idiv   %ecx
  mov    %edx,%ebp
  cmp    %r12d,%ecx
  jg     L163
L172:
  mov    $0xa,%edi
  call   <putchar@plt>
  mov    0x4e48(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L352
  add    $0x4e58,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L279:
  cmp    $0x1,%r9d
  jne    L347
L145:
  movslq %r10d,%rax
  add    $0x1,%r10d
  jmp    L19
L67:
  movslq 0xfc0(%rsp),%rax
  mov    $0xa,%edi
  movl   $0x0,0x1f60(%rsp)
  movslq 0x2f00(%rsp,%rax,8),%rax
  mov    0x20(%rsp,%rax,4),%esi
  mov    %rax,%rbp
  mov    %edi,%eax
  sub    %esi,%eax
  cltd
  idiv   %edi
  cmpl   $0x0,0x1c(%rsp)
  mov    %edx,%ebx
  jle    L172
  jmp    L98
L9:
  mov    %r11,0x8(%rsp)
  jmp    L195
L352:
  call   <__stack_chk_fail@plt>
L349:
  mov    0x8(%rsp),%rax
  mov    (%rax,%r8,1),%eax
  mov    %eax,(%r11)
  jmp    L195
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D21
datatype: string
name: extract_symbolic_data
arguments: data_label: D9
datatype: string

tool: D21: %d

tool: D9: %c

assistant: ```c
int main() {
  int n;
  char entrada;
  int numero[1000];
  int nclusters, clusters[1000][2];
  int tamclusteratual, tamclustermax;
  int inicio;
  int vetor1[1000], vetor2[1000];
  int candidatosvelho, candidatosnovo;
  int rotcand, rotmelhor;
  int melhor;
  int digposcand, digposmelhor;
  int *tmp, *clustersvelho, *clustersnovo;
  int i, j;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    while (scanf("%c", &entrada) && entrada == '\n')
      ;
    numero[i] = (int)(entrada - '0');
  }
  if (0) {
    for (i = 0; i < n; i++)
      printf("%d ", numero[i]);
    printf("\n");
  }
  tamclustermax = 1;
  nclusters = 0;
  for (i = 0; i < n; i++) {
    tamclusteratual = 1;
    inicio = i;
    i++;
    while (numero[inicio] == numero[i] && i != inicio) {
      tamclusteratual++;
      i = (i + 1) % n;
    }
    if (tamclusteratual >= tamclustermax) {
      if (tamclusteratual > tamclustermax) {
        tamclustermax = tamclusteratual;
        nclusters = 0;
      }
      clusters[nclusters][0] = inicio;
      clusters[nclusters][1] = (i ? i - 1 : n - 1);
      nclusters++;
    }
    i = inicio + tamclusteratual - 1;
  }
  if (0) {
    printf("nclusters = %d:\n", nclusters);
    printf("tamanho dos clusters = %d:\n", tamclustermax);
    for (i = 0; i < nclusters; i++)
      printf("%d %d\n", clusters[i][0], clusters[i][1]);
  }
  candidatosvelho = nclusters;
  candidatosnovo = 1;
  melhor = 0;
  clustersvelho = vetor1;
  clustersnovo = vetor2;
  for (i = 0; i < candidatosvelho; i++)
    clustersvelho[i] = i;
  clustersnovo[0] = 0;
  if (0) {
    for (i = 0; i < candidatosvelho; i++)
      printf("%d ", clustersvelho[i]);
    printf("\n");
  }
  i = 1;
  while (i < n && candidatosvelho != 1) {
    for (j = 1; j < candidatosvelho; j++) {
      rotmelhor = (10 - numero[clusters[clustersvelho[melhor]][0]]) % 10;
      digposmelhor = (numero[(clusters[clustersvelho[melhor]][0] + i) % n] + rotmelhor) % 10;
      rotcand = (10 - numero[clusters[clustersvelho[j]][0]]) % 10;
      digposcand = (numero[(clusters[clustersvelho[j]][0] + i) % n] + rotcand) % 10;
      if (0) {
        printf("----------------------------------------\n");
        printf("deslocamento = %d\n\n", i);
        printf("melhor:\n");
        printf("pos=%d\n", clustersvelho[melhor]);
        printf("digpos= %d\n", digposmelhor);
        printf("numero = %d\n", numero[(clusters[clustersvelho[melhor]][0] + i) % n]);
        printf("rot = %d\n\n", rotmelhor);
        printf("candidato:\n");
        printf("pos=%d\n", clustersvelho[j]);
        printf("digpos= %d\n", digposcand);
        printf("numero = %d\n", numero[(clusters[clustersvelho[j]][0] + i) % n]);
        printf("rot = %d\n", rotcand);
        printf("\nteste = %d x %d\n\n", digposcand, digposmelhor);
      }
      if (digposcand < digposmelhor) {
        clustersnovo[0] = clustersvelho[j];
        candidatosnovo = 1;
        melhor = j;
      } else if (digposcand == digposmelhor) {
        clustersnovo[candidatosnovo] = clustersvelho[j];
        candidatosnovo++;
      }
    }
    if (0) {
      printf("candidatosnovo = %d \n", candidatosnovo);
    }
    tmp = clustersvelho;
    clustersvelho = clustersnovo;
    clustersnovo = tmp;
    clustersnovo[0] = clustersvelho[melhor];
    candidatosvelho = candidatosnovo;
    candidatosnovo = 1;
    i++;
  }
  j = clusters[clustersvelho[0]][0];
  rotmelhor = (10 - numero[clusters[clustersvelho[0]][0]]) % 10;
  if (0) {
    printf("\nEscolhidos: cluster de %d, com rot %d na posicao %d \n\n", numero[j], rotmelhor, j);
  }
  for (i = 0; i < n; i++) {
    printf("%d", (numero[j] + rotmelhor) % 10);
    j = (j + 1) % n;
  }
  printf("\n");
  return 0;
}
```