ylfeng/ReF-Decompile-dataset huggingface dataset:
user: What is the c source code of the assembly code below?

```asm
<print_restricted_partitions>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x28,%rsp
  mov    %edi,%r15d
  mov    %esi,%ebx
  mov    %esi,-0x44(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  lea    0x1(%rdi),%edi
  movslq %edi,%rdi
  lea    0x0(,%rdi,4),%r14
  imul   %rdi,%rdi
  shl    $0x2,%edi
  call   <malloc@plt>
  mov    %rax,%r12
  mov    %ebx,%edx
  mov    %r15d,%esi
  mov    %rax,%rdi
  call   <partition_dbl_restr_numbers@plt>
  lea    0xb(%r14),%rax
  mov    %rax,%rcx
  and    $0xfffffffffffffff0,%rcx
  and    $0xfffffffffffff000,%rax
  mov    %rsp,%rdx
  sub    %rax,%rdx
L6:
  cmp    %rdx,%rsp
  je     L40
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L6
L40:
  mov    %rcx,%rax
  and    $0xfff,%eax
  sub    %rax,%rsp
  test   %rax,%rax
  je     L0
  orq    $0x0,-0x8(%rsp,%rax,1)
L0:
  mov    %rsp,%r13
  shr    $0x2,%r14
  lea    0x1(%r14),%rax
  movslq %r15d,%rdx
  imul   %rdx,%rax
  cmpl   $0x0,(%r12,%rax,4)
  jle    L23
  mov    $0x0,%ebx
  add    $0x1,%r14
  imul   %rdx,%r14
L52:
  lea    -0x3c(%rbp),%r9
  mov    %r13,%r8
  mov    %ebx,%ecx
  mov    -0x44(%rbp),%edx
  mov    %r15d,%esi
  mov    %r12,%rdi
  call   <partition_restr_from_id@plt>
  mov    -0x3c(%rbp),%esi
  mov    %r13,%rdi
  call   <array_print@plt>
  add    $0x1,%ebx
  cmp    %ebx,(%r12,%r14,4)
  jg     L52
L23:
  mov    %r12,%rdi
  call   <free@plt>
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L1
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L1:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void print_restricted_partitions(int n, int k) {
  int(*p)[n + 1][n + 1] = malloc(((n + 1) * (n + 1) * sizeof(int)));
  partition_dbl_restr_numbers(p, n, k);
  int part[n], num_part;
  int i;
  for (i = 0; i < (*p)[n][n]; i++) {
    partition_restr_from_id(p, n, k, i, part, &num_part);
    array_print(part, num_part);
  }
  free(p);
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<print_restricted_partitions>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  mov    %esi,%r15d
  push   %r14
  push   %r13
  mov    %edi,%r13d
  lea    0x1(%rdi),%edi
  movslq %edi,%rdi
  push   %r12
  push   %rbx
  lea    0x0(,%rdi,4),%rbx
  imul   %rdi,%rdi
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  shl    $0x2,%edi
  call   <malloc@plt>
  mov    %r15d,%edx
  mov    %r13d,%esi
  mov    %rax,%rdi
  mov    %rax,%r14
  call   <partition_dbl_restr_numbers@plt>
  lea    0xb(%rbx),%rax
  mov    %rsp,%rcx
  mov    %rax,%rdx
  and    $0xfffffffffffff000,%rax
  sub    %rax,%rcx
  and    $0xfffffffffffffff0,%rdx
  cmp    %rcx,%rsp
  je     L54
L8:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rcx,%rsp
  jne    L8
L54:
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  jne    L6
L64:
  mov    %rbx,%rax
  mov    %rsp,%r12
  shr    $0x2,%rax
  lea    0x1(%rax),%rdx
  movslq %r13d,%rax
  imul   %rax,%rdx
  mov    (%r14,%rdx,4),%eax
  mov    %rdx,-0x50(%rbp)
  test   %eax,%eax
  jle    L44
  xor    %ebx,%ebx
  lea    -0x3c(%rbp),%r9
  nop
L18:
  mov    %ebx,%ecx
  mov    %r12,%r8
  mov    %r15d,%edx
  mov    %r13d,%esi
  mov    %r14,%rdi
  mov    %r9,-0x48(%rbp)
  add    $0x1,%ebx
  call   <partition_restr_from_id@plt>
  mov    -0x3c(%rbp),%esi
  mov    %r12,%rdi
  call   <array_print@plt>
  mov    -0x50(%rbp),%rax
  mov    -0x48(%rbp),%r9
  cmp    %ebx,(%r14,%rax,4)
  jg     L18
L44:
  mov    %r14,%rdi
  call   <free@plt>
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L28
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
  nopl   0x0(%rax)
L6:
  orq    $0x0,-0x8(%rsp,%rdx,1)
  jmp    L64
L28:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void print_restricted_partitions(int n, int k) {
  int(*p)[n + 1][n + 1] = malloc(((n + 1) * (n + 1) * sizeof(int)));
  partition_dbl_restr_numbers(p, n, k);
  int part[n], num_part;
  int i;
  for (i = 0; i < (*p)[n][n]; i++) {
    partition_restr_from_id(p, n, k, i, part, &num_part);
    array_print(part, num_part);
  }
  free(p);
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<print_restricted_partitions>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  mov    %esi,%r15d
  push   %r14
  push   %r13
  mov    %edi,%r13d
  lea    0x1(%rdi),%edi
  movslq %edi,%rdi
  push   %r12
  push   %rbx
  lea    0x0(,%rdi,4),%rbx
  imul   %rdi,%rdi
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  shl    $0x2,%edi
  call   <malloc@plt>
  mov    %r15d,%edx
  mov    %r13d,%esi
  mov    %rax,%rdi
  mov    %rax,%r14
  call   <partition_dbl_restr_numbers@plt>
  lea    0xb(%rbx),%rax
  mov    %rsp,%rcx
  mov    %rax,%rdx
  and    $0xfffffffffffff000,%rax
  sub    %rax,%rcx
  and    $0xfffffffffffffff0,%rdx
  cmp    %rcx,%rsp
  je     L47
L52:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rcx,%rsp
  jne    L52
L47:
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  jne    L10
L29:
  mov    %rbx,%rax
  mov    %rsp,%r12
  shr    $0x2,%rax
  lea    0x1(%rax),%rdx
  movslq %r13d,%rax
  imul   %rax,%rdx
  mov    (%r14,%rdx,4),%eax
  mov    %rdx,-0x50(%rbp)
  test   %eax,%eax
  jle    L13
  xor    %ebx,%ebx
  lea    -0x3c(%rbp),%r9
  nop
L36:
  mov    %ebx,%ecx
  mov    %r12,%r8
  mov    %r15d,%edx
  mov    %r13d,%esi
  mov    %r14,%rdi
  mov    %r9,-0x48(%rbp)
  add    $0x1,%ebx
  call   <partition_restr_from_id@plt>
  mov    -0x3c(%rbp),%esi
  mov    %r12,%rdi
  call   <array_print@plt>
  mov    -0x50(%rbp),%rax
  mov    -0x48(%rbp),%r9
  cmp    %ebx,(%r14,%rax,4)
  jg     L36
L13:
  mov    %r14,%rdi
  call   <free@plt>
  mov    -0x38(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L12
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
  nopl   0x0(%rax)
L10:
  orq    $0x0,-0x8(%rsp,%rdx,1)
  jmp    L29
L12:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void print_restricted_partitions(int n, int k) {
  int(*p)[n + 1][n + 1] = malloc(((n + 1) * (n + 1) * sizeof(int)));
  partition_dbl_restr_numbers(p, n, k);
  int part[n], num_part;
  int i;
  for (i = 0; i < (*p)[n][n]; i++) {
    partition_restr_from_id(p, n, k, i, part, &num_part);
    array_print(part, num_part);
  }
  free(p);
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<own_ntohl>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x18(%rbp),%eax
  mov    %eax,-0xc(%rbp)
  movzbl -0x9(%rbp),%eax
  mov    %al,-0xd(%rbp)
  movzbl -0xc(%rbp),%eax
  mov    %al,-0x9(%rbp)
  movzbl -0xd(%rbp),%eax
  mov    %al,-0xc(%rbp)
  movzbl -0xa(%rbp),%eax
  mov    %al,-0xd(%rbp)
  movzbl -0xb(%rbp),%eax
  mov    %al,-0xa(%rbp)
  movzbl -0xd(%rbp),%eax
  mov    %al,-0xb(%rbp)
  mov    -0xc(%rbp),%eax
  mov    %eax,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L3
  call   <__stack_chk_fail@plt>
L3:
  leave
  ret
```

