ylfeng/ReF-Decompile-dataset huggingface dataset:
user: Translate the below assembly code into C programming language:

```asm
<newSock>:
  endbr64
  push   %r14
  lea    D28(%rip),%r14
  push   %r13
  lea    D26(%rip),%r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x810,%rsp
  mov    (%rdi),%r12d
  lea    D8(%rip),%rdi
  mov    %fs:0x28,%rax
  mov    %rax,0x808(%rsp)
  xor    %eax,%eax
  mov    %rsp,%rbx
  lea    0x200(%rsp),%rbp
  call   <printf@plt>
  jmp    L67
L43:
  mov    $0x200,%edx
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  call   <strncat@plt>
  mov    $0x200,%edx
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  call   <strncat@plt>
  mov    $0x200,%edx
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  call   <strncat@plt>
  xor    %ecx,%ecx
  mov    $0x600,%edx
  mov    %rbp,%rsi
  mov    %r12d,%edi
  call   <send@plt>
  test   %rax,%rax
  js     L12
L4:
  mov    $0x600,%edx
  xor    %esi,%esi
  mov    %rbp,%rdi
  call   <memset@plt>
  mov    $0x200,%edx
  xor    %esi,%esi
  mov    %rbx,%rdi
  call   <memset@plt>
L67:
  xor    %ecx,%ecx
  mov    $0x200,%edx
  mov    %rbx,%rsi
  mov    %r12d,%edi
  call   <recv@plt>
  test   %eax,%eax
  je     L56
  jns    L43
  mov    %r14,%rdi
  call   <perror@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  jmp    L43
  nopl   0x0(%rax)
L12:
  mov    %r13,%rdi
  call   <perror@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  jmp    L4
  nopl   0x0(%rax)
L56:
  mov    %r12d,%edi
  call   <close@plt>
  xor    %edi,%edi
  call   <pthread_exit@plt>
  mov    0x808(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L23
  add    $0x810,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L23:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: data_label: D28
type_guessed: string
name: disassemble_data
arguments: data_label: D26
type_guessed: string
name: disassemble_data
arguments: data_label: D8
type_guessed: string

tool: D28: Receive Error:

tool: D26: Send error:

tool: D8: Running a new thread now


assistant: ```c
void *newSock(void *new_socket) {
  int recv_len;
  char buffer[(512)], msg[(512) * 3];
  int new_s = *(int *)new_socket;
  printf("Running a new thread now\n");
  while (recv_len = recv(new_s, buffer, (512), 0)) {
    if (recv_len < 0) {
      perror("Receive Error:");
      exit(1);
    }
    strncat(msg, buffer, (512));
    strncat(msg, buffer, (512));
    strncat(msg, buffer, (512));
    if ((send(new_s, msg, (512) * 3, 0)) < 0) {
      perror("Send error:");
      exit(1);
    }
    memset(msg, 0, sizeof(msg));
    memset(buffer, 0, sizeof(buffer));
  }
  close(new_s);
  pthread_exit(NULL);
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<string_ends_with>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x8(%rbp)
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x4(%rbp)
  mov    -0x8(%rbp),%eax
  cmp    -0x4(%rbp),%eax
  jl     L12
  mov    -0x8(%rbp),%eax
  sub    -0x4(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  mov    -0x20(%rbp),%rax
  mov    %rax,%rsi
  mov    %rdx,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L12
  mov    $0x1,%eax
  jmp    L11
L12:
  mov    $0x0,%eax
L11:
  leave
  ret
```

assistant: ```c
int string_ends_with(const char *str, const char *suffix) {
  int str_len = strlen(str);
  int suffix_len = strlen(suffix);
  return (str_len >= suffix_len) && (0 == strcmp(str + (str_len - suffix_len), suffix));
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<string_ends_with>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbp
  mov    %rsi,%r12
  call   <strlen@plt>
  mov    %eax,%ebx
  mov    %r12,%rdi
  call   <strlen@plt>
  mov    $0x0,%edx
  cmp    %eax,%ebx
  jge    L14
L3:
  mov    %edx,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L14:
  sub    %eax,%ebx
  movslq %ebx,%rbx
  lea    0x0(%rbp,%rbx,1),%rdi
  mov    %r12,%rsi
  call   <strcmp@plt>
  test   %rax,%rax
  sete   %dl
  movzbl %dl,%edx
  jmp    L3
```

assistant: ```c
int string_ends_with(const char *str, const char *suffix) {
  int str_len = strlen(str);
  int suffix_len = strlen(suffix);
  return (str_len >= suffix_len) && (0 == strcmp(str + (str_len - suffix_len), suffix));
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<string_ends_with>:
  endbr64
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  call   <strlen@plt>
  mov    %r12,%rdi
  mov    %eax,%ebx
  call   <strlen@plt>
  xor    %r8d,%r8d
  cmp    %eax,%ebx
  jge    L6
  pop    %rbx
  mov    %r8d,%eax
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax)
L6:
  sub    %eax,%ebx
  mov    %r12,%rsi
  movslq %ebx,%rbx
  lea    0x0(%rbp,%rbx,1),%rdi
  call   <strcmp@plt>
  xor    %r8d,%r8d
  pop    %rbx
  pop    %rbp
  test   %rax,%rax
  pop    %r12
  sete   %r8b
  mov    %r8d,%eax
  ret
```

assistant: ```c
int string_ends_with(const char *str, const char *suffix) {
  int str_len = strlen(str);
  int suffix_len = strlen(suffix);
  return (str_len >= suffix_len) && (0 == strcmp(str + (str_len - suffix_len), suffix));
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<string_ends_with>:
  endbr64
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  call   <strlen@plt>
  mov    %r12,%rdi
  mov    %eax,%ebx
  call   <strlen@plt>
  xor    %r8d,%r8d
  cmp    %eax,%ebx
  jge    L3
  pop    %rbx
  mov    %r8d,%eax
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax)
L3:
  sub    %eax,%ebx
  mov    %r12,%rsi
  movslq %ebx,%rbx
  lea    0x0(%rbp,%rbx,1),%rdi
  call   <strcmp@plt>
  xor    %r8d,%r8d
  pop    %rbx
  pop    %rbp
  test   %rax,%rax
  pop    %r12
  sete   %r8b
  mov    %r8d,%eax
  ret
```

assistant: ```c
int string_ends_with(const char *str, const char *suffix) {
  int str_len = strlen(str);
  int suffix_len = strlen(suffix);
  return (str_len >= suffix_len) && (0 == strcmp(str + (str_len - suffix_len), suffix));
}
```
user: Translate the below assembly code into C programming language:

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %edi,-0x24(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    D38(%rip),%rax
  mov    %rax,%rsi
  lea    D29(%rip),%rax
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L33
  lea    D22(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  jmp    L33
L42:
  mov    -0x18(%rbp),%edx
  mov    -0x14(%rbp),%eax
  add    %edx,%eax
  mov    %eax,%esi
  lea    D31(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L33:
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <feof@plt>
  test   %eax,%eax
  jne    L49
  lea    -0x14(%rbp),%rcx
  lea    -0x18(%rbp),%rdx
  mov    -0x10(%rbp),%rax
  lea    D5(%rip),%rsi
  mov    %rax,%rdi
  call   <fscanf@plt>
  cmp    $0xffffffff,%eax
  jne    L42
L49:
  mov    $0x0,%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L12
  call   <__stack_chk_fail@plt>
L12:
  leave
  ret
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D38
datatype: string
name: extract_symbolic_data
arguments: data_tag: D29
datatype: string
name: extract_symbolic_data
arguments: data_tag: D22
datatype: string
name: extract_symbolic_data
arguments: data_tag: D31
datatype: string
name: extract_symbolic_data
arguments: data_tag: D5
datatype: string

tool: D38: r

tool: D29: data.txt

tool: D22: can not open file to read

tool: D31: %d


tool: D5: %d %d

assistant: ```c
int main(int argc, char *argv[]) {
  FILE *fp;
  int a, b;
  fp = fopen("data.txt", "r");
  if (fp == NULL) {
    printf("can not open file to read\n");
    exit(1);
  }
  while (!feof(fp) && fscanf(fp, "%d %d", &a, &b) != -1) {
    printf("%d\n", a + b);
  }
  return 0;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<main>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    D34(%rip),%rsi
  lea    D49(%rip),%rdi
  call   <fopen@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L19
L27:
  lea    0x4(%rsp),%r13
  mov    %rsp,%r12
  lea    D41(%rip),%rbp
  lea    D26(%rip),%r14
  jmp    L0
L19:
  lea    D19(%rip),%rdi
  call   <puts@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  jmp    L27
L31:
  mov    0x4(%rsp),%esi
  add    (%rsp),%esi
  mov    %r14,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L0:
  mov    %rbx,%rdi
  call   <feof@plt>
  test   %eax,%eax
  jne    L55
  mov    %r13,%rcx
  mov    %r12,%rdx
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  call   <fscanf@plt>
  cmp    $0xffffffff,%eax
  jne    L31
L55:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L47
  mov    $0x0,%eax
  add    $0x10,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L47:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: data_tag: D34
type_infered: string
name: read_data
arguments: data_tag: D49
type_infered: string
name: read_data
arguments: data_tag: D41
type_infered: string
name: read_data
arguments: data_tag: D26
type_infered: string
name: read_data
arguments: data_tag: D19
type_infered: string

tool: D34: r

tool: D49: data.txt

tool: D41: %d %d

tool: D26: %d


tool: D19: can not open file to read

assistant: ```c
int main(int argc, char *argv[]) {
  FILE *fp;
  int a, b;
  fp = fopen("data.txt", "r");
  if (fp == NULL) {
    printf("can not open file to read\n");
    exit(1);
  }
  while (!feof(fp) && fscanf(fp, "%d %d", &a, &b) != -1) {
    printf("%d\n", a + b);
  }
  return 0;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<main>:
  endbr64
  push   %r14
  lea    D23(%rip),%rsi
  lea    D47(%rip),%rdi
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  call   <fopen@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L36
L30:
  lea    0x4(%rsp),%r13
  mov    %rsp,%r12
  lea    D12(%rip),%rbp
  lea    D10(%rip),%r14
  jmp    L11
  nopl   0x0(%rax,%rax,1)
L42:
  mov    %r13,%rcx
  mov    %r12,%rdx
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  call   <fscanf@plt>
  cmp    $0xffffffff,%eax
  je     L26
  mov    0x4(%rsp),%esi
  mov    %r14,%rdi
  add    (%rsp),%esi
  xor    %eax,%eax
  call   <printf@plt>
L11:
  mov    %rbx,%rdi
  call   <feof@plt>
  test   %eax,%eax
  je     L42
L26:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L28
  add    $0x10,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L36:
  lea    D39(%rip),%rdi
  call   <puts@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  jmp    L30
L28:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: tag: D23
type: string
name: parse_data
arguments: tag: D47
type: string
name: parse_data
arguments: tag: D12
type: string
name: parse_data
arguments: tag: D10
type: string
name: parse_data
arguments: tag: D39
type: string

tool: D23: r

tool: D47: data.txt

tool: D12: %d %d

tool: D10: %d


tool: D39: can not open file to read

assistant: ```c
int main(int argc, char *argv[]) {
  FILE *fp;
  int a, b;
  fp = fopen("data.txt", "r");
  if (fp == NULL) {
    printf("can not open file to read\n");
    exit(1);
  }
  while (!feof(fp) && fscanf(fp, "%d %d", &a, &b) != -1) {
    printf("%d\n", a + b);
  }
  return 0;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<main>:
  endbr64
  push   %r14
  lea    D0(%rip),%rsi
  lea    D25(%rip),%rdi
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  call   <fopen@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L44
L56:
  lea    0x4(%rsp),%r13
  mov    %rsp,%r12
  lea    D31(%rip),%rbp
  lea    D34(%rip),%r14
  jmp    L12
  nopl   0x0(%rax,%rax,1)
L35:
  mov    %r13,%rcx
  mov    %r12,%rdx
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  call   <fscanf@plt>
  cmp    $0xffffffff,%eax
  je     L21
  mov    0x4(%rsp),%esi
  mov    %r14,%rdi
  add    (%rsp),%esi
  xor    %eax,%eax
  call   <printf@plt>
L12:
  mov    %rbx,%rdi
  call   <feof@plt>
  test   %eax,%eax
  je     L35
L21:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L31
  add    $0x10,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L44:
  lea    D12(%rip),%rdi
  call   <puts@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  jmp    L56
L31:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: data_label: D0
type: string
name: parse_data
arguments: data_label: D25
type: string
name: parse_data
arguments: data_label: D31
type: string
name: parse_data
arguments: data_label: D34
type: string
name: parse_data
arguments: data_label: D12
type: string

tool: D0: r

tool: D25: data.txt

tool: D31: %d %d

tool: D34: %d


tool: D12: can not open file to read

assistant: ```c
int main(int argc, char *argv[]) {
  FILE *fp;
  int a, b;
  fp = fopen("data.txt", "r");
  if (fp == NULL) {
    printf("can not open file to read\n");
    exit(1);
  }
  while (!feof(fp) && fscanf(fp, "%d %d", &a, &b) != -1) {
    printf("%d\n", a + b);
  }
  return 0;
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<wait_for_adc>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  nop
L3:
  mov    $0x44e0d028,%eax
  mov    (%rax),%eax
  and    $0x2,%eax
  test   %eax,%eax
  je     L3
  mov    $0x44e0d028,%eax
  mov    (%rax),%eax
  mov    $0x44e0d028,%edx
  or     $0x2,%eax
  mov    %eax,(%rdx)
  nop
  pop    %rbp
  ret
```

assistant: ```c
void wait_for_adc() {
  while (((*((volatile unsigned int *)(0x44e0d000 + 0x28))) & (1 << 1)) == 0) {
  }
  (*((volatile unsigned int *)(0x44e0d000 + 0x28))) |= (1 << 1);
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<wait_for_adc>:
  endbr64
L2:
  mov    0x44e0d028,%eax
  test   $0x2,%al
  je     L2
  mov    0x44e0d028,%eax
  or     $0x2,%eax
  mov    %eax,0x44e0d028
  ret
```

assistant: ```c
void wait_for_adc() {
  while (((*((volatile unsigned int *)(0x44e0d000 + 0x28))) & (1 << 1)) == 0) {
  }
  (*((volatile unsigned int *)(0x44e0d000 + 0x28))) |= (1 << 1);
}
```
user: Translate the below assembly code into C programming language:

```asm
<wait_for_adc>:
  endbr64
  nopl   0x0(%rax)
L2:
  mov    0x44e0d028,%eax
  test   $0x2,%al
  je     L2
  mov    0x44e0d028,%eax
  or     $0x2,%eax
  mov    %eax,0x44e0d028
  ret
```

assistant: ```c
void wait_for_adc() {
  while (((*((volatile unsigned int *)(0x44e0d000 + 0x28))) & (1 << 1)) == 0) {
  }
  (*((volatile unsigned int *)(0x44e0d000 + 0x28))) |= (1 << 1);
}
```
user: 这段汇编代码用C语言表示是什么样的:

```asm
<wait_for_adc>:
  endbr64
  nopl   0x0(%rax)
L5:
  mov    0x44e0d028,%eax
  test   $0x2,%al
  je     L5
  mov    0x44e0d028,%eax
  or     $0x2,%eax
  mov    %eax,0x44e0d028
  ret
```

assistant: ```c
void wait_for_adc() {
  while (((*((volatile unsigned int *)(0x44e0d000 + 0x28))) & (1 << 1)) == 0) {
  }
  (*((volatile unsigned int *)(0x44e0d000 + 0x28))) |= (1 << 1);
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<downmix_to_mono_from_interleaved_stereo>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %edx,-0x34(%rbp)
  movl   $0x8,-0x8(%rbp)
  movl   $0x0,-0x14(%rbp)
  jmp    L74
L33:
  movl   $0x0,-0x10(%rbp)
  movl   $0x0,-0xc(%rbp)
  jmp    L62
L55:
  mov    -0x14(%rbp),%edx
  mov    -0x10(%rbp),%eax
  add    %rdx,%rax
  lea    (%rax,%rax,1),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzwl (%rax),%eax
  cwtl
  mov    %eax,-0x4(%rbp)
  addl   $0x1,-0x10(%rbp)
  mov    -0x14(%rbp),%edx
  mov    -0x10(%rbp),%eax
  add    %rdx,%rax
  lea    (%rax,%rax,1),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzwl (%rax),%eax
  cwtl
  add    %eax,-0x4(%rbp)
  addl   $0x1,-0x10(%rbp)
  cmpl   $0x7fff,-0x4(%rbp)
  jg     L14
  cmpl   $0xffff8000,-0x4(%rbp)
  jl     L61
  mov    -0x4(%rbp),%eax
  jmp    L45
L61:
  mov    $0xffff8000,%eax
  jmp    L45
L14:
  mov    $0x7fff,%eax
L45:
  mov    -0xc(%rbp),%edx
  lea    (%rdx,%rdx,1),%rcx
  mov    -0x30(%rbp),%rdx
  add    %rcx,%rdx
  mov    %ax,(%rdx)
  addl   $0x1,-0xc(%rbp)
L62:
  cmpl   $0x7,-0xc(%rbp)
  jbe    L55
  mov    -0x8(%rbp),%eax
  add    %rax,%rax
  add    %rax,-0x30(%rbp)
  addl   $0x10,-0x14(%rbp)
L74:
  mov    -0x14(%rbp),%eax
  cmp    -0x34(%rbp),%eax
  jb     L33
  nop
  nop
  pop    %rbp
  ret
```

assistant: ```c
void downmix_to_mono_from_interleaved_stereo(const short *src, short *dst, unsigned n) {
  unsigned i;
  unsigned offset = 8;
  for (i = 0; i < n; i += 16) {
    unsigned i1 = 0, i2 = 0;
    while (i2 < 8) {
      int sum;
      sum = *(src + i + i1);
      i1++;
      sum += *(src + i + i1);
      i1++;
      *(dst + i2) = (short)(((sum) > (0x7FFF)) ? (0x7FFF) : (((sum) < (-0x8000)) ? (-0x8000) : (sum)));
      i2++;
    }
    dst += offset;
  }
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<downmix_to_mono_from_interleaved_stereo>:
  endbr64
  push   %rbx
  mov    %rdi,%rbx
  mov    $0x0,%r11d
  mov    $0x7fff,%r9d
  mov    $0xffff8000,%r10d
  test   %edx,%edx
  jne    L16
L43:
  pop    %rbx
  ret
L34:
  mov    %di,(%rsi,%rax,1)
  add    $0x2,%rax
  cmp    $0x10,%rax
  je     L26
L19:
  movswl (%r8,%rax,2),%edi
  movswl 0x2(%r8,%rax,2),%ecx
  add    %edi,%ecx
  mov    %r9d,%edi
  cmp    $0x7fff,%ecx
  jg     L34
  cmp    $0xffff8000,%ecx
  mov    %ecx,%edi
  cmovl  %r10d,%edi
  jmp    L34
L26:
  add    $0x10,%rsi
  add    $0x10,%r11d
  cmp    %r11d,%edx
  jbe    L43
L16:
  mov    %r11d,%eax
  lea    (%rbx,%rax,2),%r8
  mov    $0x0,%eax
  jmp    L19
```

assistant: ```c
void downmix_to_mono_from_interleaved_stereo(const short *src, short *dst, unsigned n) {
  unsigned i;
  unsigned offset = 8;
  for (i = 0; i < n; i += 16) {
    unsigned i1 = 0, i2 = 0;
    while (i2 < 8) {
      int sum;
      sum = *(src + i + i1);
      i1++;
      sum += *(src + i + i1);
      i1++;
      *(dst + i2) = (short)(((sum) > (0x7FFF)) ? (0x7FFF) : (((sum) < (-0x8000)) ? (-0x8000) : (sum)));
      i2++;
    }
    dst += offset;
  }
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<downmix_to_mono_from_interleaved_stereo>:
  endbr64
  mov    %rdi,%r11
  xor    %r10d,%r10d
  mov    $0xffff8000,%r9d
  test   %edx,%edx
  je     L34
  nopl   0x0(%rax)
L13:
  mov    %r10d,%eax
  lea    (%r11,%rax,2),%r8
  xor    %eax,%eax
  nopl   0x0(%rax)
L31:
  movswl (%r8,%rax,2),%edi
  movswl 0x2(%r8,%rax,2),%ecx
  add    %edi,%ecx
  mov    $0x7fff,%edi
  cmp    $0x7fff,%ecx
  jg     L9
  cmp    $0xffff8000,%ecx
  mov    %ecx,%edi
  cmovl  %r9d,%edi
L9:
  mov    %di,(%rsi,%rax,1)
  add    $0x2,%rax
  cmp    $0x10,%rax
  jne    L31
  add    $0x10,%r10d
  add    $0x10,%rsi
  cmp    %r10d,%edx
  ja     L13
L34:
  ret
```

assistant: ```c
void downmix_to_mono_from_interleaved_stereo(const short *src, short *dst, unsigned n) {
  unsigned i;
  unsigned offset = 8;
  for (i = 0; i < n; i += 16) {
    unsigned i1 = 0, i2 = 0;
    while (i2 < 8) {
      int sum;
      sum = *(src + i + i1);
      i1++;
      sum += *(src + i + i1);
      i1++;
      *(dst + i2) = (short)(((sum) > (0x7FFF)) ? (0x7FFF) : (((sum) < (-0x8000)) ? (-0x8000) : (sum)));
      i2++;
    }
    dst += offset;
  }
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<downmix_to_mono_from_interleaved_stereo>:
  endbr64
  mov    %rdi,%rax
  mov    %rsi,%rcx
  mov    %edx,%r9d
  test   %edx,%edx
  je     L47
  xor    %edi,%edi
  mov    $0xffff8000,%r8d
  nopl   (%rax)
L80:
  mov    %edi,%esi
  movswl (%rax,%rsi,2),%r10d
  lea    (%rsi,%rsi,1),%rdx
  movswl 0x2(%rax,%rsi,2),%esi
  add    %r10d,%esi
  mov    $0x7fff,%r10d
  cmp    $0x7fff,%esi
  jg     L50
  cmp    $0xffff8000,%esi
  mov    %esi,%r10d
  cmovl  %r8d,%r10d
L50:
  mov    %r10w,(%rcx)
  movswl 0x4(%rax,%rdx,1),%r10d
  movswl 0x6(%rax,%rdx,1),%esi
  add    %r10d,%esi
  mov    $0x7fff,%r10d
  cmp    $0x7fff,%esi
  jg     L13
  cmp    $0xffff8000,%esi
  mov    %esi,%r10d
  cmovl  %r8d,%r10d
L13:
  mov    %r10w,0x2(%rcx)
  movswl 0x8(%rax,%rdx,1),%r10d
  movswl 0xa(%rax,%rdx,1),%esi
  add    %r10d,%esi
  mov    $0x7fff,%r10d
  cmp    $0x7fff,%esi
  jg     L48
  cmp    $0xffff8000,%esi
  mov    %esi,%r10d
  cmovl  %r8d,%r10d
L48:
  mov    %r10w,0x4(%rcx)
  movswl 0xc(%rax,%rdx,1),%r10d
  movswl 0xe(%rax,%rdx,1),%esi
  add    %r10d,%esi
  mov    $0x7fff,%r10d
  cmp    $0x7fff,%esi
  jg     L63
  cmp    $0xffff8000,%esi
  mov    %esi,%r10d
  cmovl  %r8d,%r10d
L63:
  mov    %r10w,0x6(%rcx)
  movswl 0x10(%rax,%rdx,1),%r10d
  movswl 0x12(%rax,%rdx,1),%esi
  add    %r10d,%esi
  mov    $0x7fff,%r10d
  cmp    $0x7fff,%esi
  jg     L70
  cmp    $0xffff8000,%esi
  mov    %esi,%r10d
  cmovl  %r8d,%r10d
L70:
  mov    %r10w,0x8(%rcx)
  movswl 0x14(%rax,%rdx,1),%r10d
  movswl 0x16(%rax,%rdx,1),%esi
  add    %r10d,%esi
  mov    $0x7fff,%r10d
  cmp    $0x7fff,%esi
  jg     L24
  cmp    $0xffff8000,%esi
  mov    %esi,%r10d
  cmovl  %r8d,%r10d
L24:
  mov    %r10w,0xa(%rcx)
  movswl 0x18(%rax,%rdx,1),%r10d
  movswl 0x1a(%rax,%rdx,1),%esi
  add    %r10d,%esi
  mov    $0x7fff,%r10d
  cmp    $0x7fff,%esi
  jg     L41
  cmp    $0xffff8000,%esi
  mov    %esi,%r10d
  cmovl  %r8d,%r10d
L41:
  mov    %r10w,0xc(%rcx)
  movswl 0x1c(%rax,%rdx,1),%esi
  movswl 0x1e(%rax,%rdx,1),%edx
  add    %esi,%edx
  mov    $0x7fff,%esi
  cmp    $0x7fff,%edx
  jg     L89
  cmp    $0xffff8000,%edx
  mov    %edx,%esi
  cmovl  %r8d,%esi
L89:
  add    $0x10,%edi
  mov    %si,0xe(%rcx)
  add    $0x10,%rcx
  cmp    %edi,%r9d
  ja     L80
L47:
  ret
```

assistant: ```c
void downmix_to_mono_from_interleaved_stereo(const short *src, short *dst, unsigned n) {
  unsigned i;
  unsigned offset = 8;
  for (i = 0; i < n; i += 16) {
    unsigned i1 = 0, i2 = 0;
    while (i2 < 8) {
      int sum;
      sum = *(src + i + i1);
      i1++;
      sum += *(src + i + i1);
      i1++;
      *(dst + i2) = (short)(((sum) > (0x7FFF)) ? (0x7FFF) : (((sum) < (-0x8000)) ? (-0x8000) : (sum)));
      i2++;
    }
    dst += offset;
  }
}
```