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

```asm
<splint>:
  endbr64
  push   %r15
  push   %r14
  mov    %r8,%r14
  push   %r13
  mov    %rdx,%r13
  mov    $0x1,%edx
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  jmp    L15
  nopw   0x0(%rax,%rax,1)
L33:
  lea    (%rdx,%rcx,1),%eax
  sar    %eax
  movslq %eax,%rsi
  movsd  (%rdi,%rsi,8),%xmm1
  comisd %xmm0,%xmm1
  cmovbe %eax,%edx
  cmova  %eax,%ecx
L15:
  mov    %ecx,%eax
  sub    %edx,%eax
  cmp    $0x1,%eax
  jg     L33
  movslq %ecx,%rbx
  movslq %edx,%rbp
  lea    (%rdi,%rbx,8),%rcx
  lea    (%rdi,%rbp,8),%r15
  movsd  (%rcx),%xmm2
  movsd  (%r15),%xmm1
  movapd %xmm2,%xmm3
  subsd  %xmm1,%xmm3
  ucomisd D2(%rip),%xmm3
  jp     L18
  je     L7
L18:
  subsd  %xmm0,%xmm2
  subsd  %xmm1,%xmm0
  divsd  %xmm3,%xmm2
  divsd  %xmm3,%xmm0
  mulsd  %xmm3,%xmm3
  movapd %xmm2,%xmm1
  mulsd  %xmm2,%xmm1
  mulsd  %xmm2,%xmm1
  subsd  %xmm2,%xmm1
  mulsd  0x0(%r13,%rbp,8),%xmm1
  mulsd  (%r12,%rbp,8),%xmm2
  movapd %xmm0,%xmm4
  mulsd  %xmm0,%xmm4
  mulsd  %xmm0,%xmm4
  subsd  %xmm0,%xmm4
  mulsd  0x0(%r13,%rbx,8),%xmm4
  mulsd  (%r12,%rbx,8),%xmm0
  addsd  %xmm4,%xmm1
  addsd  %xmm0,%xmm2
  mulsd  %xmm3,%xmm1
  divsd  D22(%rip),%xmm1
  addsd  %xmm2,%xmm1
  movsd  %xmm1,(%r14)
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L7:
  lea    D23(%rip),%rdi
  xor    %eax,%eax
  mov    %rcx,0x8(%rsp)
  movsd  %xmm0,0x18(%rsp)
  movsd  %xmm3,0x10(%rsp)
  call   <nrerror@plt>
  mov    0x8(%rsp),%rcx
  movsd  (%r15),%xmm1
  movsd  0x18(%rsp),%xmm0
  movsd  0x10(%rsp),%xmm3
  movsd  (%rcx),%xmm2
  jmp    L18
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D2
type: f64
name: extract_symbolic_data
arguments: data_tag: D22
type: f64
name: extract_symbolic_data
arguments: data_tag: D23
type: string

tool: D2: 0

tool: D22: 6

tool: D23: Bad XA input to routine SPLINT

assistant: ```c
void splint(xa, ya, y2a, n, x, y) double xa[], ya[], y2a[], x, *y;
int n;
{
  int klo, khi, k;
  double h, b, a;
  void nrerror();
  klo = 1;
  khi = n;
  while (khi - klo > 1) {
    k = (khi + klo) >> 1;
    if (xa[k] > x)
      khi = k;
    else
      klo = k;
  }
  h = xa[khi] - xa[klo];
  if (h == 0.0)
    nrerror("Bad XA input to routine SPLINT");
  a = (xa[khi] - x) / h;
  b = (x - xa[klo]) / h;
  *y = a * ya[klo] + b * ya[khi] + ((a * a * a - a) * y2a[klo] + (b * b * b - b) * y2a[khi]) * (h * h) / 6.0;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<splint>:
  endbr64
  push   %r15
  push   %r14
  mov    %r8,%r14
  push   %r13
  mov    %rdx,%r13
  mov    $0x1,%edx
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  jmp    L46
  nopw   0x0(%rax,%rax,1)
L4:
  lea    (%rdx,%rcx,1),%eax
  sar    %eax
  movslq %eax,%rsi
  movsd  (%rdi,%rsi,8),%xmm1
  comisd %xmm0,%xmm1
  cmovbe %eax,%edx
  cmova  %eax,%ecx
L46:
  mov    %ecx,%eax
  sub    %edx,%eax
  cmp    $0x1,%eax
  jg     L4
  movslq %ecx,%rbx
  movslq %edx,%rbp
  lea    (%rdi,%rbx,8),%rcx
  lea    (%rdi,%rbp,8),%r15
  movsd  (%rcx),%xmm2
  movsd  (%r15),%xmm1
  movapd %xmm2,%xmm3
  subsd  %xmm1,%xmm3
  ucomisd D7(%rip),%xmm3
  jp     L5
  je     L38
L5:
  subsd  %xmm0,%xmm2
  subsd  %xmm1,%xmm0
  divsd  %xmm3,%xmm2
  divsd  %xmm3,%xmm0
  mulsd  %xmm3,%xmm3
  movapd %xmm2,%xmm1
  mulsd  %xmm2,%xmm1
  mulsd  %xmm2,%xmm1
  subsd  %xmm2,%xmm1
  mulsd  0x0(%r13,%rbp,8),%xmm1
  mulsd  (%r12,%rbp,8),%xmm2
  movapd %xmm0,%xmm4
  mulsd  %xmm0,%xmm4
  mulsd  %xmm0,%xmm4
  subsd  %xmm0,%xmm4
  mulsd  0x0(%r13,%rbx,8),%xmm4
  mulsd  (%r12,%rbx,8),%xmm0
  addsd  %xmm4,%xmm1
  addsd  %xmm0,%xmm2
  mulsd  %xmm3,%xmm1
  divsd  D13(%rip),%xmm1
  addsd  %xmm2,%xmm1
  movsd  %xmm1,(%r14)
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   (%rax)
L38:
  lea    D25(%rip),%rdi
  xor    %eax,%eax
  mov    %rcx,0x8(%rsp)
  movsd  %xmm0,0x18(%rsp)
  movsd  %xmm3,0x10(%rsp)
  call   <nrerror@plt>
  mov    0x8(%rsp),%rcx
  movsd  (%r15),%xmm1
  movsd  0x18(%rsp),%xmm0
  movsd  0x10(%rsp),%xmm3
  movsd  (%rcx),%xmm2
  jmp    L5
```

tool_calls: name: unpack_data
arguments: label: D7
type_guessed: f64
name: unpack_data
arguments: label: D13
type_guessed: f64
name: unpack_data
arguments: label: D25
type_guessed: string

tool: D7: 0

tool: D13: 6

tool: D25: Bad XA input to routine SPLINT

assistant: ```c
void splint(xa, ya, y2a, n, x, y) double xa[], ya[], y2a[], x, *y;
int n;
{
  int klo, khi, k;
  double h, b, a;
  void nrerror();
  klo = 1;
  khi = n;
  while (khi - klo > 1) {
    k = (khi + klo) >> 1;
    if (xa[k] > x)
      khi = k;
    else
      klo = k;
  }
  h = xa[khi] - xa[klo];
  if (h == 0.0)
    nrerror("Bad XA input to routine SPLINT");
  a = (xa[khi] - x) / h;
  b = (x - xa[klo]) / h;
  *y = a * ya[klo] + b * ya[khi] + ((a * a * a - a) * y2a[klo] + (b * b * b - b) * y2a[khi]) * (h * h) / 6.0;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    D19(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  lea    -0x10(%rbp),%rax
  mov    %rax,%rsi
  lea    D29(%rip),%rax
  mov    %rax,%rdi
  call   <scanf@plt>
  mov    -0x10(%rbp),%eax
  mov    $0x3,%edx
  mov    $0x5,%esi
  mov    %eax,%edi
  call   <invert@plt>
  mov    %eax,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  mov    %eax,%esi
  lea    D16(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x0,%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L9
  call   <__stack_chk_fail@plt>
L9:
  leave
  ret
```

tool_calls: name: unpack_data
arguments: data_tag: D19
type_infered: string
name: unpack_data
arguments: data_tag: D29
type_infered: string
name: unpack_data
arguments: data_tag: D16
type_infered: string

tool: D19: Ingrese un entero sin signo: 

tool: D29: %u

tool: D16: El resultado de la funcion es: %u

assistant: ```c
int main() {
  unsigned num;
  unsigned res;
  printf("Ingrese un entero sin signo: ");
  scanf("%u", &num);
  res = invert(num, 5, 3);
  printf("El resultado de la funcion es: %u", res);
  return 0;
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<main>:
  endbr64
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    D20(%rip),%rdi
  call   <printf@plt>
  lea    0x4(%rsp),%rsi
  lea    D13(%rip),%rdi
  call   <scanf@plt>
  mov    $0x3,%edx
  mov    $0x5,%esi
  mov    0x4(%rsp),%edi
  call   <invert@plt>
  mov    %eax,%esi
  lea    D12(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L6
  mov    $0x0,%eax
  add    $0x18,%rsp
  ret
L6:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: data_tag: D20
data_type: string
name: retrieve_data
arguments: data_tag: D13
data_type: string
name: retrieve_data
arguments: data_tag: D12
data_type: string

tool: D20: Ingrese un entero sin signo: 

tool: D13: %u

tool: D12: El resultado de la funcion es: %u

assistant: ```c
int main() {
  unsigned num;
  unsigned res;
  printf("Ingrese un entero sin signo: ");
  scanf("%u", &num);
  res = invert(num, 5, 3);
  printf("El resultado de la funcion es: %u", res);
  return 0;
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<main>:
  endbr64
  sub    $0x18,%rsp
  lea    D4(%rip),%rdi
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  call   <printf@plt>
  lea    0x4(%rsp),%rsi
  lea    D15(%rip),%rdi
  call   <scanf@plt>
  mov    0x4(%rsp),%edi
  mov    $0x5,%esi
  mov    $0x3,%edx
  call   <invert@plt>
  lea    D3(%rip),%rdi
  mov    %eax,%esi
  xor    %eax,%eax
  call   <printf@plt>
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L3
  xor    %eax,%eax
  add    $0x18,%rsp
  ret
L3:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: data_label: D4
datatype: string
name: unpack_data
arguments: data_label: D15
datatype: string
name: unpack_data
arguments: data_label: D3
datatype: string

tool: D4: Ingrese un entero sin signo: 

tool: D15: %u

tool: D3: El resultado de la funcion es: %u

assistant: ```c
int main() {
  unsigned num;
  unsigned res;
  printf("Ingrese un entero sin signo: ");
  scanf("%u", &num);
  res = invert(num, 5, 3);
  printf("El resultado de la funcion es: %u", res);
  return 0;
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<main>:
  endbr64
  sub    $0x18,%rsp
  lea    D29(%rip),%rdi
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  call   <printf@plt>
  lea    0x4(%rsp),%rsi
  lea    D7(%rip),%rdi
  call   <scanf@plt>
  mov    0x4(%rsp),%edi
  mov    $0x5,%esi
  mov    $0x3,%edx
  call   <invert@plt>
  lea    D19(%rip),%rdi
  mov    %eax,%esi
  xor    %eax,%eax
  call   <printf@plt>
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L5
  xor    %eax,%eax
  add    $0x18,%rsp
  ret
L5:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: label: D29
data_type: string
name: extract_symbolic_data
arguments: label: D7
data_type: string
name: extract_symbolic_data
arguments: label: D19
data_type: string

tool: D29: Ingrese un entero sin signo: 

tool: D7: %u

tool: D19: El resultado de la funcion es: %u

assistant: ```c
int main() {
  unsigned num;
  unsigned res;
  printf("Ingrese un entero sin signo: ");
  scanf("%u", &num);
  res = invert(num, 5, 3);
  printf("El resultado de la funcion es: %u", res);
  return 0;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<read_a_line>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    $0x400,%edi
  call   <malloc@plt>
  mov    %rax,-0x28(%rbp)
  mov    -0x28(%rbp),%rax
  mov    %rax,-0x20(%rbp)
  movq   $0x400,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x28(%rbp)
  jne    L85
  mov    $0x0,%eax
  jmp    L39
L85:
  mov    D16(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,%edi
  call   <fgetc@plt>
  mov    %eax,-0x2c(%rbp)
  mov    D11(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x2c(%rbp)
  je     L79
  subq   $0x1,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L76
  shlq   -0x18(%rbp)
  mov    -0x18(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <realloc@plt>
  mov    %rax,-0x8(%rbp)
  mov    -0x18(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L40
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    $0x0,%eax
  jmp    L39
L40:
  mov    -0x28(%rbp),%rax
  sub    -0x20(%rbp),%rax
  mov    %rax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x28(%rbp)
  mov    -0x8(%rbp),%rax
  mov    %rax,-0x20(%rbp)
L76:
  mov    -0x28(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x28(%rbp)
  mov    -0x2c(%rbp),%edx
  mov    %dl,(%rax)
  movzbl (%rax),%eax
  cmp    $0xa,%al
  je     L61
  jmp    L85
L79:
  nop
  jmp    L16
L61:
  nop
L16:
  mov    -0x28(%rbp),%rax
  movb   $0x0,(%rax)
  mov    -0x20(%rbp),%rax
L39:
  leave
  ret
```

assistant: ```c
char *read_a_line(void) {
  char *line = (char *)malloc(1024), *linep = line;
  size_t lenmax = 1024, len = lenmax;
  int c;
  if (line == NULL)
    return NULL;
  for (;;) {
    c = fgetc(stdin);
    if (c == EOF)
      break;
    if (--len == 0) {
      char *linen = (char *)realloc(linep, lenmax *= 2);
      len = lenmax;
      if (linen == NULL) {
        free(linep);
        return NULL;
      }
      line = linen + (line - linep);
      linep = linen;
    }
    if ((*line++ = c) == '\n')
      break;
  }
  *line = '\0';
  return linep;
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<read_a_line>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    $0x400,%edi
  call   <malloc@plt>
  test   %rax,%rax
  je     L71
  mov    %rax,%r12
  mov    %rax,%r14
  mov    $0x400,%ebp
  mov    $0x400,%r13d
  mov    D17(%rip),%r15
  jmp    L55
L18:
  mov    %r14,%rdi
  call   <free@plt>
  mov    $0x0,%r14d
  jmp    L33
L62:
  lea    0x1(%rdx),%r12
  mov    %bl,(%rdx)
  cmp    $0xa,%bl
  je     L70
L55:
  mov    (%r15),%edi
  call   <fgetc@plt>
  mov    %eax,%ebx
  mov    D2(%rip),%rax
  cmp    %ebx,(%rax)
  je     L70
  mov    %r12,%rdx
  sub    $0x1,%rbp
  jne    L62
  add    %r13,%r13
  mov    %r13,%rsi
  mov    %r14,%rdi
  call   <realloc@plt>
  test   %rax,%rax
  je     L18
  mov    %r12,%rdx
  sub    %r14,%rdx
  add    %rax,%rdx
  mov    %r13,%rbp
  mov    %rax,%r14
  jmp    L62
L70:
  movb   $0x0,(%r12)
L33:
  mov    %r14,%rax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L71:
  mov    $0x0,%r14d
  jmp    L33
```

assistant: ```c
char *read_a_line(void) {
  char *line = (char *)malloc(1024), *linep = line;
  size_t lenmax = 1024, len = lenmax;
  int c;
  if (line == NULL)
    return NULL;
  for (;;) {
    c = fgetc(stdin);
    if (c == EOF)
      break;
    if (--len == 0) {
      char *linen = (char *)realloc(linep, lenmax *= 2);
      len = lenmax;
      if (linen == NULL) {
        free(linep);
        return NULL;
      }
      line = linen + (line - linep);
      linep = linen;
    }
    if ((*line++ = c) == '\n')
      break;
  }
  *line = '\0';
  return linep;
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<read_a_line>:
  endbr64
  push   %r15
  mov    $0x400,%edi
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  call   <malloc@plt>
  test   %rax,%rax
  je     L44
  mov    D15(%rip),%r15
  mov    %rax,%r14
  mov    %rax,%r13
  mov    $0x400,%ebp
  mov    $0x400,%r12d
  jmp    L42
  nop
L36:
  mov    %bl,(%rdx)
  lea    0x1(%rdx),%r14
  cmp    $0xa,%bl
  je     L76
L42:
  mov    (%r15),%edi
  call   <fgetc@plt>
  mov    %eax,%ebx
  mov    D13(%rip),%rax
  cmp    %ebx,(%rax)
  je     L76
  mov    %r14,%rdx
  sub    $0x1,%rbp
  jne    L36
  add    %r12,%r12
  mov    %r13,%rdi
  mov    %r14,0x8(%rsp)
  mov    %r12,%rsi
  call   <realloc@plt>
  mov    0x8(%rsp),%rdx
  test   %rax,%rax
  je     L32
  sub    %r13,%rdx
  mov    %r12,%rbp
  mov    %rax,%r13
  add    %rax,%rdx
  mov    %bl,(%rdx)
  lea    0x1(%rdx),%r14
  cmp    $0xa,%bl
  jne    L42
  nopl   (%rax)
L76:
  movb   $0x0,(%r14)
L2:
  add    $0x18,%rsp
  mov    %r13,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  cs nopw 0x0(%rax,%rax,1)
L44:
  xor    %r13d,%r13d
  jmp    L2
  nopl   (%rax)
L32:
  mov    %r13,%rdi
  xor    %r13d,%r13d
  call   <free@plt>
  jmp    L2
```

assistant: ```c
char *read_a_line(void) {
  char *line = (char *)malloc(1024), *linep = line;
  size_t lenmax = 1024, len = lenmax;
  int c;
  if (line == NULL)
    return NULL;
  for (;;) {
    c = fgetc(stdin);
    if (c == EOF)
      break;
    if (--len == 0) {
      char *linen = (char *)realloc(linep, lenmax *= 2);
      len = lenmax;
      if (linen == NULL) {
        free(linep);
        return NULL;
      }
      line = linen + (line - linep);
      linep = linen;
    }
    if ((*line++ = c) == '\n')
      break;
  }
  *line = '\0';
  return linep;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<read_a_line>:
  endbr64
  push   %r15
  mov    $0x400,%edi
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  call   <malloc@plt>
  test   %rax,%rax
  je     L89
  mov    D4(%rip),%r15
  mov    %rax,%r14
  mov    %rax,%r13
  mov    $0x400,%ebp
  mov    $0x400,%r12d
  jmp    L72
  nop
L79:
  mov    %bl,(%rdx)
  lea    0x1(%rdx),%r14
  cmp    $0xa,%bl
  je     L19
L72:
  mov    (%r15),%edi
  call   <fgetc@plt>
  mov    %eax,%ebx
  mov    D5(%rip),%rax
  cmp    %ebx,(%rax)
  je     L19
  mov    %r14,%rdx
  sub    $0x1,%rbp
  jne    L79
  add    %r12,%r12
  mov    %r13,%rdi
  mov    %r14,0x8(%rsp)
  mov    %r12,%rsi
  call   <realloc@plt>
  mov    0x8(%rsp),%rdx
  test   %rax,%rax
  je     L4
  sub    %r13,%rdx
  mov    %r12,%rbp
  mov    %rax,%r13
  add    %rax,%rdx
  mov    %bl,(%rdx)
  lea    0x1(%rdx),%r14
  cmp    $0xa,%bl
  jne    L72
  nopl   (%rax)
L19:
  movb   $0x0,(%r14)
L68:
  add    $0x18,%rsp
  mov    %r13,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  cs nopw 0x0(%rax,%rax,1)
L89:
  xor    %r13d,%r13d
  jmp    L68
  nopl   (%rax)
L4:
  mov    %r13,%rdi
  xor    %r13d,%r13d
  call   <free@plt>
  jmp    L68
```

assistant: ```c
char *read_a_line(void) {
  char *line = (char *)malloc(1024), *linep = line;
  size_t lenmax = 1024, len = lenmax;
  int c;
  if (line == NULL)
    return NULL;
  for (;;) {
    c = fgetc(stdin);
    if (c == EOF)
      break;
    if (--len == 0) {
      char *linen = (char *)realloc(linep, lenmax *= 2);
      len = lenmax;
      if (linen == NULL) {
        free(linep);
        return NULL;
      }
      line = linen + (line - linep);
      linep = linen;
    }
    if ((*line++ = c) == '\n')
      break;
  }
  *line = '\0';
  return linep;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<cg_is_cgns>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x30(%rbp),%rax
  movl   $0x0,(%rax)
  lea    -0x20(%rbp),%rdx
  mov    -0x28(%rbp),%rax
  mov    %rdx,%rcx
  mov    $0x0,%edx
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <cgio_open_file@plt>
  test   %rax,%rax
  je     L26
  mov    $0x1,%eax
  jmp    L24
L26:
  mov    -0x20(%rbp),%eax
  lea    -0x18(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <cgio_get_root_id@plt>
  mov    -0x20(%rbp),%eax
  mov    -0x30(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <cgio_get_file_type@plt>
  mov    -0x18(%rbp),%rcx
  mov    -0x20(%rbp),%eax
  lea    -0x10(%rbp),%rdx
  lea    D1(%rip),%rsi
  movq   %rcx,%xmm0
  mov    %eax,%edi
  call   <cgio_get_node_id@plt>
  mov    %eax,-0x1c(%rbp)
  mov    -0x20(%rbp),%eax
  mov    %eax,%edi
  call   <cgio_close_file@plt>
  cmpl   $0x0,-0x1c(%rbp)
  setne  %al
  movzbl %al,%eax
L24:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L4
  call   <__stack_chk_fail@plt>
L4:
  leave
  ret
```

tool_calls: name: unpack_data
arguments: tag: D1
datatype: string

tool: D1: CGNSLibraryVersion

assistant: ```c
int cg_is_cgns(const char *filename, int *file_type) {
  int cgio, ierr;
  double rootid, childid;
  *file_type = 0;
  if (cgio_open_file(filename, 0, 0, &cgio))
    return 1;
  cgio_get_root_id(cgio, &rootid);
  cgio_get_file_type(cgio, file_type);
  ierr = cgio_get_node_id(cgio, rootid, "CGNSLibraryVersion", &childid);
  cgio_close_file(cgio);
  return ierr ? 1 : 0;
}
```
user: Translate the below assembly code into C programming language:

```asm
<cg_is_cgns>:
  endbr64
  push   %rbx
  sub    $0x20,%rsp
  mov    %rsi,%rbx
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  movl   $0x0,(%rsi)
  lea    0x4(%rsp),%rcx
  mov    $0x0,%edx
  mov    $0x0,%esi
  call   <cgio_open_file@plt>
  mov    %rax,%rdx
  mov    $0x1,%eax
  test   %rdx,%rdx
  je     L12
L5:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L17
  add    $0x20,%rsp
  pop    %rbx
  ret
L12:
  lea    0x8(%rsp),%rsi
  mov    0x4(%rsp),%edi
  call   <cgio_get_root_id@plt>
  mov    %rbx,%rsi
  mov    0x4(%rsp),%edi
  call   <cgio_get_file_type@plt>
  lea    0x10(%rsp),%rdx
  lea    D0(%rip),%rsi
  movsd  0x8(%rsp),%xmm0
  mov    0x4(%rsp),%edi
  call   <cgio_get_node_id@plt>
  mov    %eax,%ebx
  mov    0x4(%rsp),%edi
  call   <cgio_close_file@plt>
  test   %ebx,%ebx
  setne  %al
  movzbl %al,%eax
  jmp    L5
L17:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: label: D0
data_type: string

tool: D0: CGNSLibraryVersion

assistant: ```c
int cg_is_cgns(const char *filename, int *file_type) {
  int cgio, ierr;
  double rootid, childid;
  *file_type = 0;
  if (cgio_open_file(filename, 0, 0, &cgio))
    return 1;
  cgio_get_root_id(cgio, &rootid);
  cgio_get_file_type(cgio, file_type);
  ierr = cgio_get_node_id(cgio, rootid, "CGNSLibraryVersion", &childid);
  cgio_close_file(cgio);
  return ierr ? 1 : 0;
}
```
user: Translate the below assembly code into C programming language:

```asm
<cg_is_cgns>:
  endbr64
  push   %rbp
  xor    %edx,%edx
  mov    %rsi,%rbp
  sub    $0x20,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  movl   $0x0,(%rsi)
  lea    0x4(%rsp),%rcx
  xor    %esi,%esi
  call   <cgio_open_file@plt>
  mov    %rax,%r8
  mov    $0x1,%eax
  test   %r8,%r8
  jne    L7
  mov    0x4(%rsp),%edi
  lea    0x8(%rsp),%rsi
  call   <cgio_get_root_id@plt>
  mov    0x4(%rsp),%edi
  mov    %rbp,%rsi
  call   <cgio_get_file_type@plt>
  movsd  0x8(%rsp),%xmm0
  mov    0x4(%rsp),%edi
  lea    0x10(%rsp),%rdx
  lea    D1(%rip),%rsi
  call   <cgio_get_node_id@plt>
  mov    0x4(%rsp),%edi
  mov    %eax,%ebp
  call   <cgio_close_file@plt>
  xor    %eax,%eax
  test   %ebp,%ebp
  setne  %al
L7:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L11
  add    $0x20,%rsp
  pop    %rbp
  ret
L11:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D1
type_guessed: string

tool: D1: CGNSLibraryVersion

assistant: ```c
int cg_is_cgns(const char *filename, int *file_type) {
  int cgio, ierr;
  double rootid, childid;
  *file_type = 0;
  if (cgio_open_file(filename, 0, 0, &cgio))
    return 1;
  cgio_get_root_id(cgio, &rootid);
  cgio_get_file_type(cgio, file_type);
  ierr = cgio_get_node_id(cgio, rootid, "CGNSLibraryVersion", &childid);
  cgio_close_file(cgio);
  return ierr ? 1 : 0;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<cg_is_cgns>:
  endbr64
  push   %rbp
  xor    %edx,%edx
  mov    %rsi,%rbp
  sub    $0x20,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  movl   $0x0,(%rsi)
  lea    0x4(%rsp),%rcx
  xor    %esi,%esi
  call   <cgio_open_file@plt>
  mov    %rax,%r8
  mov    $0x1,%eax
  test   %r8,%r8
  jne    L13
  mov    0x4(%rsp),%edi
  lea    0x8(%rsp),%rsi
  call   <cgio_get_root_id@plt>
  mov    0x4(%rsp),%edi
  mov    %rbp,%rsi
  call   <cgio_get_file_type@plt>
  movsd  0x8(%rsp),%xmm0
  mov    0x4(%rsp),%edi
  lea    0x10(%rsp),%rdx
  lea    D8(%rip),%rsi
  call   <cgio_get_node_id@plt>
  mov    0x4(%rsp),%edi
  mov    %eax,%ebp
  call   <cgio_close_file@plt>
  xor    %eax,%eax
  test   %ebp,%ebp
  setne  %al
L13:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L6
  add    $0x20,%rsp
  pop    %rbp
  ret
L6:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: data_tag: D8
type_guessed: string

tool: D8: CGNSLibraryVersion

assistant: ```c
int cg_is_cgns(const char *filename, int *file_type) {
  int cgio, ierr;
  double rootid, childid;
  *file_type = 0;
  if (cgio_open_file(filename, 0, 0, &cgio))
    return 1;
  cgio_get_root_id(cgio, &rootid);
  cgio_get_file_type(cgio, file_type);
  ierr = cgio_get_node_id(cgio, rootid, "CGNSLibraryVersion", &childid);
  cgio_close_file(cgio);
  return ierr ? 1 : 0;
}
```