assistant: ```c
unsigned long int own_ntohl(unsigned long int in) {
  unsigned char a[4], t;
  memcpy(a, &in, 4);
  t = a[3];
  a[3] = a[0];
  a[0] = t;
  t = a[2];
  a[2] = a[1];
  a[1] = t;
  memcpy(&in, a, 4);
  return in;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<own_ntohl>:
  endbr64
  mov    %rdi,%rax
  mov    %edi,%esi
  shr    $0x18,%esi
  mov    %edi,%edx
  shl    $0x18,%edx
  movzbl %ah,%ecx
  shl    $0x10,%ecx
  or     %esi,%edx
  or     %ecx,%edx
  mov    %edi,%ecx
  shr    $0x10,%ecx
  mov    %cl,%dh
  mov    %edx,%edx
  movabs $0xffffffff00000000,%rcx
  and    %rcx,%rax
  or     %rdx,%rax
  ret
```

assistant: ```c
unsigned long int own_ntohl(unsigned long int in) {
  unsigned char a[4], t;
  memcpy(a, &in, 4);
  t = a[3];
  a[3] = a[0];
  a[0] = t;
  t = a[2];
  a[2] = a[1];
  a[1] = t;
  memcpy(&in, a, 4);
  return in;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<own_ntohl>:
  endbr64
  mov    %rdi,%rax
  mov    %edi,%esi
  mov    %edi,%edx
  shr    $0x18,%esi
  shl    $0x18,%edx
  movzbl %ah,%ecx
  shl    $0x10,%ecx
  or     %esi,%edx
  or     %ecx,%edx
  mov    %edi,%ecx
  shr    $0x10,%ecx
  mov    %cl,%dh
  movabs $0xffffffff00000000,%rcx
  mov    %edx,%edx
  and    %rcx,%rax
  or     %rdx,%rax
  ret
```

