user: Please show me the C implementation that matches the assembly code listed below:

```asm
<main>:
  endbr64
  push   %r15
  mov    $0x1,%r15d
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  lea    D12(%rip),%rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  lea    0x20(%rsp),%rax
  mov    %rax,0x10(%rsp)
  nopl   0x0(%rax)
L143:
  mov    0x10(%rsp),%rsi
  mov    %rbp,%rdi
  call   <scanf@plt>
  test   %rax,%rax
  je     L113
  mov    0x20(%rsp),%esi
  test   %esi,%esi
  je     L113
  mov    $0x0,%ebx
  mov    $0x1,%r12d
  lea    0x24(%rsp),%r13
  jle    L145
  nopl   0x0(%rax,%rax,1)
L424:
  mov    %r13,%rsi
  mov    %rbp,%rdi
  add    $0x1,%r12d
  call   <scanf@plt>
  mov    0x20(%rsp),%esi
  add    0x24(%rsp),%ebx
  cmp    %r12d,%esi
  jge    L424
  mov    %ebx,%r8d
  neg    %r8d
  cmovs  %ebx,%r8d
  mov    %r8d,%r14d
L176:
  mov    %r14d,%edi
  call   <isdivisable@plt>
  mov    %eax,%ecx
  test   %eax,%eax
  jne    L12
  mov    0x20(%rsp),%ecx
L255:
  mov    %r14d,%eax
  cltd
  idiv   %ecx
  mov    %eax,%edi
  mov    %edx,0xc(%rsp)
  mov    %eax,%r13d
  call   <countchar@plt>
  mov    0x20(%rsp),%edi
  mov    %eax,0x18(%rsp)
  call   <countchar@plt>
  mov    0xc(%rsp),%edi
  mov    %eax,%r12d
  call   <countchar@plt>
  mov    %eax,%edx
  mov    0x20(%rsp),%eax
  cmp    $0x1,%eax
  je     L344
  cmp    %r14d,%eax
  jge    L46
  mov    0x18(%rsp),%eax
  lea    (%rax,%r12,1),%r14d
  test   %ebx,%ebx
  jg     L185
  jne    L262
L182:
  add    $0x1,%r15d
  jmp    L143
  nopw   0x0(%rax,%rax,1)
L12:
  mov    %r14d,%eax
  cltd
  idiv   %ecx
  mov    %eax,%r14d
  mov    0x20(%rsp),%eax
  cltd
  idiv   %ecx
  mov    %eax,0x20(%rsp)
  mov    %eax,%ecx
  jmp    L255
  nopl   0x0(%rax,%rax,1)
L344:
  mov    %r13d,%edx
  mov    %r15d,%esi
  test   %ebx,%ebx
  js     L206
  lea    D47(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  jmp    L182
  xchg   %ax,%ax
L46:
  jle    L182
  test   %ebx,%ebx
  jg     L44
  je     L182
  mov    %r15d,%esi
  lea    D63(%rip),%rdi
  xor    %eax,%eax
  mov    %edx,0x18(%rsp)
  call   <printf@plt>
  mov    0x18(%rsp),%edx
  mov    %r12d,%ebx
  xor    %r13d,%r13d
  sub    %edx,%ebx
  cmp    $0xffffffff,%ebx
  jl     L115
  nopw   0x0(%rax,%rax,1)
L282:
  mov    $0x20,%edi
  call   <putchar@plt>
  mov    %r13d,%eax
  add    $0x1,%r13d
  cmp    %eax,%ebx
  jge    L282
L115:
  mov    0xc(%rsp),%esi
  lea    D117(%rip),%rdi
  xor    %eax,%eax
  xor    %ebx,%ebx
  call   <printf@plt>
  lea    D25(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  test   %r12d,%r12d
  jle    L102
  nopl   0x0(%rax)
L259:
  mov    $0x2d,%edi
  add    $0x1,%ebx
  call   <putchar@plt>
  cmp    %ebx,%r12d
  jne    L259
L102:
  mov    $0xa,%edi
  call   <putchar@plt>
  mov    $0x20,%edi
  call   <putchar@plt>
  mov    $0x20,%edi
  jmp    L348
  nopl   0x0(%rax,%rax,1)
L206:
  lea    D105(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  jmp    L182
  nopl   0x0(%rax,%rax,1)
L113:
  mov    0x28(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L168
  add    $0x38,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L145:
  xor    %r14d,%r14d
  jmp    L176
L185:
  mov    %r15d,%esi
  lea    D63(%rip),%rdi
  xor    %eax,%eax
  mov    %edx,0x1c(%rsp)
  call   <printf@plt>
  mov    0x1c(%rsp),%edx
  xor    %ebx,%ebx
  sub    %edx,%r14d
  test   %r14d,%r14d
  jle    L172
  nopl   0x0(%rax,%rax,1)
L132:
  mov    $0x20,%edi
  add    $0x1,%ebx
  call   <putchar@plt>
  cmp    %r14d,%ebx
  jne    L132
L172:
  mov    0xc(%rsp),%esi
  lea    D117(%rip),%rdi
  xor    %eax,%eax
  xor    %ebx,%ebx
  call   <printf@plt>
  mov    %r13d,%esi
  mov    %rbp,%rdi
  xor    %eax,%eax
  call   <printf@plt>
  test   %r12d,%r12d
  jle    L249
  nopl   0x0(%rax,%rax,1)
L341:
  mov    $0x2d,%edi
  add    $0x1,%ebx
  call   <putchar@plt>
  cmp    %ebx,%r12d
  jne    L341
L249:
  mov    $0xa,%edi
  xor    %ebx,%ebx
  call   <putchar@plt>
  cmpl   $0x0,0x18(%rsp)
  mov    0x18(%rsp),%r12d
  jle    L71
  nopw   0x0(%rax,%rax,1)
L52:
  mov    $0x20,%edi
  add    $0x1,%ebx
  call   <putchar@plt>
  cmp    %ebx,%r12d
  jne    L52
L71:
  mov    0x20(%rsp),%esi
  lea    D117(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  jmp    L182
L262:
  mov    %r15d,%esi
  lea    D63(%rip),%rdi
  xor    %eax,%eax
  mov    %edx,0x1c(%rsp)
  call   <printf@plt>
  mov    0x1c(%rsp),%edx
  mov    %r14d,%ebx
  xor    %r14d,%r14d
  sub    %edx,%ebx
  cmp    $0xffffffff,%ebx
  jl     L342
  nop
L302:
  mov    $0x20,%edi
  call   <putchar@plt>
  mov    %r14d,%eax
  add    $0x1,%r14d
  cmp    %eax,%ebx
  jge    L302
L342:
  mov    0xc(%rsp),%esi
  lea    D117(%rip),%rdi
  xor    %eax,%eax
  xor    %ebx,%ebx
  call   <printf@plt>
  mov    %r13d,%esi
  lea    D4(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  test   %r12d,%r12d
  jle    L349
  nop
L357:
  mov    $0x2d,%edi
  add    $0x1,%ebx
  call   <putchar@plt>
  cmp    %ebx,%r12d
  jne    L357
L349:
  mov    $0xa,%edi
  xor    %ebx,%ebx
  call   <putchar@plt>
  cmpl   $0xffffffff,0x18(%rsp)
  mov    0x18(%rsp),%r12d
  jl     L71
  xchg   %ax,%ax
L280:
  mov    $0x20,%edi
  call   <putchar@plt>
  mov    %ebx,%eax
  add    $0x1,%ebx
  cmp    %eax,%r12d
  jge    L280
  jmp    L71
L44:
  mov    %r15d,%esi
  lea    D63(%rip),%rdi
  xor    %eax,%eax
  mov    %edx,0x18(%rsp)
  call   <printf@plt>
  mov    0x18(%rsp),%edx
  mov    %r12d,%ebx
  xor    %r13d,%r13d
  sub    %edx,%ebx
  test   %ebx,%ebx
  jle    L114
  xchg   %ax,%ax
L37:
  mov    $0x20,%edi
  add    $0x1,%r13d
  call   <putchar@plt>
  cmp    %r13d,%ebx
  jne    L37
L114:
  mov    0xc(%rsp),%esi
  lea    D117(%rip),%rdi
  xor    %eax,%eax
  xor    %ebx,%ebx
  call   <printf@plt>
  test   %r12d,%r12d
  jle    L157
  nopl   0x0(%rax)
L298:
  mov    $0x2d,%edi
  add    $0x1,%ebx
  call   <putchar@plt>
  cmp    %ebx,%r12d
  jne    L298
L157:
  mov    $0xa,%edi
L348:
  call   <putchar@plt>
  jmp    L71
L168:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: tag: D12
type_guessed: string
name: extract_symbolic_data
arguments: tag: D47
type_guessed: string
name: extract_symbolic_data
arguments: tag: D63
type_guessed: string
name: extract_symbolic_data
arguments: tag: D117
type_guessed: string
name: extract_symbolic_data
arguments: tag: D25
type_guessed: string
name: extract_symbolic_data
arguments: tag: D105
type_guessed: string
name: extract_symbolic_data
arguments: tag: D4
type_guessed: string

tool: D12: %d

tool: D47: Case %d:
%d


tool: D63: Case %d:


tool: D117: %d


tool: D25: - 

tool: D105: Case %d:
- %d


tool: D4: - %d

assistant: ```c
int main() {
  int n, i, j, k, l = 1, m, p, a, b, c, in_avg, rest, total;
  while (scanf("%d", &n) && n) {
    b = 0, m = 0;
    for (i = 1; i <= n; i++) {
      scanf("%d", &a);
      b = b + a;
    }
    c = abs(b);
    m = isdivisable(c, n);
    if (m != 0) {
      c = c / m;
      n = n / m;
    }
    in_avg = c / n;
    rest = c - in_avg * n;
    j = countchar(in_avg);
    k = countchar(n);
    p = countchar(rest);
    total = j + k;
    if (n == 1) {
      if (b < 0) {
        printf("Case %d:\n- %d\n", l, in_avg);
      } else {
        printf("Case %d:\n%d\n", l, in_avg);
      }
    } else if (c > n) {
      if (b > 0) {
        printf("Case %d:\n", l);
        for (i = 0; i < total - p; i++) {
          printf(" ");
        }
        printf("%d\n", rest);
        printf("%d", in_avg);
        for (i = 0; i < total - j; i++) {
          printf("-");
        }
        printf("\n");
        for (i = 0; i < total - k; i++) {
          printf(" ");
        }
        printf("%d\n", n);
      } else if (b < 0) {
        printf("Case %d:\n", l);
        for (i = 0; i < total - p + 2; i++) {
          printf(" ");
        }
        printf("%d\n", rest);
        printf("- %d", in_avg);
        for (i = 0; i < total - j; i++) {
          printf("-");
        }
        printf("\n");
        for (i = 0; i < total - k + 2; i++) {
          printf(" ");
        }
        printf("%d\n", n);
      }
    } else if (c < n) {
      if (b > 0) {
        printf("Case %d:\n", l);
        for (i = 0; i < k - p; i++) {
          printf(" ");
        }
        printf("%d\n", rest);
        for (i = 0; i < k; i++) {
          printf("-");
        }
        printf("\n");
        printf("%d\n", n);
      } else if (b < 0) {
        printf("Case %d:\n", l);
        for (i = 0; i < k - p + 2; i++) {
          printf(" ");
        }
        printf("%d\n", rest);
        printf("- ");
        for (i = 0; i < k; i++) {
          printf("-");
        }
        printf("\n");
        for (i = 0; i < 2; i++) {
          printf(" ");
        }
        printf("%d\n", n);
      }
    }
    l++;
  }
  return 0;
}
```