ylfeng/ReF-Decompile-dataset huggingface dataset:
user: Converte this assembly snippet into its equivalent C code:

```asm
<adts_set_channels>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x8(%rbp)
  mov    %esi,-0xc(%rbp)
  mov    -0x8(%rbp),%rax
  add    $0x8,%rax
  mov    (%rax),%edx
  mov    -0x8(%rbp),%rax
  add    $0x8,%rax
  and    $0xfffffffc,%edx
  mov    %edx,(%rax)
  mov    -0x8(%rbp),%rax
  add    $0x8,%rax
  mov    (%rax),%edx
  mov    -0xc(%rbp),%eax
  sar    $0x2,%eax
  and    $0x1,%eax
  mov    %eax,%ecx
  mov    -0x8(%rbp),%rax
  add    $0x8,%rax
  or     %ecx,%edx
  mov    %edx,(%rax)
  mov    -0x8(%rbp),%rax
  add    $0xc,%rax
  mov    (%rax),%edx
  mov    -0x8(%rbp),%rax
  add    $0xc,%rax
  and    $0x3f,%dl
  mov    %edx,(%rax)
  mov    -0x8(%rbp),%rax
  add    $0xc,%rax
  mov    (%rax),%edx
  mov    -0xc(%rbp),%eax
  shl    $0x6,%eax
  and    $0x1c0,%eax
  mov    %eax,%ecx
  mov    -0x8(%rbp),%rax
  add    $0xc,%rax
  or     %ecx,%edx
  mov    %edx,(%rax)
  nop
  pop    %rbp
  ret
```

assistant: ```c
void adts_set_channels(uint8_t *p_adts, uint8_t i_channels) {
  p_adts[2] &= ~0x03;
  p_adts[2] |= (i_channels & 0x7) >> 2;
  p_adts[3] &= ~0xc0;
  p_adts[3] |= (i_channels & 0x7) << 6;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<adts_set_channels>:
  endbr64
  mov    0x8(%rdi),%eax
  and    $0xfffffffc,%eax
  mov    %esi,%edx
  sar    $0x2,%edx
  and    $0x1,%edx
  or     %edx,%eax
  mov    %eax,0x8(%rdi)
  mov    0xc(%rdi),%eax
  and    $0x3f,%al
  shl    $0x6,%esi
  and    $0x1c0,%esi
  or     %esi,%eax
  mov    %eax,0xc(%rdi)
  ret
```

assistant: ```c
void adts_set_channels(uint8_t *p_adts, uint8_t i_channels) {
  p_adts[2] &= ~0x03;
  p_adts[2] |= (i_channels & 0x7) >> 2;
  p_adts[3] &= ~0xc0;
  p_adts[3] |= (i_channels & 0x7) << 6;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<adts_set_channels>:
  endbr64
  mov    0x8(%rdi),%eax
  mov    %esi,%edx
  shl    $0x6,%esi
  sar    $0x2,%edx
  and    $0x1c0,%esi
  and    $0xfffffffc,%eax
  and    $0x1,%edx
  or     %edx,%eax
  mov    %eax,0x8(%rdi)
  mov    0xc(%rdi),%eax
  and    $0x3f,%al
  or     %esi,%eax
  mov    %eax,0xc(%rdi)
  ret
```

assistant: ```c
void adts_set_channels(uint8_t *p_adts, uint8_t i_channels) {
  p_adts[2] &= ~0x03;
  p_adts[2] |= (i_channels & 0x7) >> 2;
  p_adts[3] &= ~0xc0;
  p_adts[3] |= (i_channels & 0x7) << 6;
}
```
user: What is the c source code of the assembly code below?