assistant: ```c
unsigned long int own_ntohl(unsigned long int in) {
  unsigned char a[4], t;
  memcpy(a, &in, 4);
  t = a[3];
  a[3] = a[0];
  a[0] = t;
  t = a[2];
  a[2] = a[1];
  a[1] = t;
  memcpy(&in, a, 4);
  return in;
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<own_ntohl>:
  endbr64
  mov    %edi,%ecx
  xor    %edx,%edx
  mov    %rdi,%rax
  mov    %edi,%esi
  shr    $0x18,%ecx
  shl    $0x18,%esi
  mov    %cl,%dl
  mov    %edi,%ecx
  shr    $0x10,%ecx
  mov    %cl,%dh
  movzbl %ah,%ecx
  shl    $0x10,%ecx
  movzwl %dx,%edx
  or     %ecx,%edx
  movabs $0xffffffff00000000,%rcx
  or     %esi,%edx
  and    %rcx,%rax
  or     %rdx,%rax
  ret
```

assistant: ```c
unsigned long int own_ntohl(unsigned long int in) {
  unsigned char a[4], t;
  memcpy(a, &in, 4);
  t = a[3];
  a[3] = a[0];
  a[0] = t;
  t = a[2];
  a[2] = a[1];
  a[1] = t;
  memcpy(&in, a, 4);
  return in;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<to_raw>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %edx,-0x24(%rbp)
  mov    %rcx,-0x30(%rbp)
  movl   $0x0,-0x4(%rbp)
  jmp    L11
L6:
  mov    -0x4(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    -0x4(%rbp),%edx
  movslq %edx,%rcx
  mov    -0x20(%rbp),%rdx
  add    %rcx,%rdx
  movzbl (%rax),%eax
  mov    %al,(%rdx)
  addl   $0x1,-0x4(%rbp)
L11:
  mov    -0x4(%rbp),%eax
  cmp    -0x24(%rbp),%eax
  jl     L6
  nop
  nop
  pop    %rbp
  ret
```

assistant: ```c
void to_raw(const char *in_seq, unsigned char *out_seq, int seq_len, const unsigned char *map) {
  int i;
  for (i = 0; i < seq_len; i++)
    out_seq[i] = (unsigned char)map[(unsigned)in_seq[i]];
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<to_raw>:
  endbr64
  test   %edx,%edx
  jle    L7
  mov    %edx,%edx
  mov    $0x0,%eax
L9:
  movsbl (%rdi,%rax,1),%r8d
  movzbl (%rcx,%r8,1),%r8d
  mov    %r8b,(%rsi,%rax,1)
  add    $0x1,%rax
  cmp    %rdx,%rax
  jne    L9
L7:
  ret
```

