ylfeng/ReF-Decompile-dataset huggingface dataset:
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<test_blocks>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x818,%rsp
  mov    %edi,%r12d
  mov    %fs:0x28,%rax
  mov    %rax,0x808(%rsp)
  xor    %eax,%eax
  mov    $0x0,%ebp
  mov    $0x0,%ebx
  lea    D27(%rip),%r13
  jmp    L4
L7:
  mov    $0x1,%ebx
  mov    %ebp,%ecx
  shl    %cl,%ebx
  add    $0x1,%ebp
  mov    $0x0,%eax
  cmove  %eax,%ebx
L4:
  cmp    %r12d,%ebx
  mov    %r12d,%r14d
  cmovbe %ebx,%r14d
  mov    %r14d,%edx
  shl    $0xa,%edx
  mov    %r14d,%esi
  mov    %r13,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    %rsp,%r15
  mov    $0xffffffff,%edx
  mov    %ebp,%esi
  mov    %r15,%rdi
  call   <data_fill@plt>
  mov    %r15,%rsi
  mov    %r14d,%edi
  call   <block_write@plt>
  cmp    %r12d,%ebx
  jb     L7
  mov    $0x0,%ebp
  mov    $0x0,%ebx
  jmp    L16
L42:
  mov    $0x1,%ebx
  mov    %ebp,%ecx
  shl    %cl,%ebx
  add    $0x1,%ebp
  mov    $0x0,%eax
  cmove  %eax,%ebx
