user: 请从给定的汇编指令推导出C源代码：

```asm
<main>:
  endbr64
  push   %rbp
  lea    D3(%rip),%rdi
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  lea    -0x40(%rbp),%rsi
  push   %r13
  push   %r12
  push   %rbx
  lea    -0x3c(%rbp),%rbx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  call   <scanf@plt>
  mov    -0x40(%rbp),%eax
  mov    %rbx,-0x50(%rbp)
  lea    D12(%rip),%rbx
  lea    -0x1(%rax),%edx
  mov    %edx,-0x40(%rbp)
  test   %eax,%eax
  je     L161
  nopl   0x0(%rax)
L75:
  mov    -0x50(%rbp),%rsi
  mov    %rbx,%rdi
  mov    %rsp,%r14
  call   <scanf@plt>
  movslq -0x3c(%rbp),%rax
  mov    %rsp,%rcx
  mov    %rax,%r9
  lea    0xf(,%rax,4),%rax
  mov    %rax,%rdx
  and    $0xfffffffffffff000,%rax
  sub    %rax,%rcx
  and    $0xfffffffffffffff0,%rdx
  cmp    %rcx,%rsp
  je     L164
L169:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rcx,%rsp
  jne    L169
L164:
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  je     L9
  orq    $0x0,-0x8(%rsp,%rdx,1)
L9:
  lea    0x3(%rsp),%r12
  mov    %r12,%rax
  and    $0xfffffffffffffffc,%r12
  shr    $0x2,%rax
  mov    %rax,-0x48(%rbp)
  test   %r9d,%r9d
  jle    L63
  mov    %r12,%r13
  xor    %r15d,%r15d
  cs nopw 0x0(%rax,%rax,1)
L112:
  mov    %r13,%rsi
  mov    %rbx,%rdi
  add    $0x1,%r15d
  add    $0x4,%r13
  call   <scanf@plt>
  mov    -0x3c(%rbp),%r9d
  cmp    %r15d,%r9d
  jg     L112
L63:
  lea    -0x1(%r9),%r10d
  test   %r10d,%r10d
  jle    L37
  lea    -0x2(%r9),%r11d
  mov    %r12,%rsi
  mov    $0x1,%r8d
  add    $0x2,%r11
  lea    0x4(%r12),%r15
  nopl   0x0(%rax,%rax,1)
L125:
  cmp    %r8d,%r9d
  jle    L27
  mov    %r10d,%eax
  sub    %r8d,%eax
  lea    -0x1(%r8,%rax,1),%rax
  lea    (%r15,%rax,4),%rdi
  mov    %rsi,%rax
  nopw   0x0(%rax,%rax,1)
L74:
  mov    (%rsi),%edx
  mov    0x4(%rax),%ecx
  cmp    %ecx,%edx
  jle    L180
  mov    %ecx,(%rsi)
  mov    %edx,0x4(%rax)
L180:
  add    $0x4,%rax
  cmp    %rdi,%rax
  jne    L74
L27:
  add    $0x1,%r8
  add    $0x4,%rsi
  cmp    %r11,%r8
  jne    L125
L37:
  cmp    $0x1,%r10d
  jbe    L94
  mov    -0x48(%rbp),%rax
  mov    0x0(,%rax,4),%esi
  mov    0x4(,%rax,4),%ecx
  cmp    $0x3,%r9d
  je     L50
  jle    L115
  lea    -0x4(%r9),%edx
  lea    0x4(%r12),%rax
  lea    0x8(%r12,%rdx,4),%rdi
  xor    %edx,%edx
  nopl   0x0(%rax)
L190:
  add    (%rax),%edx
  add    $0x4,%rax
  cmp    %rax,%rdi
  jne    L190
  sub    $0x3,%r9d
L196:
  imul   %r9d,%esi
  movslq %r10d,%r10
  lea    (%rsi,%rdx,1),%eax
  add    (%r12,%r10,4),%eax
  lea    (%rax,%rcx,2),%esi
L151:
  lea    D3(%rip),%rdi
  call   <printf@plt>
  mov    -0x40(%rbp),%eax
  mov    %r14,%rsp
  lea    -0x1(%rax),%edx
  mov    %edx,-0x40(%rbp)
  test   %eax,%eax
  jne    L75
L161:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L70
  lea    -0x28(%rbp),%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L50:
  mov    -0x48(%rbp),%rax
  add    0x8(,%rax,4),%esi
  add    %ecx,%esi
  jmp    L151
L94:
  movslq %r10d,%r10
  mov    (%r12,%r10,4),%esi
  jmp    L151
L115:
  xor    %edx,%edx
  xor    %r9d,%r9d
  jmp    L196
L70:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: data_label: D3
data_type: string
name: unpack_data
arguments: data_label: D12
data_type: string

tool: D3: %d


tool: D12: %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;
}
```