```asm
<adts_set_channels>:
  endbr64
  movq   D11(%rip),%xmm1
  mov    %esi,%eax
  shl    $0x6,%esi
  movq   D18(%rip),%xmm2
  sar    $0x2,%eax
  movd   %esi,%xmm3
  movd   %eax,%xmm0
  punpckldq %xmm3,%xmm0
  pand   %xmm1,%xmm0
  movq   0x8(%rdi),%xmm1
  pand   %xmm2,%xmm1
  por    %xmm1,%xmm0
  movq   %xmm0,0x8(%rdi)
  ret
```

tool_calls: name: retrieve_data
arguments: data_tag: D11
data_type: byte[8]
name: retrieve_data
arguments: data_tag: D18
data_type: byte[8]

tool: {"D11": [0x01,0x00,0x00,0x00,0xc0,0x01,0x00,0x00]}

tool: {"D18": [0xfc,0xff,0xff,0xff,0x3f,0xff,0xff,0xff]}

assistant: ```c
void adts_set_channels(uint8_t *p_adts, uint8_t i_channels) {
  p_adts[2] &= ~0x03;
  p_adts[2] |= (i_channels & 0x7) >> 2;
  p_adts[3] &= ~0xc0;
  p_adts[3] |= (i_channels & 0x7) << 6;
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x410,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    -0x410(%rbp),%rax
  mov    $0x400,%edx
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memset@plt>
  lea    -0x410(%rbp),%rax
  mov    $0x6,%esi
  mov    %rax,%rdi
  call   <foo@plt>
  mov    -0x410(%rbp),%eax
  cmp    $0x6,%eax
  je     L6
  mov    $0x0,%eax
  call   <abort@plt>
L6:
  mov    $0x0,%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L16
  call   <__stack_chk_fail@plt>
L16:
  leave
  ret
```

assistant: ```c
int main() {
  int BM_tab[0400];
  memset(BM_tab, 0, sizeof(BM_tab));
  foo(BM_tab, 6);
  if (BM_tab[0] != 6)
    abort();
  return 0;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<main>:
  endbr64
  push   %rbx
  sub    $0x410,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x408(%rsp)
  xor    %eax,%eax
  mov    %rsp,%rbx
  mov    $0x400,%edx
  mov    $0x0,%esi
  mov    %rbx,%rdi
  call   <memset@plt>
  mov    $0x6,%esi
  mov    %rbx,%rdi
  call   <foo@plt>
  cmpl   $0x6,(%rsp)
  jne    L3
L22:
  mov    0x408(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L15
  mov    $0x0,%eax
  add    $0x410,%rsp
  pop    %rbx
  ret
L3:
  mov    $0x0,%eax
  call   <abort@plt>
  jmp    L22
L15:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int main() {
  int BM_tab[0400];
  memset(BM_tab, 0, sizeof(BM_tab));
  foo(BM_tab, 6);
  if (BM_tab[0] != 6)
    abort();
  return 0;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<main>:
  endbr64
  push   %rbp
  xor    %esi,%esi
  mov    $0x400,%edx
  sub    $0x410,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x408(%rsp)
  xor    %eax,%eax
  mov    %rsp,%rbp
  mov    %rbp,%rdi
  call   <memset@plt>
  mov    $0x6,%esi
  mov    %rbp,%rdi
  call   <foo@plt>
  cmpl   $0x6,(%rsp)
  je     L14
  xor    %eax,%eax
  call   <abort@plt>
L14:
  mov    0x408(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L11
  add    $0x410,%rsp
  xor    %eax,%eax
  pop    %rbp
  ret
L11:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int main() {
  int BM_tab[0400];
  memset(BM_tab, 0, sizeof(BM_tab));
  foo(BM_tab, 6);
  if (BM_tab[0] != 6)
    abort();
  return 0;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<main>:
  endbr64
  push   %rbp
  xor    %esi,%esi
  mov    $0x400,%edx
  sub    $0x410,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x408(%rsp)
  xor    %eax,%eax
  mov    %rsp,%rbp
  mov    %rbp,%rdi
  call   <memset@plt>
  mov    $0x6,%esi
  mov    %rbp,%rdi
  call   <foo@plt>
  cmpl   $0x6,(%rsp)
  je     L14
  xor    %eax,%eax
  call   <abort@plt>
L14:
  mov    0x408(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L4
  add    $0x410,%rsp
  xor    %eax,%eax
  pop    %rbp
  ret
L4:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int main() {
  int BM_tab[0400];
  memset(BM_tab, 0, sizeof(BM_tab));
  foo(BM_tab, 6);
  if (BM_tab[0] != 6)
    abort();
  return 0;
}
```
user: Translate the below assembly code into C programming language:

