ylfeng/ReF-Decompile-dataset huggingface dataset:
user: 下面的汇编指令对应的C源代码是什么:

```asm
<get_header>:
  endbr64
  push   %rbp
  lea    D60(%rip),%r9
  lea    D96(%rip),%r8
  lea    D51(%rip),%rcx
  lea    D94(%rip),%rdx
  lea    D104(%rip),%rsi
  sub    $0x210,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x208(%rsp)
  xor    %eax,%eax
  lea    D61(%rip),%rax
  lea    0x8(%rsp),%rdi
  push   %rax
  lea    D1(%rip),%rax
  push   %rax
  lea    D59(%rip),%rax
  push   %rax
  lea    D15(%rip),%rax
  push   %rax
  xor    %eax,%eax
  call   <asprintf@plt>
  add    $0x20,%rsp
  cmp    $0xffffffff,%eax
  je     L1
  mov    0x8(%rsp),%rax
  mov    0x208(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L12
  add    $0x210,%rsp
  pop    %rbp
  ret
L1:
  lea    0x10(%rsp),%rbp
  push   %rax
  lea    D10(%rip),%rax
  mov    $0x33,%r9d
  push   %rax
  lea    D76(%rip),%r8
  mov    $0x1f4,%esi
  mov    %rbp,%rdi
  lea    D45(%rip),%rcx
  lea    D17(%rip),%rdx
  xor    %eax,%eax
  call   <snprintf@plt>
  mov    %rbp,%rdi
  xor    %eax,%eax
  call   <perror@plt>
  mov    $0x1,%edi
  call   <exit@plt>
L12:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: data_label: D60
type_infered: string
name: retrieve_data
arguments: data_label: D96
type_infered: string
name: retrieve_data
arguments: data_label: D51
type_infered: string
name: retrieve_data
arguments: data_label: D94
type_infered: string
name: retrieve_data
arguments: data_label: D104
type_infered: string
name: retrieve_data
arguments: data_label: D61
type_infered: string
name: retrieve_data
arguments: data_label: D1
type_infered: string
name: retrieve_data
arguments: data_label: D59
type_infered: string
name: retrieve_data
arguments: data_label: D15
type_infered: string
name: retrieve_data
arguments: data_label: D10
type_infered: string
name: retrieve_data
arguments: data_label: D76
type_infered: string
name: retrieve_data
arguments: data_label: D45
type_infered: string
name: retrieve_data
arguments: data_label: D17
type_infered: string

tool: D60: SHR(KiB)

tool: D96: RES(KiB)

tool: D51: User

tool: D94: PID

tool: D104: %-5.5s %-9.9s %-8.8s %-8.8s %-5.5s %-4.4s %-9.9s %s

tool: D61: Command

tool: D1: Uptime

tool: D59: Prcs

tool: D15: CPU%

tool: D10: get_header

tool: D76: /scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/pmillerchip/firejail/refs/heads/master/src/firemon/top.c

tool: D45: asprintf

tool: D17: Error %s: %s:%d %s

assistant: ```c
char *get_header(void) {
  char *rv;
  if (asprintf(&rv, "%-5.5s %-9.9s %-8.8s %-8.8s %-5.5s %-4.4s %-9.9s %s", "PID", "User", "RES(KiB)", "SHR(KiB)", "CPU%", "Prcs", "Uptime", "Command") == -1)
    do {
      char msgout[500];
      snprintf(msgout, 500, "Error %s: %s:%d %s", "asprintf", "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/pmillerchip/firejail/refs/heads/master/src/firemon/top.c", 51, __FUNCTION__);
      perror(msgout);
      exit(1);
    } while (0);
  return rv;
}
```
user: Translate the below assembly code into C programming language:

```asm
<get_header>:
  endbr64
  push   %rbp
  lea    D101(%rip),%r9
  lea    D20(%rip),%r8
  lea    D126(%rip),%rcx
  lea    D59(%rip),%rdx
  lea    D129(%rip),%rsi
  sub    $0x210,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x208(%rsp)
  xor    %eax,%eax
  lea    D58(%rip),%rax
  lea    0x8(%rsp),%rdi
  push   %rax
  lea    D34(%rip),%rax
  push   %rax
  lea    D89(%rip),%rax
  push   %rax
  lea    D65(%rip),%rax
  push   %rax
  xor    %eax,%eax
  call   <asprintf@plt>
  add    $0x20,%rsp
  cmp    $0xffffffff,%eax
  je     L0
  mov    0x8(%rsp),%rax
  mov    0x208(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L16
  add    $0x210,%rsp
  pop    %rbp
  ret
L0:
  lea    0x10(%rsp),%rbp
  push   %rax
  lea    D88(%rip),%rax
  mov    $0x33,%r9d
  push   %rax
  lea    D73(%rip),%r8
  mov    $0x1f4,%esi
  mov    %rbp,%rdi
  lea    D90(%rip),%rcx
  lea    D56(%rip),%rdx
  xor    %eax,%eax
  call   <snprintf@plt>
  mov    %rbp,%rdi
  xor    %eax,%eax
  call   <perror@plt>
  mov    $0x1,%edi
  call   <exit@plt>
L16:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: data_tag: D101
data_type: string
name: read_data
arguments: data_tag: D20
data_type: string
name: read_data
arguments: data_tag: D126
data_type: string
name: read_data
arguments: data_tag: D59
data_type: string
name: read_data
arguments: data_tag: D129
data_type: string
name: read_data
arguments: data_tag: D58
data_type: string
name: read_data
arguments: data_tag: D34
data_type: string
name: read_data
arguments: data_tag: D89
data_type: string
name: read_data
arguments: data_tag: D65
data_type: string
name: read_data
arguments: data_tag: D88
data_type: string
name: read_data
arguments: data_tag: D73
data_type: string
name: read_data
arguments: data_tag: D90
data_type: string
name: read_data
arguments: data_tag: D56
data_type: string

tool: D101: SHR(KiB)

tool: D20: RES(KiB)

tool: D126: User

tool: D59: PID

tool: D129: %-5.5s %-9.9s %-8.8s %-8.8s %-5.5s %-4.4s %-9.9s %s

tool: D58: Command

tool: D34: Uptime

tool: D89: Prcs

tool: D65: CPU%

tool: D88: get_header

tool: D73: /scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/pmillerchip/firejail/refs/heads/master/src/firemon/top.c

tool: D90: asprintf

tool: D56: Error %s: %s:%d %s

assistant: ```c
char *get_header(void) {
  char *rv;
  if (asprintf(&rv, "%-5.5s %-9.9s %-8.8s %-8.8s %-5.5s %-4.4s %-9.9s %s", "PID", "User", "RES(KiB)", "SHR(KiB)", "CPU%", "Prcs", "Uptime", "Command") == -1)
    do {
      char msgout[500];
      snprintf(msgout, 500, "Error %s: %s:%d %s", "asprintf", "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/pmillerchip/firejail/refs/heads/master/src/firemon/top.c", 51, __FUNCTION__);
      perror(msgout);
      exit(1);
    } while (0);
  return rv;
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<halfp2singles>:
  endbr64
  test   %rsi,%rsi
  je     L44
  mov    %rsi,%rcx
  test   %rdi,%rdi
  je     L44
  test   %edx,%edx
  je     L44
  lea    0x4(%rdi),%rsi
  mov    %edx,%edx
  lea    (%rcx,%rdx,4),%rdi
  mov    $0xffc00000,%r9d
  mov    $0x70,%r8d
L47:
  add    $0x4,%rcx
  mov    -0x4(%rcx),%eax
  test   $0x7fff,%eax
  jne    L75
  shl    $0x10,%eax
  mov    %eax,-0x4(%rsi)
  add    $0x4,%rsi
  cmp    %rcx,%rdi
  jne    L47
L44:
  mov    $0x0,%eax
  ret
L83:
  mov    $0xffffffff,%r11d
L13:
  add    $0x1,%r11d
  mov    %edx,%ebx
  add    %edx,%edx
  test   $0x4,%dh
  je     L13
  mov    %r8d,%eax
  sub    %r11d,%eax
  shl    $0x17,%eax
  shl    $0x10,%r10d
  or     %r10d,%eax
  shl    $0xe,%ebx
  and    $0x7fe000,%ebx
  or     %ebx,%eax
  jmp    L63
L66:
  shl    $0x10,%r10d
  or     $0x7f800000,%r10d
  test   %edx,%edx
  mov    %r10d,%eax
  cmovne %r9d,%eax
  jmp    L63
L7:
  mov    $0x0,%eax
  pop    %rbx
  ret
L75:
  push   %rbx
L45:
  mov    %eax,%r10d
  and    $0x8000,%r10d
  mov    %eax,%edx
  and    $0x3ff,%edx
  and    $0x7c00,%eax
  je     L83
  cmp    $0x7c00,%eax
  je     L66
  shl    $0x10,%r10d
  shl    $0xd,%edx
  or     %edx,%r10d
  shl    $0xd,%eax
  lea    0x38000000(%rax),%eax
  or     %r10d,%eax
L63:
  mov    %eax,-0x4(%rsi)
  add    $0x4,%rsi
  cmp    %rcx,%rdi
  je     L7
  add    $0x4,%rcx
  mov    -0x4(%rcx),%eax
  test   $0x7fff,%eax
  jne    L45
  shl    $0x10,%eax
  jmp    L63
```

assistant: ```c
int halfp2singles(void *target, void *source, int numel) {
  uint16_t *hp = (uint16_t *)source;
  uint32_t *xp = (uint32_t *)target;
  uint16_t h, hs, he, hm;
  uint32_t xs, xe, xm;
  int32_t xes;
  int e;
  if (source == NULL || target == NULL)
    return 0;
  while (numel--) {
    h = *hp++;
    if ((h & 0x7FFFu) == 0) {
      *xp++ = ((uint32_t)h) << 16;
    } else {
      hs = h & 0x8000u;
      he = h & 0x7C00u;
      hm = h & 0x03FFu;
      if (he == 0) {
        e = -1;
        do {
          e++;
          hm <<= 1;
        } while ((hm & 0x0400u) == 0);
        xs = ((uint32_t)hs) << 16;
        xes = ((int32_t)(he >> 10)) - 15 + 127 - e;
        xe = (uint32_t)(xes << 23);
        xm = ((uint32_t)(hm & 0x03FFu)) << 13;
        *xp++ = (xs | xe | xm);
      } else if (he == 0x7C00u) {
        if (hm == 0) {
          *xp++ = (((uint32_t)hs) << 16) | ((uint32_t)0x7F800000u);
        } else {
          *xp++ = (uint32_t)0xFFC00000u;
        }
      } else {
        xs = ((uint32_t)hs) << 16;
        xes = ((int32_t)(he >> 10)) - 15 + 127;
        xe = (uint32_t)(xes << 23);
        xm = ((uint32_t)hm) << 13;
        *xp++ = (xs | xe | xm);
      }
    }
  }
  return 0;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<halfp2singles>:
  endbr64
  test   %rsi,%rsi
  je     L121
  mov    %rdi,%r8
  test   %rdi,%rdi
  je     L121
  test   %edx,%edx
  je     L121
  mov    %rsi,%rdi
  xor    %ecx,%ecx
  mov    %edx,%esi
  mov    $0xffc00000,%r10d
  mov    $0x70,%r9d
L88:
  mov    (%rdi,%rcx,4),%eax
  test   $0x7fff,%eax
  jne    L112
  shl    $0x10,%eax
  mov    %eax,(%r8,%rcx,4)
  add    $0x1,%rcx
  cmp    %rsi,%rcx
  jne    L88
L121:
  xor    %eax,%eax
  ret
  nopl   (%rax)
L112:
  push   %rbp
  push   %rbx
L12:
  mov    %eax,%r11d
  mov    %eax,%edx
  and    $0x8000,%r11d
  and    $0x3ff,%edx
  and    $0x7c00,%eax
  je     L98
  shl    $0x10,%r11d
  cmp    $0x7c00,%eax
  je     L105
  shl    $0xd,%edx
  shl    $0xd,%eax
  or     %edx,%r11d
  add    $0x38000000,%eax
  or     %r11d,%eax
L115:
  mov    %eax,(%r8,%rcx,4)
  add    $0x1,%rcx
  cmp    %rsi,%rcx
  je     L85
L55:
  mov    (%rdi,%rcx,4),%eax
  test   $0x7fff,%eax
  jne    L12
  shl    $0x10,%eax
  mov    %eax,(%r8,%rcx,4)
  add    $0x1,%rcx
  cmp    %rsi,%rcx
  jne    L55
L85:
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  ret
  nopl   0x0(%rax,%rax,1)
L98:
  mov    $0xffffffff,%ebx
  nopl   (%rax)
L31:
  mov    %edx,%ebp
  add    %edx,%edx
  add    $0x1,%ebx
  test   $0x4,%dh
  je     L31
  shl    $0x10,%r11d
  mov    %r9d,%eax
  shl    $0xe,%ebp
  sub    %ebx,%eax
  and    $0x7fe000,%ebp
  shl    $0x17,%eax
  or     %r11d,%eax
  or     %ebp,%eax
  jmp    L115
L105:
  or     $0x7f800000,%r11d
  test   %edx,%edx
  mov    %r11d,%eax
  cmovne %r10d,%eax
  jmp    L115
```

assistant: ```c
int halfp2singles(void *target, void *source, int numel) {
  uint16_t *hp = (uint16_t *)source;
  uint32_t *xp = (uint32_t *)target;
  uint16_t h, hs, he, hm;
  uint32_t xs, xe, xm;
  int32_t xes;
  int e;
  if (source == NULL || target == NULL)
    return 0;
  while (numel--) {
    h = *hp++;
    if ((h & 0x7FFFu) == 0) {
      *xp++ = ((uint32_t)h) << 16;
    } else {
      hs = h & 0x8000u;
      he = h & 0x7C00u;
      hm = h & 0x03FFu;
      if (he == 0) {
        e = -1;
        do {
          e++;
          hm <<= 1;
        } while ((hm & 0x0400u) == 0);
        xs = ((uint32_t)hs) << 16;
        xes = ((int32_t)(he >> 10)) - 15 + 127 - e;
        xe = (uint32_t)(xes << 23);
        xm = ((uint32_t)(hm & 0x03FFu)) << 13;
        *xp++ = (xs | xe | xm);
      } else if (he == 0x7C00u) {
        if (hm == 0) {
          *xp++ = (((uint32_t)hs) << 16) | ((uint32_t)0x7F800000u);
        } else {
          *xp++ = (uint32_t)0xFFC00000u;
        }
      } else {
        xs = ((uint32_t)hs) << 16;
        xes = ((int32_t)(he >> 10)) - 15 + 127;
        xe = (uint32_t)(xes << 23);
        xm = ((uint32_t)hm) << 13;
        *xp++ = (xs | xe | xm);
      }
    }
  }
  return 0;
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<halfp2singles>:
  endbr64
  test   %rsi,%rsi
  je     L115
  mov    %rdi,%r8
  test   %rdi,%rdi
  je     L115
  test   %edx,%edx
  je     L115
  mov    %rsi,%rdi
  xor    %ecx,%ecx
  mov    %edx,%esi
  mov    $0xffc00000,%r10d
  mov    $0x70,%r9d
L49:
  mov    (%rdi,%rcx,4),%eax
  test   $0x7fff,%eax
  jne    L51
  shl    $0x10,%eax
  mov    %eax,(%r8,%rcx,4)
  add    $0x1,%rcx
  cmp    %rsi,%rcx
  jne    L49
L115:
  xor    %eax,%eax
  ret
  nopl   (%rax)
L51:
  push   %rbp
  push   %rbx
L95:
  mov    %eax,%r11d
  mov    %eax,%edx
  and    $0x8000,%r11d
  and    $0x3ff,%edx
  and    $0x7c00,%eax
  je     L72
  shl    $0x10,%r11d
  cmp    $0x7c00,%eax
  je     L75
  shl    $0xd,%edx
  shl    $0xd,%eax
  or     %edx,%r11d
  add    $0x38000000,%eax
  or     %r11d,%eax
L46:
  mov    %eax,(%r8,%rcx,4)
  add    $0x1,%rcx
  cmp    %rsi,%rcx
  je     L98
L78:
  mov    (%rdi,%rcx,4),%eax
  test   $0x7fff,%eax
  jne    L95
  shl    $0x10,%eax
  mov    %eax,(%r8,%rcx,4)
  add    $0x1,%rcx
  cmp    %rsi,%rcx
  jne    L78
L98:
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  ret
  nopl   0x0(%rax,%rax,1)
L72:
  mov    $0xffffffff,%ebx
  nopl   (%rax)
L55:
  mov    %edx,%ebp
  add    %edx,%edx
  add    $0x1,%ebx
  test   $0x4,%dh
  je     L55
  shl    $0x10,%r11d
  mov    %r9d,%eax
  shl    $0xe,%ebp
  sub    %ebx,%eax
  and    $0x7fe000,%ebp
  shl    $0x17,%eax
  or     %r11d,%eax
  or     %ebp,%eax
  jmp    L46
L75:
  or     $0x7f800000,%r11d
  test   %edx,%edx
  mov    %r11d,%eax
  cmovne %r10d,%eax
  jmp    L46
```

assistant: ```c
int halfp2singles(void *target, void *source, int numel) {
  uint16_t *hp = (uint16_t *)source;
  uint32_t *xp = (uint32_t *)target;
  uint16_t h, hs, he, hm;
  uint32_t xs, xe, xm;
  int32_t xes;
  int e;
  if (source == NULL || target == NULL)
    return 0;
  while (numel--) {
    h = *hp++;
    if ((h & 0x7FFFu) == 0) {
      *xp++ = ((uint32_t)h) << 16;
    } else {
      hs = h & 0x8000u;
      he = h & 0x7C00u;
      hm = h & 0x03FFu;
      if (he == 0) {
        e = -1;
        do {
          e++;
          hm <<= 1;
        } while ((hm & 0x0400u) == 0);
        xs = ((uint32_t)hs) << 16;
        xes = ((int32_t)(he >> 10)) - 15 + 127 - e;
        xe = (uint32_t)(xes << 23);
        xm = ((uint32_t)(hm & 0x03FFu)) << 13;
        *xp++ = (xs | xe | xm);
      } else if (he == 0x7C00u) {
        if (hm == 0) {
          *xp++ = (((uint32_t)hs) << 16) | ((uint32_t)0x7F800000u);
        } else {
          *xp++ = (uint32_t)0xFFC00000u;
        }
      } else {
        xs = ((uint32_t)hs) << 16;
        xes = ((int32_t)(he >> 10)) - 15 + 127;
        xe = (uint32_t)(xes << 23);
        xm = ((uint32_t)hm) << 13;
        *xp++ = (xs | xe | xm);
      }
    }
  }
  return 0;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<xzalloc>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <xmalloc@plt>
  mov    %rax,-0x8(%rbp)
  mov    -0x18(%rbp),%rdx
  mov    -0x8(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  mov    -0x8(%rbp),%rax
  leave
  ret
```

assistant: ```c
void *xzalloc(size_t s) {
  void *value = xmalloc(s);
  memset(value, 0, s);
  return value;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<xzalloc>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%rbp
  call   <xmalloc@plt>
  mov    %rax,%rbx
  mov    %rbp,%rdx
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  mov    %rbx,%rax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
```

assistant: ```c
void *xzalloc(size_t s) {
  void *value = xmalloc(s);
  memset(value, 0, s);
  return value;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<xzalloc>:
  endbr64
  push   %r13
  mov    %rdi,%r13
  push   %r12
  sub    $0x8,%rsp
  call   <xmalloc@plt>
  mov    %r13,%rdx
  xor    %esi,%esi
  mov    %rax,%rdi
  mov    %rax,%r12
  call   <memset@plt>
  add    $0x8,%rsp
  mov    %r12,%rax
  pop    %r12
  pop    %r13
  ret
```

assistant: ```c
void *xzalloc(size_t s) {
  void *value = xmalloc(s);
  memset(value, 0, s);
  return value;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<xzalloc>:
  endbr64
  push   %r13
  mov    %rdi,%r13
  push   %r12
  sub    $0x8,%rsp
  call   <xmalloc@plt>
  mov    %r13,%rdx
  xor    %esi,%esi
  mov    %rax,%rdi
  mov    %rax,%r12
  call   <memset@plt>
  add    $0x8,%rsp
  mov    %r12,%rax
  pop    %r12
  pop    %r13
  ret
```

assistant: ```c
void *xzalloc(size_t s) {
  void *value = xmalloc(s);
  memset(value, 0, s);
  return value;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<ui_box>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %edi,%r12d
  mov    %esi,%r13d
  mov    %edx,%r15d
  mov    %ecx,%ebp
  mov    %r8d,%r14d
  call   <move@plt>
  test   %ebp,%ebp
  jle    L0
  mov    $0x0,%ebx
  jmp    L149
L202:
  test   %r15d,%r15d
  je     L69
  lea    0x1(%rbx),%eax
  cmp    %eax,%ebp
  jle    L60
L69:
  mov    D57(%rip),%rax
  movsbl (%rax),%edi
  call   <addch@plt>
L77:
  add    $0x1,%ebx
  cmp    %ebx,%ebp
  je     L0
L149:
  test   %r15d,%r15d
  je     L202
  test   %ebx,%ebx
  jne    L202
  mov    D62(%rip),%rax
  movsbl (%rax),%edi
  call   <addch@plt>
  jmp    L77
L60:
  mov    D67(%rip),%rax
  movsbl (%rax),%edi
  call   <addch@plt>
L0:
  cmp    $0x1,%r15d
  jle    L146
  cmp    $0x2,%r15d
  jle    L160
  lea    -0x2(%r12,%r15,1),%r15d
  lea    0x0(%r13,%rbp,1),%eax
  mov    %eax,0xc(%rsp)
  jmp    L145
L7:
  cmp    $0x2,%ebp
  jle    L175
  mov    $0x2,%ebx
L178:
  mov    $0x20,%edi
  call   <addch@plt>
  add    $0x1,%ebx
  cmp    %ebx,%ebp
  jne    L178
L175:
  mov    D65(%rip),%rax
  movsbl (%rax),%edi
  call   <addch@plt>
  cmp    %r15d,%r12d
  je     L160
L145:
  add    $0x1,%r12d
  mov    %r13d,%esi
  mov    %r12d,%edi
  call   <move@plt>
  mov    D65(%rip),%rax
  movsbl (%rax),%edi
  call   <addch@plt>
  test   %r14d,%r14d
  jne    L7
  mov    0xc(%rsp),%eax
  lea    -0x1(%rax),%esi
  mov    %r12d,%edi
  call   <move@plt>
  jmp    L175
L160:
  lea    0x1(%r12),%edi
  mov    %r13d,%esi
  call   <move@plt>
  test   %ebp,%ebp
  jle    L146
  mov    $0x1,%ebx
  jmp    L159
L218:
  mov    D78(%rip),%rax
  movsbl (%rax),%edi
  call   <addch@plt>
  cmp    $0x1,%ebp
  jle    L146
L40:
  add    $0x1,%ebx
L159:
  cmp    $0x1,%ebx
  je     L218
  cmp    %ebx,%ebp
  jle    L6
  mov    D57(%rip),%rax
  movsbl (%rax),%edi
  call   <addch@plt>
  jmp    L40
L6:
  mov    D20(%rip),%rax
  movsbl (%rax),%edi
  call   <addch@plt>
L146:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
void ui_box(int y, int x, int height, int width, int fill) {
  int i;
  move(y, x);
  for (i = 0; i < width; i++) {
    if (height && i == 0) {
      addch(ACS_ULCORNER);
    } else if (height && i + 1 >= width) {
      addch(ACS_URCORNER);
    } else {
      addch(ACS_HLINE);
    }
  }
  if (height > 1) {
    while (--height > 1) {
      move(++y, x);
      addch(ACS_VLINE);
      if (fill) {
        for (i = 2; i < width; i++) {
          addch(' ');
        }
      } else {
        move(y, x + width - 1);
      }
      addch(ACS_VLINE);
    }
    move(++y, x);
    for (i = 0; i < width; i++) {
      if (i == 0) {
        addch(ACS_LLCORNER);
      } else if (i + 1 >= width) {
        addch(ACS_LRCORNER);
      } else {
        addch(ACS_HLINE);
      }
    }
  }
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<get_line>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %edx,-0x24(%rbp)
  mov    D0(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,-0x8(%rbp)
  movl   $0x0,-0x4(%rbp)
  jmp    L74
L11:
  mov    -0x4(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x4(%rbp)
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  mov    -0x8(%rbp),%edx
  mov    %dl,(%rax)
L74:
  subl   $0x1,-0x24(%rbp)
  cmpl   $0x0,-0x24(%rbp)
  jle    L37
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <fgetc@plt>
  mov    %eax,-0x8(%rbp)
  mov    D0(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x8(%rbp)
  je     L37
  cmpl   $0xa,-0x8(%rbp)
  jne    L11
L37:
  mov    -0x4(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  cmpl   $0x0,-0x4(%rbp)
  jne    L84
  mov    D0(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x8(%rbp)
  jne    L84
  mov    $0xffffffff,%eax
  jmp    L100
L84:
  cmpl   $0x0,-0x24(%rbp)
  jne    L28
  mov    D0(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x8(%rbp)
  je     L28
  cmpl   $0xa,-0x8(%rbp)
  je     L28
  nop
L1:
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <fgetc@plt>
  mov    %eax,-0x8(%rbp)
  mov    D0(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x8(%rbp)
  je     L19
  cmpl   $0xa,-0x8(%rbp)
  jne    L1
L19:
  mov    $0xfffffffe,%eax
  jmp    L100
L28:
  mov    -0x4(%rbp),%eax
L100:
  leave
  ret
```

assistant: ```c
int get_line(FILE *fp, char *buf, int limit) {
  int ch = EOF, i = 0;
  while (--limit > 0 && (ch = fgetc(fp)) != EOF && ch != '\n') {
    buf[i++] = ch;
  }
  buf[i] = '\0';
  if (i == 0 && ch == EOF) {
    return -1;
  }
  if (limit == 0 && ch != EOF && ch != '\n') {
    while ((ch = fgetc(fp)) != EOF && ch != '\n') {
    }
    return -2;
  }
  return i;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<get_line>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%r13
  mov    %rsi,%r14
  mov    D10(%rip),%rax
  mov    (%rax),%eax
  lea    -0x1(%rdx),%ebx
  test   %ebx,%ebx
  jle    L122
  mov    %rsi,%rbp
  mov    $0x0,%r12d
L99:
  mov    %r13,%rdi
  call   <fgetc@plt>
  mov    D10(%rip),%rdx
  cmp    %eax,(%rdx)
  je     L156
  cmp    $0xa,%eax
  je     L156
  add    $0x1,%r12d
  mov    %al,0x0(%rbp)
  add    $0x1,%rbp
  sub    $0x1,%ebx
  jne    L99
  movslq %r12d,%rdx
  movb   $0x0,(%r14,%rdx,1)
  test   %r12d,%r12d
  je     L145
L1:
  mov    D10(%rip),%rdx
  cmp    %eax,(%rdx)
  je     L46
  cmp    $0xa,%eax
  je     L46
L45:
  mov    %r13,%rdi
  call   <fgetc@plt>
  mov    D10(%rip),%rdx
  cmp    %eax,(%rdx)
  je     L55
  cmp    $0xa,%eax
  jne    L45
L55:
  mov    $0xfffffffe,%r12d
  jmp    L46
L156:
  movslq %r12d,%rdx
  movb   $0x0,(%r14,%rdx,1)
  test   %r12d,%r12d
  jne    L144
L115:
  mov    D10(%rip),%rdx
  cmp    %eax,(%rdx)
  je     L88
  mov    $0x0,%r12d
L144:
  test   %ebx,%ebx
  je     L1
L46:
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L145:
  mov    %r12d,%ebx
  jmp    L115
L88:
  mov    $0xffffffff,%r12d
  jmp    L46
L122:
  movb   $0x0,(%rsi)
  jmp    L115
```

assistant: ```c
int get_line(FILE *fp, char *buf, int limit) {
  int ch = EOF, i = 0;
  while (--limit > 0 && (ch = fgetc(fp)) != EOF && ch != '\n') {
    buf[i++] = ch;
  }
  buf[i] = '\0';
  if (i == 0 && ch == EOF) {
    return -1;
  }
  if (limit == 0 && ch != EOF && ch != '\n') {
    while ((ch = fgetc(fp)) != EOF && ch != '\n') {
    }
    return -2;
  }
  return i;
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<get_line>:
  endbr64
  push   %r15
  push   %r14
  mov    %rsi,%r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  lea    -0x1(%rdx),%ebx
  sub    $0x8,%rsp
  mov    D7(%rip),%r13
  mov    0x0(%r13),%eax
  test   %ebx,%ebx
  jle    L150
  mov    %rsi,%r15
  xor    %r12d,%r12d
  jmp    L55
  cs nopw 0x0(%rax,%rax,1)
L57:
  cmp    $0xa,%eax
  je     L124
  mov    %al,(%r15)
  add    $0x1,%r12d
  add    $0x1,%r15
  sub    $0x1,%ebx
  je     L121
L55:
  mov    %rbp,%rdi
  call   <fgetc@plt>
  cmp    %eax,0x0(%r13)
  jne    L57
L124:
  movb   $0x0,(%r15)
  test   %r12d,%r12d
  jne    L19
L100:
  cmp    %eax,0x0(%r13)
  je     L2
  xor    %r12d,%r12d
  test   %ebx,%ebx
  je     L16
L19:
  add    $0x8,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L121:
  movslq %r12d,%rdx
  movb   $0x0,(%r14,%rdx,1)
L16:
  cmp    %eax,0x0(%r13)
  je     L19
  cmp    $0xa,%eax
  je     L19
  jmp    L135
L31:
  cmp    $0xa,%eax
  je     L6
L135:
  mov    %rbp,%rdi
  call   <fgetc@plt>
  cmp    %eax,0x0(%r13)
  jne    L31
L6:
  mov    $0xfffffffe,%r12d
  jmp    L19
L2:
  mov    $0xffffffff,%r12d
  jmp    L19
  nopl   0x0(%rax,%rax,1)
L150:
  movb   $0x0,(%rsi)
  jmp    L100
```

assistant: ```c
int get_line(FILE *fp, char *buf, int limit) {
  int ch = EOF, i = 0;
  while (--limit > 0 && (ch = fgetc(fp)) != EOF && ch != '\n') {
    buf[i++] = ch;
  }
  buf[i] = '\0';
  if (i == 0 && ch == EOF) {
    return -1;
  }
  if (limit == 0 && ch != EOF && ch != '\n') {
    while ((ch = fgetc(fp)) != EOF && ch != '\n') {
    }
    return -2;
  }
  return i;
}
```