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

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  xor    %eax,%eax
  lea    0x24(%rsp),%rsi
  lea    D9(%rip),%rdi
  call   <scanf@plt>
  cmpl   $0x0,0x24(%rsp)
  jle    L69
  movl   $0x0,0xc(%rsp)
  lea    0x34(%rsp),%rax
  mov    %rax,0x18(%rsp)
  lea    D18(%rip),%r15
L45:
  lea    0x30(%rsp),%rsi
  mov    0x18(%rsp),%rdx
  lea    D13(%rip),%rdi
  mov    $0x0,%eax
  call   <scanf@plt>
  mov    $0x8,%esi
  mov    $0x989680,%edi
  call   <calloc@plt>
  mov    %rax,%r14
  mov    $0x8,%esi
  mov    $0x989680,%edi
  call   <calloc@plt>
  mov    %rax,%r13
  mov    $0x8,%esi
  mov    0x30(%rsp),%edi
  call   <calloc@plt>
  mov    %rax,0x10(%rsp)
  mov    0x30(%rsp),%eax
  test   %eax,%eax
  jle    L21
  mov    $0x0,%ebx
L2:
  lea    0x2c(%rsp),%rdx
  lea    0x28(%rsp),%rsi
  mov    %r15,%rdi
  mov    $0x0,%eax
  call   <scanf@plt>
  push   $0x1
  mov    0x34(%rsp),%eax
  push   %rax
  mov    0x38(%rsp),%r9d
  mov    0x40(%rsp),%eax
  lea    -0x1(%rax),%r8d
  mov    $0x0,%ecx
  mov    $0x1,%edx
  mov    %r13,%rsi
  mov    %r14,%rdi
  call   <update_tree@plt>
  add    $0x1,%ebx
  mov    0x40(%rsp),%eax
  add    $0x10,%rsp
  cmp    %ebx,%eax
  jg     L2
L21:
  mov    0x34(%rsp),%edx
  mov    %edx,%r12d
  imul   %eax,%r12d
  sub    $0x8,%rsp
  sub    $0x1,%edx
  push   %rdx
  mov    $0x0,%r9d
  lea    -0x1(%rax),%r8d
  mov    $0x0,%ecx
  mov    $0x1,%edx
  mov    %r13,%rsi
  mov    %r14,%rdi
  call   <query_tree@plt>
  sub    %eax,%r12d
  mov    0x40(%rsp),%eax
  mov    0x44(%rsp),%edx
  add    $0x10,%rsp
  cmp    %edx,%eax
  jle    L37
  mov    $0x1,%ebx
L63:
  mov    %eax,%ebp
  imul   %edx,%ebp
  sub    $0x8,%rsp
  lea    -0x1(%rdx,%rbx,1),%edx
  push   %rdx
  mov    %ebx,%r9d
  lea    -0x1(%rax),%r8d
  mov    $0x0,%ecx
  mov    $0x1,%edx
  mov    %r13,%rsi
  mov    %r14,%rdi
  call   <query_tree@plt>
  mov    %eax,%edx
  mov    %ebp,%eax
  sub    %edx,%eax
  cmp    %eax,%r12d
  cmovg  %eax,%r12d
  add    $0x1,%ebx
  mov    0x40(%rsp),%eax
  mov    0x44(%rsp),%edx
  mov    %eax,%ecx
  sub    %edx,%ecx
  add    $0x10,%rsp
  cmp    %ebx,%ecx
  jge    L63
L37:
  mov    %r12d,%esi
  lea    D36(%rip),%rdi
  call   <printf@plt>
  mov    %r14,%rdi
  call   <free@plt>
  mov    %r13,%rdi
  call   <free@plt>
  mov    0x10(%rsp),%rdi
  call   <free@plt>
  addl   $0x1,0xc(%rsp)
  mov    0xc(%rsp),%eax
  cmp    %eax,0x24(%rsp)
  jg     L45
L69:
  mov    0x38(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L34
  mov    $0x0,%eax
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L34:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: data_tag: D9
type_guessed: string
name: retrieve_data
arguments: data_tag: D18
type_guessed: string
name: retrieve_data
arguments: data_tag: D13
type_guessed: string
name: retrieve_data
arguments: data_tag: D36
type_guessed: string

tool: D9: %d

tool: D18: %d%d

tool: D13: %d %d

tool: D36: %d


assistant: ```c
int main(void) {
  int t, li, hi;
  scanf("%d", &t);
  int a;
  for (a = 0; a < t; a++) {
    int g, h;
    scanf("%d %d", &g, &h);
    int i;
    int *tree = (int *)calloc(10000000, 8);
    int *lazy = (int *)calloc(10000000, 8);
    int *arr = (int *)calloc(g, 8);
    for (i = 0; i < g; i++) {
      scanf("%d%d", &li, &hi);
      update_tree(tree, lazy, 1, 0, g - 1, li, hi, 1);
    }
    int min = g * h - query_tree(tree, lazy, 1, 0, g - 1, 0, h - 1);
    for (i = 1; i < g - h + 1; i++) {
      int y = g * h - query_tree(tree, lazy, 1, 0, g - 1, i, i + h - 1);
      if (y < min)
        min = y;
    }
    printf("%d\n", min);
    free(tree);
    free(lazy);
    free(arr);
  }
}
```