```asm
<decbig>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  add    $0x4,%rax
  mov    (%rax),%edx
  sub    $0x1,%edx
  mov    %edx,(%rax)
  movl   $0x1,-0x4(%rbp)
  jmp    L22
L44:
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  test   %eax,%eax
  jns    L39
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x18(%rbp),%rax
  add    %rcx,%rax
  add    $0x2,%edx
  mov    %edx,(%rax)
  mov    -0x4(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  sub    $0x1,%edx
  mov    %edx,(%rax)
L39:
  addl   $0x1,-0x4(%rbp)
L22:
  mov    -0x18(%rbp),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x4(%rbp)
  jl     L44
  jmp    L58
L51:
  mov    -0x18(%rbp),%rax
  mov    (%rax),%eax
  lea    -0x1(%rax),%edx
  mov    -0x18(%rbp),%rax
  mov    %edx,(%rax)
L58:
  mov    -0x18(%rbp),%rax
  mov    (%rax),%eax
  cmp    $0x1,%eax
  jle    L47
  mov    -0x18(%rbp),%rax
  mov    (%rax),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  test   %eax,%eax
  je     L51
L47:
  nop
  pop    %rbp
  ret
```

assistant: ```c
void decbig(int *x) {
  int a;
  x[1]--;
  for (a = 1; a < x[0]; a++)
    if (x[a] < 0) {
      x[a] += 2;
      x[a + 1]--;
    }
  for (; x[0] > 1 && x[x[0]] == 0; x[0]--)
    ;
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<decbig>:
  endbr64
  subl   $0x1,0x4(%rdi)
  cmpl   $0x1,(%rdi)
  jle    L68
  mov    $0x1,%eax
  jmp    L48
L10:
  mov    (%rdi),%edx
  add    $0x1,%rax
  cmp    %eax,%edx
  jle    L77
L48:
  mov    (%rdi,%rax,4),%edx
  test   %edx,%edx
  jns    L10
  add    $0x2,%edx
  mov    %edx,(%rdi,%rax,4)
  subl   $0x1,0x4(%rdi,%rax,4)
  jmp    L10
L77:
  cmp    $0x1,%edx
  jle    L68
  lea    -0x1(%rdx),%eax
  cltq
  movslq %edx,%rcx
  sub    $0x2,%rcx
  lea    -0x2(%rdx),%esi
  sub    %rsi,%rcx
  mov    %rcx,%rdx
L8:
  cmpl   $0x0,0x4(%rdi,%rax,4)
  jne    L68
  mov    %eax,(%rdi)
  sub    $0x1,%rax
  cmp    %rdx,%rax
  jne    L8
L68:
  ret
```

