ylfeng/ReF-Decompile-dataset huggingface dataset:
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<procnetdev_version>:
  endbr64
  push   %rbx
  mov    %rdi,%rbx
  lea    D19(%rip),%rsi
  call   <strstr@plt>
  mov    %rax,%rdx
  mov    $0x2,%eax
  test   %rdx,%rdx
  jne    L4
  lea    D6(%rip),%rsi
  mov    %rbx,%rdi
  call   <strstr@plt>
  test   %rax,%rax
  setne  %al
  movzbl %al,%eax
L4:
  pop    %rbx
  ret
```

tool_calls: name: parse_data
arguments: tag: D19
data_type: string
name: parse_data
arguments: tag: D6
data_type: string

tool: D19: compressed

tool: D6: bytes

assistant: ```c
int procnetdev_version(char *buf) {
  if (strstr(buf, "compressed"))
    return 2;
  if (strstr(buf, "bytes"))
    return 1;
  return 0;
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<procnetdev_version>:
  endbr64
  push   %rbp
  lea    D8(%rip),%rsi
  mov    %rdi,%rbp
  call   <strstr@plt>
  mov    %rax,%r8
  mov    $0x2,%eax
  test   %r8,%r8
  jne    L8
  lea    D6(%rip),%rsi
  mov    %rbp,%rdi
  call   <strstr@plt>
  test   %rax,%rax
  setne  %al
  movzbl %al,%eax
L8:
  pop    %rbp
  ret
```

tool_calls: name: read_data
arguments: label: D8
type_guessed: string
name: read_data
arguments: label: D6
type_guessed: string

tool: D8: compressed

tool: D6: bytes

assistant: ```c
int procnetdev_version(char *buf) {
  if (strstr(buf, "compressed"))
    return 2;
  if (strstr(buf, "bytes"))
    return 1;
  return 0;
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<procnetdev_version>:
  endbr64
  push   %rbp
  lea    D6(%rip),%rsi
  mov    %rdi,%rbp
  call   <strstr@plt>
  mov    %rax,%r8
  mov    $0x2,%eax
  test   %r8,%r8
  jne    L9
  lea    D13(%rip),%rsi
  mov    %rbp,%rdi
  call   <strstr@plt>
  test   %rax,%rax
  setne  %al
  movzbl %al,%eax
L9:
  pop    %rbp
  ret
```

tool_calls: name: extract_symbolic_data
arguments: label: D6
type_infered: string
name: extract_symbolic_data
arguments: label: D13
type_infered: string

tool: D6: compressed

tool: D13: bytes

assistant: ```c
int procnetdev_version(char *buf) {
  if (strstr(buf, "compressed"))
    return 2;
  if (strstr(buf, "bytes"))
    return 1;
  return 0;
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<section_by_type>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %edi,-0x24(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %rdx,-0x38(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movq   $0x0,-0x20(%rbp)
  movq   $0x0,-0x18(%rbp)
  mov    -0x38(%rbp),%rax
  movq   $0x0,(%rax)
  lea    -0x20(%rbp),%rdx
  mov    -0x24(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <read_header@plt>
  test   %rax,%rax
  jne    L22
  mov    -0x20(%rbp),%rcx
  lea    -0x18(%rbp),%rdx
  mov    -0x24(%rbp),%eax
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <read_section_table@plt>
  test   %rax,%rax
  je     L50
L22:
  mov    D8(%rip),%rax
  mov    (%rax),%eax
  jmp    L26
L50:
  movq   $0x0,-0x10(%rbp)
  jmp    L98
L83:
  mov    -0x18(%rbp),%rdx
  mov    -0x10(%rbp),%rax
  shl    $0x4,%rax
  add    %rdx,%rax
  mov    0x8(%rax),%rax
  cmp    %rax,-0x30(%rbp)
  jne    L4
  mov    $0x10,%edi
  call   <malloc@plt>
  mov    %rax,%rdx
  mov    -0x38(%rbp),%rax
  mov    %rdx,(%rax)
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  jne    L49
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    D8(%rip),%rax
  mov    (%rax),%eax
  jmp    L26
L49:
  mov    -0x18(%rbp),%rdx
  mov    -0x10(%rbp),%rax
  shl    $0x4,%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x38(%rbp),%rax
  mov    (%rax),%rax
  mov    $0x10,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  jmp    L65
L4:
  addq   $0x1,-0x10(%rbp)
L98:
  mov    -0x20(%rbp),%rax
  mov    (%rax),%rax
  cmp    %rax,-0x10(%rbp)
  jb     L83
L65:
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    $0x0,%eax
L26:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L28
  call   <__stack_chk_fail@plt>
L28:
  leave
  ret
```

assistant: ```c
int section_by_type(int d, size_t const section_type, Elf64_Shdr **section) {
  Elf64_Ehdr *header = NULL;
  Elf64_Shdr *sections = NULL;
  size_t i;
  *section = NULL;
  if (read_header(d, &header) || read_section_table(d, header, &sections))
    return errno;
  for (i = 0; i < header->e_shnum; ++i)
    if (section_type == sections[i].sh_type) {
      *section = (Elf64_Shdr *)malloc(sizeof(Elf64_Shdr));
      if (NULL == *section) {
        free(header);
        free(sections);
        return errno;
      }
      memcpy(*section, sections + i, sizeof(Elf64_Shdr));
      break;
    }
  free(header);
  free(sections);
  return 0;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<section_by_type>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x20,%rsp
  mov    %edi,%ebx
  mov    %rsi,%rbp
  mov    %rdx,%r12
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  movq   $0x0,0x8(%rsp)
  movq   $0x0,0x10(%rsp)
  movq   $0x0,(%rdx)
  lea    0x8(%rsp),%rsi
  call   <read_header@plt>
  test   %rax,%rax
  je     L95
L56:
  mov    D8(%rip),%rax
  mov    (%rax),%eax
L22:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L10
  add    $0x20,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L95:
  lea    0x10(%rsp),%rdx
  mov    0x8(%rsp),%rsi
  mov    %ebx,%edi
  call   <read_section_table@plt>
  test   %rax,%rax
  jne    L56
  mov    0x8(%rsp),%rax
  mov    (%rax),%rdx
  test   %rdx,%rdx
  je     L78
  mov    0x10(%rsp),%rcx
  mov    $0x0,%ebx
  mov    $0x0,%eax
L62:
  cmp    %rbp,0x8(%rcx,%rbx,1)
  je     L84
  add    $0x1,%rax
  add    $0x10,%rbx
  cmp    %rdx,%rax
  jne    L62
L78:
  mov    0x8(%rsp),%rdi
  call   <free@plt>
  mov    0x10(%rsp),%rdi
  call   <free@plt>
  mov    $0x0,%eax
  jmp    L22
L84:
  mov    $0x10,%edi
  call   <malloc@plt>
  mov    %rax,%rdi
  mov    %rax,(%r12)
  test   %rax,%rax
  je     L19
  mov    %rbx,%rsi
  add    0x10(%rsp),%rsi
  mov    $0x10,%edx
  call   <memcpy@plt>
  jmp    L78
L19:
  mov    0x8(%rsp),%rdi
  call   <free@plt>
  mov    0x10(%rsp),%rdi
  call   <free@plt>
  mov    D8(%rip),%rax
  mov    (%rax),%eax
  jmp    L22
L10:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int section_by_type(int d, size_t const section_type, Elf64_Shdr **section) {
  Elf64_Ehdr *header = NULL;
  Elf64_Shdr *sections = NULL;
  size_t i;
  *section = NULL;
  if (read_header(d, &header) || read_section_table(d, header, &sections))
    return errno;
  for (i = 0; i < header->e_shnum; ++i)
    if (section_type == sections[i].sh_type) {
      *section = (Elf64_Shdr *)malloc(sizeof(Elf64_Shdr));
      if (NULL == *section) {
        free(header);
        free(sections);
        return errno;
      }
      memcpy(*section, sections + i, sizeof(Elf64_Shdr));
      break;
    }
  free(header);
  free(sections);
  return 0;
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<section_by_type>:
  endbr64
  push   %r13
  mov    %rdx,%r13
  push   %r12
  mov    %edi,%r12d
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  movq   $0x0,(%rdx)
  lea    0x8(%rsp),%rsi
  movq   $0x0,0x8(%rsp)
  movq   $0x0,0x10(%rsp)
  call   <read_header@plt>
  test   %rax,%rax
  je     L76
L60:
  mov    D0(%rip),%rax
  mov    (%rax),%eax
L58:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L83
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopw   0x0(%rax,%rax,1)
L76:
  mov    0x8(%rsp),%rsi
  lea    0x10(%rsp),%rdx
  mov    %r12d,%edi
  call   <read_section_table@plt>
  test   %rax,%rax
  jne    L60
  mov    0x8(%rsp),%rdi
  mov    (%rdi),%rdx
  test   %rdx,%rdx
  je     L40
  mov    0x10(%rsp),%rcx
  xor    %ebx,%ebx
  xor    %eax,%eax
  jmp    L3
  nop
L42:
  add    $0x1,%rax
  add    $0x10,%rbx
  cmp    %rdx,%rax
  je     L40
L3:
  cmp    %rbp,0x8(%rcx,%rbx,1)
  jne    L42
  mov    $0x10,%edi
  call   <malloc@plt>
  mov    %rax,0x0(%r13)
  mov    %rax,%rdi
  test   %rax,%rax
  je     L10
  add    0x10(%rsp),%rbx
  mov    $0x10,%edx
  mov    %rbx,%rsi
  call   <memcpy@plt>
  mov    0x8(%rsp),%rdi
L40:
  call   <free@plt>
  mov    0x10(%rsp),%rdi
  call   <free@plt>
  xor    %eax,%eax
  jmp    L58
L10:
  mov    0x8(%rsp),%rdi
  call   <free@plt>
  mov    0x10(%rsp),%rdi
  call   <free@plt>
  jmp    L60
L83:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int section_by_type(int d, size_t const section_type, Elf64_Shdr **section) {
  Elf64_Ehdr *header = NULL;
  Elf64_Shdr *sections = NULL;
  size_t i;
  *section = NULL;
  if (read_header(d, &header) || read_section_table(d, header, &sections))
    return errno;
  for (i = 0; i < header->e_shnum; ++i)
    if (section_type == sections[i].sh_type) {
      *section = (Elf64_Shdr *)malloc(sizeof(Elf64_Shdr));
      if (NULL == *section) {
        free(header);
        free(sections);
        return errno;
      }
      memcpy(*section, sections + i, sizeof(Elf64_Shdr));
      break;
    }
  free(header);
  free(sections);
  return 0;
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<section_by_type>:
  endbr64
  push   %r13
  mov    %rdx,%r13
  push   %r12
  mov    %edi,%r12d
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  movq   $0x0,(%rdx)
  lea    0x8(%rsp),%rsi
  movq   $0x0,0x8(%rsp)
  movq   $0x0,0x10(%rsp)
  call   <read_header@plt>
  test   %rax,%rax
  je     L98
L83:
  mov    D3(%rip),%rax
  mov    (%rax),%eax
L56:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L59
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopw   0x0(%rax,%rax,1)
L98:
  mov    0x8(%rsp),%rsi
  lea    0x10(%rsp),%rdx
  mov    %r12d,%edi
  call   <read_section_table@plt>
  test   %rax,%rax
  jne    L83
  mov    0x8(%rsp),%rdi
  mov    (%rdi),%rdx
  test   %rdx,%rdx
  je     L1
  mov    0x10(%rsp),%rcx
  xor    %ebx,%ebx
  xor    %eax,%eax
  jmp    L79
  nop
L46:
  add    $0x1,%rax
  add    $0x10,%rbx
  cmp    %rdx,%rax
  je     L1
L79:
  cmp    %rbp,0x8(%rcx,%rbx,1)
  jne    L46
  mov    $0x10,%edi
  call   <malloc@plt>
  mov    %rax,0x0(%r13)
  mov    %rax,%rdi
  test   %rax,%rax
  je     L13
  add    0x10(%rsp),%rbx
  mov    $0x10,%edx
  mov    %rbx,%rsi
  call   <memcpy@plt>
  mov    0x8(%rsp),%rdi
L1:
  call   <free@plt>
  mov    0x10(%rsp),%rdi
  call   <free@plt>
  xor    %eax,%eax
  jmp    L56
L13:
  mov    0x8(%rsp),%rdi
  call   <free@plt>
  mov    0x10(%rsp),%rdi
  call   <free@plt>
  jmp    L83
L59:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int section_by_type(int d, size_t const section_type, Elf64_Shdr **section) {
  Elf64_Ehdr *header = NULL;
  Elf64_Shdr *sections = NULL;
  size_t i;
  *section = NULL;
  if (read_header(d, &header) || read_section_table(d, header, &sections))
    return errno;
  for (i = 0; i < header->e_shnum; ++i)
    if (section_type == sections[i].sh_type) {
      *section = (Elf64_Shdr *)malloc(sizeof(Elf64_Shdr));
      if (NULL == *section) {
        free(header);
        free(sections);
        return errno;
      }
      memcpy(*section, sections + i, sizeof(Elf64_Shdr));
      break;
    }
  free(header);
  free(sections);
  return 0;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<LCMclosed_BM_occurrence_deliver_>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %edi,-0x4(%rbp)
  mov    %esi,-0x8(%rbp)
  mov    -0x8(%rbp),%edx
  mov    -0x4(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <LCMclosed_BM_occurrence_deliver_iter_delete@plt>
  mov    -0x4(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    -0x8(%rbp),%eax
  mov    %eax,%esi
  mov    %edx,%edi
  call   <LCMclosed_BM_occurrence_deliver@plt>
  nop
  leave
  ret
```

assistant: ```c
void LCMclosed_BM_occurrence_deliver_(int item, int mask) {
  LCMclosed_BM_occurrence_deliver_iter_delete(item, mask);
  LCMclosed_BM_occurrence_deliver(item - 1, mask);
}
```
user: 这段汇编代码用C语言表示是什么样的?

```asm
<LCMclosed_BM_occurrence_deliver_>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %edi,%ebx
  mov    %esi,%ebp
  call   <LCMclosed_BM_occurrence_deliver_iter_delete@plt>
  lea    -0x1(%rbx),%edi
  mov    %ebp,%esi
  call   <LCMclosed_BM_occurrence_deliver@plt>
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
```

assistant: ```c
void LCMclosed_BM_occurrence_deliver_(int item, int mask) {
  LCMclosed_BM_occurrence_deliver_iter_delete(item, mask);
  LCMclosed_BM_occurrence_deliver(item - 1, mask);
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<LCMclosed_BM_occurrence_deliver_>:
  endbr64
  push   %rbp
  mov    %esi,%ebp
  push   %rbx
  mov    %edi,%ebx
  sub    $0x8,%rsp
  call   <LCMclosed_BM_occurrence_deliver_iter_delete@plt>
  add    $0x8,%rsp
  lea    -0x1(%rbx),%edi
  mov    %ebp,%esi
  pop    %rbx
  pop    %rbp
  jmp    1070 <LCMclosed_BM_occurrence_deliver@plt>
```

assistant: ```c
void LCMclosed_BM_occurrence_deliver_(int item, int mask) {
  LCMclosed_BM_occurrence_deliver_iter_delete(item, mask);
  LCMclosed_BM_occurrence_deliver(item - 1, mask);
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<LCMclosed_BM_occurrence_deliver_>:
  endbr64
  push   %rbp
  mov    %esi,%ebp
  push   %rbx
  mov    %edi,%ebx
  sub    $0x8,%rsp
  call   <LCMclosed_BM_occurrence_deliver_iter_delete@plt>
  add    $0x8,%rsp
  lea    -0x1(%rbx),%edi
  mov    %ebp,%esi
  pop    %rbx
  pop    %rbp
  jmp    1070 <LCMclosed_BM_occurrence_deliver@plt>
```

assistant: ```c
void LCMclosed_BM_occurrence_deliver_(int item, int mask) {
  LCMclosed_BM_occurrence_deliver_iter_delete(item, mask);
  LCMclosed_BM_occurrence_deliver(item - 1, mask);
}
```
user: What is the c source code of the assembly code below?

```asm
<get_line>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x28(%rbp)
  movq   $0x0,-0x10(%rbp)
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdx
  mov    $0x100000,%esi
  lea    D43(%rip),%rax
  mov    %rax,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  jne    L88
  mov    $0x0,%eax
  jmp    L16
L88:
  mov    $0xa,%esi
  lea    D43(%rip),%rax
  mov    %rax,%rdi
  call   <strrchr@plt>
  test   %eax,%eax
  jne    L31
  lea    D43(%rip),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  cmp    $0xfffff,%eax
  jne    L31
  movl   $0x100000,-0x14(%rbp)
L89:
  mov    -0x14(%rbp),%eax
  lea    (%rax,%rax,1),%edx
  mov    -0x10(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <realloc@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L68
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  movq   $0x0,-0x10(%rbp)
  mov    $0x0,%eax
  jmp    L16
L68:
  cmpq   $0x0,-0x10(%rbp)
  jne    L69
  mov    -0x8(%rbp),%rax
  mov    $0x100000,%edx
  lea    D43(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncpy@plt>
L69:
  mov    -0x8(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x14(%rbp),%eax
  lea    0x1(%rax),%esi
  mov    -0x14(%rbp),%eax
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x10(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdx
  mov    %rcx,%rdi
  call   <fgets@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L13
  mov    -0x10(%rbp),%rax
  jmp    L16
L13:
  shll   -0x14(%rbp)
  mov    -0x10(%rbp),%rax
  mov    $0xa,%esi
  mov    %rax,%rdi
  call   <strrchr@plt>
  test   %eax,%eax
  je     L89
  mov    -0x10(%rbp),%rax
  jmp    L16
L31:
  lea    D43(%rip),%rax
  mov    %rax,%rdi
  call   <xxstrdup@plt>
L16:
  leave
  ret
```

assistant: ```c
char *get_line(FILE *fp) {
  static char buffer[1048576];
  char *other = NULL;
  if (!fgets(buffer, 1048576, fp)) {
    return NULL;
  }
  if (!strrchr(buffer, '\n') && strlen(buffer) == 1048576 - 1) {
    int s = 1048576;
    do {
      char *tmp = realloc(other, 2 * s * sizeof(char));
      if (!tmp) {
        free(other);
        other = NULL;
        return NULL;
      } else {
        if (!other) {
          strncpy(tmp, buffer, 1048576);
        }
        other = tmp;
      }
      tmp = fgets(other + s - 1, s + 1, fp);
      if (!tmp) {
        return other;
      }
      s *= 2;
    } while (!strrchr(other, '\n'));
    return other;
  } else {
    return xxstrdup(buffer);
  }
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<get_line>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%r13
  mov    %rdi,%rdx
  mov    $0x100000,%esi
  lea    D9(%rip),%rdi
  call   <fgets@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L58
  mov    $0xa,%esi
  lea    D9(%rip),%rdi
  call   <strrchr@plt>
  test   %eax,%eax
  jne    L18
  lea    D9(%rip),%rdi
  call   <strlen@plt>
  cmp    $0xfffff,%eax
  jne    L18
  mov    $0x100000,%r12d
  mov    $0x0,%ebx
  lea    D9(%rip),%r14
  jmp    L13
L31:
  mov    %r15,%rdi
  call   <free@plt>
  jmp    L58
L10:
  movslq %ebp,%rax
  lea    -0x1(%rbx,%rax,1),%rdi
  lea    0x1(%rbp),%esi
  mov    %r13,%rdx
  call   <fgets@plt>
  test   %rax,%rax
  je     L58
  mov    $0xa,%esi
  mov    %rbx,%rdi
  call   <strrchr@plt>
  test   %eax,%eax
  jne    L58
L13:
  mov    %r12d,%ebp
  add    %r12d,%r12d
  mov    %rbx,%r15
  mov    %r12d,%esi
  mov    %rbx,%rdi
  call   <realloc@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L31
  test   %r15,%r15
  jne    L10
  mov    $0x100000,%edx
  mov    %r14,%rsi
  mov    %rax,%rdi
  call   <strncpy@plt>
  jmp    L10
L18:
  lea    D9(%rip),%rdi
  call   <xxstrdup@plt>
  mov    %rax,%rbx
L58:
  mov    %rbx,%rax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
char *get_line(FILE *fp) {
  static char buffer[1048576];
  char *other = NULL;
  if (!fgets(buffer, 1048576, fp)) {
    return NULL;
  }
  if (!strrchr(buffer, '\n') && strlen(buffer) == 1048576 - 1) {
    int s = 1048576;
    do {
      char *tmp = realloc(other, 2 * s * sizeof(char));
      if (!tmp) {
        free(other);
        other = NULL;
        return NULL;
      } else {
        if (!other) {
          strncpy(tmp, buffer, 1048576);
        }
        other = tmp;
      }
      tmp = fgets(other + s - 1, s + 1, fp);
      if (!tmp) {
        return other;
      }
      s *= 2;
    } while (!strrchr(other, '\n'));
    return other;
  } else {
    return xxstrdup(buffer);
  }
}
```
user: Translate the below assembly code into C programming language:

```asm
<get_line>:
  endbr64
  push   %r15
  mov    %rdi,%rdx
  mov    $0x100000,%esi
  push   %r14
  push   %r13
  lea    D1(%rip),%r13
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  mov    %r13,%rdi
  push   %rbx
  sub    $0x8,%rsp
  call   <fgets@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L82
  mov    $0xa,%esi
  mov    %r13,%rdi
  call   <strrchr@plt>
  test   %eax,%eax
  jne    L16
  mov    %r13,%rdi
  call   <strlen@plt>
  cmp    $0xfffff,%eax
  jne    L16
  mov    $0x100000,%r14d
  xor    %r12d,%r12d
  jmp    L79
  nopl   0x0(%rax,%rax,1)
L35:
  movslq %ebx,%rax
  lea    0x1(%rbx),%esi
  mov    %rbp,%rdx
  lea    -0x1(%r12,%rax,1),%rdi
  call   <fgets@plt>
  test   %rax,%rax
  je     L82
  mov    $0xa,%esi
  mov    %r12,%rdi
  call   <strrchr@plt>
  test   %eax,%eax
  jne    L82
L79:
  mov    %r14d,%ebx
  add    %r14d,%r14d
  mov    %r12,%rdi
  mov    %r12,%r15
  mov    %r14d,%esi
  call   <realloc@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L13
  test   %r15,%r15
  jne    L35
  mov    $0x100000,%edx
  mov    %r13,%rsi
  mov    %rax,%rdi
  call   <strncpy@plt>
  jmp    L35
  nopl   0x0(%rax)
L16:
  add    $0x8,%rsp
  mov    %r13,%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1110 <xxstrdup@plt>
  xchg   %ax,%ax
L13:
  mov    %r15,%rdi
  call   <free@plt>
L82:
  add    $0x8,%rsp
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
char *get_line(FILE *fp) {
  static char buffer[1048576];
  char *other = NULL;
  if (!fgets(buffer, 1048576, fp)) {
    return NULL;
  }
  if (!strrchr(buffer, '\n') && strlen(buffer) == 1048576 - 1) {
    int s = 1048576;
    do {
      char *tmp = realloc(other, 2 * s * sizeof(char));
      if (!tmp) {
        free(other);
        other = NULL;
        return NULL;
      } else {
        if (!other) {
          strncpy(tmp, buffer, 1048576);
        }
        other = tmp;
      }
      tmp = fgets(other + s - 1, s + 1, fp);
      if (!tmp) {
        return other;
      }
      s *= 2;
    } while (!strrchr(other, '\n'));
    return other;
  } else {
    return xxstrdup(buffer);
  }
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<get_line>:
  endbr64
  push   %r15
  mov    %rdi,%rdx
  mov    $0x100000,%esi
  push   %r14
  push   %r13
  lea    D7(%rip),%r13
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  mov    %r13,%rdi
  push   %rbx
  sub    $0x8,%rsp
  call   <fgets@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L39
  mov    $0xa,%esi
  mov    %r13,%rdi
  call   <strrchr@plt>
  test   %eax,%eax
  jne    L20
  mov    %r13,%rdi
  call   <strlen@plt>
  cmp    $0xfffff,%eax
  jne    L20
  mov    $0x100000,%r14d
  xor    %r12d,%r12d
  jmp    L51
  nopl   0x0(%rax,%rax,1)
L10:
  movslq %ebx,%rax
  lea    0x1(%rbx),%esi
  mov    %rbp,%rdx
  lea    -0x1(%r12,%rax,1),%rdi
  call   <fgets@plt>
  test   %rax,%rax
  je     L39
  mov    $0xa,%esi
  mov    %r12,%rdi
  call   <strrchr@plt>
  test   %eax,%eax
  jne    L39
L51:
  mov    %r14d,%ebx
  add    %r14d,%r14d
  mov    %r12,%rdi
  mov    %r12,%r15
  mov    %r14d,%esi
  call   <realloc@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L69
  test   %r15,%r15
  jne    L10
  mov    $0x100000,%edx
  mov    %r13,%rsi
  mov    %rax,%rdi
  call   <strncpy@plt>
  jmp    L10
  nopl   0x0(%rax)
L20:
  add    $0x8,%rsp
  mov    %r13,%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  jmp    1110 <xxstrdup@plt>
  xchg   %ax,%ax
L69:
  mov    %r15,%rdi
  call   <free@plt>
L39:
  add    $0x8,%rsp
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
char *get_line(FILE *fp) {
  static char buffer[1048576];
  char *other = NULL;
  if (!fgets(buffer, 1048576, fp)) {
    return NULL;
  }
  if (!strrchr(buffer, '\n') && strlen(buffer) == 1048576 - 1) {
    int s = 1048576;
    do {
      char *tmp = realloc(other, 2 * s * sizeof(char));
      if (!tmp) {
        free(other);
        other = NULL;
        return NULL;
      } else {
        if (!other) {
          strncpy(tmp, buffer, 1048576);
        }
        other = tmp;
      }
      tmp = fgets(other + s - 1, s + 1, fp);
      if (!tmp) {
        return other;
      }
      s *= 2;
    } while (!strrchr(other, '\n'));
    return other;
  } else {
    return xxstrdup(buffer);
  }
}
```