ylfeng/ReF-Decompile-dataset huggingface dataset:
user: 下面的汇编指令对应的C源代码是什么：

```asm
<insertion_sort>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  movl   $0x0,-0xc(%rbp)
  movl   $0x0,-0x8(%rbp)
  movl   $0x0,-0x4(%rbp)
  movl   $0x1,-0x8(%rbp)
  jmp    L19
L0:
  mov    -0x8(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x8(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0xc(%rbp)
  jmp    L35
L9:
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    -0xc(%rbp),%edx
  movslq %edx,%rdx
  add    $0x1,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x18(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%eax
  mov    %eax,(%rdx)
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  mov    -0x4(%rbp),%eax
  mov    %eax,(%rdx)
  subl   $0x1,-0xc(%rbp)
L35:
  cmpl   $0x0,-0xc(%rbp)
  js     L11
  mov    -0xc(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x18(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  cmp    %eax,%edx
  jl     L9
L11:
  addl   $0x1,-0x8(%rbp)
L19:
  mov    -0x8(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jl     L0
  nop
  pop    %rbp
  ret
```

assistant: ```c
void insertion_sort(int *array, int size) {
  int i = 0, j = 0, key = 0;
  for (j = 1; j < size; j++) {
    key = *(array + j);
    i = j - 1;
    while (i >= 0 && *(array + i + 1) < *(array + i)) {
      *(array + i + 1) = *(array + i);
      *(array + i) = key;
      i--;
    }
  }
  return;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<insertion_sort>:
  endbr64
  cmp    $0x1,%esi
  jle    L68
  add    $0x4,%rdi
  lea    -0x1(%rsi),%r9d
  mov    $0x0,%r8d
  jmp    L52
L0:
  add    $0x1,%r8
  add    $0x4,%rdi
  cmp    %r9,%r8
  je     L68
L52:
  mov    (%rdi),%esi
  test   %r8d,%r8d
  js     L0
  lea    -0x4(%rdi),%rax
  lea    -0x8(%rdi),%rcx
  lea    0x0(,%r8,4),%rdx
  sub    %rdx,%rcx
L57:
  mov    (%rax),%edx
  cmp    %edx,0x4(%rax)
  jge    L0
  mov    %edx,0x4(%rax)
  mov    %esi,(%rax)
  sub    $0x4,%rax
  cmp    %rcx,%rax
  jne    L57
  jmp    L0
L68:
  ret
```

assistant: ```c
void insertion_sort(int *array, int size) {
  int i = 0, j = 0, key = 0;
  for (j = 1; j < size; j++) {
    key = *(array + j);
    i = j - 1;
    while (i >= 0 && *(array + i + 1) < *(array + i)) {
      *(array + i + 1) = *(array + i);
      *(array + i) = key;
      i--;
    }
  }
  return;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<insertion_sort>:
  endbr64
  cmp    $0x1,%esi
  jle    L16
  add    $0x4,%rdi
  lea    -0x1(%rsi),%r9d
  xor    %r8d,%r8d
  nopl   0x0(%rax)
L8:
  lea    -0x8(%rdi),%rcx
  lea    0x0(,%r8,4),%rdx
  mov    (%rdi),%esi
  lea    -0x4(%rdi),%rax
  sub    %rdx,%rcx
  nopl   (%rax)
L11:
  mov    (%rax),%edx
  cmp    %edx,0x4(%rax)
  jge    L1
  mov    %edx,0x4(%rax)
  sub    $0x4,%rax
  mov    %esi,0x4(%rax)
  cmp    %rax,%rcx
  jne    L11
L1:
  add    $0x1,%r8
  add    $0x4,%rdi
  cmp    %r9,%r8
  jne    L8
  ret
L16:
  ret
```

assistant: ```c
void insertion_sort(int *array, int size) {
  int i = 0, j = 0, key = 0;
  for (j = 1; j < size; j++) {
    key = *(array + j);
    i = j - 1;
    while (i >= 0 && *(array + i + 1) < *(array + i)) {
      *(array + i + 1) = *(array + i);
      *(array + i) = key;
      i--;
    }
  }
  return;
}
```
user: Translate the below assembly code into C programming language:

```asm
<insertion_sort>:
  endbr64
  cmp    $0x1,%esi
  jle    L9
  lea    -0x1(%rsi),%r8d
  add    $0x4,%rdi
  xor    %esi,%esi
  nopl   0x0(%rax,%rax,1)
L25:
  lea    -0x8(%rdi),%rcx
  lea    0x0(,%rsi,4),%rdx
  movd   (%rdi),%xmm1
  lea    -0x4(%rdi),%rax
  sub    %rdx,%rcx
  nop
L24:
  mov    (%rax),%edx
  movdqa %xmm1,%xmm0
  movd   %edx,%xmm2
  punpckldq %xmm2,%xmm0
  cmp    %edx,0x4(%rax)
  jge    L35
  movq   %xmm0,(%rax)
  sub    $0x4,%rax
  cmp    %rcx,%rax
  jne    L24
L35:
  add    $0x1,%rsi
  add    $0x4,%rdi
  cmp    %r8,%rsi
  jne    L25
  ret
L9:
  ret
```

assistant: ```c
void insertion_sort(int *array, int size) {
  int i = 0, j = 0, key = 0;
  for (j = 1; j < size; j++) {
    key = *(array + j);
    i = j - 1;
    while (i >= 0 && *(array + i + 1) < *(array + i)) {
      *(array + i + 1) = *(array + i);
      *(array + i) = key;
      i--;
    }
  }
  return;
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<xxtea_decrypt>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x140,%rsp
  mov    %rdi,-0x118(%rbp)
  mov    %rsi,-0x120(%rbp)
  mov    %rdx,-0x128(%rbp)
  mov    %rcx,-0x130(%rbp)
  mov    %r8,-0x138(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x138(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,%esi
  lea    -0x110(%rbp),%rdx
  mov    -0x138(%rbp),%rax
  mov    $0x100,%ecx
  mov    %rax,%rdi
  call   <xxtea_to_key_array@plt>
  lea    -0x110(%rbp),%rdi
  mov    -0x130(%rbp),%rcx
  mov    -0x128(%rbp),%rdx
  mov    -0x120(%rbp),%rsi
  mov    -0x118(%rbp),%rax
  mov    %rdi,%r8
  mov    %rax,%rdi
  call   <xxtea_ubyte_decrypt@plt>
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L8
  call   <__stack_chk_fail@plt>
L8:
  leave
  ret
```

assistant: ```c
size_t xxtea_decrypt(const void *data, size_t len, uint8_t *out, size_t out_size, const char *key) {
  uint32_t key_array[64];
  xxtea_to_key_array(key, strlen(key), key_array, sizeof(key_array));
  return xxtea_ubyte_decrypt((const uint8_t *)data, len, out, out_size, key_array);
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<xxtea_decrypt>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x118,%rsp
  mov    %rdi,%rbp
  mov    %rsi,%r12
  mov    %rdx,%r13
  mov    %rcx,%r14
  mov    %r8,%rbx
  mov    %fs:0x28,%rax
  mov    %rax,0x108(%rsp)
  xor    %eax,%eax
  mov    %r8,%rdi
  call   <strlen@plt>
  mov    %eax,%esi
  mov    %rsp,%r15
  mov    $0x100,%ecx
  mov    %r15,%rdx
  mov    %rbx,%rdi
  call   <xxtea_to_key_array@plt>
  mov    %r15,%r8
  mov    %r14,%rcx
  mov    %r13,%rdx
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <xxtea_ubyte_decrypt@plt>
  mov    0x108(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L1
  add    $0x118,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L1:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
size_t xxtea_decrypt(const void *data, size_t len, uint8_t *out, size_t out_size, const char *key) {
  uint32_t key_array[64];
  xxtea_to_key_array(key, strlen(key), key_array, sizeof(key_array));
  return xxtea_ubyte_decrypt((const uint8_t *)data, len, out, out_size, key_array);
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<xxtea_decrypt>:
  endbr64
  push   %r15
  mov    %rcx,%r15
  push   %r14
  mov    %rdx,%r14
  push   %r13
  mov    %rsi,%r13
  push   %r12
  mov    %rdi,%r12
  mov    %r8,%rdi
  push   %rbp
  mov    %r8,%rbp
  push   %rbx
  sub    $0x118,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x108(%rsp)
  xor    %eax,%eax
  mov    %rsp,%rbx
  call   <strlen@plt>
  mov    $0x100,%ecx
  mov    %rbx,%rdx
  mov    %rbp,%rdi
  mov    %eax,%esi
  call   <xxtea_to_key_array@plt>
  mov    %r14,%rdx
  mov    %rbx,%r8
  mov    %r15,%rcx
  mov    %r13,%rsi
  mov    %r12,%rdi
  call   <xxtea_ubyte_decrypt@plt>
  mov    0x108(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L5
  add    $0x118,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L5:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
size_t xxtea_decrypt(const void *data, size_t len, uint8_t *out, size_t out_size, const char *key) {
  uint32_t key_array[64];
  xxtea_to_key_array(key, strlen(key), key_array, sizeof(key_array));
  return xxtea_ubyte_decrypt((const uint8_t *)data, len, out, out_size, key_array);
}
```
user: 这段汇编代码用C语言表示是什么样的?