assistant: ```c
void decbig(int *x) {
  int a;
  x[1]--;
  for (a = 1; a < x[0]; a++)
    if (x[a] < 0) {
      x[a] += 2;
      x[a + 1]--;
    }
  for (; x[0] > 1 && x[x[0]] == 0; x[0]--)
    ;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<decbig>:
  endbr64
  subl   $0x1,0x4(%rdi)
  cmpl   $0x1,(%rdi)
  mov    $0x1,%eax
  jle    L17
  nopw   0x0(%rax,%rax,1)
L16:
  mov    (%rdi,%rax,4),%edx
  test   %edx,%edx
  jns    L37
  add    $0x2,%edx
  subl   $0x1,0x4(%rdi,%rax,4)
  mov    %edx,(%rdi,%rax,4)
L37:
  mov    (%rdi),%edx
  add    $0x1,%rax
  cmp    %eax,%edx
  jg     L16
  cmp    $0x1,%edx
  jle    L17
  movslq %edx,%rcx
  lea    -0x2(%rdx),%esi
  lea    -0x1(%rdx),%eax
  sub    $0x2,%rcx
  cltq
  sub    %rsi,%rcx
  mov    %rcx,%rdx
  jmp    L60
L45:
  mov    %eax,(%rdi)
  sub    $0x1,%rax
  cmp    %rax,%rdx
  je     L17
L60:
  mov    0x4(%rdi,%rax,4),%ecx
  test   %ecx,%ecx
  je     L45
L17:
  ret
```

assistant: ```c
void decbig(int *x) {
  int a;
  x[1]--;
  for (a = 1; a < x[0]; a++)
    if (x[a] < 0) {
      x[a] += 2;
      x[a + 1]--;
    }
  for (; x[0] > 1 && x[x[0]] == 0; x[0]--)
    ;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<decbig>:
  endbr64
  mov    (%rdi),%ecx
  subl   $0x1,0x4(%rdi)
  mov    $0x1,%eax
  cmp    $0x1,%ecx
  jle    L24
  nopl   0x0(%rax)
L17:
  mov    (%rdi,%rax,4),%edx
  test   %edx,%edx
  js     L45
  add    $0x1,%rax
  cmp    %eax,%ecx
  jg     L17
L8:
  movslq %ecx,%rdx
  lea    -0x1(%rcx),%eax
  sub    $0x2,%ecx
  sub    $0x2,%rdx
  cltq
  sub    %rcx,%rdx
  jmp    L22
  nopl   0x0(%rax,%rax,1)
L49:
  mov    %eax,(%rdi)
  sub    $0x1,%rax
  cmp    %rax,%rdx
  je     L24
L22:
  mov    0x4(%rdi,%rax,4),%ecx
  test   %ecx,%ecx
  je     L49
L24:
  ret
  nopl   0x0(%rax)
L45:
  add    $0x2,%edx
  subl   $0x1,0x4(%rdi,%rax,4)
  mov    %edx,(%rdi,%rax,4)
  mov    (%rdi),%ecx
  add    $0x1,%rax
  cmp    %eax,%ecx
  jg     L17
  cmp    $0x1,%ecx
  jg     L8
  ret
```

assistant: ```c
void decbig(int *x) {
  int a;
  x[1]--;
  for (a = 1; a < x[0]; a++)
    if (x[a] < 0) {
      x[a] += 2;
      x[a + 1]--;
    }
  for (; x[0] > 1 && x[x[0]] == 0; x[0]--)
    ;
}
```
user: What is the c source code of the assembly code below:

```asm
<factorial>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %edi,-0x4(%rbp)
  cmpl   $0x1,-0x4(%rbp)
  jg     L10
  mov    -0x4(%rbp),%eax
  jmp    L8
L10:
  mov    -0x4(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,%edi
  call   <factorial>
  imul   -0x4(%rbp),%eax
L8:
  leave
  ret
```

assistant: ```c
int factorial(int i) {
  if (i <= 1)
    return i;
  return (i * factorial(i - 1));
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<factorial>:
  endbr64
  mov    %edi,%eax
  cmp    $0x1,%edi
  jle    L5
  push   %rbx
  mov    %edi,%ebx
  lea    -0x1(%rdi),%edi
  call   <factorial>
  imul   %ebx,%eax
  pop    %rbx
  ret
L5:
  ret
```

assistant: ```c
int factorial(int i) {
  if (i <= 1)
    return i;
  return (i * factorial(i - 1));
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<factorial>:
  endbr64
  mov    $0x1,%eax
  cmp    $0x1,%edi
  jle    L17
  xchg   %ax,%ax
L12:
  mov    %edi,%edx
  sub    $0x1,%edi
  imul   %edx,%eax
  cmp    $0x1,%edi
  jne    L12
  ret
  xchg   %ax,%ax
L17:
  mov    %edi,%eax
  ret
```

