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

```asm
<main>:
  endbr64
  push   %rbp
  lea    D20(%rip),%rdi
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  lea    -0x50(%rbp),%rsi
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x68,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  call   <scanf@plt>
  mov    -0x50(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    %edx,-0x50(%rbp)
  test   %eax,%eax
  je     L259
  lea    -0x44(%rbp),%rax
  mov    %rax,-0x80(%rbp)
  lea    -0x48(%rbp),%rax
  mov    %rax,-0x78(%rbp)
  lea    -0x4c(%rbp),%rax
  mov    %rax,-0x70(%rbp)
  lea    -0x3c(%rbp),%rax
  mov    %rax,-0x60(%rbp)
  lea    -0x40(%rbp),%rax
  mov    %rax,-0x58(%rbp)
L153:
  mov    -0x80(%rbp),%rcx
  mov    -0x78(%rbp),%rdx
  xor    %eax,%eax
  mov    %rsp,-0x68(%rbp)
  mov    -0x70(%rbp),%rsi
  lea    D44(%rip),%rdi
  call   <scanf@plt>
  movslq -0x4c(%rbp),%rax
  mov    %rsp,%rcx
  add    $0xf,%rax
  mov    %rax,%rdx
  and    $0xfffffffffffff000,%rax
  sub    %rax,%rcx
  and    $0xfffffffffffffff0,%rdx
  cmp    %rcx,%rsp
  je     L272
L291:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rcx,%rsp
  jne    L291
L272:
  mov    %rdx,%rax
  and    $0xfff,%eax
  sub    %rax,%rsp
  test   %rax,%rax
  je     L266
  orq    $0x0,-0x8(%rsp,%rax,1)
L266:
  mov    %rsp,%rsi
  lea    D55(%rip),%rdi
  xor    %eax,%eax
  mov    %rsp,%r13
  call   <scanf@plt>
  movslq -0x4c(%rbp),%r14
  mov    %rsp,%rcx
  lea    0xf(,%r14,4),%rax
  mov    %r14,%r15
  mov    %rax,%rsi
  mov    %rax,%rdx
  and    $0xfffffffffffff000,%rsi
  and    $0xfffffffffffffff0,%rdx
  sub    %rsi,%rcx
  cmp    %rcx,%rsp
  je     L89
L39:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rcx,%rsp
  jne    L39
L89:
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  jne    L312
L151:
  mov    %rax,%rdx
  mov    %rsp,%rcx
  and    $0xfffffffffffff000,%rax
  mov    %rsp,%r12
  and    $0xfffffffffffffff0,%rdx
  sub    %rax,%rcx
L196:
  cmp    %rcx,%rsp
  je     L46
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L196
L137:
  mov    -0x50(%rbp),%eax
  mov    -0x68(%rbp),%rsp
  lea    -0x1(%rax),%edx
  mov    %edx,-0x50(%rbp)
  test   %eax,%eax
  jne    L153
L259:
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L138
  lea    -0x28(%rbp),%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L312:
  orq    $0x0,-0x8(%rsp,%rdx,1)
  jmp    L151
L46:
  mov    %rdx,%rax
  and    $0xfff,%eax
  sub    %rax,%rsp
  test   %rax,%rax
  jne    L174
L157:
  mov    %rsp,%rbx
  test   %r15d,%r15d
  jle    L214
  lea    0x0(,%r14,4),%rdx
  xor    %esi,%esi
  mov    %r12,%rdi
  mov    %rdx,-0x88(%rbp)
  call   <memset@plt>
  mov    -0x88(%rbp),%rdx
  xor    %esi,%esi
  mov    %rbx,%rdi
  call   <memset@plt>
  mov    %r13,%rax
  lea    0x0(%r13,%r14,1),%rdx
  jmp    L50
L287:
  add    $0x1,%rax
  addl   $0x1,(%rbx)
  cmp    %rdx,%rax
  je     L35
L50:
  cmpb   $0x30,(%rax)
  jne    L287
  add    $0x1,%rax
  addl   $0x1,(%r12)
  cmp    %rdx,%rax
  jne    L50
L35:
  cmp    $0x1,%r15d
  jle    L214
  mov    $0x1,%eax
  jmp    L193
L5:
  sub    $0x1,%edx
  mov    %ecx,(%r12,%rax,4)
  mov    %edx,(%rbx,%rax,4)
  add    $0x1,%rax
  cmp    %r14,%rax
  je     L214
L193:
  cmpb   $0x30,-0x1(%r13,%rax,1)
  mov    -0x4(%rbx,%rax,4),%edx
  mov    -0x4(%r12,%rax,4),%ecx
  jne    L5
  sub    $0x1,%ecx
  mov    %edx,(%rbx,%rax,4)
  mov    %ecx,(%r12,%rax,4)
  add    $0x1,%rax
  cmp    %r14,%rax
  jne    L193
  nopl   (%rax)
L214:
  mov    -0x44(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    %edx,-0x44(%rbp)
  test   %eax,%eax
  je     L137
  mov    -0x60(%rbp),%rdx
  mov    -0x58(%rbp),%rsi
  lea    D2(%rip),%rdi
  xor    %eax,%eax
  call   <scanf@plt>
  movslq -0x40(%rbp),%rax
  mov    -0x3c(%rbp),%r10d
  lea    -0x1(%rax),%r14d
  cmp    %r10d,%r14d
  jge    L63
  mov    -0x48(%rbp),%r11d
  movslq %r14d,%r14
  lea    (%rbx,%rax,4),%r15
  xor    %r8d,%r8d
  nopw   0x0(%rax,%rax,1)
L254:
  mov    (%r12,%r14,4),%esi
  mov    -0x4(%r15),%edi
  mov    %r14,%rdx
  mov    %esi,%eax
  jmp    L236
  nop
L172:
  cmp    $0x31,%r9b
  sete   %r9b
  movzbl %r9b,%r9d
  add    %r9d,%eax
  cmp    %ecx,%eax
  cmovl  %ecx,%eax
  cmp    %eax,%r11d
  jl     L150
L243:
  add    $0x1,%rdx
  add    $0x1,%r8d
  cmp    %edx,%r10d
  jle    L150
  mov    (%r12,%rdx,4),%eax
L236:
  movzbl 0x0(%r13,%rdx,1),%r9d
  mov    %esi,%ecx
  sub    %eax,%ecx
  mov    %edi,%eax
  sub    (%rbx,%rdx,4),%eax
  cmp    $0x30,%r9b
  jne    L172
  add    $0x1,%ecx
  cmp    %ecx,%eax
  cmovl  %ecx,%eax
  cmp    %eax,%r11d
  jge    L243
L150:
  add    $0x1,%r14
  add    $0x4,%r15
  cmp    %r14d,%r10d
  jg     L254
  mov    %r8d,%esi
  lea    D36(%rip),%rdi
  call   <printf@plt>
  jmp    L214
L63:
  xor    %r8d,%r8d
  lea    D36(%rip),%rdi
  mov    %r8d,%esi
  call   <printf@plt>
  jmp    L214
L174:
  orq    $0x0,-0x8(%rsp,%rax,1)
  jmp    L157
L138:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: data_label: D20
data_type: string
name: read_data
arguments: data_label: D44
data_type: string
name: read_data
arguments: data_label: D55
data_type: string
name: read_data
arguments: data_label: D2
data_type: string
name: read_data
arguments: data_label: D36
data_type: string

tool: D20: %d

tool: D44: %d%d%d

tool: D55: %s

tool: D2: %d%d

tool: D36: %d


assistant: ```c
int main(void) {
  int terms;
  scanf("%d", &terms);
  while (terms--) {
    int n, k, q;
    scanf("%d%d%d", &n, &k, &q);
    char str[n];
    scanf("%s", str);
    int zeros[n];
    int ones[n];
    int i, j;
    for (i = 0; i < n; i++) {
      zeros[i] = 0;
      ones[i] = 0;
    }
    for (i = 0; i < n; i++) {
      if (str[i] == '0')
        zeros[0]++;
      else
        ones[0]++;
    }
    for (i = 1; i < n; i++) {
      if (str[i - 1] == '0') {
        zeros[i] = zeros[i - 1] - 1;
        ones[i] = ones[i - 1];
      } else {
        ones[i] = ones[i - 1] - 1;
        zeros[i] = zeros[i - 1];
      }
    }
    while (q--) {
      int count = 0;
      int li, ri;
      scanf("%d%d", &li, &ri);
      int looper, l;
      for (looper = li - 1; looper < ri; looper++) {
        for (l = looper; l < ri; l++) {
          int z = zeros[looper] - zeros[l];
          if (str[l] == '0')
            z++;
          int o = ones[looper] - ones[l];
          if (str[l] == '1')
            o++;
          if (z <= k && o <= k)
            count++;
          else
            break;
        }
      }
      printf("%d\n", count);
    }
  }
}
```