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

```asm
<balance>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x28(%rbp)
  movl   $0x1,-0x10(%rbp)
  movl   $0x0,-0xc(%rbp)
  movl   $0x0,-0x8(%rbp)
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x4(%rbp)
  jmp    L35
L28:
  movl   $0x0,-0xc(%rbp)
  movl   $0x0,-0x8(%rbp)
  mov    -0x10(%rbp),%eax
  mov    %eax,-0x14(%rbp)
  movl   $0x0,-0x18(%rbp)
  jmp    L84
L18:
  mov    -0x14(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    %edx,-0x14(%rbp)
  mov    -0x18(%rbp),%edx
  movslq %edx,%rcx
  mov    -0x28(%rbp),%rdx
  add    %rcx,%rdx
  movzbl (%rdx),%edx
  movsbl %dl,%edx
  sub    $0x40,%edx
  imul   %edx,%eax
  add    %eax,-0xc(%rbp)
  addl   $0x1,-0x18(%rbp)
L84:
  mov    -0x18(%rbp),%eax
  cmp    -0x10(%rbp),%eax
  jl     L18
  movl   $0x1,-0x14(%rbp)
  mov    -0x10(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,-0x18(%rbp)
  jmp    L53
L56:
  mov    -0x14(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x14(%rbp)
  mov    -0x18(%rbp),%edx
  movslq %edx,%rcx
  mov    -0x28(%rbp),%rdx
  add    %rcx,%rdx
  movzbl (%rdx),%edx
  movsbl %dl,%edx
  sub    $0x40,%edx
  imul   %edx,%eax
  add    %eax,-0x8(%rbp)
  addl   $0x1,-0x18(%rbp)
L53:
  mov    -0x18(%rbp),%eax
  cmp    -0x4(%rbp),%eax
  jl     L56
  mov    -0xc(%rbp),%eax
  cmp    -0x8(%rbp),%eax
  jne    L83
  movl   $0x0,-0x18(%rbp)
  jmp    L4
L60:
  mov    -0x18(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <putchar@plt>
  addl   $0x1,-0x18(%rbp)
L4:
  mov    -0x18(%rbp),%eax
  cmp    -0x10(%rbp),%eax
  jl     L60
  mov    -0x10(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%esi
  lea    D28(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    -0x10(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,-0x18(%rbp)
  jmp    L6
L59:
  mov    -0x18(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <putchar@plt>
  addl   $0x1,-0x18(%rbp)
L6:
  mov    -0x18(%rbp),%eax
  cmp    -0x4(%rbp),%eax
  jl     L59
  mov    -0xc(%rbp),%eax
  mov    %eax,%esi
  lea    D12(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x0,%eax
  jmp    L9
L83:
  addl   $0x1,-0x10(%rbp)
L35:
  mov    -0x10(%rbp),%eax
  cmp    -0x4(%rbp),%eax
  jl     L28
  mov    -0x28(%rbp),%rax
  mov    %rax,%rsi
  lea    D24(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x0,%eax
L9:
  leave
  ret
```

tool_calls: name: read_data
arguments: tag: D28
type: string
name: read_data
arguments: tag: D12
type: string
name: read_data
arguments: tag: D24
type: string

tool: D28:  %c 

tool: D12: - %d


tool: D24: %s DOES NOT BALANCE


assistant: ```c
int balance(char *word) {
  int i, pos, pivot = 1, left = 0, right = 0, len = strlen(word);
  while (pivot < len) {
    left = 0;
    right = 0;
    pos = pivot;
    for (i = 0; i < pivot; i++) {
      left += (pos--) * (word[i] - 64);
    }
    pos = 1;
    for (i = pivot + 1; i < len; i++) {
      right += (pos++) * (word[i] - 64);
    }
    if (left == right) {
      for (i = 0; i < pivot; i++)
        printf("%c", word[i]);
      printf(" %c ", word[pivot]);
      for (i = pivot + 1; i < len; i++)
        printf("%c", word[i]);
      printf("- %d\n", left);
      return 0;
    }
    pivot++;
  }
  printf("%s DOES NOT BALANCE\n", word);
  return 0;
}
```