assistant: ```c
int factorial(int i) {
  if (i <= 1)
    return i;
  return (i * factorial(i - 1));
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<factorial>:
  endbr64
  mov    $0x1,%eax
  cmp    $0x1,%edi
  jle    L2
  xchg   %ax,%ax
L16:
  mov    %edi,%edx
  sub    $0x1,%edi
  imul   %edx,%eax
  cmp    $0x1,%edi
  jne    L16
  ret
  xchg   %ax,%ax
L2:
  mov    %edi,%eax
  ret
```

assistant: ```c
int factorial(int i) {
  if (i <= 1)
    return i;
  return (i * factorial(i - 1));
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<cstpncpy>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %rdx,-0x28(%rbp)
  cmpq   $0x0,-0x28(%rbp)
  je     L34
  mov    -0x18(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x20(%rbp),%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x28(%rbp),%rax
  add    %rax,-0x18(%rbp)
L26:
  mov    -0x8(%rbp),%rdx
  lea    0x1(%rdx),%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x10(%rbp),%rax
  lea    0x1(%rax),%rcx
  mov    %rcx,-0x10(%rbp)
  movzbl (%rdx),%edx
  mov    %dl,(%rax)
  movzbl (%rax),%eax
  test   %al,%al
  jne    L9
  mov    -0x10(%rbp),%rax
  sub    $0x1,%rax
  mov    %rax,-0x18(%rbp)
  jmp    L53
L20:
  mov    -0x10(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x10(%rbp)
  movb   $0x0,(%rax)
L53:
  subq   $0x1,-0x28(%rbp)
  cmpq   $0x0,-0x28(%rbp)
  jne    L20
  jmp    L34
L9:
  subq   $0x1,-0x28(%rbp)
  cmpq   $0x0,-0x28(%rbp)
  jne    L26
L34:
  mov    -0x18(%rbp),%rax
  pop    %rbp
  ret
```

assistant: ```c
char *cstpncpy(char *dst, const char *src, size_t n) {
  if (n != 0) {
    char *d = dst;
    const char *s = src;
    dst = &dst[n];
    do {
      if ((*d++ = *s++) == 0) {
        dst = d - 1;
        while (--n != 0)
          *d++ = 0;
        break;
      }
    } while (--n != 0);
  }
  return (dst);
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<cstpncpy>:
  endbr64
  mov    %rdi,%rax
  test   %rdx,%rdx
  je     L14
  mov    %rdi,%rcx
  mov    %rdx,%r8
L10:
  add    $0x1,%rsi
  mov    %rcx,%rdi
  add    $0x1,%rcx
  movzbl -0x1(%rsi),%r9d
  mov    %r9b,-0x1(%rcx)
  test   %r9b,%r9b
  je     L49
  sub    $0x1,%r8
  jne    L10
  add    %rdx,%rax
  ret
L49:
  cmp    $0x1,%r8
  je     L11
  add    %rdi,%r8
L6:
  add    $0x1,%rcx
  movb   $0x0,-0x1(%rcx)
  cmp    %rcx,%r8
  jne    L6
  mov    %rdi,%rax
  ret
L11:
  mov    %rdi,%rax
L14:
  ret
```

