ylfeng/ReF-Decompile-dataset huggingface dataset:
user: 请将以下的汇编代码转换成C语言代码：

```asm
<restore_md5_array>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  mov    %rsi,%r12
  call   <strlen@plt>
  cmp    $0x16,%eax
  jne    L43
  sub    $0x8,%rsp
  push   $0xc
  mov    $0x6,%r9d
  mov    $0x0,%r8d
  mov    $0x4,%ecx
  mov    $0x0,%edx
  mov    %r12,%rsi
  mov    %rbx,%rdi
  call   <split_24bit@plt>
  add    $0x10,%rsp
  test   %rax,%rax
  js     L114
  sub    $0x8,%rsp
  push   $0xd
  mov    $0x7,%r9d
  mov    $0x1,%r8d
  mov    $0x4,%ecx
  mov    $0x4,%edx
  mov    %r12,%rsi
  mov    %rbx,%rdi
  call   <split_24bit@plt>
  add    $0x10,%rsp
  test   %rax,%rax
  js     L25
  sub    $0x8,%rsp
  push   $0xe
  mov    $0x8,%r9d
  mov    $0x2,%r8d
  mov    $0x4,%ecx
  mov    $0x8,%edx
  mov    %r12,%rsi
  mov    %rbx,%rdi
  call   <split_24bit@plt>
  add    $0x10,%rsp
  test   %rax,%rax
  js     L37
  sub    $0x8,%rsp
  push   $0xf
  mov    $0x9,%r9d
  mov    $0x3,%r8d
  mov    $0x4,%ecx
  mov    $0xc,%edx
  mov    %r12,%rsi
  mov    %rbx,%rdi
  call   <split_24bit@plt>
  add    $0x10,%rsp
  test   %rax,%rax
  js     L5
  sub    $0x8,%rsp
  push   $0x5
  mov    $0xa,%r9d
  mov    $0x4,%r8d
  mov    $0x4,%ecx
  mov    $0x10,%edx
  mov    %r12,%rsi
  mov    %rbx,%rdi
  call   <split_24bit@plt>
  add    $0x10,%rsp
  test   %rax,%rax
  js     L44
  movsbl 0x15(%rbx),%edi
  call   <b64_to_int@plt>
  mov    %eax,%ebp
  test   %eax,%eax
  js     L154
  movsbl 0x14(%rbx),%edi
  call   <b64_to_int@plt>
  test   %eax,%eax
  js     L111
  shl    $0x6,%ebp
  or     %eax,%ebp
  movslq %ebp,%rbp
  mov    %rbp,0x58(%r12)
  mov    $0x0,%eax
L106:
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L43:
  mov    $0xffffffff,%eax
  jmp    L106
L114:
  mov    $0xffffffff,%eax
  jmp    L106
L25:
  mov    $0xffffffff,%eax
  jmp    L106
L37:
  mov    $0xffffffff,%eax
  jmp    L106
L5:
  mov    $0xffffffff,%eax
  jmp    L106
L44:
  mov    $0xffffffff,%eax
  jmp    L106
L154:
  mov    $0xffffffff,%eax
  jmp    L106
L111:
  mov    $0xffffffff,%eax
  jmp    L106
```

assistant: ```c
int restore_md5_array(const char *string, uint8_t *hash) {
  uint32_t tmp = 0;
  int value1, value2;
  if (strlen(string) != 22)
    return -1;
  if (split_24bit(string, hash, 0, 4, 0, 6, 12) < 0)
    return -1;
  if (split_24bit(string, hash, 4, 4, 1, 7, 13) < 0)
    return -1;
  if (split_24bit(string, hash, 8, 4, 2, 8, 14) < 0)
    return -1;
  if (split_24bit(string, hash, 12, 4, 3, 9, 15) < 0)
    return -1;
  if (split_24bit(string, hash, 16, 4, 4, 10, 5) < 0)
    return -1;
  value1 = b64_to_int(string[21]);
  if (value1 < 0)
    return -1;
  value2 = b64_to_int(string[20]);
  if (value2 < 0)
    return -1;
  tmp = (value1 << 6) | value2;
  hash[11] = (uint8_t)tmp;
  return 0;
}
```
user: What is the c source code of the assembly code below:

```asm
<restore_md5_array>:
  endbr64
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  call   <strlen@plt>
  cmp    $0x16,%eax
  jne    L77
  sub    $0x8,%rsp
  xor    %edx,%edx
  mov    $0x6,%r9d
  xor    %r8d,%r8d
  push   $0xc
  mov    $0x4,%ecx
  mov    %r12,%rsi
  mov    %rbx,%rdi
  call   <split_24bit@plt>
  pop    %rbp
  pop    %rdx
  test   %rax,%rax
  js     L77
  sub    $0x8,%rsp
  mov    $0x7,%r9d
  mov    %r12,%rsi
  mov    %rbx,%rdi
  push   $0xd
  mov    $0x1,%r8d
  mov    $0x4,%ecx
  mov    $0x4,%edx
  call   <split_24bit@plt>
  pop    %r10
  pop    %r11
  test   %rax,%rax
  js     L77
  sub    $0x8,%rsp
  mov    $0x8,%r9d
  mov    %r12,%rsi
  mov    %rbx,%rdi
  push   $0xe
  mov    $0x2,%r8d
  mov    $0x4,%ecx
  mov    $0x8,%edx
  call   <split_24bit@plt>
  pop    %r8
  pop    %r9
  test   %rax,%rax
  js     L77
  sub    $0x8,%rsp
  mov    %r12,%rsi
  mov    %rbx,%rdi
  mov    $0x9,%r9d
  push   $0xf
  mov    $0x3,%r8d
  mov    $0x4,%ecx
  mov    $0xc,%edx
  call   <split_24bit@plt>
  pop    %rsi
  pop    %rdi
  test   %rax,%rax
  js     L77
  sub    $0x8,%rsp
  mov    $0x4,%ecx
  mov    %r12,%rsi
  mov    %rbx,%rdi
  push   $0x5
  mov    $0x10,%edx
  mov    $0xa,%r9d
  mov    $0x4,%r8d
  call   <split_24bit@plt>
  pop    %rdx
  pop    %rcx
  test   %rax,%rax
  js     L77
  movsbl 0x15(%rbx),%edi
  call   <b64_to_int@plt>
  mov    %eax,%ebp
  test   %eax,%eax
  js     L77
  movsbl 0x14(%rbx),%edi
  call   <b64_to_int@plt>
  test   %eax,%eax
  js     L77
  shl    $0x6,%ebp
  pop    %rbx
  or     %eax,%ebp
  xor    %eax,%eax
  movslq %ebp,%rbp
  mov    %rbp,0x58(%r12)
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax)
L77:
  pop    %rbx
  mov    $0xffffffff,%eax
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
int restore_md5_array(const char *string, uint8_t *hash) {
  uint32_t tmp = 0;
  int value1, value2;
  if (strlen(string) != 22)
    return -1;
  if (split_24bit(string, hash, 0, 4, 0, 6, 12) < 0)
    return -1;
  if (split_24bit(string, hash, 4, 4, 1, 7, 13) < 0)
    return -1;
  if (split_24bit(string, hash, 8, 4, 2, 8, 14) < 0)
    return -1;
  if (split_24bit(string, hash, 12, 4, 3, 9, 15) < 0)
    return -1;
  if (split_24bit(string, hash, 16, 4, 4, 10, 5) < 0)
    return -1;
  value1 = b64_to_int(string[21]);
  if (value1 < 0)
    return -1;
  value2 = b64_to_int(string[20]);
  if (value2 < 0)
    return -1;
  tmp = (value1 << 6) | value2;
  hash[11] = (uint8_t)tmp;
  return 0;
}
```
user: What is the c source code of the assembly code below?

