ylfeng/ReF-Decompile-dataset huggingface dataset:
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<srec_get_hex8>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    -0xa(%rbp),%rdx
  mov    -0x18(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <srec_get_hex4@plt>
  test   %rax,%rax
  jne    L5
  lea    -0x9(%rbp),%rdx
  mov    -0x18(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <srec_get_hex4@plt>
  test   %rax,%rax
  je     L26
L5:
  mov    $0x1,%eax
  jmp    L7
L26:
  movzbl -0xa(%rbp),%eax
  movzbl %al,%eax
  shl    $0x4,%eax
  mov    %eax,%edx
  movzbl -0x9(%rbp),%eax
  and    $0xf,%eax
  or     %edx,%eax
  mov    %eax,%edx
  mov    -0x20(%rbp),%rax
  mov    %dl,(%rax)
  mov    $0x0,%eax
L7:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L24
  call   <__stack_chk_fail@plt>
L24:
  leave
  ret
```

assistant: ```c
int srec_get_hex8(FILE *fp, unsigned char *val) {
  unsigned char v1, v2;
  if (srec_get_hex4(fp, &v1) || srec_get_hex4(fp, &v2)) {
    return (1);
  }
  *val = ((v1 & 0x0f) << 4) | (v2 & 0x0f);
  return (0);
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<srec_get_hex8>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%rbx
  mov    %rsi,%rbp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    0x6(%rsp),%rsi
  call   <srec_get_hex4@plt>
  mov    %rax,%rdx
  mov    $0x1,%eax
  test   %rdx,%rdx
  je     L25
L20:
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L32
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  ret
L25:
  lea    0x7(%rsp),%rsi
  mov    %rbx,%rdi
  call   <srec_get_hex4@plt>
  mov    %rax,%rdx
  mov    $0x1,%eax
  test   %rdx,%rdx
  jne    L20
  movzbl 0x6(%rsp),%edx
  shl    $0x4,%edx
  movzbl 0x7(%rsp),%eax
  and    $0xf,%eax
  or     %edx,%eax
  mov    %al,0x0(%rbp)
  mov    $0x0,%eax
  jmp    L20
L32:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int srec_get_hex8(FILE *fp, unsigned char *val) {
  unsigned char v1, v2;
  if (srec_get_hex4(fp, &v1) || srec_get_hex4(fp, &v2)) {
    return (1);
  }
  *val = ((v1 & 0x0f) << 4) | (v2 & 0x0f);
  return (0);
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<srec_get_hex8>:
  endbr64
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  mov    %rsi,%rbx
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    0x6(%rsp),%rsi
  call   <srec_get_hex4@plt>
  test   %rax,%rax
  je     L15
L33:
  mov    $0x1,%eax
L20:
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L8
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  ret
  nopl   0x0(%rax,%rax,1)
L15:
  lea    0x7(%rsp),%rsi
  mov    %rbp,%rdi
  call   <srec_get_hex4@plt>
  test   %rax,%rax
  jne    L33
  movzbl 0x6(%rsp),%edx
  movzbl 0x7(%rsp),%eax
  shl    $0x4,%edx
  and    $0xf,%eax
  or     %edx,%eax
  mov    %al,(%rbx)
  xor    %eax,%eax
  jmp    L20
L8:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int srec_get_hex8(FILE *fp, unsigned char *val) {
  unsigned char v1, v2;
  if (srec_get_hex4(fp, &v1) || srec_get_hex4(fp, &v2)) {
    return (1);
  }
  *val = ((v1 & 0x0f) << 4) | (v2 & 0x0f);
  return (0);
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<srec_get_hex8>:
  endbr64
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  mov    %rsi,%rbx
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    0x6(%rsp),%rsi
  call   <srec_get_hex4@plt>
  test   %rax,%rax
  je     L0
L30:
  mov    $0x1,%eax
L21:
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L14
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  ret
  nopl   0x0(%rax,%rax,1)
L0:
  lea    0x7(%rsp),%rsi
  mov    %rbp,%rdi
  call   <srec_get_hex4@plt>
  test   %rax,%rax
  jne    L30
  movzbl 0x6(%rsp),%edx
  movzbl 0x7(%rsp),%eax
  shl    $0x4,%edx
  and    $0xf,%eax
  or     %edx,%eax
  mov    %al,(%rbx)
  xor    %eax,%eax
  jmp    L21
L14:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int srec_get_hex8(FILE *fp, unsigned char *val) {
  unsigned char v1, v2;
  if (srec_get_hex4(fp, &v1) || srec_get_hex4(fp, &v2)) {
    return (1);
  }
  *val = ((v1 & 0x0f) << 4) | (v2 & 0x0f);
  return (0);
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<IsArgPresent>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %rdx,-0x28(%rbp)
  movl   $0x0,-0x4(%rbp)
  movl   $0x1,-0x8(%rbp)
  jmp    L46
L44:
  mov    -0x8(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x28(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  jne    L3
  addl   $0x1,-0x8(%rbp)
  jmp    L38
L16:
  mov    -0x8(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  mov    -0x8(%rbp),%edx
  movslq %edx,%rdx
  shl    $0x3,%rdx
  lea    -0x8(%rdx),%rcx
  mov    -0x20(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%rax
  mov    %rax,(%rdx)
  addl   $0x1,-0x8(%rbp)
L38:
  mov    -0x18(%rbp),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x8(%rbp)
  jl     L16
  mov    -0x18(%rbp),%rax
  mov    (%rax),%eax
  lea    -0x1(%rax),%edx
  mov    -0x18(%rbp),%rax
  mov    %edx,(%rax)
  subl   $0x1,-0x8(%rbp)
  movl   $0x1,-0x4(%rbp)
L3:
  addl   $0x1,-0x8(%rbp)
L46:
  mov    -0x18(%rbp),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x8(%rbp)
  jl     L44
  mov    -0x4(%rbp),%eax
  leave
  ret
```

assistant: ```c
IsArgPresent(argc, argv, switchName) int *argc;
char **argv, *switchName;
{
  int i, returnVal;
  returnVal = 0;
  for (i = 1; i < *argc; i++) {
    if (!strcmp(switchName, argv[i])) {
      for (i++; i < *argc; i++) {
        argv[i - 1] = argv[i];
      }
      (*argc)--;
      i--;
      returnVal = 1;
    }
  }
  return returnVal;
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<IsArgPresent>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  cmpl   $0x1,(%rdi)
  jle    L2
  mov    %rdi,%rbp
  mov    %rsi,%r12
  mov    %rdx,%r13
  movl   $0x0,0xc(%rsp)
  mov    $0x1,%ebx
  mov    $0x1,%r15d
  jmp    L10
L25:
  sub    $0x1,%edx
  mov    %edx,0x0(%rbp)
  sub    $0x1,%ebx
  mov    %r15d,0xc(%rsp)
L51:
  add    $0x1,%ebx
  cmp    %ebx,0x0(%rbp)
  jle    L67
L10:
  movslq %ebx,%rax
  lea    0x0(,%rax,8),%r14
  mov    (%r12,%rax,8),%rsi
  mov    %r13,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  jne    L51
  add    $0x1,%ebx
  mov    0x0(%rbp),%edx
  cmp    %edx,%ebx
  jge    L25
  lea    0x8(%r12,%r14,1),%rax
L17:
  mov    (%rax),%rdx
  mov    %rdx,-0x8(%rax)
  add    $0x1,%ebx
  mov    0x0(%rbp),%edx
  add    $0x8,%rax
  cmp    %ebx,%edx
  jg     L17
  jmp    L25
L2:
  movl   $0x0,0xc(%rsp)
L67:
  mov    0xc(%rsp),%eax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
IsArgPresent(argc, argv, switchName) int *argc;
char **argv, *switchName;
{
  int i, returnVal;
  returnVal = 0;
  for (i = 1; i < *argc; i++) {
    if (!strcmp(switchName, argv[i])) {
      for (i++; i < *argc; i++) {
        argv[i - 1] = argv[i];
      }
      (*argc)--;
      i--;
      returnVal = 1;
    }
  }
  return returnVal;
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<IsArgPresent>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    (%rdi),%r15d
  mov    %rdi,(%rsp)
  cmp    $0x1,%r15d
  jle    L45
  movl   $0x0,0xc(%rsp)
  mov    %rsi,%r12
  mov    %rdx,%r14
  mov    $0x1,%ebx
  jmp    L28
  nopl   0x0(%rax,%rax,1)
L24:
  mov    (%rsp),%rax
  mov    %r8d,%ebx
  mov    (%rax),%r15d
  cmp    %ebx,%r15d
  jle    L58
L28:
  movslq %ebx,%rbp
  mov    %r14,%rdi
  shl    $0x3,%rbp
  lea    (%r12,%rbp,1),%r13
  mov    0x0(%r13),%rsi
  call   <strcmp@plt>
  lea    0x1(%rbx),%r8d
  test   %eax,%eax
  jne    L24
  cmp    %r8d,%r15d
  jle    L69
  lea    -0x2(%r15),%eax
  lea    0x8(%r12,%rbp,1),%rsi
  mov    %r13,%rdi
  mov    %r8d,0xc(%rsp)
  sub    %ebx,%eax
  lea    0x8(,%rax,8),%rdx
  call   <memmove@plt>
  mov    0xc(%rsp),%r8d
  lea    -0x1(%r15),%ecx
  add    %ecx,%r8d
  sub    %ebx,%r8d
  mov    %r8d,%ebx
L61:
  mov    (%rsp),%rax
  mov    %ecx,%r15d
  movl   $0x1,0xc(%rsp)
  mov    %ecx,(%rax)
  cmp    %ebx,%r15d
  jg     L28
L58:
  mov    0xc(%rsp),%eax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  xchg   %ax,%ax
L69:
  mov    %r8d,%ebx
  lea    -0x1(%r15),%ecx
  jmp    L61
L45:
  movl   $0x0,0xc(%rsp)
  jmp    L58
```

assistant: ```c
IsArgPresent(argc, argv, switchName) int *argc;
char **argv, *switchName;
{
  int i, returnVal;
  returnVal = 0;
  for (i = 1; i < *argc; i++) {
    if (!strcmp(switchName, argv[i])) {
      for (i++; i < *argc; i++) {
        argv[i - 1] = argv[i];
      }
      (*argc)--;
      i--;
      returnVal = 1;
    }
  }
  return returnVal;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<IsArgPresent>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    (%rdi),%r15d
  mov    %rdi,(%rsp)
  cmp    $0x1,%r15d
  jle    L60
  movl   $0x0,0xc(%rsp)
  mov    %rsi,%r12
  mov    %rdx,%r14
  mov    $0x1,%ebx
  jmp    L73
  nopl   0x0(%rax,%rax,1)
L52:
  mov    (%rsp),%rax
  mov    %r8d,%ebx
  mov    (%rax),%r15d
  cmp    %ebx,%r15d
  jle    L0
L73:
  movslq %ebx,%rbp
  mov    %r14,%rdi
  shl    $0x3,%rbp
  lea    (%r12,%rbp,1),%r13
  mov    0x0(%r13),%rsi
  call   <strcmp@plt>
  lea    0x1(%rbx),%r8d
  test   %eax,%eax
  jne    L52
  cmp    %r8d,%r15d
  jle    L27
  lea    -0x2(%r15),%eax
  lea    0x8(%r12,%rbp,1),%rsi
  mov    %r13,%rdi
  mov    %r8d,0xc(%rsp)
  sub    %ebx,%eax
  lea    0x8(,%rax,8),%rdx
  call   <memmove@plt>
  mov    0xc(%rsp),%r8d
  lea    -0x1(%r15),%ecx
  add    %ecx,%r8d
  sub    %ebx,%r8d
  mov    %r8d,%ebx
L72:
  mov    (%rsp),%rax
  mov    %ecx,%r15d
  movl   $0x1,0xc(%rsp)
  mov    %ecx,(%rax)
  cmp    %ebx,%r15d
  jg     L73
L0:
  mov    0xc(%rsp),%eax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  xchg   %ax,%ax
L27:
  mov    %r8d,%ebx
  lea    -0x1(%r15),%ecx
  jmp    L72
L60:
  movl   $0x0,0xc(%rsp)
  jmp    L0
```

assistant: ```c
IsArgPresent(argc, argv, switchName) int *argc;
char **argv, *switchName;
{
  int i, returnVal;
  returnVal = 0;
  for (i = 1; i < *argc; i++) {
    if (!strcmp(switchName, argv[i])) {
      for (i++; i < *argc; i++) {
        argv[i - 1] = argv[i];
      }
      (*argc)--;
      i--;
      returnVal = 1;
    }
  }
  return returnVal;
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<replace_byte>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,-0x14(%rbp)
  mov    %esi,%eax
  mov    %edx,-0x1c(%rbp)
  mov    %al,-0x18(%rbp)
  mov    -0x1c(%rbp),%eax
  shl    $0x3,%eax
  mov    $0xff,%edx
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    %edx,%eax
  not    %eax
  mov    %eax,-0x8(%rbp)
  movzbl -0x18(%rbp),%edx
  mov    -0x1c(%rbp),%eax
  shl    $0x3,%eax
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    %edx,%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x14(%rbp),%eax
  and    -0x8(%rbp),%eax
  or     -0x4(%rbp),%eax
  pop    %rbp
  ret
```

assistant: ```c
unsigned replace_byte(unsigned x, unsigned char b, int i) {
  unsigned y, z;
  y = ~(0xFF << (i << 3));
  z = b << (i << 3);
  return x & y | z;
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<replace_byte>:
  endbr64
  mov    %edi,%r8d
  mov    %esi,%edi
  lea    0x0(,%rdx,8),%ecx
  mov    $0xff,%esi
  mov    %esi,%eax
  shl    %cl,%eax
  not    %eax
  and    %r8d,%eax
  movzbl %dil,%edi
  shl    %cl,%edi
  or     %edi,%eax
  ret
```

assistant: ```c
unsigned replace_byte(unsigned x, unsigned char b, int i) {
  unsigned y, z;
  y = ~(0xFF << (i << 3));
  z = b << (i << 3);
  return x & y | z;
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<replace_byte>:
  endbr64
  lea    0x0(,%rdx,8),%ecx
  mov    $0xff,%eax
  movzbl %sil,%r8d
  shl    %cl,%eax
  shl    %cl,%r8d
  not    %eax
  and    %edi,%eax
  or     %r8d,%eax
  ret
```

assistant: ```c
unsigned replace_byte(unsigned x, unsigned char b, int i) {
  unsigned y, z;
  y = ~(0xFF << (i << 3));
  z = b << (i << 3);
  return x & y | z;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<replace_byte>:
  endbr64
  lea    0x0(,%rdx,8),%ecx
  mov    $0xff,%eax
  movzbl %sil,%r8d
  shl    %cl,%eax
  shl    %cl,%r8d
  not    %eax
  and    %edi,%eax
  or     %r8d,%eax
  ret
```

assistant: ```c
unsigned replace_byte(unsigned x, unsigned char b, int i) {
  unsigned y, z;
  y = ~(0xFF << (i << 3));
  z = b << (i << 3);
  return x & y | z;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0xb0,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    -0xa0(%rbp),%rax
  mov    $0x96,%edx
  mov    %rax,%rsi
  mov    $0x0,%edi
  call   <read@plt>
  movl   $0x0,-0xa4(%rbp)
  jmp    L11
L24:
  mov    -0xa4(%rbp),%eax
  cltq
  movzbl -0xa0(%rbp,%rax,1),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <putchar@plt>
  addl   $0x1,-0xa4(%rbp)
L11:
  cmpl   $0x95,-0xa4(%rbp)
  jle    L24
  mov    $0x0,%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L28
  call   <__stack_chk_fail@plt>
L28:
  leave
  ret
```

assistant: ```c
int main() {
  char buf[150];
  int i;
  read(0, buf, sizeof(buf));
  for (i = 0; i < 150; i++) {
    putchar(buf[i]);
  }
  return 0;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<main>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0xa8,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x98(%rsp)
  xor    %eax,%eax
  mov    %rsp,%rbx
  mov    $0x96,%edx
  mov    %rbx,%rsi
  mov    $0x0,%edi
  call   <read@plt>
  lea    0x96(%rsp),%rbp
L11:
  movsbl (%rbx),%edi
  call   <putchar@plt>
  add    $0x1,%rbx
  cmp    %rbp,%rbx
  jne    L11
  mov    0x98(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L2
  mov    $0x0,%eax
  add    $0xa8,%rsp
  pop    %rbx
  pop    %rbp
  ret
L2:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int main() {
  char buf[150];
  int i;
  read(0, buf, sizeof(buf));
  for (i = 0; i < 150; i++) {
    putchar(buf[i]);
  }
  return 0;
}
```
user: Translate the below assembly code into C programming language:

```asm
<main>:
  endbr64
  push   %rbp
  mov    $0x96,%edx
  xor    %edi,%edi
  push   %rbx
  sub    $0xa8,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x98(%rsp)
  xor    %eax,%eax
  mov    %rsp,%rbx
  lea    0x96(%rsp),%rbp
  mov    %rbx,%rsi
  call   <read@plt>
  nopw   0x0(%rax,%rax,1)
L1:
  movsbl (%rbx),%edi
  add    $0x1,%rbx
  call   <putchar@plt>
  cmp    %rbp,%rbx
  jne    L1
  mov    0x98(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L3
  add    $0xa8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  ret
L3:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int main() {
  char buf[150];
  int i;
  read(0, buf, sizeof(buf));
  for (i = 0; i < 150; i++) {
    putchar(buf[i]);
  }
  return 0;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<main>:
  endbr64
  push   %rbp
  mov    $0x96,%edx
  xor    %edi,%edi
  push   %rbx
  sub    $0xa8,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x98(%rsp)
  xor    %eax,%eax
  mov    %rsp,%rbx
  lea    0x96(%rsp),%rbp
  mov    %rbx,%rsi
  call   <read@plt>
  nopw   0x0(%rax,%rax,1)
L3:
  movsbl (%rbx),%edi
  add    $0x1,%rbx
  call   <putchar@plt>
  cmp    %rbp,%rbx
  jne    L3
  mov    0x98(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L0
  add    $0xa8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  ret
L0:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int main() {
  char buf[150];
  int i;
  read(0, buf, sizeof(buf));
  for (i = 0; i < 150; i++) {
    putchar(buf[i]);
  }
  return 0;
}
```
user: What is the c source code of the assembly code below?

```asm
<emit_generic_instruction>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %edi,-0x14(%rbp)
  mov    %esi,-0x18(%rbp)
  mov    %edx,-0x1c(%rbp)
  movl   $0x48,-0x4(%rbp)
  mov    -0x14(%rbp),%eax
  and    $0x8,%eax
  test   %eax,%eax
  je     L14
  orl    $0x2,-0x4(%rbp)
L14:
  mov    -0x18(%rbp),%eax
  and    $0x8,%eax
  test   %eax,%eax
  je     L12
  orl    $0x1,-0x4(%rbp)
L12:
  mov    -0x4(%rbp),%eax
  mov    %eax,%edi
  call   <write_byte@plt>
  mov    -0x1c(%rbp),%eax
  mov    %eax,%edi
  call   <write_byte@plt>
  mov    -0x14(%rbp),%eax
  shl    $0x3,%eax
  and    $0x38,%eax
  or     $0xc0,%al
  mov    %eax,%edx
  mov    -0x18(%rbp),%eax
  and    $0x7,%eax
  or     %edx,%eax
  mov    %eax,%edi
  call   <write_byte@plt>
  nop
  leave
  ret
```

assistant: ```c
void emit_generic_instruction(uint8_t dest, uint8_t source, uint8_t opcode) {
  uint8_t rex = 0x40 | 0x08;
  if (((dest >> 3) & 1))
    rex |= 0x02;
  if (((source >> 3) & 1))
    rex |= 0x01;
  write_byte(rex);
  write_byte(opcode);
  write_byte(((((3) & 0x3) << 6) | (((dest)&0x7) << 3) | ((source)&0x7)));
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<emit_generic_instruction>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    %edi,%ebx
  mov    %esi,%ebp
  mov    %edx,%r12d
  mov    %edi,%eax
  and    $0x8,%eax
  cmp    $0x1,%eax
  sbb    %edi,%edi
  and    $0xfffffffe,%edi
  add    $0x4a,%edi
  mov    %edi,%eax
  or     $0x1,%eax
  test   $0x8,%sil
  cmovne %eax,%edi
  call   <write_byte@plt>
  mov    %r12d,%edi
  call   <write_byte@plt>
  lea    0x0(,%rbx,8),%edi
  and    $0x38,%edi
  and    $0x7,%ebp
  or     %ebp,%edi
  or     $0xc0,%dil
  call   <write_byte@plt>
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
void emit_generic_instruction(uint8_t dest, uint8_t source, uint8_t opcode) {
  uint8_t rex = 0x40 | 0x08;
  if (((dest >> 3) & 1))
    rex |= 0x02;
  if (((source >> 3) & 1))
    rex |= 0x01;
  write_byte(rex);
  write_byte(opcode);
  write_byte(((((3) & 0x3) << 6) | (((dest)&0x7) << 3) | ((source)&0x7)));
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<emit_generic_instruction>:
  endbr64
  mov    %edi,%eax
  push   %r12
  mov    %edx,%r12d
  and    $0x8,%eax
  push   %rbp
  mov    %esi,%ebp
  cmp    $0x1,%eax
  push   %rbx
  mov    %edi,%ebx
  sbb    %edi,%edi
  and    $0xfffffffe,%edi
  add    $0x4a,%edi
  mov    %edi,%eax
  or     $0x1,%eax
  test   $0x8,%sil
  cmovne %eax,%edi
  and    $0x7,%ebp
  call   <write_byte@plt>
  mov    %r12d,%edi
  call   <write_byte@plt>
  lea    0x0(,%rbx,8),%edi
  pop    %rbx
  and    $0x38,%edi
  or     %ebp,%edi
  pop    %rbp
  pop    %r12
  or     $0xc0,%dil
  jmp    1050 <write_byte@plt>
```

assistant: ```c
void emit_generic_instruction(uint8_t dest, uint8_t source, uint8_t opcode) {
  uint8_t rex = 0x40 | 0x08;
  if (((dest >> 3) & 1))
    rex |= 0x02;
  if (((source >> 3) & 1))
    rex |= 0x01;
  write_byte(rex);
  write_byte(opcode);
  write_byte(((((3) & 0x3) << 6) | (((dest)&0x7) << 3) | ((source)&0x7)));
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<emit_generic_instruction>:
  endbr64
  mov    %edi,%eax
  push   %r12
  mov    %edx,%r12d
  and    $0x8,%eax
  push   %rbp
  mov    %esi,%ebp
  cmp    $0x1,%eax
  push   %rbx
  mov    %edi,%ebx
  sbb    %edi,%edi
  and    $0xfffffffe,%edi
  add    $0x4b,%edi
  cmp    $0x1,%eax
  sbb    %eax,%eax
  and    $0xfffffffe,%eax
  add    $0x4a,%eax
  test   $0x8,%sil
  cmove  %eax,%edi
  and    $0x7,%ebp
  call   <write_byte@plt>
  mov    %r12d,%edi
  call   <write_byte@plt>
  lea    0x0(,%rbx,8),%edi
  pop    %rbx
  and    $0x38,%edi
  or     %ebp,%edi
  pop    %rbp
  pop    %r12
  or     $0xc0,%dil
  jmp    1050 <write_byte@plt>
```

assistant: ```c
void emit_generic_instruction(uint8_t dest, uint8_t source, uint8_t opcode) {
  uint8_t rex = 0x40 | 0x08;
  if (((dest >> 3) & 1))
    rex |= 0x02;
  if (((source >> 3) & 1))
    rex |= 0x01;
  write_byte(rex);
  write_byte(opcode);
  write_byte(((((3) & 0x3) << 6) | (((dest)&0x7) << 3) | ((source)&0x7)));
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<compare_headers>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  movl   $0x0,-0x4(%rbp)
  jmp    L59
L52:
  mov    -0x4(%rbp),%edx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%edx
  mov    -0x4(%rbp),%ecx
  mov    -0x20(%rbp),%rax
  add    %rcx,%rax
  movzbl (%rax),%eax
  cmp    %al,%dl
  je     L0
  mov    $0x0,%eax
  jmp    L67
L0:
  addl   $0x1,-0x4(%rbp)
L59:
  mov    -0x4(%rbp),%edx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L35
  mov    -0x4(%rbp),%edx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L52
L35:
  mov    -0x4(%rbp),%edx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0xd,%al
  je     L38
  mov    -0x4(%rbp),%edx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L38
  mov    $0x1,%eax
  jmp    L67
L38:
  mov    -0x4(%rbp),%edx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0xd,%al
  je     L90
  mov    -0x4(%rbp),%edx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L90
  mov    $0x1,%eax
  jmp    L67
L90:
  mov    $0x0,%eax
L67:
  pop    %rbp
  ret
```

assistant: ```c
int compare_headers(const char *hdr1, const char *hdr2) {
  unsigned int slen = 0;
  while (hdr1[slen] != '\0' && hdr2[slen] != '\0') {
    if (hdr1[slen] != hdr2[slen]) {
      return 0;
    }
    slen++;
  }
  if (hdr1[slen] != '\r' && hdr1[slen] != '\0') {
    return 1;
  }
  if (hdr2[slen] != '\r' && hdr2[slen] != '\0') {
    return 1;
  }
  return 0;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<compare_headers>:
  endbr64
  movzbl (%rdi),%edx
  mov    $0x0,%r8d
  mov    $0x0,%ecx
  test   %dl,%dl
  je     L33
L45:
  movzbl (%rsi,%rcx,1),%eax
  test   %al,%al
  je     L35
  cmp    %dl,%al
  jne    L67
  add    $0x1,%r8d
  mov    %r8d,%ecx
  movzbl (%rdi,%rcx,1),%edx
  test   %dl,%dl
  jne    L45
L33:
  movzbl (%rsi,%rcx,1),%eax
  cmp    $0xd,%al
  setne  %dl
  test   %al,%al
  setne  %al
  movzbl %al,%eax
  and    %edx,%eax
  ret
L35:
  cmp    $0xd,%dl
  je     L33
  mov    $0x1,%eax
  test   %dl,%dl
  jne    L6
  jmp    L33
L67:
  mov    $0x0,%eax
L6:
  ret
```

assistant: ```c
int compare_headers(const char *hdr1, const char *hdr2) {
  unsigned int slen = 0;
  while (hdr1[slen] != '\0' && hdr2[slen] != '\0') {
    if (hdr1[slen] != hdr2[slen]) {
      return 0;
    }
    slen++;
  }
  if (hdr1[slen] != '\r' && hdr1[slen] != '\0') {
    return 1;
  }
  if (hdr2[slen] != '\r' && hdr2[slen] != '\0') {
    return 1;
  }
  return 0;
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<compare_headers>:
  endbr64
  movzbl (%rdi),%ecx
  xor    %r8d,%r8d
  xor    %eax,%eax
  test   %cl,%cl
  jne    L11
  jmp    L61
  nopw   0x0(%rax,%rax,1)
L39:
  cmp    %cl,%dl
  jne    L43
  lea    0x1(%r8),%eax
  movzbl (%rdi,%rax,1),%ecx
  mov    %rax,%r8
  test   %cl,%cl
  je     L55
L11:
  movzbl (%rsi,%rax,1),%edx
  test   %dl,%dl
  jne    L39
  mov    $0x1,%eax
  cmp    $0xd,%cl
  je     L63
  ret
  xchg   %ax,%ax
L55:
  movzbl (%rsi,%rax,1),%edx
L63:
  cmp    $0xd,%dl
  setne  %cl
  xor    %eax,%eax
  test   %dl,%dl
  setne  %al
  and    %ecx,%eax
  ret
  nopl   0x0(%rax)
L43:
  xor    %eax,%eax
  ret
L61:
  movzbl (%rsi),%edx
  jmp    L63
```

assistant: ```c
int compare_headers(const char *hdr1, const char *hdr2) {
  unsigned int slen = 0;
  while (hdr1[slen] != '\0' && hdr2[slen] != '\0') {
    if (hdr1[slen] != hdr2[slen]) {
      return 0;
    }
    slen++;
  }
  if (hdr1[slen] != '\r' && hdr1[slen] != '\0') {
    return 1;
  }
  if (hdr2[slen] != '\r' && hdr2[slen] != '\0') {
    return 1;
  }
  return 0;
}
```