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

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x1,-0x30(%rbp)
  jmp    L120
L105:
  movl   $0x0,-0x2c(%rbp)
  movl   $0x0,-0x24(%rbp)
  movl   $0x1,-0x34(%rbp)
  jmp    L86
L173:
  lea    -0x38(%rbp),%rax
  mov    %rax,%rsi
  lea    D183(%rip),%rax
  mov    %rax,%rdi
  call   <scanf@plt>
  mov    -0x38(%rbp),%eax
  add    %eax,-0x2c(%rbp)
  addl   $0x1,-0x34(%rbp)
L86:
  mov    -0x3c(%rbp),%eax
  cmp    %eax,-0x34(%rbp)
  jle    L173
  mov    -0x2c(%rbp),%eax
  mov    %eax,%edx
  neg    %edx
  cmovns %edx,%eax
  mov    %eax,-0x28(%rbp)
  mov    -0x3c(%rbp),%edx
  mov    -0x28(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <isdivisable@plt>
  mov    %eax,-0x24(%rbp)
  cmpl   $0x0,-0x24(%rbp)
  je     L215
  mov    -0x28(%rbp),%eax
  cltd
  idivl  -0x24(%rbp)
  mov    %eax,-0x28(%rbp)
  mov    -0x3c(%rbp),%eax
  cltd
  idivl  -0x24(%rbp)
  mov    %eax,-0x3c(%rbp)
L215:
  mov    -0x3c(%rbp),%ecx
  mov    -0x28(%rbp),%eax
  cltd
  idiv   %ecx
  mov    %eax,-0x20(%rbp)
  mov    -0x3c(%rbp),%eax
  imul   -0x20(%rbp),%eax
  mov    %eax,%edx
  mov    -0x28(%rbp),%eax
  sub    %edx,%eax
  mov    %eax,-0x1c(%rbp)
  mov    -0x20(%rbp),%eax
  mov    %eax,%edi
  call   <countchar@plt>
  mov    %eax,-0x18(%rbp)
  mov    -0x3c(%rbp),%eax
  mov    %eax,%edi
  call   <countchar@plt>
  mov    %eax,-0x14(%rbp)
  mov    -0x1c(%rbp),%eax
  mov    %eax,%edi
  call   <countchar@plt>
  mov    %eax,-0x10(%rbp)
  mov    -0x18(%rbp),%edx
  mov    -0x14(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x3c(%rbp),%eax
  cmp    $0x1,%eax
  jne    L210
  cmpl   $0x0,-0x2c(%rbp)
  jns    L270
  mov    -0x20(%rbp),%edx
  mov    -0x30(%rbp),%eax
  mov    %eax,%esi
  lea    D169(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L162
L270:
  mov    -0x20(%rbp),%edx
  mov    -0x30(%rbp),%eax
  mov    %eax,%esi
  lea    D104(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L162
L210:
  mov    -0x3c(%rbp),%eax
  cmp    %eax,-0x28(%rbp)
  jle    L236
  cmpl   $0x0,-0x2c(%rbp)
  jle    L341
  mov    -0x30(%rbp),%eax
  mov    %eax,%esi
  lea    D176(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  movl   $0x0,-0x34(%rbp)
  jmp    L260
L418:
  mov    $0x20,%edi
  call   <putchar@plt>
  addl   $0x1,-0x34(%rbp)
L260:
  mov    -0xc(%rbp),%eax
  sub    -0x10(%rbp),%eax
  cmp    %eax,-0x34(%rbp)
  jl     L418
  mov    -0x1c(%rbp),%eax
  mov    %eax,%esi
  lea    D144(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    -0x20(%rbp),%eax
  mov    %eax,%esi
  lea    D183(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  movl   $0x0,-0x34(%rbp)
  jmp    L331
L208:
  mov    $0x2d,%edi
  call   <putchar@plt>
  addl   $0x1,-0x34(%rbp)
L331:
  mov    -0xc(%rbp),%eax
  sub    -0x18(%rbp),%eax
  cmp    %eax,-0x34(%rbp)
  jl     L208
  mov    $0xa,%edi
  call   <putchar@plt>
  movl   $0x0,-0x34(%rbp)
  jmp    L304
L312:
  mov    $0x20,%edi
  call   <putchar@plt>
  addl   $0x1,-0x34(%rbp)
L304:
  mov    -0xc(%rbp),%eax
  sub    -0x14(%rbp),%eax
  cmp    %eax,-0x34(%rbp)
  jl     L312
  mov    -0x3c(%rbp),%eax
  mov    %eax,%esi
  lea    D144(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L162
L341:
  cmpl   $0x0,-0x2c(%rbp)
  jns    L162
  mov    -0x30(%rbp),%eax
  mov    %eax,%esi
  lea    D176(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  movl   $0x0,-0x34(%rbp)
  jmp    L197
L231:
  mov    $0x20,%edi
  call   <putchar@plt>
  addl   $0x1,-0x34(%rbp)
L197:
  mov    -0xc(%rbp),%eax
  sub    -0x10(%rbp),%eax
  add    $0x1,%eax
  cmp    %eax,-0x34(%rbp)
  jle    L231
  mov    -0x1c(%rbp),%eax
  mov    %eax,%esi
  lea    D144(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    -0x20(%rbp),%eax
  mov    %eax,%esi
  lea    D5(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  movl   $0x0,-0x34(%rbp)
  jmp    L334
L185:
  mov    $0x2d,%edi
  call   <putchar@plt>
  addl   $0x1,-0x34(%rbp)
L334:
  mov    -0xc(%rbp),%eax
  sub    -0x18(%rbp),%eax
  cmp    %eax,-0x34(%rbp)
  jl     L185
  mov    $0xa,%edi
  call   <putchar@plt>
  movl   $0x0,-0x34(%rbp)
  jmp    L330
L201:
  mov    $0x20,%edi
  call   <putchar@plt>
  addl   $0x1,-0x34(%rbp)
L330:
  mov    -0xc(%rbp),%eax
  sub    -0x14(%rbp),%eax
  add    $0x1,%eax
  cmp    %eax,-0x34(%rbp)
  jle    L201
  mov    -0x3c(%rbp),%eax
  mov    %eax,%esi
  lea    D144(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L162
L236:
  mov    -0x3c(%rbp),%eax
  cmp    %eax,-0x28(%rbp)
  jge    L162
  cmpl   $0x0,-0x2c(%rbp)
  jle    L163
  mov    -0x30(%rbp),%eax
  mov    %eax,%esi
  lea    D176(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  movl   $0x0,-0x34(%rbp)
  jmp    L339
L109:
  mov    $0x20,%edi
  call   <putchar@plt>
  addl   $0x1,-0x34(%rbp)
L339:
  mov    -0x14(%rbp),%eax
  sub    -0x10(%rbp),%eax
  cmp    %eax,-0x34(%rbp)
  jl     L109
  mov    -0x1c(%rbp),%eax
  mov    %eax,%esi
  lea    D144(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  movl   $0x0,-0x34(%rbp)
  jmp    L177
L61:
  mov    $0x2d,%edi
  call   <putchar@plt>
  addl   $0x1,-0x34(%rbp)
L177:
  mov    -0x34(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jl     L61
  mov    $0xa,%edi
  call   <putchar@plt>
  mov    -0x3c(%rbp),%eax
  mov    %eax,%esi
  lea    D144(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L162
L163:
  cmpl   $0x0,-0x2c(%rbp)
  jns    L162
  mov    -0x30(%rbp),%eax
  mov    %eax,%esi
  lea    D176(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  movl   $0x0,-0x34(%rbp)
  jmp    L259
L207:
  mov    $0x20,%edi
  call   <putchar@plt>
  addl   $0x1,-0x34(%rbp)
L259:
  mov    -0x14(%rbp),%eax
  sub    -0x10(%rbp),%eax
  add    $0x1,%eax
  cmp    %eax,-0x34(%rbp)
  jle    L207
  mov    -0x1c(%rbp),%eax
  mov    %eax,%esi
  lea    D144(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  lea    D90(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  movl   $0x0,-0x34(%rbp)
  jmp    L126
L66:
  mov    $0x2d,%edi
  call   <putchar@plt>
  addl   $0x1,-0x34(%rbp)
L126:
  mov    -0x34(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jl     L66
  mov    $0xa,%edi
  call   <putchar@plt>
  movl   $0x0,-0x34(%rbp)
  jmp    L352
L159:
  mov    $0x20,%edi
  call   <putchar@plt>
  addl   $0x1,-0x34(%rbp)
L352:
  cmpl   $0x1,-0x34(%rbp)
  jle    L159
  mov    -0x3c(%rbp),%eax
  mov    %eax,%esi
  lea    D144(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L162:
  addl   $0x1,-0x30(%rbp)
L120:
  lea    -0x3c(%rbp),%rax
  mov    %rax,%rsi
  lea    D183(%rip),%rax
  mov    %rax,%rdi
  call   <scanf@plt>
  test   %rax,%rax
  je     L258
  mov    -0x3c(%rbp),%eax
  test   %eax,%eax
  jne    L105
L258:
  mov    $0x0,%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L125
  call   <__stack_chk_fail@plt>
L125:
  leave
  ret
```

tool_calls: name: unpack_data
arguments: tag: D183
type: string
name: unpack_data
arguments: tag: D169
type: string
name: unpack_data
arguments: tag: D104
type: string
name: unpack_data
arguments: tag: D176
type: string
name: unpack_data
arguments: tag: D144
type: string
name: unpack_data
arguments: tag: D5
type: string
name: unpack_data
arguments: tag: D90
type: string

tool: D183: %d

tool: D169: Case %d:
- %d


tool: D104: Case %d:
%d


tool: D176: Case %d:


tool: D144: %d


tool: D5: - %d

tool: D90: - 

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;
}
```