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

```asm
<main>:
  endbr64
  push   %rbp
  lea    D12(%rip),%rdi
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  lea    -0x50(%rbp),%rdx
  lea    -0x54(%rbp),%rsi
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x38,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  call   <scanf@plt>
  mov    -0x54(%rbp),%ecx
  mov    %rsp,%rsi
  lea    0x1(%rcx),%eax
  cltq
  lea    0xf(,%rax,4),%rax
  mov    %rax,%rdi
  mov    %rax,%rdx
  and    $0xfffffffffffff000,%rdi
  and    $0xfffffffffffffff0,%rdx
  sub    %rdi,%rsi
  cmp    %rsi,%rsp
  je     L77
L20:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rsi,%rsp
  jne    L20
L77:
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  jne    L80
L16:
  lea    0x3(%rsp),%r13
  mov    %rax,%rdx
  mov    %rsp,%rsi
  and    $0xfffffffffffff000,%rax
  mov    %r13,%rdi
  and    $0xfffffffffffffff0,%rdx
  and    $0xfffffffffffffffc,%r13
  sub    %rax,%rsi
  shr    $0x2,%rdi
L74:
  cmp    %rsi,%rsp
  je     L79
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L74
L80:
  orq    $0x0,-0x8(%rsp,%rdx,1)
  jmp    L16
L79:
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  jne    L7
L96:
  movl   $0x0,0x0(,%rdi,4)
  mov    %rsp,%rbx
  test   %ecx,%ecx
  jle    L23
  add    $0x4,%r13
  mov    $0x1,%r12d
  lea    D18(%rip),%r14
  xchg   %ax,%ax
L106:
  mov    %r13,%rsi
  mov    %r14,%rdi
  xor    %eax,%eax
  add    $0x4,%r13
  call   <scanf@plt>
  mov    -0x4(%r13),%eax
  add    -0x4(%rbx,%r12,4),%eax
  mov    %eax,(%rbx,%r12,4)
  add    $0x1,%r12
  cmp    %r12d,-0x54(%rbp)
  jge    L106
L23:
  mov    -0x50(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    %edx,-0x50(%rbp)
  test   %eax,%eax
  je     L73
  lea    -0x48(%rbp),%r15
  lea    -0x4c(%rbp),%r14
  lea    -0x42(%rbp),%r13
  lea    D31(%rip),%r12
  nopl   0x0(%rax,%rax,1)
L111:
  mov    %r15,%rcx
  mov    %r14,%rdx
  mov    %r13,%rsi
  mov    %r12,%rdi
  xor    %eax,%eax
  call   <scanf@plt>
  mov    -0x4c(%rbp),%eax
  movslq -0x48(%rbp),%rdx
  lea    D15(%rip),%rdi
  sub    $0x1,%eax
  mov    (%rbx,%rdx,4),%esi
  cltq
  sub    (%rbx,%rax,4),%esi
  call   <printf@plt>
  mov    -0x50(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    %edx,-0x50(%rbp)
  test   %eax,%eax
  jne    L111
L73:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L67
  lea    -0x28(%rbp),%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L7:
  orq    $0x0,-0x8(%rsp,%rdx,1)
  jmp    L96
L67:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: data_tag: D12
type_guessed: string
name: disassemble_data
arguments: data_tag: D18
type_guessed: string
name: disassemble_data
arguments: data_tag: D31
type_guessed: string
name: disassemble_data
arguments: data_tag: D15
type_guessed: string

tool: D12: %d %d

tool: D18: %d

tool: D31: %s %d %d

tool: D15: %d


assistant: ```c
int main() {
  int N, Q, a, b;
  scanf("%d %d", &N, &Q);
  int arr[N + 1];
  int sum[N + 1];
  char str[10];
  int i;
  arr[0] = 0;
  for (i = 1; i <= N; i++) {
    scanf("%d", &arr[i]);
    sum[i] = sum[i - 1] + arr[i];
  }
  while (Q--) {
    scanf("%s %d %d", str, &a, &b);
    printf("%d\n", sum[b] - sum[a - 1]);
  }
  return 0;
}
```