ylfeng/ReF-Decompile-dataset huggingface dataset:
user: What would the C source look like for the assembly code provided here?

```asm
<predict_seq>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  sub    $0xe8,%rsp
  mov    %rdx,0x20(%rsp)
  lea    0x30(%rsp),%r12
  lea    0xd4(%rsp),%rdx
  mov    %rsi,0x18(%rsp)
  mov    %rcx,0x28(%rsp)
  mov    %fs:0x28,%rax
  mov    %rax,0xd8(%rsp)
  xor    %eax,%eax
  mov    %r12,%rax
  nopw   0x0(%rax,%rax,1)
L47:
  movl   $0x14,(%rax)
  add    $0x4,%rax
  cmp    %rdx,%rax
  jne    L47
  mov    0x18(%rsp),%rax
  xor    %ebx,%ebx
  lea    D0(%rip),%r15
  lea    -0x50(%rax),%r14
  mov    0x20(%rsp),%rax
  lea    -0x50(%rax),%r13
  mov    0x28(%rsp),%rax
  sub    $0x50,%rax
  mov    %rax,0x10(%rsp)
  jmp    L31
  nopw   0x0(%rax,%rax,1)
L64:
  addq   $0x4,0x10(%rsp)
  add    $0x1,%rbx
  add    $0x4,%r14
  add    $0x4,%r13
L31:
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %ebx,(%rsp)
  cmp    %ebx,%eax
  jle    L37
  movsbl 0x0(%rbp,%rbx,1),%esi
  mov    %r15,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  mov    %rax,0x8(%rsp)
  je     L64
  lea    0x34(%rsp),%rdi
  mov    $0xa0,%edx
  mov    %r12,%rsi
  call   <memmove@plt>
  mov    0x8(%rsp),%rcx
  sub    %r15,%rcx
  cmpl   $0x13,(%rsp)
  mov    %ecx,0x30(%rsp)
  jle    L64
  mov    0x10(%rsp),%rcx
  mov    %r13,%rdx
  mov    %r14,%rsi
  mov    %r12,%rdi
  call   <predict@plt>
  jmp    L64
L37:
  lea    -0x14(%rax),%ebx
  mov    0x18(%rsp),%r15
  mov    0x20(%rsp),%r14
  lea    0x34(%rsp),%rsi
  movslq %ebx,%r13
  mov    %rsi,(%rsp)
  shl    $0x2,%r13
  add    %r13,%r15
  add    %r13,%r14
  add    0x28(%rsp),%r13
  jmp    L77
  nopl   0x0(%rax,%rax,1)
L25:
  mov    (%rsp),%rdi
  mov    $0xa0,%edx
  mov    %r12,%rsi
  add    $0x1,%ebx
  call   <memmove@plt>
  mov    %r13,%rcx
  mov    %r14,%rdx
  mov    %r15,%rsi
  mov    %r12,%rdi
  add    $0x4,%r15
  add    $0x4,%r14
  add    $0x4,%r13
  movl   $0x14,0x30(%rsp)
  call   <predict@plt>
  mov    %rbp,%rdi
  call   <strlen@plt>
L77:
  cmp    %eax,%ebx
  jl     L25
  mov    0xd8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L1
  add    $0xe8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L1:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: data_label: D0
type_infered: string

tool: D0: FIVWMLCHYAGNRTPDEQSK

assistant: ```c
void predict_seq(char const *seq, float sm_arr[], float sb_arr[], float sr_arr[]) {
  char *alphabet = "FIVWMLCHYAGNRTPDEQSK";
  char *p;
  int i, j, s[41];
  for (i = 0; i < 41; ++i)
    s[i] = 21 - 1;
  for (i = 0; i < (int)strlen(seq); ++i) {
    p = strchr(alphabet, seq[i]);
    if (p != NULL) {
      for (j = 1; j < 41; ++j)
        s[41 - j] = s[41 - j - 1];
      s[0] = p - alphabet;
      if (i >= (41 - 1) / 2) {
        predict(s, &sm_arr[i - (41 - 1) / 2], &sb_arr[i - (41 - 1) / 2], &sr_arr[i - (41 - 1) / 2]);
      }
    }
  }
  for (i = (int)strlen(seq) - (41 - 1) / 2; i < (int)strlen(seq); ++i) {
    for (j = 1; j < 41; ++j)
      s[41 - j] = s[41 - j - 1];
    s[0] = 21 - 1;
    predict(s, &sm_arr[i], &sb_arr[i], &sr_arr[i]);
  }
  return;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<print_indentation>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %edi,-0x14(%rbp)
  movl   $0x0,-0x4(%rbp)
  jmp    L8
L18:
  lea    D5(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  addl   $0x1,-0x4(%rbp)
L8:
  mov    -0x4(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jne    L18
  nop
  nop
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: data_label: D5
type_infered: string

tool: D5:   

assistant: ```c
void print_indentation(int level) {
  static char const indentation[] = "  ";
  for (int i = 0; i != level; ++i) {
    printf(indentation);
  }
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<print_indentation>:
  endbr64
  test   %edi,%edi
  je     L13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %edi,%ebp
  mov    $0x0,%ebx
  lea    D9(%rip),%r12
L10:
  mov    %r12,%rdi
  call   <printf@plt>
  add    $0x1,%rbx
  cmp    %rbp,%rbx
  jne    L10
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L13:
  ret
```

tool_calls: name: extract_symbolic_data
arguments: label: D9
datatype: string

tool: D9:   

assistant: ```c
void print_indentation(int level) {
  static char const indentation[] = "  ";
  for (int i = 0; i != level; ++i) {
    printf(indentation);
  }
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<print_indentation>:
  endbr64
  test   %edi,%edi
  je     L5
  push   %r12
  lea    D0(%rip),%r12
  push   %rbp
  mov    %edi,%ebp
  push   %rbx
  xor    %ebx,%ebx
  nopw   0x0(%rax,%rax,1)
L10:
  mov    %r12,%rdi
  add    $0x1,%rbx
  call   <printf@plt>
  cmp    %rbp,%rbx
  jne    L10
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  cs nopw 0x0(%rax,%rax,1)
L5:
  ret
```

tool_calls: name: retrieve_data
arguments: data_label: D0
type: string

tool: D0:   

assistant: ```c
void print_indentation(int level) {
  static char const indentation[] = "  ";
  for (int i = 0; i != level; ++i) {
    printf(indentation);
  }
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<print_indentation>:
  endbr64
  test   %edi,%edi
  je     L2
  push   %r12
  lea    D9(%rip),%r12
  push   %rbp
  mov    %edi,%ebp
  push   %rbx
  xor    %ebx,%ebx
  nopw   0x0(%rax,%rax,1)
L8:
  mov    %r12,%rdi
  add    $0x1,%rbx
  call   <printf@plt>
  cmp    %rbp,%rbx
  jne    L8
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  cs nopw 0x0(%rax,%rax,1)
L2:
  ret
```

tool_calls: name: disassemble_data
arguments: data_label: D9
type: string

tool: D9:   

assistant: ```c
void print_indentation(int level) {
  static char const indentation[] = "  ";
  for (int i = 0; i != level; ++i) {
    printf(indentation);
  }
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<proto_usage>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %rdi,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  je     L9
  mov    -0x8(%rbp),%rax
  mov    %rax,%rsi
  lea    D21(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L13
L9:
  lea    D27(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
L13:
  lea    D4(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    $0x1,%edi
  call   <ntkresolv_safe_exit@plt>
  nop
  leave
  ret
```

tool_calls: name: read_data
arguments: tag: D21
type_infered: string
name: read_data
arguments: tag: D27
type_infered: string
name: read_data
arguments: tag: D4
type_infered: string

tool: D21: Bad Protocol %s



tool: D27: ntk-resolv Protocol Help.


tool: D4: Valid protocols are:
 * tcp
   udp
(you can also use univoque abbreviation)
Note: you can also specify the protocol with option `-s'.
To know more, type:
	ntk-resolv -s help


assistant: ```c
void proto_usage(char *arg) {
  if (arg)
    printf("Bad Protocol %s\n\n", arg);
  else
    printf("ntk-resolv Protocol Help.\n\n");
  printf("Valid protocols are:\n"
         " * tcp\n"
         "   udp\n"
         "(you can also use univoque abbreviation)\n"
         "Note: you can also specify the protocol with option `-s'.\n"
         "To know more, type:\n"
         "\tntk-resolv -s help\n\n");
  ntkresolv_safe_exit(1);
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<proto_usage>:
  endbr64
  sub    $0x8,%rsp
  test   %rdi,%rdi
  je     L2
  mov    %rdi,%rsi
  lea    D22(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L3:
  lea    D20(%rip),%rdi
  call   <puts@plt>
  mov    $0x1,%edi
  call   <ntkresolv_safe_exit@plt>
  add    $0x8,%rsp
  ret
L2:
  lea    D9(%rip),%rdi
  call   <puts@plt>
  jmp    L3
```

tool_calls: name: parse_data
arguments: data_tag: D22
type_guessed: string
name: parse_data
arguments: data_tag: D20
type_guessed: string
name: parse_data
arguments: data_tag: D9
type_guessed: string

tool: D22: Bad Protocol %s



tool: D20: Valid protocols are:
 * tcp
   udp
(you can also use univoque abbreviation)
Note: you can also specify the protocol with option `-s'.
To know more, type:
	ntk-resolv -s help


tool: D9: ntk-resolv Protocol Help.


assistant: ```c
void proto_usage(char *arg) {
  if (arg)
    printf("Bad Protocol %s\n\n", arg);
  else
    printf("ntk-resolv Protocol Help.\n\n");
  printf("Valid protocols are:\n"
         " * tcp\n"
         "   udp\n"
         "(you can also use univoque abbreviation)\n"
         "Note: you can also specify the protocol with option `-s'.\n"
         "To know more, type:\n"
         "\tntk-resolv -s help\n\n");
  ntkresolv_safe_exit(1);
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<proto_usage>:
  endbr64
  sub    $0x8,%rsp
  test   %rdi,%rdi
  je     L1
  mov    %rdi,%rsi
  xor    %eax,%eax
  lea    D9(%rip),%rdi
  call   <printf@plt>
L11:
  lea    D16(%rip),%rdi
  call   <puts@plt>
  mov    $0x1,%edi
  add    $0x8,%rsp
  jmp    1070 <ntkresolv_safe_exit@plt>
  nopl   0x0(%rax,%rax,1)
L1:
  lea    D23(%rip),%rdi
  call   <puts@plt>
  jmp    L11
```

tool_calls: name: unpack_data
arguments: data_label: D9
type_guessed: string
name: unpack_data
arguments: data_label: D16
type_guessed: string
name: unpack_data
arguments: data_label: D23
type_guessed: string

tool: D9: Bad Protocol %s



tool: D16: Valid protocols are:
 * tcp
   udp
(you can also use univoque abbreviation)
Note: you can also specify the protocol with option `-s'.
To know more, type:
	ntk-resolv -s help


tool: D23: ntk-resolv Protocol Help.


assistant: ```c
void proto_usage(char *arg) {
  if (arg)
    printf("Bad Protocol %s\n\n", arg);
  else
    printf("ntk-resolv Protocol Help.\n\n");
  printf("Valid protocols are:\n"
         " * tcp\n"
         "   udp\n"
         "(you can also use univoque abbreviation)\n"
         "Note: you can also specify the protocol with option `-s'.\n"
         "To know more, type:\n"
         "\tntk-resolv -s help\n\n");
  ntkresolv_safe_exit(1);
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<proto_usage>:
  endbr64
  sub    $0x8,%rsp
  test   %rdi,%rdi
  je     L18
  mov    %rdi,%rsi
  xor    %eax,%eax
  lea    D9(%rip),%rdi
  call   <printf@plt>
L15:
  lea    D15(%rip),%rdi
  call   <puts@plt>
  mov    $0x1,%edi
  add    $0x8,%rsp
  jmp    1070 <ntkresolv_safe_exit@plt>
  nopl   0x0(%rax,%rax,1)
L18:
  lea    D20(%rip),%rdi
  call   <puts@plt>
  jmp    L15
```

tool_calls: name: unpack_data
arguments: data_label: D9
datatype: string
name: unpack_data
arguments: data_label: D15
datatype: string
name: unpack_data
arguments: data_label: D20
datatype: string

tool: D9: Bad Protocol %s



tool: D15: Valid protocols are:
 * tcp
   udp
(you can also use univoque abbreviation)
Note: you can also specify the protocol with option `-s'.
To know more, type:
	ntk-resolv -s help


tool: D20: ntk-resolv Protocol Help.


assistant: ```c
void proto_usage(char *arg) {
  if (arg)
    printf("Bad Protocol %s\n\n", arg);
  else
    printf("ntk-resolv Protocol Help.\n\n");
  printf("Valid protocols are:\n"
         " * tcp\n"
         "   udp\n"
         "(you can also use univoque abbreviation)\n"
         "Note: you can also specify the protocol with option `-s'.\n"
         "To know more, type:\n"
         "\tntk-resolv -s help\n\n");
  ntkresolv_safe_exit(1);
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<usb_enable_endpoint>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %edi,-0x14(%rbp)
  mov    %esi,-0x18(%rbp)
  mov    -0x14(%rbp),%eax
  shl    $0x2,%eax
  mov    %eax,%eax
  lea    0x0(,%rax,4),%rdx
  mov    $0xbf885300,%eax
  add    %rdx,%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  mov    -0x18(%rbp),%edx
  mov    %edx,(%rax)
  mov    -0x18(%rbp),%eax
  and    $0x8,%eax
  test   %eax,%eax
  je     L13
  mov    -0x14(%rbp),%eax
  mov    $0x0,%esi
  mov    %eax,%edi
  call   <usb_configure_endpoint@plt>
L13:
  mov    -0x18(%rbp),%eax
  and    $0x4,%eax
  test   %eax,%eax
  je     L4
  mov    -0x14(%rbp),%eax
  mov    $0x1,%esi
  mov    %eax,%edi
  call   <usb_configure_endpoint@plt>
L4:
  nop
  leave
  ret
```

assistant: ```c
void usb_enable_endpoint(unsigned ep, unsigned options) {
  unsigned int *p = (unsigned int *)(&*(volatile unsigned *)(0xBF800000 + (0x85300 + (0 << 4))) + (4 * ep));
  *p = options;
  if (options & 0x08) {
    usb_configure_endpoint(ep, 0);
  }
  if (options & 0x04) {
    usb_configure_endpoint(ep, 1);
  }
}
```
user: What is the c source code of the assembly code below?

```asm
<usb_enable_endpoint>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %edi,%ebp
  mov    %esi,%ebx
  lea    0x0(,%rdi,4),%eax
  mov    %eax,%eax
  mov    $0xbf885300,%edx
  mov    %esi,(%rdx,%rax,4)
  test   $0x8,%sil
  jne    L13
L9:
  test   $0x4,%bl
  jne    L12
L29:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
L13:
  mov    $0x0,%esi
  call   <usb_configure_endpoint@plt>
  jmp    L9
L12:
  mov    $0x1,%esi
  mov    %ebp,%edi
  call   <usb_configure_endpoint@plt>
  jmp    L29
```

assistant: ```c
void usb_enable_endpoint(unsigned ep, unsigned options) {
  unsigned int *p = (unsigned int *)(&*(volatile unsigned *)(0xBF800000 + (0x85300 + (0 << 4))) + (4 * ep));
  *p = options;
  if (options & 0x08) {
    usb_configure_endpoint(ep, 0);
  }
  if (options & 0x04) {
    usb_configure_endpoint(ep, 1);
  }
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<usb_enable_endpoint>:
  endbr64
  push   %rbp
  lea    0x0(,%rdi,4),%eax
  mov    $0xbf885300,%edx
  mov    %edi,%ebp
  push   %rbx
  mov    %esi,%ebx
  sub    $0x8,%rsp
  mov    %esi,(%rdx,%rax,4)
  and    $0x8,%esi
  jne    L28
  and    $0x4,%ebx
  jne    L19
L20:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
  xchg   %ax,%ax
L28:
  xor    %esi,%esi
  call   <usb_configure_endpoint@plt>
  and    $0x4,%ebx
  je     L20
L19:
  add    $0x8,%rsp
  mov    %ebp,%edi
  mov    $0x1,%esi
  pop    %rbx
  pop    %rbp
  jmp    1050 <usb_configure_endpoint@plt>
```

assistant: ```c
void usb_enable_endpoint(unsigned ep, unsigned options) {
  unsigned int *p = (unsigned int *)(&*(volatile unsigned *)(0xBF800000 + (0x85300 + (0 << 4))) + (4 * ep));
  *p = options;
  if (options & 0x08) {
    usb_configure_endpoint(ep, 0);
  }
  if (options & 0x04) {
    usb_configure_endpoint(ep, 1);
  }
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<usb_enable_endpoint>:
  endbr64
  push   %rbp
  lea    0x0(,%rdi,4),%eax
  mov    $0xbf885300,%edx
  mov    %edi,%ebp
  push   %rbx
  mov    %esi,%ebx
  sub    $0x8,%rsp
  mov    %esi,(%rdx,%rax,4)
  and    $0x8,%esi
  jne    L13
  and    $0x4,%ebx
  jne    L0
L25:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
  xchg   %ax,%ax
L13:
  xor    %esi,%esi
  call   <usb_configure_endpoint@plt>
  and    $0x4,%ebx
  je     L25
L0:
  add    $0x8,%rsp
  mov    %ebp,%edi
  mov    $0x1,%esi
  pop    %rbx
  pop    %rbp
  jmp    1050 <usb_configure_endpoint@plt>
```

assistant: ```c
void usb_enable_endpoint(unsigned ep, unsigned options) {
  unsigned int *p = (unsigned int *)(&*(volatile unsigned *)(0xBF800000 + (0x85300 + (0 << 4))) + (4 * ep));
  *p = options;
  if (options & 0x08) {
    usb_configure_endpoint(ep, 0);
  }
  if (options & 0x04) {
    usb_configure_endpoint(ep, 1);
  }
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  lea    D18(%rip),%rax
  mov    %rax,%rsi
  lea    D9(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    $0x0,%eax
  pop    %rbp
  ret
```

tool_calls: name: retrieve_data
arguments: tag: D18
type_infered: string
name: retrieve_data
arguments: tag: D9
type_infered: string

tool: D18: Hello world!

tool: D9: %s


assistant: ```c
int main() {
  printf("%s\n", "Hello world!");
  return 0;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<main>:
  endbr64
  sub    $0x8,%rsp
  lea    D12(%rip),%rsi
  lea    D11(%rip),%rdi
  call   <printf@plt>
  mov    $0x0,%eax
  add    $0x8,%rsp
  ret
```

tool_calls: name: disassemble_data
arguments: data_label: D12
type: string
name: disassemble_data
arguments: data_label: D11
type: string

tool: D12: Hello world!

tool: D11: %s


assistant: ```c
int main() {
  printf("%s\n", "Hello world!");
  return 0;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<main>:
  endbr64
  sub    $0x8,%rsp
  lea    D11(%rip),%rsi
  lea    D1(%rip),%rdi
  call   <printf@plt>
  xor    %eax,%eax
  add    $0x8,%rsp
  ret
```

tool_calls: name: read_data
arguments: tag: D11
type_infered: string
name: read_data
arguments: tag: D1
type_infered: string

tool: D11: Hello world!

tool: D1: %s


assistant: ```c
int main() {
  printf("%s\n", "Hello world!");
  return 0;
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<main>:
  endbr64
  sub    $0x8,%rsp
  lea    D11(%rip),%rsi
  lea    D19(%rip),%rdi
  call   <printf@plt>
  xor    %eax,%eax
  add    $0x8,%rsp
  ret
```

tool_calls: name: disassemble_data
arguments: data_label: D11
type_infered: string
name: disassemble_data
arguments: data_label: D19
type_infered: string

tool: D11: Hello world!

tool: D19: %s


assistant: ```c
int main() {
  printf("%s\n", "Hello world!");
  return 0;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<pipe_close>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %rdi,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    $0x0,%eax
  leave
  ret
```

assistant: ```c
int pipe_close(void *ptr) {
  free(ptr);
  return 0;
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<pipe_close>:
  endbr64
  sub    $0x8,%rsp
  call   <free@plt>
  mov    $0x0,%eax
  add    $0x8,%rsp
  ret
```

assistant: ```c
int pipe_close(void *ptr) {
  free(ptr);
  return 0;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<pipe_close>:
  endbr64
  sub    $0x8,%rsp
  call   <free@plt>
  xor    %eax,%eax
  add    $0x8,%rsp
  ret
```

assistant: ```c
int pipe_close(void *ptr) {
  free(ptr);
  return 0;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<pipe_close>:
  endbr64
  sub    $0x8,%rsp
  call   <free@plt>
  xor    %eax,%eax
  add    $0x8,%rsp
  ret
```

assistant: ```c
int pipe_close(void *ptr) {
  free(ptr);
  return 0;
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<CHECK_SCORE>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %edi,%r15d
  mov    %rsi,%r12
  mov    %edx,%ebx
  mov    %ecx,%ebp
  mov    0x40(%rsp),%r13d
  test   %edx,%edx
  jg     L36
  test   %ecx,%ecx
  jle    L61
L36:
  mov    $0x0,%r11d
  mov    $0x0,%eax
  mov    $0x0,%edi
  mov    $0x0,%r10d
  mov    $0x0,%esi
  mov    $0x0,%ecx
  mov    %r13d,0x40(%rsp)
L14:
  add    $0x4,%r8
  mov    -0x4(%r8),%edx
  test   %edx,%edx
  jne    L54
  add    $0x1,%esi
  lea    (%r15,%rcx,1),%edx
  movslq %edx,%rdx
  movslq %esi,%r14
  movzbl (%r12,%r14,1),%r14d
  mov    (%r9,%rdx,8),%rdx
  mov    (%rdx,%r14,4),%edx
  add    %edx,%edi
  add    $0x1,%ecx
  add    $0x1,%r10d
  add    %edx,%eax
  mov    $0x0,%edx
  cmovs  %edx,%eax
  cmp    %eax,%r11d
  cmovl  %eax,%r11d
L4:
  cmp    %ecx,%ebx
  jg     L14
  cmp    %ebp,%esi
  jl     L14
L19:
  mov    0x48(%rsp),%rax
  mov    %r10d,(%rax)
  mov    0x50(%rsp),%rax
  mov    %r11d,(%rax)
  mov    %edi,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L54:
  jle    L79
  mov    %edx,%r14d
  imul   0x40(%rsp),%r14d
  add    0x38(%rsp),%r14d
  sub    %r14d,%edi
  add    %edx,%esi
  add    %edx,%r10d
  sub    %r14d,%eax
  mov    $0x0,%edx
  cmovs  %edx,%eax
  jmp    L4
L79:
  mov    %edx,%r14d
  imul   0x40(%rsp),%r14d
  mov    0x38(%rsp),%r13d
  sub    %r14d,%r13d
  sub    %r13d,%edi
  sub    %edx,%ecx
  sub    %edx,%r10d
  sub    %r13d,%eax
  mov    $0x0,%edx
  cmovs  %edx,%eax
  jmp    L4
L61:
  mov    $0x0,%r11d
  mov    $0x0,%edi
  mov    $0x0,%r10d
  jmp    L19
```

assistant: ```c
int CHECK_SCORE(int iw, const unsigned char *B, int M, int N, int *S, int **w, int g, int h, int *NC, int *sw_score) {
  register int i, j, op, nc;
  int itmp;
  int score;
  int l_score, mx_l_score;
  score = i = j = nc = l_score = mx_l_score = 0;
  while (i < M || j < N) {
    op = *S++;
    if (op == 0) {
      itmp = w[iw + i][B[++j]];
      score += itmp;
      i++;
      nc++;
      l_score += itmp;
      if (l_score < 0)
        l_score = 0;
      if (l_score > mx_l_score)
        mx_l_score = l_score;
    } else if (op > 0) {
      score = score - (g + op * h);
      j += op;
      nc += op;
      l_score -= (g + op * h);
      if (l_score < 0)
        l_score = 0;
    } else {
      score = score - (g - op * h);
      i -= op;
      nc -= op;
      l_score -= (g - op * h);
      if (l_score < 0)
        l_score = 0;
    }
  }
  *NC = nc;
  *sw_score = mx_l_score;
  return score;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<CHECK_SCORE>:
  endbr64
  push   %r15
  push   %r14
  mov    %ecx,%r14d
  push   %r13
  mov    %edx,%r13d
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  mov    %edi,%ebp
  push   %rbx
  xor    %ebx,%ebx
  test   %edx,%edx
  jg     L31
  test   %ecx,%ecx
  jle    L38
L31:
  xor    %eax,%eax
  xor    %r10d,%r10d
  xor    %edi,%edi
  xor    %esi,%esi
  xor    %ecx,%ecx
  nopw   0x0(%rax,%rax,1)
L49:
  mov    (%r8),%edx
  add    $0x4,%r8
  test   %edx,%edx
  jne    L54
  add    $0x1,%esi
  lea    0x0(%rbp,%rcx,1),%edx
  add    $0x1,%edi
  add    $0x1,%ecx
  movslq %edx,%rdx
  movslq %esi,%r11
  movzbl (%r12,%r11,1),%r11d
  mov    (%r9,%rdx,8),%rdx
  mov    (%rdx,%r11,4),%edx
  add    %edx,%r10d
  add    %edx,%eax
  mov    $0x0,%edx
  cmovs  %edx,%eax
  cmp    %eax,%ebx
  cmovl  %eax,%ebx
L19:
  cmp    %r13d,%ecx
  jl     L49
  cmp    %esi,%r14d
  jg     L49
L72:
  mov    0x48(%rsp),%rax
  mov    %edi,(%rax)
  mov    0x50(%rsp),%rax
  mov    %ebx,(%rax)
  mov    %r10d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L54:
  mov    0x40(%rsp),%r11d
  imul   %edx,%r11d
  test   %edx,%edx
  jle    L8
  add    0x38(%rsp),%r11d
  add    %edx,%esi
  add    %edx,%edi
  mov    $0x0,%edx
  sub    %r11d,%r10d
  sub    %r11d,%eax
  cmovs  %edx,%eax
  jmp    L19
  cs nopw 0x0(%rax,%rax,1)
L8:
  mov    0x38(%rsp),%r15d
  sub    %edx,%ecx
  sub    %edx,%edi
  mov    $0x0,%edx
  sub    %r11d,%r15d
  sub    %r15d,%r10d
  sub    %r15d,%eax
  cmovs  %edx,%eax
  jmp    L19
  nopl   0x0(%rax)
L38:
  xor    %r10d,%r10d
  xor    %edi,%edi
  jmp    L72
```

assistant: ```c
int CHECK_SCORE(int iw, const unsigned char *B, int M, int N, int *S, int **w, int g, int h, int *NC, int *sw_score) {
  register int i, j, op, nc;
  int itmp;
  int score;
  int l_score, mx_l_score;
  score = i = j = nc = l_score = mx_l_score = 0;
  while (i < M || j < N) {
    op = *S++;
    if (op == 0) {
      itmp = w[iw + i][B[++j]];
      score += itmp;
      i++;
      nc++;
      l_score += itmp;
      if (l_score < 0)
        l_score = 0;
      if (l_score > mx_l_score)
        mx_l_score = l_score;
    } else if (op > 0) {
      score = score - (g + op * h);
      j += op;
      nc += op;
      l_score -= (g + op * h);
      if (l_score < 0)
        l_score = 0;
    } else {
      score = score - (g - op * h);
      i -= op;
      nc -= op;
      l_score -= (g - op * h);
      if (l_score < 0)
        l_score = 0;
    }
  }
  *NC = nc;
  *sw_score = mx_l_score;
  return score;
}
```