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

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  lea    -0x40(%rbp),%rsi
  lea    D28(%rip),%rdi
  call   <scanf@plt>
  mov    -0x40(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    %edx,-0x40(%rbp)
  test   %eax,%eax
  je     L115
  lea    -0x3c(%rbp),%rax
  mov    %rax,-0x50(%rbp)
  lea    D23(%rip),%r13
  jmp    L133
L23:
  mov    %rax,%rdx
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  je     L88
  orq    $0x0,-0x8(%rsp,%rdx,1)
L88:
  lea    0x3(%rsp),%r14
  mov    %r14,%r15
  shr    $0x2,%r15
  and    $0xfffffffffffffffc,%r14
  test   %ecx,%ecx
  jle    L123
  mov    %r14,%r12
  mov    $0x0,%ebx
L64:
  mov    %r12,%rsi
  mov    %r13,%rdi
  call   <scanf@plt>
  add    $0x1,%ebx
  mov    -0x3c(%rbp),%ecx
  add    $0x4,%r12
  cmp    %ebx,%ecx
  jg     L64
L123:
  mov    %ecx,%esi
  lea    -0x1(%rcx),%eax
  cmp    $0x1,%eax
  jbe    L130
  cmp    $0x3,%ecx
  je     L84
  mov    $0x0,%edx
  mov    $0x0,%eax
  jle    L45
  lea    0x4(%r14),%rax
  lea    -0x4(%rcx),%edx
  lea    0x8(%r14,%rdx,4),%rdi
  mov    $0x0,%edx
L87:
  add    (%rax),%edx
  add    $0x4,%rax
  cmp    %rdi,%rax
  jne    L87
  lea    -0x3(%rsi),%eax
L45:
  imul   0x0(,%r15,4),%eax
  add    %edx,%eax
  sub    $0x1,%ecx
  movslq %ecx,%rcx
  add    (%r14,%rcx,4),%eax
  mov    0x4(,%r15,4),%edx
  lea    (%rax,%rdx,2),%esi
L34:
  lea    D28(%rip),%rdi
  call   <printf@plt>
  mov    -0x48(%rbp),%rsp
  mov    -0x40(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    %edx,-0x40(%rbp)
  test   %eax,%eax
  je     L115
L133:
  mov    %rsp,-0x48(%rbp)
  mov    -0x50(%rbp),%rsi
  mov    %r13,%rdi
  call   <scanf@plt>
  mov    -0x3c(%rbp),%ecx
  movslq %ecx,%rax
  lea    0xf(,%rax,4),%rax
  mov    $0x10,%edi
  mov    $0x0,%edx
  div    %rdi
  shl    $0x4,%rax
  mov    %rax,%rsi
  and    $0xfffffffffffff000,%rsi
  mov    %rsp,%rdx
  sub    %rsi,%rdx
L56:
  cmp    %rdx,%rsp
  je     L23
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L56
L130:
  movslq %eax,%rcx
  mov    (%r14,%rcx,4),%esi
  jmp    L34
L84:
  mov    0x0(,%r15,4),%esi
  add    0x8(,%r15,4),%esi
  add    0x4(,%r15,4),%esi
  jmp    L34
L115:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L94
  mov    $0x0,%eax
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L94:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: label: D28
type: string
name: extract_symbolic_data
arguments: label: D23
type: string

tool: D28: %d


tool: D23: %d

assistant: ```c
int main() {
  int t;
  scanf("%d\n", &t);
  while (t--) {
    int n, y, temp, x = 0, i, sum = 0, j = 0;
    scanf("%d", &n);
    int a[n];
    for (i = 0; i < n; i++) {
      scanf("%d", &a[i]);
    }
    if (n == 1 || n == 2) {
      sum = a[n - 1];
      goto A;
    } else if (n == 3) {
      sum = a[2] + a[0] + a[1];
      goto A;
    }
    for (i = 1; i < n - 2; i++) {
      sum = sum + a[i];
      x++;
    }
    sum = sum + a[0] * (x) + a[n - 1] + 2 * a[1];
  A:
    printf("%d\n", sum);
  }
  return 0;
}
```