```asm
<xxtea_decrypt>:
  endbr64
  push   %r15
  mov    %rcx,%r15
  push   %r14
  mov    %rdx,%r14
  push   %r13
  mov    %rsi,%r13
  push   %r12
  mov    %rdi,%r12
  mov    %r8,%rdi
  push   %rbp
  mov    %r8,%rbp
  push   %rbx
  sub    $0x118,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x108(%rsp)
  xor    %eax,%eax
  mov    %rsp,%rbx
  call   <strlen@plt>
  mov    $0x100,%ecx
  mov    %rbx,%rdx
  mov    %rbp,%rdi
  mov    %eax,%esi
  call   <xxtea_to_key_array@plt>
  mov    %r14,%rdx
  mov    %rbx,%r8
  mov    %r15,%rcx
  mov    %r13,%rsi
  mov    %r12,%rdi
  call   <xxtea_ubyte_decrypt@plt>
  mov    0x108(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L1
  add    $0x118,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L1:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
size_t xxtea_decrypt(const void *data, size_t len, uint8_t *out, size_t out_size, const char *key) {
  uint32_t key_array[64];
  xxtea_to_key_array(key, strlen(key), key_array, sizeof(key_array));
  return xxtea_ubyte_decrypt((const uint8_t *)data, len, out, out_size, key_array);
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<unicode_write_utf16_with_endianness>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %edi,-0x24(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %edx,-0x28(%rbp)
  cmpl   $0xffff,-0x24(%rbp)
  jg     L6
  cmpl   $0x0,-0x28(%rbp)
  sete   %al
  movzbl %al,%edx
  mov    -0x24(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <unicode_reverse_byte_order_utf16@plt>
  mov    -0x30(%rbp),%rdx
  mov    %eax,(%rdx)
  mov    $0x2,%eax
  jmp    L5
L6:
  mov    -0x24(%rbp),%eax
  sub    $0x10000,%eax
  mov    %eax,-0x14(%rbp)
  cmpl   $0x0,-0x28(%rbp)
  sete   %al
  movzbl %al,%eax
  mov    -0x14(%rbp),%edx
  sar    $0xa,%edx
  and    $0x3ff,%edx
  or     $0xd8,%dh
  mov    %eax,%esi
  mov    %edx,%edi
  call   <unicode_reverse_byte_order_utf16@plt>
  mov    -0x30(%rbp),%rdx
  mov    %eax,(%rdx)
  cmpl   $0x0,-0x28(%rbp)
  sete   %al
  movzbl %al,%eax
  mov    -0x14(%rbp),%edx
  and    $0x3ff,%edx
  or     $0xdc,%dh
  mov    -0x30(%rbp),%rcx
  lea    0x2(%rcx),%rbx
  mov    %eax,%esi
  mov    %edx,%edi
  call   <unicode_reverse_byte_order_utf16@plt>
  mov    %eax,(%rbx)
  mov    $0x4,%eax
L5:
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

assistant: ```c
int unicode_write_utf16_with_endianness(uint32_t code_point, char *string, bool system_endianness) {
  if (code_point <= 0xFFFF) {
    *((uint16_t *)string) = unicode_reverse_byte_order_utf16(code_point, !system_endianness);
    return 2;
  } else {
    uint32_t de_aug = code_point - 0x10000;
    *((uint16_t *)string) = unicode_reverse_byte_order_utf16((((uint16_t)(de_aug >> 10)) & 0x3FF) | 0xD800, !system_endianness);
    *((uint16_t *)&string[2]) = unicode_reverse_byte_order_utf16((((uint16_t)de_aug) & 0x3FF) | 0xDC00, !system_endianness);
    return 4;
  }
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<unicode_write_utf16_with_endianness>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rsi,%rbp
  cmp    $0xffff,%edi
  jg     L5
  test   %edx,%edx
  sete   %sil
  movzbl %sil,%esi
  call   <unicode_reverse_byte_order_utf16@plt>
  mov    %eax,0x0(%rbp)
  mov    $0x2,%eax
L18:
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L5:
  lea    -0x10000(%rdi),%ebx
  test   %edx,%edx
  sete   %r12b
  movzbl %r12b,%r12d
  mov    %ebx,%edi
  sar    $0xa,%edi
  and    $0x3ff,%edi
  or     $0xd800,%edi
  mov    %r12d,%esi
  call   <unicode_reverse_byte_order_utf16@plt>
  mov    %eax,0x0(%rbp)
  and    $0x3ff,%ebx
  mov    %ebx,%edi
  or     $0xdc00,%edi
  mov    %r12d,%esi
  call   <unicode_reverse_byte_order_utf16@plt>
  mov    %eax,0x2(%rbp)
  mov    $0x4,%eax
  jmp    L18
```

assistant: ```c
int unicode_write_utf16_with_endianness(uint32_t code_point, char *string, bool system_endianness) {
  if (code_point <= 0xFFFF) {
    *((uint16_t *)string) = unicode_reverse_byte_order_utf16(code_point, !system_endianness);
    return 2;
  } else {
    uint32_t de_aug = code_point - 0x10000;
    *((uint16_t *)string) = unicode_reverse_byte_order_utf16((((uint16_t)(de_aug >> 10)) & 0x3FF) | 0xD800, !system_endianness);
    *((uint16_t *)&string[2]) = unicode_reverse_byte_order_utf16((((uint16_t)de_aug) & 0x3FF) | 0xDC00, !system_endianness);
    return 4;
  }
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<unicode_write_utf16_with_endianness>:
  endbr64
  push   %r12
  xor    %r12d,%r12d
  test   %edx,%edx
  push   %rbp
  sete   %r12b
  mov    %rsi,%rbp
  push   %rbx
  cmp    $0xffff,%edi
  jg     L3
  mov    %r12d,%esi
  call   <unicode_reverse_byte_order_utf16@plt>
  pop    %rbx
  mov    %eax,0x0(%rbp)
  mov    $0x2,%eax
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax)
L3:
  lea    -0x10000(%rdi),%ebx
  mov    %r12d,%esi
  mov    %ebx,%edi
  and    $0x3ff,%ebx
  sar    $0xa,%edi
  and    $0x3ff,%edi
  or     $0xd800,%edi
  call   <unicode_reverse_byte_order_utf16@plt>
  mov    %ebx,%edi
  mov    %r12d,%esi
  mov    %eax,0x0(%rbp)
  or     $0xdc00,%edi
  call   <unicode_reverse_byte_order_utf16@plt>
  pop    %rbx
  mov    %eax,0x2(%rbp)
  mov    $0x4,%eax
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
int unicode_write_utf16_with_endianness(uint32_t code_point, char *string, bool system_endianness) {
  if (code_point <= 0xFFFF) {
    *((uint16_t *)string) = unicode_reverse_byte_order_utf16(code_point, !system_endianness);
    return 2;
  } else {
    uint32_t de_aug = code_point - 0x10000;
    *((uint16_t *)string) = unicode_reverse_byte_order_utf16((((uint16_t)(de_aug >> 10)) & 0x3FF) | 0xD800, !system_endianness);
    *((uint16_t *)&string[2]) = unicode_reverse_byte_order_utf16((((uint16_t)de_aug) & 0x3FF) | 0xDC00, !system_endianness);
    return 4;
  }
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<unicode_write_utf16_with_endianness>:
  endbr64
  push   %r12
  xor    %r12d,%r12d
  test   %edx,%edx
  push   %rbp
  sete   %r12b
  mov    %rsi,%rbp
  push   %rbx
  cmp    $0xffff,%edi
  jg     L4
  mov    %r12d,%esi
  call   <unicode_reverse_byte_order_utf16@plt>
  pop    %rbx
  mov    %eax,0x0(%rbp)
  mov    $0x2,%eax
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax)
L4:
  lea    -0x10000(%rdi),%ebx
  mov    %r12d,%esi
  mov    %ebx,%edi
  and    $0x3ff,%ebx
  sar    $0xa,%edi
  and    $0x3ff,%edi
  or     $0xd800,%edi
  call   <unicode_reverse_byte_order_utf16@plt>
  mov    %ebx,%edi
  mov    %r12d,%esi
  mov    %eax,0x0(%rbp)
  or     $0xdc00,%edi
  call   <unicode_reverse_byte_order_utf16@plt>
  pop    %rbx
  mov    %eax,0x2(%rbp)
  mov    $0x4,%eax
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
int unicode_write_utf16_with_endianness(uint32_t code_point, char *string, bool system_endianness) {
  if (code_point <= 0xFFFF) {
    *((uint16_t *)string) = unicode_reverse_byte_order_utf16(code_point, !system_endianness);
    return 2;
  } else {
    uint32_t de_aug = code_point - 0x10000;
    *((uint16_t *)string) = unicode_reverse_byte_order_utf16((((uint16_t)(de_aug >> 10)) & 0x3FF) | 0xD800, !system_endianness);
    *((uint16_t *)&string[2]) = unicode_reverse_byte_order_utf16((((uint16_t)de_aug) & 0x3FF) | 0xDC00, !system_endianness);
    return 4;
  }
}
```
user: What is the c source code of the assembly code below:

```asm
<slave_update>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    D24(%rip),%rax
  mov    (%rax),%eax
  mov    $0x0,%esi
  mov    %eax,%edi
  call   <slave_set_blocking_io@plt>
  mov    D24(%rip),%rax
  mov    (%rax),%edx
  lea    -0x10(%rbp),%rax
  mov    %edx,%ecx
  mov    $0x1,%edx
  mov    $0x4,%esi
  mov    %rax,%rdi
  call   <fread@plt>
  mov    %eax,-0xc(%rbp)
  mov    D24(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,%edi
  call   <feof@plt>
  test   %rax,%rax
  jne    L50
  cmpl   $0x0,-0xc(%rbp)
  jg     L52
  mov    D10(%rip),%rax
  mov    (%rax),%rdx
  mov    D12(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  je     L7
L52:
  cmpl   $0x1,-0xc(%rbp)
  sete   %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  mov    D24(%rip),%rax
  mov    (%rax),%eax
  mov    $0x1,%esi
  mov    %eax,%edi
  call   <slave_set_blocking_io@plt>
  mov    -0x10(%rbp),%eax
  mov    %eax,%edi
  call   <slave_exec@plt>
  mov    $0x0,%edi
  call   <fflush@plt>
  jmp    L58
L50:
  nop
  jmp    L58
L7:
  nop
L58:
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L19
  call   <__stack_chk_fail@plt>
L19:
  leave
  ret
```

assistant: ```c
void slave_update() {
  slave_set_blocking_io(stdin, 0);
  int ret;
  int command_id;
  ret = (fread(&command_id, sizeof(*&command_id), 1, stdin));
  if (feof(stdin)) {
    return;
  }
  if (ret <= 0 && errno == EWOULDBLOCK) {
    return;
  }
  assert(ret == 1);
  slave_set_blocking_io(stdin, 1);
  slave_exec(command_id);
  fflush(0);
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<slave_update>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  mov    D1(%rip),%rbp
  mov    $0x0,%esi
  mov    0x0(%rbp),%edi
  call   <slave_set_blocking_io@plt>
  lea    0x4(%rsp),%rdi
  mov    0x0(%rbp),%ecx
  mov    $0x1,%edx
  mov    $0x4,%esi
  call   <fread@plt>
  mov    %eax,%ebx
  mov    0x0(%rbp),%edi
  call   <feof@plt>
  test   %rax,%rax
  jne    L17
  test   %ebx,%ebx
  jg     L18
  mov    D29(%rip),%rdx
  mov    D37(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,(%rdx)
  je     L17
L18:
  cmp    $0x1,%ebx
  sete   %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    $0x1,%esi
  mov    D1(%rip),%rax
  mov    (%rax),%edi
  call   <slave_set_blocking_io@plt>
  mov    0x4(%rsp),%edi
  call   <slave_exec@plt>
  mov    $0x0,%edi
  call   <fflush@plt>
L17:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L1
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  ret
L1:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void slave_update() {
  slave_set_blocking_io(stdin, 0);
  int ret;
  int command_id;
  ret = (fread(&command_id, sizeof(*&command_id), 1, stdin));
  if (feof(stdin)) {
    return;
  }
  if (ret <= 0 && errno == EWOULDBLOCK) {
    return;
  }
  assert(ret == 1);
  slave_set_blocking_io(stdin, 1);
  slave_exec(command_id);
  fflush(0);
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<slave_update>:
  endbr64
  push   %rbp
  xor    %esi,%esi
  push   %rbx
  sub    $0x18,%rsp
  mov    D14(%rip),%rbx
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  mov    (%rbx),%edi
  call   <slave_set_blocking_io@plt>
  mov    (%rbx),%ecx
  lea    0x4(%rsp),%rdi
  mov    $0x1,%edx
  mov    $0x4,%esi
  call   <fread@plt>
  mov    (%rbx),%edi
  mov    %eax,%ebp
  call   <feof@plt>
  test   %rax,%rax
  jne    L20
  test   %ebp,%ebp
  jg     L5
  mov    D6(%rip),%rax
  mov    D29(%rip),%rdx
  mov    (%rax),%rax
  cmp    %rax,(%rdx)
  je     L20
L5:
  xor    %edi,%edi
  cmp    $0x1,%ebp
  sete   %dil
  call   <assert@plt>
  mov    (%rbx),%edi
  mov    $0x1,%esi
  call   <slave_set_blocking_io@plt>
  mov    0x4(%rsp),%edi
  call   <slave_exec@plt>
  xor    %edi,%edi
  call   <fflush@plt>
L20:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L0
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  ret
L0:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void slave_update() {
  slave_set_blocking_io(stdin, 0);
  int ret;
  int command_id;
  ret = (fread(&command_id, sizeof(*&command_id), 1, stdin));
  if (feof(stdin)) {
    return;
  }
  if (ret <= 0 && errno == EWOULDBLOCK) {
    return;
  }
  assert(ret == 1);
  slave_set_blocking_io(stdin, 1);
  slave_exec(command_id);
  fflush(0);
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<slave_update>:
  endbr64
  push   %rbp
  xor    %esi,%esi
  push   %rbx
  sub    $0x18,%rsp
  mov    D6(%rip),%rbx
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  mov    (%rbx),%edi
  call   <slave_set_blocking_io@plt>
  mov    (%rbx),%ecx
  lea    0x4(%rsp),%rdi
  mov    $0x1,%edx
  mov    $0x4,%esi
  call   <fread@plt>
  mov    (%rbx),%edi
  mov    %eax,%ebp
  call   <feof@plt>
  test   %rax,%rax
  jne    L3
  test   %ebp,%ebp
  jg     L8
  mov    D2(%rip),%rax
  mov    D9(%rip),%rdx
  mov    (%rax),%rax
  cmp    %rax,(%rdx)
  je     L3
L8:
  xor    %edi,%edi
  cmp    $0x1,%ebp
  sete   %dil
  call   <assert@plt>
  mov    (%rbx),%edi
  mov    $0x1,%esi
  call   <slave_set_blocking_io@plt>
  mov    0x4(%rsp),%edi
  call   <slave_exec@plt>
  xor    %edi,%edi
  call   <fflush@plt>
L3:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L36
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  ret
L36:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void slave_update() {
  slave_set_blocking_io(stdin, 0);
  int ret;
  int command_id;
  ret = (fread(&command_id, sizeof(*&command_id), 1, stdin));
  if (feof(stdin)) {
    return;
  }
  if (ret <= 0 && errno == EWOULDBLOCK) {
    return;
  }
  assert(ret == 1);
  slave_set_blocking_io(stdin, 1);
  slave_exec(command_id);
  fflush(0);
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<semap_wait>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %edi,-0x34(%rbp)
  mov    %esi,-0x38(%rbp)
  mov    %edx,-0x3c(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x38(%rbp),%eax
  mov    %eax,-0x20(%rbp)
  mov    -0x3c(%rbp),%eax
  neg    %eax
  mov    %eax,-0x1c(%rbp)
  movq   $0x0,-0x18(%rbp)
  lea    -0x20(%rbp),%rcx
  mov    -0x34(%rbp),%eax
  mov    $0x1,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <semop@plt>
  mov    %eax,-0x24(%rbp)
  cmpl   $0xffffffff,-0x24(%rbp)
  jne    L17
  mov    D0(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,%esi
  mov    $0x0,%edi
  call   <kill@plt>
L17:
  mov    -0x24(%rbp),%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L18
  call   <__stack_chk_fail@plt>
L18:
  leave
  ret
```

assistant: ```c
int semap_wait(int sem_id, int nsem, int cnt) {
  struct sembuf op[1];
  op[0].sem_num = nsem;
  op[0].sem_op = -cnt;
  op[0].sem_flg = 0;
  int ret;
  ret = semop(sem_id, op, 1);
  if (ret == -1) {
    kill(0, SIGINT);
  }
  return ret;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<semap_wait>:
  endbr64
  push   %rbx
  sub    $0x20,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  mov    %esi,(%rsp)
  neg    %edx
  mov    %edx,0x4(%rsp)
  movq   $0x0,0x8(%rsp)
  mov    %rsp,%rsi
  mov    $0x1,%edx
  call   <semop@plt>
  mov    %eax,%ebx
  cmp    $0xffffffff,%eax
  je     L24
L0:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L2
  mov    %ebx,%eax
  add    $0x20,%rsp
  pop    %rbx
  ret
L24:
  mov    D0(%rip),%rax
  mov    (%rax),%esi
  mov    $0x0,%edi
  call   <kill@plt>
  jmp    L0
L2:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int semap_wait(int sem_id, int nsem, int cnt) {
  struct sembuf op[1];
  op[0].sem_num = nsem;
  op[0].sem_op = -cnt;
  op[0].sem_flg = 0;
  int ret;
  ret = semop(sem_id, op, 1);
  if (ret == -1) {
    kill(0, SIGINT);
  }
  return ret;
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<semap_wait>:
  endbr64
  push   %r12
  neg    %edx
  sub    $0x20,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  mov    %esi,(%rsp)
  mov    %rsp,%rsi
  mov    %edx,0x4(%rsp)
  mov    $0x1,%edx
  movq   $0x0,0x8(%rsp)
  call   <semop@plt>
  mov    %eax,%r12d
  cmp    $0xffffffff,%eax
  je     L19
L27:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L23
  add    $0x20,%rsp
  mov    %r12d,%eax
  pop    %r12
  ret
  nopl   0x0(%rax,%rax,1)
L19:
  mov    D6(%rip),%rax
  xor    %edi,%edi
  mov    (%rax),%esi
  call   <kill@plt>
  jmp    L27
L23:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int semap_wait(int sem_id, int nsem, int cnt) {
  struct sembuf op[1];
  op[0].sem_num = nsem;
  op[0].sem_op = -cnt;
  op[0].sem_flg = 0;
  int ret;
  ret = semop(sem_id, op, 1);
  if (ret == -1) {
    kill(0, SIGINT);
  }
  return ret;
}
```