assistant: ```c
void to_raw(const char *in_seq, unsigned char *out_seq, int seq_len, const unsigned char *map) {
  int i;
  for (i = 0; i < seq_len; i++)
    out_seq[i] = (unsigned char)map[(unsigned)in_seq[i]];
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<to_raw>:
  endbr64
  test   %edx,%edx
  jle    L14
  movslq %edx,%rdx
  xor    %eax,%eax
  nopl   (%rax)
L12:
  movsbl (%rdi,%rax,1),%r8d
  movzbl (%rcx,%r8,1),%r8d
  mov    %r8b,(%rsi,%rax,1)
  add    $0x1,%rax
  cmp    %rax,%rdx
  jne    L12
L14:
  ret
```

assistant: ```c
void to_raw(const char *in_seq, unsigned char *out_seq, int seq_len, const unsigned char *map) {
  int i;
  for (i = 0; i < seq_len; i++)
    out_seq[i] = (unsigned char)map[(unsigned)in_seq[i]];
}
```
user: What is the c source code of the assembly code below?

```asm
<to_raw>:
  endbr64
  test   %edx,%edx
  jle    L5
  movslq %edx,%rdx
  xor    %eax,%eax
  nopl   (%rax)
L14:
  movsbl (%rdi,%rax,1),%r8d
  movzbl (%rcx,%r8,1),%r8d
  mov    %r8b,(%rsi,%rax,1)
  add    $0x1,%rax
  cmp    %rax,%rdx
  jne    L14
L5:
  ret
```

assistant: ```c
void to_raw(const char *in_seq, unsigned char *out_seq, int seq_len, const unsigned char *map) {
  int i;
  for (i = 0; i < seq_len; i++)
    out_seq[i] = (unsigned char)map[(unsigned)in_seq[i]];
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<Base64_DecodeSizeInBytes>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  movl   $0x0,-0x8(%rbp)
  mov    -0x1c(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x4(%rbp)
  jmp    L29
L3:
  addl   $0x1,-0x8(%rbp)
  subl   $0x1,-0x4(%rbp)
L29:
  cmpl   $0x0,-0x4(%rbp)
  js     L20
  mov    -0x4(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x3d,%al
  je     L3
L20:
  mov    -0x1c(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,%eax
  add    %eax,%eax
  add    %edx,%eax
  lea    0x3(%rax),%edx
  test   %eax,%eax
  cmovs  %edx,%eax
  sar    $0x2,%eax
  sub    -0x8(%rbp),%eax
  pop    %rbp
  ret
```

assistant: ```c
int Base64_DecodeSizeInBytes(const char *base64, const int base64SizeInBytes) {
  int padding = 0;
  for (int i = base64SizeInBytes - 1; i >= 0 && base64[i] == '='; i--) {
    padding++;
  }
  return ((3 * base64SizeInBytes + 3) / 4) - padding;
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<Base64_DecodeSizeInBytes>:
  endbr64
  mov    %esi,%eax
  sub    $0x1,%eax
  js     L0
  cltq
  add    %rax,%rdi
  mov    $0x0,%edx
L1:
  cmpb   $0x3d,(%rdi)
  jne    L9
  add    $0x1,%edx
  sub    $0x1,%rdi
  cmp    %edx,%esi
  jne    L1
  mov    %esi,%edx
L9:
  lea    0x3(%rsi,%rsi,2),%ecx
  lea    0x3(%rcx),%eax
  test   %ecx,%ecx
  cmovns %ecx,%eax
  sar    $0x2,%eax
  sub    %edx,%eax
  ret
L0:
  mov    $0x0,%edx
  jmp    L9
```

