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

```asm
<main>:
  endbr64
  push   %r13
  lea    D28(%rip),%rdi
  push   %r12
  lea    D40(%rip),%r12
  push   %rbp
  push   %rbx
  sub    $0x1b8,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x1a8(%rsp)
  xor    %eax,%eax
  call   <printf@plt>
  lea    0xc(%rsp),%rsi
  mov    %r12,%rdi
  call   <scanf@plt>
  lea    D67(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    0xc(%rsp),%edx
  test   %edx,%edx
  jle    L75
  lea    0x10(%rsp),%rbp
  xor    %ebx,%ebx
  nopl   0x0(%rax)
L111:
  mov    %rbp,%rsi
  mov    %r12,%rdi
  add    $0x1,%ebx
  add    $0x4,%rbp
  call   <scanf@plt>
  cmp    %ebx,0xc(%rsp)
  jg     L111
L75:
  lea    D24(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    0xc(%rsp),%eax
  test   %eax,%eax
  jle    L14
  xor    %ebx,%ebx
  lea    0x10(%rsp),%r13
  lea    D25(%rip),%rbp
  nopl   0x0(%rax)
L117:
  mov    0x0(%r13,%rbx,4),%esi
  mov    %rbp,%rdi
  xor    %eax,%eax
  add    $0x1,%rbx
  call   <printf@plt>
  cmp    %ebx,0xc(%rsp)
  jg     L117
L14:
  lea    D32(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  lea    0x8(%rsp),%rsi
  mov    %r12,%rdi
  call   <scanf@plt>
  mov    0xc(%rsp),%eax
  test   %eax,%eax
  jle    L27
  sub    $0x1,%eax
  mov    0x8(%rsp),%r11d
  lea    0x10(%rsp),%r9
  xor    %esi,%esi
  lea    0x14(%rsp,%rax,4),%r10
  nopl   0x0(%rax)
L51:
  mov    (%r9),%ecx
  mov    %r11d,%r8d
  xor    %eax,%eax
  jmp    L7
  nopw   0x0(%rax,%rax,1)
L74:
  lea    (%rax,%r8,1),%edx
  lea    0x1(%rsi),%edi
  cmp    %edx,%ecx
  jl     L84
  mov    %edx,%eax
  mov    %edi,%esi
L7:
  cmp    %eax,%ecx
  jne    L74
  add    $0x4,%r9
  cmp    %r10,%r9
  jne    L51
L12:
  xor    %eax,%eax
  lea    D66(%rip),%rdi
  call   <printf@plt>
  mov    0x1a8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L68
  add    $0x1b8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   (%rax)
L84:
  sub    $0x1,%r8d
  jmp    L7
L27:
  xor    %esi,%esi
  jmp    L12
L68:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: data_label: D28
type: string
name: read_data
arguments: data_label: D40
type: string
name: read_data
arguments: data_label: D67
type: string
name: read_data
arguments: data_label: D24
type: string
name: read_data
arguments: data_label: D25
type: string
name: read_data
arguments: data_label: D32
type: string
name: read_data
arguments: data_label: D66
type: string

tool: D28: Array size : 

tool: D40: %d

tool: D67: Elements to Array : 

tool: D24: Array   elements  : 

tool: D25: %d 

tool: D32: 
Threshold value   : 

tool: D66: count = %d


assistant: ```c
int main(void) {
  int a[100], i, th, n, count = 0, sum, temp;
  printf("Array size : ");
  scanf("%d", &n);
  printf("Elements to Array : ");
  for (i = 0; i < n; i++)
    scanf("%d", &a[i]);
  printf("Array   elements  : ");
  for (i = 0; i < n; i++)
    printf("%d ", a[i]);
  printf("\nThreshold value   : ");
  scanf("%d", &th);
  for (i = 0; i < n; i++) {
    temp = th;
    sum = 0;
    while (sum != a[i]) {
      sum += temp;
      count++;
      if (sum > a[i]) {
        sum -= temp;
        temp--;
        count--;
      }
    }
  }
  printf("count = %d\n", count);
  return 0;
}
```