user: Translate the below assembly code into C programming language:

```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    D26(%rip),%rdi
  call   <scanf@plt>
  mov    -0x40(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    %edx,-0x40(%rbp)
  test   %eax,%eax
  je     L52
  lea    -0x3c(%rbp),%rax
  mov    %rax,-0x50(%rbp)
  lea    D6(%rip),%r12
  jmp    L1
L144:
  mov    %rax,%rdx
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  je     L43
  orq    $0x0,-0x8(%rsp,%rdx,1)
L43:
  lea    0x3(%rsp),%rbx
  mov    %rbx,%r13
  shr    $0x2,%r13
  and    $0xfffffffffffffffc,%rbx
  test   %r9d,%r9d
  jle    L173
  mov    %rbx,%r15
  mov    $0x0,%r14d
L131:
  mov    %r15,%rsi
  mov    %r12,%rdi
  call   <scanf@plt>
  add    $0x1,%r14d
  mov    -0x3c(%rbp),%r9d
  add    $0x4,%r15
  cmp    %r14d,%r9d
  jg     L131
L173:
  lea    -0x1(%r9),%r15d
  test   %r15d,%r15d
  jle    L33
  lea    -0x2(%r9),%r10d
  add    $0x2,%r10
  mov    %rbx,%rsi
  mov    $0x1,%r8d
  mov    %r15d,%r14d
  lea    0x4(%rbx),%r11
  jmp    L120
L26:
  add    $0x4,%rax
  cmp    %rdi,%rax
  je     L227
L163:
  mov    (%rsi),%edx
  mov    0x4(%rax),%ecx
  cmp    %ecx,%edx
  jle    L26
  mov    %ecx,(%rsi)
  mov    %edx,0x4(%rax)
  jmp    L26
L227:
  add    $0x1,%r8
  add    $0x4,%rsi
  cmp    %r10,%r8
  je     L33
L120:
  cmp    %r8d,%r9d
  jle    L227
  mov    %r14d,%eax
  sub    %r8d,%eax
  lea    -0x1(%r8,%rax,1),%rax
  lea    (%r11,%rax,4),%rdi
  mov    %rsi,%rax
  jmp    L163
L33:
  mov    %r9d,%ecx
  lea    -0x1(%r9),%eax
  cmp    $0x1,%eax
  jbe    L56
  cmp    $0x3,%r9d
  je     L81
  jle    L57
  lea    0x4(%rbx),%rax
  lea    -0x4(%r9),%edx
  lea    0x8(%rbx,%rdx,4),%rsi
  mov    $0x0,%edx
L171:
  add    (%rax),%edx
  add    $0x4,%rax
  cmp    %rax,%rsi
  jne    L171
  sub    $0x3,%ecx
L83:
  imul   0x0(,%r13,4),%ecx
  lea    (%rcx,%rdx,1),%eax
  movslq %r15d,%r15
  add    (%rbx,%r15,4),%eax
  mov    0x4(,%r13,4),%edx
  lea    (%rax,%rdx,2),%esi
L168:
  lea    D26(%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     L52
L1:
  mov    %rsp,-0x48(%rbp)
  mov    -0x50(%rbp),%rsi
  mov    %r12,%rdi
  call   <scanf@plt>
  mov    -0x3c(%rbp),%r9d
  movslq %r9d,%rax
  lea    0xf(,%rax,4),%rax
  mov    $0x10,%ebx
  mov    $0x0,%edx
  div    %rbx
  shl    $0x4,%rax
  mov    %rax,%rcx
  and    $0xfffffffffffff000,%rcx
  mov    %rsp,%rdx
  sub    %rcx,%rdx
L158:
  cmp    %rdx,%rsp
  je     L144
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L158
L56:
  movslq %r15d,%r15
  mov    (%rbx,%r15,4),%esi
  jmp    L168
L57:
  mov    $0x0,%edx
  mov    $0x0,%ecx
  jmp    L83
L81:
  mov    0x0(,%r13,4),%esi
  add    0x8(,%r13,4),%esi
  add    0x4(,%r13,4),%esi
  jmp    L168
L52:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L230
  mov    $0x0,%eax
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L230:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: label: D26
type_infered: string
name: disassemble_data
arguments: label: D6
type_infered: string

tool: D26: %d


tool: D6: %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]);
    }
    for (i = 0; i < n - 1; i++) {
      for (j = i + 1; j < n; j++) {
        if (a[i] > a[j]) {
          temp = a[i];
          a[i] = a[j];
          a[j] = temp;
        }
      }
    }
    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;
}
```