```asm
<restore_md5_array>:
  endbr64
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  call   <strlen@plt>
  cmp    $0x16,%eax
  jne    L11
  sub    $0x8,%rsp
  xor    %edx,%edx
  mov    $0x6,%r9d
  xor    %r8d,%r8d
  push   $0xc
  mov    $0x4,%ecx
  mov    %r12,%rsi
  mov    %rbx,%rdi
  call   <split_24bit@plt>
  pop    %rbp
  pop    %rdx
  test   %rax,%rax
  js     L11
  sub    $0x8,%rsp
  mov    $0x7,%r9d
  mov    %r12,%rsi
  mov    %rbx,%rdi
  push   $0xd
  mov    $0x1,%r8d
  mov    $0x4,%ecx
  mov    $0x4,%edx
  call   <split_24bit@plt>
  pop    %r10
  pop    %r11
  test   %rax,%rax
  js     L11
  sub    $0x8,%rsp
  mov    $0x8,%r9d
  mov    %r12,%rsi
  mov    %rbx,%rdi
  push   $0xe
  mov    $0x2,%r8d
  mov    $0x4,%ecx
  mov    $0x8,%edx
  call   <split_24bit@plt>
  pop    %r8
  pop    %r9
  test   %rax,%rax
  js     L11
  sub    $0x8,%rsp
  mov    %r12,%rsi
  mov    %rbx,%rdi
  mov    $0x9,%r9d
  push   $0xf
  mov    $0x3,%r8d
  mov    $0x4,%ecx
  mov    $0xc,%edx
  call   <split_24bit@plt>
  pop    %rsi
  pop    %rdi
  test   %rax,%rax
  js     L11
  sub    $0x8,%rsp
  mov    $0x4,%ecx
  mov    %r12,%rsi
  mov    %rbx,%rdi
  push   $0x5
  mov    $0x10,%edx
  mov    $0xa,%r9d
  mov    $0x4,%r8d
  call   <split_24bit@plt>
  pop    %rdx
  pop    %rcx
  test   %rax,%rax
  js     L11
  movsbl 0x15(%rbx),%edi
  call   <b64_to_int@plt>
  mov    %eax,%ebp
  test   %eax,%eax
  js     L11
  movsbl 0x14(%rbx),%edi
  call   <b64_to_int@plt>
  test   %eax,%eax
  js     L11
  shl    $0x6,%ebp
  pop    %rbx
  or     %eax,%ebp
  xor    %eax,%eax
  movslq %ebp,%rbp
  mov    %rbp,0x58(%r12)
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax)
L11:
  pop    %rbx
  mov    $0xffffffff,%eax
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
int restore_md5_array(const char *string, uint8_t *hash) {
  uint32_t tmp = 0;
  int value1, value2;
  if (strlen(string) != 22)
    return -1;
  if (split_24bit(string, hash, 0, 4, 0, 6, 12) < 0)
    return -1;
  if (split_24bit(string, hash, 4, 4, 1, 7, 13) < 0)
    return -1;
  if (split_24bit(string, hash, 8, 4, 2, 8, 14) < 0)
    return -1;
  if (split_24bit(string, hash, 12, 4, 3, 9, 15) < 0)
    return -1;
  if (split_24bit(string, hash, 16, 4, 4, 10, 5) < 0)
    return -1;
  value1 = b64_to_int(string[21]);
  if (value1 < 0)
    return -1;
  value2 = b64_to_int(string[20]);
  if (value2 < 0)
    return -1;
  tmp = (value1 << 6) | value2;
  hash[11] = (uint8_t)tmp;
  return 0;
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<rand_in_range>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %edi,-0x4(%rbp)
  cmpl   $0x0,-0x4(%rbp)
  setne  %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  mov    $0x0,%eax
  call   <rand@plt>
  cltd
  idivl  -0x4(%rbp)
  mov    %edx,%eax
  add    $0x1,%eax
  leave
  ret
```

assistant: ```c
int rand_in_range(int max) {
  assert(max != 0);
  return (rand() % max) + 1;
}
```
user: What is the c source code of the assembly code below?

```asm
<rand_in_range>:
  endbr64
  push   %rbx
  mov    %edi,%ebx
  test   %edi,%edi
  setne  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  mov    $0x0,%eax
  call   <rand@plt>
  cltd
  idiv   %ebx
  lea    0x1(%rdx),%eax
  pop    %rbx
  ret
```

assistant: ```c
int rand_in_range(int max) {
  assert(max != 0);
  return (rand() % max) + 1;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<rand_in_range>:
  endbr64
  push   %rbx
  mov    %edi,%ebx
  xor    %edi,%edi
  test   %ebx,%ebx
  setne  %dil
  call   <assert@plt>
  xor    %eax,%eax
  call   <rand@plt>
  cltd
  idiv   %ebx
  pop    %rbx
  lea    0x1(%rdx),%eax
  ret
```

assistant: ```c
int rand_in_range(int max) {
  assert(max != 0);
  return (rand() % max) + 1;
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<rand_in_range>:
  endbr64
  push   %rbx
  mov    %edi,%ebx
  xor    %edi,%edi
  test   %ebx,%ebx
  setne  %dil
  call   <assert@plt>
  xor    %eax,%eax
  call   <rand@plt>
  cltd
  idiv   %ebx
  pop    %rbx
  lea    0x1(%rdx),%eax
  ret
```