assistant: ```c
char *cstpncpy(char *dst, const char *src, size_t n) {
  if (n != 0) {
    char *d = dst;
    const char *s = src;
    dst = &dst[n];
    do {
      if ((*d++ = *s++) == 0) {
        dst = d - 1;
        while (--n != 0)
          *d++ = 0;
        break;
      }
    } while (--n != 0);
  }
  return (dst);
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<cstpncpy>:
  endbr64
  push   %r12
  mov    %rdi,%r12
  test   %rdx,%rdx
  je     L47
  mov    %rdi,%r8
  mov    %rdx,%rcx
  jmp    L3
  cs nopw 0x0(%rax,%rax,1)
L15:
  test   %rdx,%rdx
  je     L1
L3:
  movzbl (%rsi),%eax
  mov    %rdi,%r12
  add    $0x1,%rsi
  lea    0x1(%rdi),%rdi
  sub    $0x1,%rdx
  mov    %al,-0x1(%rdi)
  test   %al,%al
  jne    L15
  test   %rdx,%rdx
  je     L47
  xor    %esi,%esi
  call   <memset@plt>
L47:
  mov    %r12,%rax
  pop    %r12
  ret
L1:
  lea    (%r8,%rcx,1),%r12
  mov    %r12,%rax
  pop    %r12
  ret
```

assistant: ```c
char *cstpncpy(char *dst, const char *src, size_t n) {
  if (n != 0) {
    char *d = dst;
    const char *s = src;
    dst = &dst[n];
    do {
      if ((*d++ = *s++) == 0) {
        dst = d - 1;
        while (--n != 0)
          *d++ = 0;
        break;
      }
    } while (--n != 0);
  }
  return (dst);
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<cstpncpy>:
  endbr64
  push   %r12
  mov    %rdi,%r12
  test   %rdx,%rdx
  je     L6
  mov    %rdi,%r8
  mov    %rdx,%rcx
  jmp    L21
  cs nopw 0x0(%rax,%rax,1)
L7:
  test   %rdx,%rdx
  je     L22
L21:
  movzbl (%rsi),%eax
  mov    %rdi,%r12
  add    $0x1,%rsi
  lea    0x1(%rdi),%rdi
  sub    $0x1,%rdx
  mov    %al,-0x1(%rdi)
  test   %al,%al
  jne    L7
  test   %rdx,%rdx
  je     L6
  xor    %esi,%esi
  call   <memset@plt>
L6:
  mov    %r12,%rax
  pop    %r12
  ret
L22:
  lea    (%r8,%rcx,1),%r12
  mov    %r12,%rax
  pop    %r12
  ret
```

assistant: ```c
char *cstpncpy(char *dst, const char *src, size_t n) {
  if (n != 0) {
    char *d = dst;
    const char *s = src;
    dst = &dst[n];
    do {
      if ((*d++ = *s++) == 0) {
        dst = d - 1;
        while (--n != 0)
          *d++ = 0;
        break;
      }
    } while (--n != 0);
  }
  return (dst);
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<FKO_ReadLine>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  jne    L92
  mov    D159(%rip),%rax
  test   %rax,%rax
  je     L78
  mov    D159(%rip),%rax
  mov    %rax,%rdi
  call   <free@plt>
L78:
  movl   $0x0,D26(%rip)
  mov    $0x0,%eax
  jmp    L66
L92:
  mov    D26(%rip),%eax
  test   %eax,%eax
  jne    L59
  mov    $0x80,%edi
  call   <malloc@plt>
  mov    %rax,D15(%rip)
  movl   $0x80,D26(%rip)
  mov    D15(%rip),%rax
  mov    %rax,%rdi
  call   <assert@plt>
L59:
  mov    D15(%rip),%rdx
  mov    D26(%rip),%ecx
  mov    -0x18(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <GetLineWithChars@plt>
  mov    %eax,-0x8(%rbp)
  cmpl   $0x0,-0x8(%rbp)
  jne    L12
  mov    $0x0,%eax
  jmp    L66
L7:
  mov    D26(%rip),%eax
  add    %eax,%eax
  mov    %eax,-0x4(%rbp)
  mov    D15(%rip),%rax
  mov    -0x4(%rbp),%edx
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <realloc@plt>
  mov    %rax,D15(%rip)
  mov    D15(%rip),%rax
  mov    %rax,%rdi
  call   <assert@plt>
  mov    D26(%rip),%eax
  mov    D15(%rip),%rcx
  mov    -0x8(%rbp),%edx
  movslq %edx,%rdx
  add    %rdx,%rcx
  mov    -0x18(%rbp),%rdx
  mov    %eax,%esi
  mov    %rcx,%rdi
  call   <fgets@plt>
  test   %eax,%eax
  je     L11
  mov    -0x4(%rbp),%eax
  mov    %eax,D15(%rip)
  jmp    L97
L101:
  addl   $0x1,-0x8(%rbp)
L97:
  mov    D15(%rip),%rdx
  mov    -0x8(%rbp),%eax
  cltq
  add    %rdx,%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L101
L12:
  mov    D15(%rip),%rdx
  mov    -0x8(%rbp),%eax
  cltq
  sub    $0x1,%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0xa,%al
  jne    L7
  jmp    L19
L11:
  nop
L19:
  mov    D15(%rip),%rax
L66:
  leave
  ret
```