assistant: ```c
int Base64_DecodeSizeInBytes(const char *base64, const int base64SizeInBytes) {
  int padding = 0;
  for (int i = base64SizeInBytes - 1; i >= 0 && base64[i] == '='; i--) {
    padding++;
  }
  return ((3 * base64SizeInBytes + 3) / 4) - padding;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<Base64_DecodeSizeInBytes>:
  endbr64
  mov    %esi,%eax
  sub    $0x1,%eax
  js     L35
  cltq
  xor    %edx,%edx
  add    %rax,%rdi
  jmp    L10
  nopl   0x0(%rax)
L26:
  add    $0x1,%edx
  sub    $0x1,%rdi
  cmp    %edx,%esi
  je     L29
L10:
  cmpb   $0x3d,(%rdi)
  je     L26
L29:
  lea    0x3(%rsi,%rsi,2),%ecx
  test   %ecx,%ecx
  lea    0x3(%rcx),%eax
  cmovns %ecx,%eax
  sar    $0x2,%eax
  sub    %edx,%eax
  ret
L35:
  xor    %edx,%edx
  jmp    L29
```

assistant: ```c
int Base64_DecodeSizeInBytes(const char *base64, const int base64SizeInBytes) {
  int padding = 0;
  for (int i = base64SizeInBytes - 1; i >= 0 && base64[i] == '='; i--) {
    padding++;
  }
  return ((3 * base64SizeInBytes + 3) / 4) - padding;
}
```
user: What is the c source code of the assembly code below?

```asm
<Base64_DecodeSizeInBytes>:
  endbr64
  mov    %esi,%eax
  sub    $0x1,%eax
  js     L0
  cltq
  xor    %edx,%edx
  add    %rax,%rdi
  jmp    L6
  nopl   0x0(%rax)
L26:
  add    $0x1,%edx
  sub    $0x1,%rdi
  cmp    %edx,%esi
  je     L10
L6:
  cmpb   $0x3d,(%rdi)
  je     L26
L10:
  lea    0x3(%rsi,%rsi,2),%ecx
  test   %ecx,%ecx
  lea    0x3(%rcx),%eax
  cmovns %ecx,%eax
  sar    $0x2,%eax
  sub    %edx,%eax
  ret
L0:
  xor    %edx,%edx
  jmp    L10
```

assistant: ```c
int Base64_DecodeSizeInBytes(const char *base64, const int base64SizeInBytes) {
  int padding = 0;
  for (int i = base64SizeInBytes - 1; i >= 0 && base64[i] == '='; i--) {
    padding++;
  }
  return ((3 * base64SizeInBytes + 3) / 4) - padding;
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<strrchr>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  movq   $0x0,-0x8(%rbp)
L17:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  mov    -0x1c(%rbp),%edx
  cmp    %dl,%al
  jne    L0
  mov    -0x18(%rbp),%rax
  mov    %rax,-0x8(%rbp)
L0:
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movzbl (%rax),%eax
  test   %al,%al
  jne    L17
  mov    -0x8(%rbp),%rax
  pop    %rbp
  ret
```

assistant: ```c
char *strrchr(const char *s, int c) {
  const char *last = 0;
  do {
    if (*s == (char)c)
      last = s;
  } while (*s++);
  return (char *)last;
}
```
user: 这段汇编代码用C语言表示是什么样的：

```asm
<strrchr>:
  endbr64
  mov    $0x0,%edx
L8:
  movzbl (%rdi),%eax
  cmp    %sil,%al
  cmove  %rdi,%rdx
  add    $0x1,%rdi
  test   %al,%al
  jne    L8
  mov    %rdx,%rax
  ret
```

assistant: ```c
char *strrchr(const char *s, int c) {
  const char *last = 0;
  do {
    if (*s == (char)c)
      last = s;
  } while (*s++);
  return (char *)last;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<strrchr>:
  endbr64
  xor    %r8d,%r8d
  nopw   0x0(%rax,%rax,1)
L8:
  movzbl (%rdi),%eax
  cmp    %sil,%al
  cmove  %rdi,%r8
  add    $0x1,%rdi
  test   %al,%al
  jne    L8
  mov    %r8,%rax
  ret
```

assistant: ```c
char *strrchr(const char *s, int c) {
  const char *last = 0;
  do {
    if (*s == (char)c)
      last = s;
  } while (*s++);
  return (char *)last;
}
```
user: What is the c source code of the assembly code below:

```asm
<strrchr>:
  endbr64
  xor    %r8d,%r8d
  nopw   0x0(%rax,%rax,1)
L23:
  movzbl (%rdi),%eax
  cmp    %al,%sil
  je     L29
  add    $0x1,%rdi
  test   %al,%al
  jne    L23
L25:
  mov    %r8,%rax
  ret
  nopl   0x0(%rax)
L29:
  lea    0x1(%rdi),%rax
  mov    %rdi,%r8
  test   %sil,%sil
  je     L25
  mov    %rax,%rdi
  jmp    L23
```

assistant: ```c
char *strrchr(const char *s, int c) {
  const char *last = 0;
  do {
    if (*s == (char)c)
      last = s;
  } while (*s++);
  return (char *)last;
}
```
user: 这段汇编代码用C语言表示是什么样的？

```asm
<Barcode_upc_verify>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,%rbp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  call   <strlen@plt>
  mov    %eax,%r13d
  mov    $0x20,%esi
  mov    %rbp,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  je     L76
  sub    %rbp,%rax
  mov    %eax,%r12d
  mov    %r13d,%edx
  sub    %eax,%edx
  lea    -0x1(%rdx),%ecx
  cmp    $0x3,%edx
  je     L176
  cmp    $0x5,%ecx
  jne    L69
L176:
  lea    0x1(%rax),%ebx
  cmp    %ebx,%r13d
  jle    L186
  movslq %ebx,%rbx
  add    %rbp,%rbx
  movslq %eax,%rdx
  lea    0x2(%rbp,%rdx,1),%rdx
  sub    $0x2,%r13d
  sub    %eax,%r13d
  add    %rdx,%r13
L164:
  movzbl (%rbx),%edi
  call   <isdigit@plt>
  test   %eax,%eax
  je     L37
  add    $0x1,%rbx
  cmp    %r13,%rbx
  jne    L164
L186:
  test   %r12d,%r12d
  jle    L85
  mov    %rbp,%rbx
  lea    -0x1(%r12),%eax
  lea    0x1(%rbp,%rax,1),%r13
L82:
  movzbl (%rbx),%edi
  call   <isdigit@plt>
  test   %eax,%eax
  je     L133
  add    $0x1,%rbx
  cmp    %r13,%rbx
  jne    L82
L85:
  mov    $0x0,%eax
  cmp    $0xb,%r12d
  je     L0
  jg     L119
  lea    -0x6(%r12),%edx
  mov    $0xffffffff,%eax
  cmp    $0x2,%edx
  ja     L0
  mov    %rsp,%rbx
  mov    %r12d,%edx
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  call   <strncpy@plt>
  movslq %r12d,%r12
  movb   $0x0,(%rsp,%r12,1)
  mov    %rbx,%rdi
  call   <upc_e_to_a@plt>
  cmp    $0x1,%eax
  sbb    %eax,%eax
  jmp    L0
L76:
  mov    %r13d,%r12d
  jmp    L186
L119:
  mov    $0xffffffff,%eax
  cmp    $0xc,%r12d
  jne    L0
  mov    %rsp,%rbx
  mov    $0xb,%edx
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  call   <strncpy@plt>
  movb   $0x0,0xb(%rsp)
  movzbl 0xb(%rbp),%ebp
  mov    $0x0,%esi
  mov    %rbx,%rdi
  call   <ean_make_checksum@plt>
  add    $0x30,%eax
  cmp    %ebp,%eax
  setne  %al
  movzbl %al,%eax
  neg    %eax
  jmp    L0
L69:
  mov    $0xffffffff,%eax
  jmp    L0
L37:
  mov    $0xffffffff,%eax
L0:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L121
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L133:
  mov    $0xffffffff,%eax
  jmp    L0
L121:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int Barcode_upc_verify(unsigned char *text) {
  int i, len0, len, addon;
  unsigned char tmp[24], *spc;
  len = strlen(text);
  spc = strchr(text, ' ');
  if (spc) {
    len0 = spc - text;
    addon = len - len0 - 1;
    if (addon != 2 && addon != 5)
      return -1;
    for (i = len0 + 1; i < len; i++)
      if (!isdigit(text[i]))
        return -1;
  } else
    len0 = len;
  for (i = 0; i < len0; i++)
    if (!isdigit(text[i]))
      return -1;
  switch (len0) {
  case 6:
  case 7:
  case 8:
    strncpy(tmp, text, len0);
    tmp[len0] = '\0';
    if (!upc_e_to_a(tmp))
      return -1;
    break;
  case 12:
    strncpy(tmp, text, 11);
    tmp[11] = '\0';
    if (text[11] != (ean_make_checksum(tmp, 0) + '0'))
      return -1;
  case 11:
    break;
  default:
    return -1;
  }
  return 0;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<Barcode_upc_verify>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  call   <strlen@plt>
  mov    $0x20,%esi
  mov    %rbp,%rdi
  mov    %eax,%r13d
  call   <strchr@plt>
  test   %rax,%rax
  je     L100
  sub    %rbp,%rax
  mov    %r13d,%edx
  sub    %eax,%edx
  movslq %eax,%r12
  lea    -0x1(%rdx),%ecx
  cmp    $0x3,%edx
  je     L45
  cmp    $0x5,%ecx
  jne    L90
L45:
  lea    0x1(%rax),%ebx
  cmp    %ebx,%r13d
  jle    L56
  movslq %eax,%rdx
  sub    $0x2,%r13d
  movslq %ebx,%rbx
  lea    0x2(%rbp,%rdx,1),%rdx
  sub    %eax,%r13d
  add    %rbp,%rbx
  add    %rdx,%r13
  jmp    L123
  nopl   (%rax)
L0:
  add    $0x1,%rbx
  cmp    %r13,%rbx
  je     L56
L123:
  movzbl (%rbx),%edi
  call   <isdigit@plt>
  test   %eax,%eax
  jne    L0
L90:
  mov    $0xffffffff,%eax
L66:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L36
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L100:
  movslq %r13d,%r12
L56:
  test   %r12d,%r12d
  jle    L134
  lea    -0x1(%r12),%eax
  mov    %rbp,%rbx
  lea    0x1(%rbp,%rax,1),%r13
  jmp    L113
  nop
L165:
  add    $0x1,%rbx
  cmp    %rbx,%r13
  je     L179
L113:
  movzbl (%rbx),%edi
  call   <isdigit@plt>
  test   %eax,%eax
  jne    L165
  jmp    L90
  nopw   0x0(%rax,%rax,1)
L179:
  xor    %eax,%eax
  cmp    $0xb,%r12d
  je     L66
L134:
  cmp    $0xb,%r12d
  jg     L151
  lea    -0x6(%r12),%edx
  mov    $0xffffffff,%eax
  cmp    $0x2,%edx
  ja     L66
  mov    %rsp,%r13
  mov    %r12d,%edx
  mov    %rbp,%rsi
  mov    %r13,%rdi
  call   <strncpy@plt>
  mov    %r13,%rdi
  movb   $0x0,(%rsp,%r12,1)
  call   <upc_e_to_a@plt>
  cmp    $0x1,%eax
  sbb    %eax,%eax
  jmp    L66
  nopl   (%rax)
L151:
  cmp    $0xc,%r12d
  jne    L90
  mov    %rsp,%r12
  mov    $0xb,%edx
  mov    %rbp,%rsi
  mov    %r12,%rdi
  call   <strncpy@plt>
  xor    %esi,%esi
  mov    %r12,%rdi
  movzbl 0xb(%rbp),%ebx
  movb   $0x0,0xb(%rsp)
  call   <ean_make_checksum@plt>
  add    $0x30,%eax
  cmp    %ebx,%eax
  setne  %al
  movzbl %al,%eax
  neg    %eax
  jmp    L66
L36:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int Barcode_upc_verify(unsigned char *text) {
  int i, len0, len, addon;
  unsigned char tmp[24], *spc;
  len = strlen(text);
  spc = strchr(text, ' ');
  if (spc) {
    len0 = spc - text;
    addon = len - len0 - 1;
    if (addon != 2 && addon != 5)
      return -1;
    for (i = len0 + 1; i < len; i++)
      if (!isdigit(text[i]))
        return -1;
  } else
    len0 = len;
  for (i = 0; i < len0; i++)
    if (!isdigit(text[i]))
      return -1;
  switch (len0) {
  case 6:
  case 7:
  case 8:
    strncpy(tmp, text, len0);
    tmp[len0] = '\0';
    if (!upc_e_to_a(tmp))
      return -1;
    break;
  case 12:
    strncpy(tmp, text, 11);
    tmp[11] = '\0';
    if (text[11] != (ean_make_checksum(tmp, 0) + '0'))
      return -1;
  case 11:
    break;
  default:
    return -1;
  }
  return 0;
}
```