L16:
  cmp    %r12d,%ebx
  mov    %r12d,%r13d
  cmovbe %ebx,%r13d
  mov    %r13d,%edx
  shl    $0xa,%edx
  mov    %r13d,%esi
  lea    D9(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    %rsp,%r14
  mov    $0xffffffff,%edx
  mov    %ebp,%esi
  mov    %r14,%rdi
  call   <data_fill@plt>
  lea    0x400(%rsp),%r15
  mov    %r15,%rsi
  mov    %r13d,%edi
  call   <block_read@plt>
  mov    %r15,%rsi
  mov    %r14,%rdi
  call   <data_check@plt>
  cmp    %r12d,%ebx
  jb     L42
  lea    D3(%rip),%rdi
  call   <puts@plt>
  mov    0x808(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L20
  add    $0x818,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L20:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D27
type: string
name: extract_symbolic_data
arguments: data_tag: D9
type: string
name: extract_symbolic_data
arguments: data_tag: D3
type: string

tool: D27: Writing block %u at address %06X.


tool: D9: Reading block %u at address %06X.


tool: D3: Done.

assistant: ```c
void test_blocks(unsigned blocknum) {
  unsigned char data[1024];
  unsigned char rdata[1024];
  unsigned bn;
  int i;
  for (i = 0;; i++) {
    if (i == 0)
      bn = 0;
    else
      bn = 1 << (i - 1);
    if (bn > blocknum)
      bn = blocknum;
    printf("Writing block %u at address %06X.\n", bn, bn * 1024);
    data_fill(data, i, ~0);
    block_write(bn, data);
    if (bn == blocknum)
      break;
  }
  for (i = 0;; i++) {
    if (i == 0)
      bn = 0;
    else
      bn = 1 << (i - 1);
    if (bn > blocknum)
      bn = blocknum;
    printf("Reading block %u at address %06X.\n", bn, bn * 1024);
    data_fill(data, i, ~0);
    block_read(bn, rdata);
    data_check(data, rdata);
    if (bn == blocknum)
      break;
  }
  printf("Done.\n");
}
```
user: What is the c source code of the assembly code below:

```asm
<test_blocks>:
  endbr64
  push   %r15
  xor    %r15d,%r15d
  push   %r14
  lea    D16(%rip),%r14
  push   %r13
  push   %r12
  xor    %r12d,%r12d
  push   %rbp
  push   %rbx
  mov    %edi,%ebx
  sub    $0x818,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x808(%rsp)
  xor    %eax,%eax
  mov    %rsp,%rbp
  jmp    L35
  nopl   0x0(%rax)
L14:
  mov    %r15d,%ecx
  mov    $0x1,%r12d
  add    $0x1,%r15d
  shl    %cl,%r12d
L35:
  cmp    %ebx,%r12d
  mov    %ebx,%r13d
  mov    %r14,%rdi
  cmovbe %r12d,%r13d
  xor    %eax,%eax
  mov    %r13d,%edx
  mov    %r13d,%esi
  shl    $0xa,%edx
  call   <printf@plt>
  mov    %r15d,%esi
  mov    %rbp,%rdi
  mov    $0xffffffff,%edx
  call   <data_fill@plt>
  mov    %rbp,%rsi
  mov    %r13d,%edi
  call   <block_write@plt>
  cmp    %ebx,%r12d
  jb     L14
  xor    %r15d,%r15d
  xor    %r12d,%r12d
  lea    0x400(%rsp),%r13
  jmp    L45
  nopl   (%rax)
L23:
  mov    %r15d,%ecx
  mov    $0x1,%r12d
  add    $0x1,%r15d
  shl    %cl,%r12d
L45:
  cmp    %ebx,%r12d
  mov    %ebx,%r14d
  lea    D4(%rip),%rdi
  cmovbe %r12d,%r14d
  xor    %eax,%eax
  mov    %r14d,%edx
  mov    %r14d,%esi
  shl    $0xa,%edx
  call   <printf@plt>
  mov    $0xffffffff,%edx
  mov    %r15d,%esi
  mov    %rbp,%rdi
  call   <data_fill@plt>
  mov    %r13,%rsi
  mov    %r14d,%edi
  call   <block_read@plt>
  mov    %r13,%rsi
  mov    %rbp,%rdi
  call   <data_check@plt>
  cmp    %ebx,%r12d
  jb     L23
  lea    D2(%rip),%rdi
  call   <puts@plt>
  mov    0x808(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L48
  add    $0x818,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L48:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: data_tag: D16
type_guessed: string
name: unpack_data
arguments: data_tag: D4
type_guessed: string
name: unpack_data
arguments: data_tag: D2
type_guessed: string

tool: D16: Writing block %u at address %06X.


tool: D4: Reading block %u at address %06X.


tool: D2: Done.

assistant: ```c
void test_blocks(unsigned blocknum) {
  unsigned char data[1024];
  unsigned char rdata[1024];
  unsigned bn;
  int i;
  for (i = 0;; i++) {
    if (i == 0)
      bn = 0;
    else
      bn = 1 << (i - 1);
    if (bn > blocknum)
      bn = blocknum;
    printf("Writing block %u at address %06X.\n", bn, bn * 1024);
    data_fill(data, i, ~0);
    block_write(bn, data);
    if (bn == blocknum)
      break;
  }
  for (i = 0;; i++) {
    if (i == 0)
      bn = 0;
    else
      bn = 1 << (i - 1);
    if (bn > blocknum)
      bn = blocknum;
    printf("Reading block %u at address %06X.\n", bn, bn * 1024);
    data_fill(data, i, ~0);
    block_read(bn, rdata);
    data_check(data, rdata);
    if (bn == blocknum)
      break;
  }
  printf("Done.\n");
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<test_blocks>:
  endbr64
  push   %r15
  xor    %r15d,%r15d
  push   %r14
  lea    D9(%rip),%r14
  push   %r13
  push   %r12
  xor    %r12d,%r12d
  push   %rbp
  push   %rbx
  mov    %edi,%ebx
  sub    $0x818,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x808(%rsp)
  xor    %eax,%eax
  mov    %rsp,%rbp
  jmp    L35
  nopl   0x0(%rax)
L9:
  mov    %r15d,%ecx
  mov    $0x1,%r12d
  add    $0x1,%r15d
  shl    %cl,%r12d
L35:
  cmp    %ebx,%r12d
  mov    %ebx,%r13d
  mov    %r14,%rdi
  cmovbe %r12d,%r13d
  xor    %eax,%eax
  mov    %r13d,%edx
  mov    %r13d,%esi
  shl    $0xa,%edx
  call   <printf@plt>
  mov    %r15d,%esi
  mov    %rbp,%rdi
  mov    $0xffffffff,%edx
  call   <data_fill@plt>
  mov    %rbp,%rsi
  mov    %r13d,%edi
  call   <block_write@plt>
  cmp    %ebx,%r12d
  jb     L9
  xor    %r15d,%r15d
  xor    %r12d,%r12d
  lea    0x400(%rsp),%r13
  jmp    L29
  nopl   (%rax)
L10:
  mov    %r15d,%ecx
  mov    $0x1,%r12d
  add    $0x1,%r15d
  shl    %cl,%r12d
L29:
  cmp    %ebx,%r12d
  mov    %ebx,%r14d
  lea    D5(%rip),%rdi
  cmovbe %r12d,%r14d
  xor    %eax,%eax
  mov    %r14d,%edx
  mov    %r14d,%esi
  shl    $0xa,%edx
  call   <printf@plt>
  mov    $0xffffffff,%edx
  mov    %r15d,%esi
  mov    %rbp,%rdi
  call   <data_fill@plt>
  mov    %r13,%rsi
  mov    %r14d,%edi
  call   <block_read@plt>
  mov    %r13,%rsi
  mov    %rbp,%rdi
  call   <data_check@plt>
  cmp    %ebx,%r12d
  jb     L10
  lea    D10(%rip),%rdi
  call   <puts@plt>
  mov    0x808(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L19
  add    $0x818,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L19:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: label: D9
data_type: string
name: retrieve_data
arguments: label: D5
data_type: string
name: retrieve_data
arguments: label: D10
data_type: string

tool: D9: Writing block %u at address %06X.


tool: D5: Reading block %u at address %06X.


tool: D10: Done.

assistant: ```c
void test_blocks(unsigned blocknum) {
  unsigned char data[1024];
  unsigned char rdata[1024];
  unsigned bn;
  int i;
  for (i = 0;; i++) {
    if (i == 0)
      bn = 0;
    else
      bn = 1 << (i - 1);
    if (bn > blocknum)
      bn = blocknum;
    printf("Writing block %u at address %06X.\n", bn, bn * 1024);
    data_fill(data, i, ~0);
    block_write(bn, data);
    if (bn == blocknum)
      break;
  }
  for (i = 0;; i++) {
    if (i == 0)
      bn = 0;
    else
      bn = 1 << (i - 1);
    if (bn > blocknum)
      bn = blocknum;
    printf("Reading block %u at address %06X.\n", bn, bn * 1024);
    data_fill(data, i, ~0);
    block_read(bn, rdata);
    data_check(data, rdata);
    if (bn == blocknum)
      break;
  }
  printf("Done.\n");
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  lea    D16(%rip),%rax
  mov    %rax,%rdi
  call   <opendir@plt>
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L36
  lea    D35(%rip),%rax
  mov    %rax,%rdi
  call   <perror@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  jmp    L36
L33:
  mov    -0x8(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,%rsi
  lea    D17(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L36:
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <readdir@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L33
  lea    D49(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <rewinddir@plt>
  jmp    L40
L17:
  mov    -0x8(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,%rsi
  lea    D19(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L40:
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <readdir@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L17
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <closedir@plt>
  mov    $0x0,%eax
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: data_label: D16
type: string
name: disassemble_data
arguments: data_label: D35
type: string
name: disassemble_data
arguments: data_label: D17
type: string
name: disassemble_data
arguments: data_label: D49
type: string
name: disassemble_data
arguments: data_label: D19
type: string

tool: D16: ./

tool: D35: fail to open dir

tool: D17: dir name is :%s 


tool: D49: read again

tool: D19: dir name is :%s


assistant: ```c
int main(void) {
  DIR *dir;
  struct dirent *d_ptr;
  dir = opendir("./");
  if (dir == NULL) {
    perror("fail to open dir");
    exit(1);
  }
  while ((d_ptr = readdir(dir)) != NULL)
    printf("dir name is :%s \n", d_ptr->d_name);
  printf("read again\n");
  rewinddir(dir);
  while ((d_ptr = readdir(dir)) != NULL)
    printf("dir name is :%s\n", d_ptr->d_name);
  closedir(dir);
  return 0;
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<main>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  lea    D20(%rip),%rdi
  call   <opendir@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L52
L12:
  lea    D21(%rip),%rbp
  jmp    L56
L52:
  lea    D47(%rip),%rdi
  call   <perror@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  jmp    L12
L11:
  mov    (%rax),%rsi
  mov    %rbp,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L56:
  mov    %rbx,%rdi
  call   <readdir@plt>
  test   %rax,%rax
  jne    L11
  lea    D3(%rip),%rdi
  call   <puts@plt>
  mov    %rbx,%rdi
  call   <rewinddir@plt>
  lea    D24(%rip),%rbp
  jmp    L7
L13:
  mov    (%rax),%rsi
  mov    %rbp,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L7:
  mov    %rbx,%rdi
  call   <readdir@plt>
  test   %rax,%rax
  jne    L13
  mov    %rbx,%rdi
  call   <closedir@plt>
  mov    $0x0,%eax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
```

tool_calls: name: retrieve_data
arguments: tag: D20
datatype: string
name: retrieve_data
arguments: tag: D21
datatype: string
name: retrieve_data
arguments: tag: D47
datatype: string
name: retrieve_data
arguments: tag: D3
datatype: string
name: retrieve_data
arguments: tag: D24
datatype: string

tool: D20: ./

tool: D21: dir name is :%s 


tool: D47: fail to open dir

tool: D3: read again

tool: D24: dir name is :%s


assistant: ```c
int main(void) {
  DIR *dir;
  struct dirent *d_ptr;
  dir = opendir("./");
  if (dir == NULL) {
    perror("fail to open dir");
    exit(1);
  }
  while ((d_ptr = readdir(dir)) != NULL)
    printf("dir name is :%s \n", d_ptr->d_name);
  printf("read again\n");
  rewinddir(dir);
  while ((d_ptr = readdir(dir)) != NULL)
    printf("dir name is :%s\n", d_ptr->d_name);
  closedir(dir);
  return 0;
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<main>:
  endbr64
  push   %rbp
  lea    D12(%rip),%rdi
  push   %rbx
  sub    $0x8,%rsp
  call   <opendir@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L42
L39:
  lea    D4(%rip),%rbx
  jmp    L19
  nopw   0x0(%rax,%rax,1)
L11:
  mov    (%rax),%rsi
  mov    %rbx,%rdi
  xor    %eax,%eax
  call   <printf@plt>
L19:
  mov    %rbp,%rdi
  call   <readdir@plt>
  test   %rax,%rax
  jne    L11
  lea    D46(%rip),%rdi
  lea    D7(%rip),%rbx
  call   <puts@plt>
  mov    %rbp,%rdi
  call   <rewinddir@plt>
  jmp    L32
  nopw   0x0(%rax,%rax,1)
L14:
  mov    (%rax),%rsi
  mov    %rbx,%rdi
  xor    %eax,%eax
  call   <printf@plt>
L32:
  mov    %rbp,%rdi
  call   <readdir@plt>
  test   %rax,%rax
  jne    L14
  mov    %rbp,%rdi
  call   <closedir@plt>
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  ret
L42:
  lea    D27(%rip),%rdi
  call   <perror@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  jmp    L39
```

tool_calls: name: unpack_data
arguments: data_tag: D12
type_guessed: string
name: unpack_data
arguments: data_tag: D4
type_guessed: string
name: unpack_data
arguments: data_tag: D46
type_guessed: string
name: unpack_data
arguments: data_tag: D7
type_guessed: string
name: unpack_data
arguments: data_tag: D27
type_guessed: string

tool: D12: ./

tool: D4: dir name is :%s 


tool: D46: read again

tool: D7: dir name is :%s


tool: D27: fail to open dir

assistant: ```c
int main(void) {
  DIR *dir;
  struct dirent *d_ptr;
  dir = opendir("./");
  if (dir == NULL) {
    perror("fail to open dir");
    exit(1);
  }
  while ((d_ptr = readdir(dir)) != NULL)
    printf("dir name is :%s \n", d_ptr->d_name);
  printf("read again\n");
  rewinddir(dir);
  while ((d_ptr = readdir(dir)) != NULL)
    printf("dir name is :%s\n", d_ptr->d_name);
  closedir(dir);
  return 0;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<main>:
  endbr64
  push   %rbp
  lea    D47(%rip),%rdi
  push   %rbx
  sub    $0x8,%rsp
  call   <opendir@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L37
L29:
  lea    D6(%rip),%rbx
  jmp    L7
  nopw   0x0(%rax,%rax,1)
L22:
  mov    (%rax),%rsi
  mov    %rbx,%rdi
  xor    %eax,%eax
  call   <printf@plt>
L7:
  mov    %rbp,%rdi
  call   <readdir@plt>
  test   %rax,%rax
  jne    L22
  lea    D48(%rip),%rdi
  lea    D3(%rip),%rbx
  call   <puts@plt>
  mov    %rbp,%rdi
  call   <rewinddir@plt>
  jmp    L26
  nopw   0x0(%rax,%rax,1)
L15:
  mov    (%rax),%rsi
  mov    %rbx,%rdi
  xor    %eax,%eax
  call   <printf@plt>
L26:
  mov    %rbp,%rdi
  call   <readdir@plt>
  test   %rax,%rax
  jne    L15
  mov    %rbp,%rdi
  call   <closedir@plt>
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  ret
L37:
  lea    D18(%rip),%rdi
  call   <perror@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  jmp    L29
```

tool_calls: name: parse_data
arguments: tag: D47
datatype: string
name: parse_data
arguments: tag: D6
datatype: string
name: parse_data
arguments: tag: D48
datatype: string
name: parse_data
arguments: tag: D3
datatype: string
name: parse_data
arguments: tag: D18
datatype: string

tool: D47: ./

tool: D6: dir name is :%s 


tool: D48: read again

tool: D3: dir name is :%s


tool: D18: fail to open dir

assistant: ```c
int main(void) {
  DIR *dir;
  struct dirent *d_ptr;
  dir = opendir("./");
  if (dir == NULL) {
    perror("fail to open dir");
    exit(1);
  }
  while ((d_ptr = readdir(dir)) != NULL)
    printf("dir name is :%s \n", d_ptr->d_name);
  printf("read again\n");
  rewinddir(dir);
  while ((d_ptr = readdir(dir)) != NULL)
    printf("dir name is :%s\n", d_ptr->d_name);
  closedir(dir);
  return 0;
}
```
user: What is the c source code of the assembly code below:

```asm
<xyz_sock_write_to>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %edi,-0x24(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %edx,-0x28(%rbp)
  mov    %ecx,-0x34(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <FD_ZERO@plt>
  lea    -0x18(%rbp),%rdx
  mov    -0x24(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <FD_SET@plt>
  mov    -0x34(%rbp),%eax
  movslq %eax,%rdx
  imul   $0x431bde83,%rdx,%rdx
  shr    $0x20,%rdx
  sar    $0x12,%edx
  sar    $0x1f,%eax
  mov    %eax,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  mov    %eax,-0x10(%rbp)
  mov    -0x34(%rbp),%edx
  movslq %edx,%rax
  imul   $0x431bde83,%rax,%rax
  shr    $0x20,%rax
  sar    $0x12,%eax
  mov    %edx,%ecx
  sar    $0x1f,%ecx
  sub    %ecx,%eax
  imul   $0xf4240,%eax,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  mov    %eax,-0xc(%rbp)
  cmpl   $0x3ff,-0x24(%rbp)
  jle    L10
  mov    -0x28(%rbp),%edx
  mov    -0x30(%rbp),%rcx
  mov    -0x24(%rbp),%eax
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <write@plt>
  jmp    L14
L10:
  mov    -0x24(%rbp),%eax
  lea    0x1(%rax),%edi
  lea    -0x10(%rbp),%rdx
  lea    -0x18(%rbp),%rax
  mov    %rdx,%r8
  mov    $0x0,%ecx
  mov    %rax,%rdx
  mov    $0x0,%esi
  call   <select@plt>
  mov    %eax,-0x14(%rbp)
  cmpl   $0x0,-0x14(%rbp)
  jne    L33
  mov    $0x0,%eax
  jmp    L14
L33:
  cmpl   $0x1,-0x14(%rbp)
  jne    L105
  mov    -0x28(%rbp),%edx
  mov    -0x30(%rbp),%rcx
  mov    -0x24(%rbp),%eax
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <write@plt>
  jmp    L14
L105:
  cmpl   $0xffffffff,-0x14(%rbp)
  jne    L107
  mov    D7(%rip),%rax
  mov    (%rax),%rdx
  mov    D5(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  jne    L89
  mov    $0x0,%eax
  jmp    L14
L89:
  mov    $0xffffffff,%eax
  jmp    L14
L107:
  mov    $0x0,%eax
L14:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L53
  call   <__stack_chk_fail@plt>
L53:
  leave
  ret
```

assistant: ```c
int xyz_sock_write_to(int sockfd, char *data, int len, int usec) {
  fd_set wtset;
  FD_ZERO(&wtset);
  FD_SET(sockfd, &wtset);
  struct timeval tv;
  tv.tv_sec = usec / 1000000;
  tv.tv_usec = usec % 1000000;
  if (sockfd >= 1024) {
    return write(sockfd, data, len);
  }
  int n = select(sockfd + 1, NULL, &wtset, NULL, &tv);
  if (n == 0) {
    return 0;
  }
  if (n == 1) {
    return write(sockfd, data, len);
  }
  if (n == -1) {
    if (errno == EINTR) {
      return 0;
    } else {
      return -1;
    }
  }
  return 0;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<xyz_sock_write_to>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x20,%rsp
  mov    %edi,%ebp
  mov    %rsi,%r12
  mov    %edx,%r13d
  mov    %ecx,%ebx
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  lea    0xc(%rsp),%r14
  mov    %r14,%rdi
  call   <FD_ZERO@plt>
  mov    %r14,%rsi
  mov    %ebp,%edi
  call   <FD_SET@plt>
  movslq %ebx,%rax
  imul   $0x431bde83,%rax,%rax
  sar    $0x32,%rax
  mov    %ebx,%edx
  sar    $0x1f,%edx
  sub    %edx,%eax
  mov    %eax,0x10(%rsp)
  imul   $0xf4240,%eax,%eax
  sub    %eax,%ebx
  mov    %ebx,0x14(%rsp)
  cmp    $0x3ff,%ebp
  jg     L65
  lea    0xc(%rsp),%rdx
  lea    0x1(%rbp),%edi
  lea    0x10(%rsp),%r8
  mov    $0x0,%ecx
  mov    $0x0,%esi
  call   <select@plt>
  test   %eax,%eax
  je     L30
  cmp    $0x1,%eax
  je     L42
  cmp    $0xffffffff,%eax
  je     L29
  mov    $0x0,%eax
  jmp    L30
L65:
  mov    %r13d,%edx
  mov    %r12,%rsi
  mov    %ebp,%edi
  call   <write@plt>
L30:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L10
  add    $0x20,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L42:
  mov    %r13d,%edx
  mov    %r12,%rsi
  mov    %ebp,%edi
  call   <write@plt>
  jmp    L30
L29:
  mov    D15(%rip),%rdx
  mov    D7(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,(%rdx)
  setne  %al
  movzbl %al,%eax
  neg    %eax
  jmp    L30
L10:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int xyz_sock_write_to(int sockfd, char *data, int len, int usec) {
  fd_set wtset;
  FD_ZERO(&wtset);
  FD_SET(sockfd, &wtset);
  struct timeval tv;
  tv.tv_sec = usec / 1000000;
  tv.tv_usec = usec % 1000000;
  if (sockfd >= 1024) {
    return write(sockfd, data, len);
  }
  int n = select(sockfd + 1, NULL, &wtset, NULL, &tv);
  if (n == 0) {
    return 0;
  }
  if (n == 1) {
    return write(sockfd, data, len);
  }
  if (n == -1) {
    if (errno == EINTR) {
      return 0;
    } else {
      return -1;
    }
  }
  return 0;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<xyz_sock_write_to>:
  endbr64
  push   %r14
  push   %r13
  mov    %edx,%r13d
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  mov    %edi,%ebp
  push   %rbx
  mov    %ecx,%ebx
  sub    $0x20,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  lea    0xc(%rsp),%r14
  mov    %r14,%rdi
  call   <FD_ZERO@plt>
  mov    %r14,%rsi
  mov    %ebp,%edi
  call   <FD_SET@plt>
  movslq %ebx,%rax
  mov    %ebx,%edx
  imul   $0x431bde83,%rax,%rax
  sar    $0x1f,%edx
  sar    $0x32,%rax
  sub    %edx,%eax
  mov    %eax,0x10(%rsp)
  imul   $0xf4240,%eax,%eax
  sub    %eax,%ebx
  mov    %ebx,0x14(%rsp)
  cmp    $0x3ff,%ebp
  jg     L63
  xor    %ecx,%ecx
  xor    %esi,%esi
  lea    0x1(%rbp),%edi
  mov    %r14,%rdx
  lea    0x10(%rsp),%r8
  call   <select@plt>
  test   %eax,%eax
  je     L37
  cmp    $0x1,%eax
  je     L63
  cmp    $0xffffffff,%eax
  je     L19
  xor    %eax,%eax
L37:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L7
  add    $0x20,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nop
L63:
  mov    %r13d,%edx
  mov    %r12,%rsi
  mov    %ebp,%edi
  call   <write@plt>
  jmp    L37
  nop
L19:
  mov    D0(%rip),%rdx
  mov    D5(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,(%rdx)
  setne  %al
  movzbl %al,%eax
  neg    %eax
  jmp    L37
L7:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int xyz_sock_write_to(int sockfd, char *data, int len, int usec) {
  fd_set wtset;
  FD_ZERO(&wtset);
  FD_SET(sockfd, &wtset);
  struct timeval tv;
  tv.tv_sec = usec / 1000000;
  tv.tv_usec = usec % 1000000;
  if (sockfd >= 1024) {
    return write(sockfd, data, len);
  }
  int n = select(sockfd + 1, NULL, &wtset, NULL, &tv);
  if (n == 0) {
    return 0;
  }
  if (n == 1) {
    return write(sockfd, data, len);
  }
  if (n == -1) {
    if (errno == EINTR) {
      return 0;
    } else {
      return -1;
    }
  }
  return 0;
}
```