assistant: ```c
char *FKO_ReadLine(FILE *fp) {
  int i;
  static int len = 0;
  static char *ln = NULL;
  if (!fp) {
    if (ln)
      free(ln);
    len = 0;
    return (NULL);
  }
  if (!len) {
    ln = malloc(128);
    len = 128;
    assert(ln);
  }
  i = GetLineWithChars(fp, len, ln);
  if (!i)
    return (NULL);
  while (ln[i - 1] != '\n') {
    int len2;
    len2 = len + len;
    ln = realloc(ln, len2);
    assert(ln);
    if (!fgets(ln + i, len, fp))
      break;
    len = len2;
    for (; ln[i]; i++)
      ;
  }
  return (ln);
}
```
user: Translate the below assembly code into C programming language:

```asm
<FKO_ReadLine>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%r12
  test   %rdi,%rdi
  je     L34
  cmpl   $0x0,D39(%rip)
  je     L113
L1:
  mov    D135(%rip),%rdx
  mov    D39(%rip),%esi
  mov    %r12,%rdi
  call   <GetLineWithChars@plt>
  mov    %eax,%ebx
  test   %eax,%eax
  je     L8
  mov    D135(%rip),%rdi
  movslq %eax,%rbp
  cmpb   $0xa,-0x1(%rdi,%rbp,1)
  jne    L21
L60:
  mov    D135(%rip),%rax
L70:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L34:
  mov    D135(%rip),%rdi
  test   %rdi,%rdi
  je     L123
  call   <free@plt>
L123:
  movl   $0x0,D39(%rip)
  mov    %r12,%rax
  jmp    L70
L113:
  mov    $0x80,%edi
  call   <malloc@plt>
  mov    %rax,%rdi
  mov    %rax,D22(%rip)
  movl   $0x80,D39(%rip)
  call   <assert@plt>
  jmp    L1
L75:
  movslq %ebx,%rbp
  cmpb   $0xa,-0x1(%rdi,%rbp,1)
  je     L60
L21:
  mov    D39(%rip),%eax
  lea    (%rax,%rax,1),%r13d
  mov    %r13d,%esi
  call   <realloc@plt>
  mov    %rax,%rdi
  mov    %rax,D22(%rip)
  call   <assert@plt>
  mov    %rbp,%rdi
  add    D22(%rip),%rdi
  mov    %r12,%rdx
  mov    D39(%rip),%esi
  call   <fgets@plt>
  test   %eax,%eax
  je     L60
  mov    %r13d,D22(%rip)
  mov    D22(%rip),%rdi
  movslq %ebx,%rax
  cmpb   $0x0,(%rdi,%rax,1)
  je     L75
  lea    0x1(%rbx),%eax
  cltq
L55:
  mov    %eax,%ebx
  add    $0x1,%rax
  cmpb   $0x0,-0x1(%rdi,%rax,1)
  jne    L55
  jmp    L75
L8:
  mov    $0x0,%eax
  jmp    L70
```