assistant: ```c
int rand_in_range(int max) {
  assert(max != 0);
  return (rand() % max) + 1;
}
```
user: Translate the below assembly code into C programming language:

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  movl   $0x0,-0x10(%rbp)
  movl   $0x0,-0x8(%rbp)
  movl   $0x1,-0x4(%rbp)
  movl   $0x3e7,-0xc(%rbp)
  jmp    L42
L29:
  movl   $0x1,-0x4(%rbp)
  movl   $0x2,-0x14(%rbp)
  jmp    L95
L75:
  mov    -0xc(%rbp),%eax
  cltd
  idivl  -0x14(%rbp)
  mov    %edx,%eax
  test   %eax,%eax
  jne    L0
  movl   $0x0,-0x4(%rbp)
  jmp    L41
L0:
  addl   $0x1,-0x14(%rbp)
L95:
  mov    -0x14(%rbp),%eax
  cmp    -0xc(%rbp),%eax
  jl     L75
L41:
  cmpl   $0x1,-0x4(%rbp)
  jne    L3
  cmpl   $0x8,-0x10(%rbp)
  jg     L4
  mov    -0xc(%rbp),%eax
  add    %eax,-0x8(%rbp)
  addl   $0x1,-0x10(%rbp)
  mov    -0xc(%rbp),%eax
  mov    %eax,%esi
  lea    D18(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L3
L4:
  cmpl   $0x9,-0x10(%rbp)
  jne    L3
  mov    -0xc(%rbp),%eax
  add    %eax,-0x8(%rbp)
  addl   $0x1,-0x10(%rbp)
  mov    -0x8(%rbp),%edx
  mov    -0xc(%rbp),%eax
  mov    %eax,%esi
  lea    D12(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L3:
  subl   $0x2,-0xc(%rbp)
L42:
  cmpl   $0x9,-0x10(%rbp)
  jle    L29
  mov    $0x0,%eax
  leave
  ret
```

tool_calls: name: unpack_data
arguments: label: D18
type_guessed: string
name: unpack_data
arguments: label: D12
type_guessed: string

tool: D18: %d+

tool: D12: %d=%d

assistant: ```c
int main() {
  int i, t = 0, n, s = 0, isprime = 1;
  for (n = 999; t < 10; n -= 2) {
    isprime = 1;
    for (i = 2; i < n; i++) {
      if (0 == n % i) {
        isprime = 0;
        break;
      }
    }
    if (1 == isprime) {
      if (t < 9) {
        s += n;
        t += 1;
        printf("%d+", n);
      } else if (9 == t) {
        s += n;
        t += 1;
        printf("%d=%d", n, s);
      }
    }
  }
  return 0;
}
```
user: Translate the below assembly code into C programming language:

```asm
<main>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    $0x3e7,%ebx
  mov    $0x0,%r12d
  mov    $0x0,%ebp
  lea    D5(%rip),%r13
  jmp    L33
L79:
  add    %esi,%r12d
  add    $0x1,%ebp
  mov    %r13,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  jmp    L81
L45:
  lea    (%rsi,%r12,1),%edx
  lea    D13(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
L74:
  mov    $0x0,%eax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L56:
  cmp    $0x8,%ebp
  jle    L79
  cmp    $0x9,%ebp
  je     L45
L7:
  cmp    $0x9,%ebp
  jg     L74
L81:
  sub    $0x2,%ebx
L33:
  mov    %ebx,%esi
  mov    $0x2,%ecx
  cmp    $0x2,%ebx
  jle    L56
L62:
  add    $0x1,%ecx
  cmp    %esi,%ecx
  je     L56
  mov    %esi,%eax
  cltd
  idiv   %ecx
  test   %edx,%edx
  jne    L62
  jmp    L7
```

tool_calls: name: read_data
arguments: data_tag: D5
type_guessed: string
name: read_data
arguments: data_tag: D13
type_guessed: string

tool: D5: %d+

tool: D13: %d=%d

assistant: ```c
int main() {
  int i, t = 0, n, s = 0, isprime = 1;
  for (n = 999; t < 10; n -= 2) {
    isprime = 1;
    for (i = 2; i < n; i++) {
      if (0 == n % i) {
        isprime = 0;
        break;
      }
    }
    if (1 == isprime) {
      if (t < 9) {
        s += n;
        t += 1;
        printf("%d+", n);
      } else if (9 == t) {
        s += n;
        t += 1;
        printf("%d=%d", n, s);
      }
    }
  }
  return 0;
}
```
user: Translate the below assembly code into C programming language:

```asm
<main>:
  endbr64
  push   %r13
  xor    %r13d,%r13d
  push   %r12
  mov    $0x3e7,%r12d
  push   %rbp
  lea    D6(%rip),%rbp
  push   %rbx
  xor    %ebx,%ebx
  sub    $0x8,%rsp
L24:
  mov    $0x2,%ecx
  cmp    $0x2,%r12d
  jg     L43
  jmp    L33
  nopl   (%rax)
L12:
  mov    %r12d,%eax
  cltd
  idiv   %ecx
  test   %edx,%edx
  je     L2
L43:
  add    $0x1,%ecx
  cmp    %r12d,%ecx
  jne    L12
L33:
  add    %r12d,%r13d
  cmp    $0x9,%ebx
  je     L58
  mov    %r12d,%esi
  mov    %rbp,%rdi
  xor    %eax,%eax
  add    $0x1,%ebx
  call   <printf@plt>
L2:
  sub    $0x2,%r12d
  cmp    $0xa,%ebx
  jne    L24
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L58:
  mov    %r13d,%edx
  mov    %r12d,%esi
  lea    D14(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

tool_calls: name: disassemble_data
arguments: data_tag: D6
type: string
name: disassemble_data
arguments: data_tag: D14
type: string

tool: D6: %d+

tool: D14: %d=%d

assistant: ```c
int main() {
  int i, t = 0, n, s = 0, isprime = 1;
  for (n = 999; t < 10; n -= 2) {
    isprime = 1;
    for (i = 2; i < n; i++) {
      if (0 == n % i) {
        isprime = 0;
        break;
      }
    }
    if (1 == isprime) {
      if (t < 9) {
        s += n;
        t += 1;
        printf("%d+", n);
      } else if (9 == t) {
        s += n;
        t += 1;
        printf("%d=%d", n, s);
      }
    }
  }
  return 0;
}
```
user: What is the c source code of the assembly code below?

```asm
<main>:
  endbr64
  push   %r13
  xor    %r13d,%r13d
  push   %r12
  mov    $0x3e7,%r12d
  push   %rbp
  lea    D12(%rip),%rbp
  push   %rbx
  xor    %ebx,%ebx
  sub    $0x8,%rsp
L22:
  mov    $0x2,%ecx
  cmp    $0x2,%r12d
  jg     L14
  jmp    L3
  nopl   (%rax)
L32:
  mov    %r12d,%eax
  cltd
  idiv   %ecx
  test   %edx,%edx
  je     L46
L14:
  add    $0x1,%ecx
  cmp    %r12d,%ecx
  jne    L32
L3:
  add    %r12d,%r13d
  cmp    $0x9,%ebx
  je     L33
  mov    %r12d,%esi
  mov    %rbp,%rdi
  xor    %eax,%eax
  add    $0x1,%ebx
  call   <printf@plt>
L46:
  sub    $0x2,%r12d
  cmp    $0xa,%ebx
  jne    L22
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L33:
  mov    %r13d,%edx
  mov    %r12d,%esi
  lea    D4(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

tool_calls: name: read_data
arguments: tag: D12
type_infered: string
name: read_data
arguments: tag: D4
type_infered: string

tool: D12: %d+

tool: D4: %d=%d

assistant: ```c
int main() {
  int i, t = 0, n, s = 0, isprime = 1;
  for (n = 999; t < 10; n -= 2) {
    isprime = 1;
    for (i = 2; i < n; i++) {
      if (0 == n % i) {
        isprime = 0;
        break;
      }
    }
    if (1 == isprime) {
      if (t < 9) {
        s += n;
        t += 1;
        printf("%d+", n);
      } else if (9 == t) {
        s += n;
        t += 1;
        printf("%d=%d", n, s);
      }
    }
  }
  return 0;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<dsa_pkey_ctrl>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %esi,-0x3c(%rbp)
  mov    %rdx,-0x48(%rbp)
  mov    %rcx,-0x50(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x18(%rbp)
  xor    %eax,%eax
  cmpl   $0x80,-0x3c(%rbp)
  je     L82
  cmpl   $0x81,-0x3c(%rbp)
  je     L70
  jmp    L102
L82:
  cmpq   $0x0,-0x48(%rbp)
  jne    L40
  lea    -0x20(%rbp),%rcx
  lea    -0x28(%rbp),%rdx
  mov    -0x50(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <PKCS7_SIGNER_INFO_get0_algs@plt>
  mov    -0x28(%rbp),%rax
  test   %rax,%rax
  je     L66
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  jne    L28
L66:
  mov    $0xffffffff,%eax
  jmp    L101
L28:
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <OBJ_obj2nid@plt>
  mov    %eax,-0x2c(%rbp)
  mov    D27(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,-0x2c(%rbp)
  jne    L117
  mov    $0xffffffff,%eax
  jmp    L101
L117:
  mov    -0x38(%rbp),%rax
  mov    %rax,%rdi
  call   <EVP_PKEY_id@plt>
  mov    %eax,%edx
  mov    -0x2c(%rbp),%ecx
  lea    -0x30(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <OBJ_find_sigid_by_algs@plt>
  test   %eax,%eax
  jne    L111
  mov    $0xffffffff,%eax
  jmp    L101
L111:
  mov    D10(%rip),%rax
  mov    (%rax),%ebx
  mov    -0x30(%rbp),%eax
  mov    %eax,%edi
  call   <OBJ_nid2obj@plt>
  mov    %eax,%esi
  mov    -0x20(%rbp),%rax
  mov    $0x0,%ecx
  mov    %ebx,%edx
  mov    %rax,%rdi
  call   <X509_ALGOR_set0@plt>
L40:
  mov    $0x1,%eax
  jmp    L101
L70:
  mov    D19(%rip),%rax
  mov    (%rax),%edx
  mov    -0x50(%rbp),%rax
  mov    %edx,(%rax)
  mov    $0x2,%eax
  jmp    L101
L102:
  mov    $0xfffffffe,%eax
L101:
  mov    -0x18(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L139
  call   <__stack_chk_fail@plt>
L139:
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

assistant: ```c
int dsa_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2) {
  switch (op) {
  case ASN1_PKEY_CTRL_PKCS7_SIGN:
    if (arg1 == 0) {
      int snid, hnid;
      X509_ALGOR *alg1, *alg2;
      PKCS7_SIGNER_INFO_get0_algs(arg2, NULL, &alg1, &alg2);
      if (alg1 == NULL || alg1->algorithm == NULL)
        return -1;
      hnid = OBJ_obj2nid(alg1->algorithm);
      if (hnid == NID_undef)
        return -1;
      if (!OBJ_find_sigid_by_algs(&snid, hnid, EVP_PKEY_id(pkey)))
        return -1;
      X509_ALGOR_set0(alg2, OBJ_nid2obj(snid), V_ASN1_UNDEF, 0);
    }
    return 1;
  case ASN1_PKEY_CTRL_DEFAULT_MD_NID:
    *(int *)arg2 = NID_sha1;
    return 2;
  default:
    return -2;
  }
}
```
user: 这段汇编代码用C语言表示是什么样的？

```asm
<dsa_pkey_ctrl>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,%rbx
  mov    %rcx,%rdi
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  cmp    $0x80,%esi
  je     L89
  mov    $0xfffffffe,%eax
  cmp    $0x81,%esi
  jne    L68
  mov    D19(%rip),%rax
  mov    (%rax),%eax
  mov    %eax,(%rcx)
  mov    $0x2,%eax
L68:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L2
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  ret
L89:
  mov    $0x1,%eax
  test   %rdx,%rdx
  jne    L68
  lea    0x10(%rsp),%rcx
  lea    0x8(%rsp),%rdx
  mov    $0x0,%esi
  call   <PKCS7_SIGNER_INFO_get0_algs@plt>
  mov    0x8(%rsp),%rax
  test   %rax,%rax
  je     L98
  mov    (%rax),%rdi
  test   %rdi,%rdi
  je     L98
  call   <OBJ_obj2nid@plt>
  mov    %eax,%ebp
  mov    D2(%rip),%rax
  cmp    %ebp,(%rax)
  je     L98
  mov    %rbx,%rdi
  call   <EVP_PKEY_id@plt>
  mov    %eax,%edx
  lea    0x4(%rsp),%rdi
  mov    %ebp,%esi
  call   <OBJ_find_sigid_by_algs@plt>
  test   %eax,%eax
  je     L98
  mov    D3(%rip),%rax
  mov    (%rax),%ebx
  mov    0x4(%rsp),%edi
  call   <OBJ_nid2obj@plt>
  mov    %eax,%esi
  mov    $0x0,%ecx
  mov    %ebx,%edx
  mov    0x10(%rsp),%rdi
  call   <X509_ALGOR_set0@plt>
  mov    $0x1,%eax
  jmp    L68
L98:
  mov    $0xffffffff,%eax
  jmp    L68
L2:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int dsa_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2) {
  switch (op) {
  case ASN1_PKEY_CTRL_PKCS7_SIGN:
    if (arg1 == 0) {
      int snid, hnid;
      X509_ALGOR *alg1, *alg2;
      PKCS7_SIGNER_INFO_get0_algs(arg2, NULL, &alg1, &alg2);
      if (alg1 == NULL || alg1->algorithm == NULL)
        return -1;
      hnid = OBJ_obj2nid(alg1->algorithm);
      if (hnid == NID_undef)
        return -1;
      if (!OBJ_find_sigid_by_algs(&snid, hnid, EVP_PKEY_id(pkey)))
        return -1;
      X509_ALGOR_set0(alg2, OBJ_nid2obj(snid), V_ASN1_UNDEF, 0);
    }
    return 1;
  case ASN1_PKEY_CTRL_DEFAULT_MD_NID:
    *(int *)arg2 = NID_sha1;
    return 2;
  default:
    return -2;
  }
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<dsa_pkey_ctrl>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  mov    %rcx,%rdi
  sub    $0x20,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  cmp    $0x80,%esi
  je     L59
  mov    $0xfffffffe,%r12d
  cmp    $0x81,%esi
  jne    L82
  mov    D16(%rip),%rax
  mov    $0x2,%r12d
  mov    (%rax),%eax
  mov    %eax,(%rcx)
L82:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L62
  add    $0x20,%rsp
  mov    %r12d,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax,%rax,1)
L59:
  mov    $0x1,%r12d
  test   %rdx,%rdx
  jne    L82
  lea    0x10(%rsp),%rcx
  lea    0x8(%rsp),%rdx
  xor    %esi,%esi
  call   <PKCS7_SIGNER_INFO_get0_algs@plt>
  mov    0x8(%rsp),%rax
  test   %rax,%rax
  je     L49
  mov    (%rax),%rdi
  test   %rdi,%rdi
  je     L49
  call   <OBJ_obj2nid@plt>
  mov    %eax,%r13d
  mov    D29(%rip),%rax
  cmp    %r13d,(%rax)
  je     L49
  mov    %rbp,%rdi
  call   <EVP_PKEY_id@plt>
  lea    0x4(%rsp),%rdi
  mov    %r13d,%esi
  mov    %eax,%edx
  call   <OBJ_find_sigid_by_algs@plt>
  test   %eax,%eax
  je     L49
  mov    D14(%rip),%rax
  mov    0x4(%rsp),%edi
  mov    (%rax),%r13d
  call   <OBJ_nid2obj@plt>
  mov    0x10(%rsp),%rdi
  xor    %ecx,%ecx
  mov    %eax,%esi
  mov    %r13d,%edx
  call   <X509_ALGOR_set0@plt>
  jmp    L82
L49:
  mov    $0xffffffff,%r12d
  jmp    L82
L62:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int dsa_pkey_ctrl(EVP_PKEY *pkey, int op, long arg1, void *arg2) {
  switch (op) {
  case ASN1_PKEY_CTRL_PKCS7_SIGN:
    if (arg1 == 0) {
      int snid, hnid;
      X509_ALGOR *alg1, *alg2;
      PKCS7_SIGNER_INFO_get0_algs(arg2, NULL, &alg1, &alg2);
      if (alg1 == NULL || alg1->algorithm == NULL)
        return -1;
      hnid = OBJ_obj2nid(alg1->algorithm);
      if (hnid == NID_undef)
        return -1;
      if (!OBJ_find_sigid_by_algs(&snid, hnid, EVP_PKEY_id(pkey)))
        return -1;
      X509_ALGOR_set0(alg2, OBJ_nid2obj(snid), V_ASN1_UNDEF, 0);
    }
    return 1;
  case ASN1_PKEY_CTRL_DEFAULT_MD_NID:
    *(int *)arg2 = NID_sha1;
    return 2;
  default:
    return -2;
  }
}
```