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

```asm
<fmerge>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %rdi,0x10(%rsp)
  mov    %rsi,0x8(%rsp)
  mov    %rdx,0x18(%rsp)
  mov    %ecx,0x20(%rsp)
  mov    %r8d,0x24(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  xor    %eax,%eax
  mov    %r8d,%eax
  sub    %ecx,%eax
  movl   $0x0,0x30(%rsp)
  movl   $0x0,0x34(%rsp)
  test   %eax,%eax
  jle    L134
  cmp    $0x1,%eax
  je     L65
  movslq 0x20(%rsp),%rax
  mov    0x8(%rsp),%rsi
  mov    (%rsi,%rax,8),%r14
  lea    0x8(%rsi,%rax,8),%rax
  mov    %rax,0x28(%rsp)
  mov    (%rax),%r15
  mov    $0x0,%eax
  call   <tmpfile@plt>
  mov    %rax,%r12
  lea    0x30(%rsp),%rdi
  mov    %r14,%rcx
  mov    $0x1,%edx
  mov    $0x4,%esi
  call   <fread@plt>
  mov    %eax,%ebx
  lea    0x34(%rsp),%rdi
  mov    %r15,%rcx
  mov    $0x1,%edx
  mov    $0x4,%esi
  call   <fread@plt>
  mov    %eax,%ebp
  lea    0x34(%rsp),%r13
  jmp    L78
L65:
  mov    %rdi,%rdx
  lea    D4(%rip),%rsi
  mov    $0x0,%edi
  call   <freopen@plt>
  mov    %rax,%rsi
  movslq 0x20(%rsp),%rax
  mov    0x8(%rsp),%rcx
  lea    (%rcx,%rax,8),%rbx
  mov    (%rbx),%rdi
  call   <copy_content@plt>
  mov    (%rbx),%rdi
  call   <fclose@plt>
  jmp    L134
L107:
  lea    0x30(%rsp),%rbx
  mov    %r12,%rcx
  mov    $0x1,%edx
  mov    $0x4,%esi
  mov    %rbx,%rdi
  call   <fwrite@plt>
  mov    %r14,%rcx
  mov    $0x1,%edx
  mov    $0x4,%esi
  mov    %rbx,%rdi
  call   <fread@plt>
  mov    %eax,%ebx
L78:
  test   %ebx,%ebx
  setne  %al
  test   %ebp,%ebp
  jne    L71
  test   %al,%al
  jne    L107
L71:
  test   %ebp,%ebp
  setne  %dl
  test   %ebx,%ebx
  jne    L44
  test   %dl,%dl
  jne    L104
L44:
  test   %al,%al
  je     L94
  test   %dl,%dl
  je     L94
  mov    0x34(%rsp),%eax
  cmp    %eax,0x30(%rsp)
  jge    L39
  lea    0x30(%rsp),%rbx
  mov    %r12,%rcx
  mov    $0x1,%edx
  mov    $0x4,%esi
  mov    %rbx,%rdi
  call   <fwrite@plt>
  mov    %r14,%rcx
  mov    $0x1,%edx
  mov    $0x4,%esi
  mov    %rbx,%rdi
  call   <fread@plt>
  mov    %eax,%ebx
  jmp    L78
L104:
  mov    %r12,%rcx
  mov    $0x1,%edx
  mov    $0x4,%esi
  mov    %r13,%rdi
  call   <fwrite@plt>
  mov    %r15,%rcx
  mov    $0x1,%edx
  mov    $0x4,%esi
  mov    %r13,%rdi
  call   <fread@plt>
  mov    %eax,%ebp
  jmp    L78
L39:
  mov    %r12,%rcx
  mov    $0x1,%edx
  mov    $0x4,%esi
  mov    %r13,%rdi
  call   <fwrite@plt>
  mov    %r15,%rcx
  mov    $0x1,%edx
  mov    $0x4,%esi
  mov    %r13,%rdi
  call   <fread@plt>
  mov    %eax,%ebp
  jmp    L78
L94:
  mov    %r14,%rdi
  call   <fclose@plt>
  mov    %r15,%rdi
  call   <fclose@plt>
  mov    $0x0,%eax
  call   <tmpfile@plt>
  mov    %rax,%rbx
  mov    %r12,%rdi
  call   <rewind@plt>
  mov    %rbx,%rsi
  mov    %r12,%rdi
  call   <copy_content@plt>
  mov    %r12,%rdi
  call   <fclose@plt>
  mov    %rbx,%rdi
  call   <rewind@plt>
  mov    0x28(%rsp),%rax
  mov    %rbx,(%rax)
  mov    0x20(%rsp),%ecx
  add    $0x1,%ecx
  mov    0x24(%rsp),%r8d
  mov    0x18(%rsp),%rdx
  mov    0x8(%rsp),%rsi
  mov    0x10(%rsp),%rdi
  call   <fmerge>
L134:
  mov    0x38(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L126
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L126:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: data_tag: D4
data_type: string

tool: D4: wb

assistant: ```c
void fmerge(FILE *f, FILE **file_list, size_t buffer_size, int begin, int end) {
  int len = end - begin;
  FILE *f1 = 0;
  FILE *f2 = 0;
  FILE *f3 = 0;
  int a = 0;
  int read_a = 0;
  int b = 0;
  int read_b = 0;
  if (len < 1) {
    return;
  }
  if (len == 1) {
    f = freopen(0, "wb", f);
    copy_content(file_list[begin], f);
    fclose(file_list[begin]);
    return;
  }
  f1 = file_list[begin];
  f2 = file_list[begin + 1];
  f3 = tmpfile();
  read_a = (int)fread(&a, sizeof(a), 1, f1);
  read_b = (int)fread(&b, sizeof(b), 1, f2);
  while (1) {
    if (read_a && !read_b) {
      fwrite(&a, sizeof(a), 1, f3);
      read_a = (int)fread(&a, sizeof(a), 1, f1);
    } else if (read_b && !read_a) {
      fwrite(&b, sizeof(b), 1, f3);
      read_b = (int)fread(&b, sizeof(b), 1, f2);
    } else if (read_a && read_b) {
      if (a < b) {
        fwrite(&a, sizeof(a), 1, f3);
        read_a = (int)fread(&a, sizeof(a), 1, f1);
      } else {
        fwrite(&b, sizeof(b), 1, f3);
        read_b = (int)fread(&b, sizeof(b), 1, f2);
      }
    } else {
      break;
    }
  }
  fclose(f1);
  fclose(f2);
  f2 = tmpfile();
  rewind(f3);
  copy_content(f3, f2);
  fclose(f3);
  rewind(f2);
  file_list[begin + 1] = f2;
  fmerge(f, file_list, buffer_size, begin + 1, end);
}
```