assistant: ```c
char *FKO_ReadLine(FILE *fp) {
  int i;
  static int len = 0;
  static char *ln = NULL;
  if (!fp) {
    if (ln)
      free(ln);
    len = 0;
    return (NULL);
  }
  if (!len) {
    ln = malloc(128);
    len = 128;
    assert(ln);
  }
  i = GetLineWithChars(fp, len, ln);
  if (!i)
    return (NULL);
  while (ln[i - 1] != '\n') {
    int len2;
    len2 = len + len;
    ln = realloc(ln, len2);
    assert(ln);
    if (!fgets(ln + i, len, fp))
      break;
    len = len2;
    for (; ln[i]; i++)
      ;
  }
  return (ln);
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<FKO_ReadLine>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  test   %rdi,%rdi
  je     L12
  mov    D24(%rip),%esi
  mov    %rdi,%r12
  test   %esi,%esi
  je     L64
L10:
  mov    D107(%rip),%rdx
  mov    %r12,%rdi
  call   <GetLineWithChars@plt>
  mov    %eax,%ebp
  test   %eax,%eax
  je     L62
  mov    D107(%rip),%rdi
  movslq %eax,%rbx
  cmpb   $0xa,-0x1(%rdi,%rbx,1)
  je     L82
  mov    D24(%rip),%r13d
  nopl   0x0(%rax)
L80:
  add    %r13d,%r13d
  mov    %r13d,%esi
  call   <realloc@plt>
  mov    %rax,%rdi
  mov    %rax,D8(%rip)
  call   <assert@plt>
  add    D8(%rip),%rbx
  mov    D24(%rip),%esi
  mov    %r12,%rdx
  mov    %rbx,%rdi
  call   <fgets@plt>
  test   %eax,%eax
  je     L7
  mov    D8(%rip),%rdi
  movslq %ebp,%rbx
  mov    %r13d,D8(%rip)
  cmpb   $0x0,(%rdi,%rbx,1)
  je     L73
  add    $0x1,%ebp
  movslq %ebp,%rax
  nopl   0x0(%rax,%rax,1)
L43:
  mov    %eax,%ebp
  mov    %rax,%rbx
  add    $0x1,%rax
  cmpb   $0x0,-0x1(%rdi,%rax,1)
  jne    L43
L73:
  cmpb   $0xa,-0x1(%rdi,%rbx,1)
  jne    L80
L82:
  add    $0x8,%rsp
  mov    %rdi,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L7:
  mov    D8(%rip),%rdi
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  mov    %rdi,%rax
  pop    %r12
  pop    %r13
  ret
L64:
  mov    $0x80,%edi
  call   <malloc@plt>
  movl   $0x80,D8(%rip)
  mov    %rax,%rdi
  mov    %rax,D8(%rip)
  call   <assert@plt>
  mov    D8(%rip),%esi
  jmp    L10
L62:
  add    $0x8,%rsp
  xor    %edi,%edi
  pop    %rbx
  mov    %rdi,%rax
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L12:
  mov    D8(%rip),%rdi
  test   %rdi,%rdi
  je     L28
  call   <free@plt>
L28:
  movl   $0x0,D8(%rip)
  xor    %edi,%edi
  jmp    L82
```

assistant: ```c
char *FKO_ReadLine(FILE *fp) {
  int i;
  static int len = 0;
  static char *ln = NULL;
  if (!fp) {
    if (ln)
      free(ln);
    len = 0;
    return (NULL);
  }
  if (!len) {
    ln = malloc(128);
    len = 128;
    assert(ln);
  }
  i = GetLineWithChars(fp, len, ln);
  if (!i)
    return (NULL);
  while (ln[i - 1] != '\n') {
    int len2;
    len2 = len + len;
    ln = realloc(ln, len2);
    assert(ln);
    if (!fgets(ln + i, len, fp))
      break;
    len = len2;
    for (; ln[i]; i++)
      ;
  }
  return (ln);
}
```