user: Demonstrate the C code that generates the assembly output below:

```asm
<main>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x128,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x118(%rsp)
  xor    %eax,%eax
  lea    D59(%rip),%rsi
  lea    D67(%rip),%rdi
  call   <fopen@plt>
  mov    %rax,%r15
  lea    D30(%rip),%rsi
  lea    D95(%rip),%rdi
  call   <fopen@plt>
  mov    %rax,0x10(%rsp)
  lea    0x60(%rsp),%rdi
  mov    $0x14,%ecx
  mov    $0x0,%eax
  rep stos %rax,%es:(%rdi)
  movl   $0x0,(%rdi)
  movb   $0x0,0x4(%rdi)
  movq   $0x0,0x109(%rsp)
  movl   $0x0,0x111(%rsp)
  movw   $0x0,0x115(%rsp)
  movb   $0x0,0x117(%rsp)
  movq   $0x0,0x30(%rsp)
  movq   $0x0,0x38(%rsp)
  movq   $0x0,0x40(%rsp)
  movq   $0x0,0x48(%rsp)
  movq   $0x0,0x50(%rsp)
  movl   $0x0,0x58(%rsp)
  lea    0x24(%rsp),%rdx
  lea    D7(%rip),%rsi
  mov    %r15,%rdi
  call   <fscanf@plt>
  cmpl   $0x0,0x24(%rsp)
  jle    L81
  mov    $0x0,%ebx
  lea    D74(%rip),%rbp
L149:
  lea    0x60(%rsp),%rax
  mov    %rax,(%rsp)
  mov    %rbx,%rdx
  shl    $0x4,%rdx
  sub    %rbx,%rdx
  add    %rax,%rdx
  mov    %rbp,%rsi
  mov    %r15,%rdi
  mov    $0x0,%eax
  call   <fscanf@plt>
  mov    0x24(%rsp),%eax
  add    $0x1,%rbx
  cmp    %ebx,%eax
  jg     L149
  test   %eax,%eax
  jle    L81
  movl   $0x0,0xc(%rsp)
  lea    0x109(%rsp),%r12
  lea    0x2c(%rsp),%rax
  mov    %rax,0x18(%rsp)
  jmp    L11
L157:
  add    $0x1,%ebx
L99:
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  add    $0xf,%rbp
  test   %rax,%rax
  jne    L157
  lea    0x28(%rsp),%rdx
  mov    0x18(%rsp),%rcx
  lea    D88(%rip),%rsi
  mov    %r15,%rdi
  call   <fscanf@plt>
  mov    0x2c(%rsp),%ecx
  test   %ecx,%ecx
  je     L14
  mov    0x28(%rsp),%eax
  cltd
  idiv   %ecx
  mov    %eax,%r14d
  movslq %ebx,%rbx
  mov    %ecx,%eax
  imul   %r14d,%eax
  sub    %eax,0x30(%rsp,%rbx,4)
  test   %ecx,%ecx
  jle    L14
  mov    $0x0,%r13d
  jmp    L87
L3:
  add    $0x1,%ebp
L101:
  mov    %r12,%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  add    $0xf,%rbx
  test   %rax,%rax
  jne    L3
  movslq %ebp,%rbp
  add    %r14d,0x30(%rsp,%rbp,4)
  add    $0x1,%r13d
  cmp    %r13d,0x2c(%rsp)
  jle    L14
L87:
  mov    %r12,%rdx
  lea    D74(%rip),%rsi
  mov    %r15,%rdi
  mov    $0x0,%eax
  call   <fscanf@plt>
  mov    (%rsp),%rbx
  mov    $0x0,%ebp
  jmp    L101
L14:
  addl   $0x1,0xc(%rsp)
  mov    0xc(%rsp),%ecx
  mov    0x24(%rsp),%eax
  cmp    %ecx,%eax
  jle    L34
L11:
  mov    %r12,%rdx
  lea    D74(%rip),%rsi
  mov    %r15,%rdi
  mov    $0x0,%eax
  call   <fscanf@plt>
  mov    (%rsp),%rbp
  mov    $0x0,%ebx
  jmp    L99
L34:
  test   %eax,%eax
  jle    L81
  mov    $0x0,%ebx
  lea    D1(%rip),%rbp
L38:
  mov    0x30(%rsp,%rbx,4),%ecx
  mov    %rbx,%rdx
  shl    $0x4,%rdx
  sub    %rbx,%rdx
  add    (%rsp),%rdx
  mov    %rbp,%rsi
  mov    0x10(%rsp),%rdi
  call   <fprintf@plt>
  add    $0x1,%rbx
  cmp    %ebx,0x24(%rsp)
  jg     L38
L81:
  mov    %r15,%rdi
  call   <fclose@plt>
  mov    0x10(%rsp),%rdi
  call   <fclose@plt>
  mov    0x118(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L127
  mov    $0x0,%eax
  add    $0x128,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L127:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: label: D59
type: string
name: unpack_data
arguments: label: D67
type: string
name: unpack_data
arguments: label: D30
type: string
name: unpack_data
arguments: label: D95
type: string
name: unpack_data
arguments: label: D7
type: string
name: unpack_data
arguments: label: D74
type: string
name: unpack_data
arguments: label: D88
type: string
name: unpack_data
arguments: label: D1
type: string

tool: D59: r

tool: D67: gift1.in

tool: D30: w

tool: D95: gift1.out

tool: D7: %d

tool: D74: %s

tool: D88: %d %d

tool: D1: %s %d


assistant: ```c
int main(void) {
  FILE *fin = fopen("gift1.in", "r");
  FILE *fout = fopen("gift1.out", "w");
  char person_name[11][15] = {0};
  char temp_name[15] = {0};
  int i;
  int j;
  int k;
  int NP;
  int average_money;
  int money_give;
  int number_give;
  int total_money[11] = {0};
  fscanf(fin, "%d", &NP);
  for (i = 0; i < NP; ++i) {
    fscanf(fin, "%s", person_name[i]);
  }
  for (i = 0; i < NP; ++i) {
    j = 0;
    fscanf(fin, "%s", temp_name);
    while (strcmp(person_name[j], temp_name)) {
      ++j;
    }
    fscanf(fin, "%d %d", &money_give, &number_give);
    if (0 == number_give) {
      average_money = 0;
    } else {
      average_money = money_give / number_give;
    }
    total_money[j] -= average_money * number_give;
    for (k = 0; k < number_give; ++k) {
      j = 0;
      fscanf(fin, "%s", temp_name);
      while (strcmp(person_name[j], temp_name)) {
        ++j;
      }
      total_money[j] += average_money;
    }
  }
  for (i = 0; i < NP; ++i) {
    fprintf(fout, "%s %d\n", person_name[i], total_money[i]);
  }
  fclose(fin);
  fclose(fout);
  return 0;
}
```