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

```asm
<destroyNodeArrays>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%r12
  test   %esi,%esi
  jle    L19
  mov    %rdi,%rbx
  lea    -0x1(%rsi),%eax
  lea    0x8(%rdi,%rax,8),%rbp
L14:
  mov    (%rbx),%rdi
  call   <free@plt>
  add    $0x8,%rbx
  cmp    %rbp,%rbx
  jne    L14
L19:
  mov    %r12,%rdi
  call   <free@plt>
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
void destroyNodeArrays(double **node_array, int size) {
  int i;
  for (i = 0; i < size; i++) {
    free(node_array[i]);
  }
  free(node_array);
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<destroyNodeArrays>:
  endbr64
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  push   %rbx
  test   %esi,%esi
  jle    L2
  lea    -0x1(%rsi),%eax
  mov    %rdi,%rbx
  lea    0x8(%rdi,%rax,8),%rbp
  nopw   0x0(%rax,%rax,1)
L12:
  mov    (%rbx),%rdi
  add    $0x8,%rbx
  call   <free@plt>
  cmp    %rbp,%rbx
  jne    L12
L2:
  pop    %rbx
  mov    %r12,%rdi
  pop    %rbp
  pop    %r12
  jmp    1050 <free@plt>
```

assistant: ```c
void destroyNodeArrays(double **node_array, int size) {
  int i;
  for (i = 0; i < size; i++) {
    free(node_array[i]);
  }
  free(node_array);
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<destroyNodeArrays>:
  endbr64
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  push   %rbx
  test   %esi,%esi
  jle    L19
  lea    -0x1(%rsi),%eax
  mov    %rdi,%rbx
  lea    0x8(%rdi,%rax,8),%rbp
  nopw   0x0(%rax,%rax,1)
L1:
  mov    (%rbx),%rdi
  add    $0x8,%rbx
  call   <free@plt>
  cmp    %rbp,%rbx
  jne    L1
L19:
  pop    %rbx
  mov    %r12,%rdi
  pop    %rbp
  pop    %r12
  jmp    1050 <free@plt>
```

assistant: ```c
void destroyNodeArrays(double **node_array, int size) {
  int i;
  for (i = 0; i < size; i++) {
    free(node_array[i]);
  }
  free(node_array);
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<ft_print_words_tables>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  movl   $0x0,-0x4(%rbp)
  jmp    L0
L20:
  movl   $0x0,-0x8(%rbp)
  jmp    L29
L6:
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x8(%rbp),%eax
  cltq
  add    %rdx,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <ft_putchar@plt>
  addl   $0x1,-0x8(%rbp)
L29:
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x8(%rbp),%eax
  cltq
  add    %rdx,%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L6
  mov    $0xa,%edi
  call   <ft_putchar@plt>
  addq   $0x8,-0x18(%rbp)
L0:
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  test   %rax,%rax
  jne    L20
  nop
  nop
  leave
  ret
```

assistant: ```c
void ft_print_words_tables(char **tab) {
  int i;
  int k;
  i = 0;
  while (tab[i]) {
    k = 0;
    while (tab[i][k]) {
      ft_putchar(tab[i][k]);
      k++;
    }
    ft_putchar('\n');
    tab++;
  }
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<ft_print_words_tables>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%rbp
  cmpq   $0x0,(%rdi)
  jne    L8
L38:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
L41:
  movsbl %dil,%edi
  call   <ft_putchar@plt>
  mov    0x0(%rbp),%rax
  movzbl (%rax,%rbx,1),%edi
  add    $0x1,%rbx
  test   %dil,%dil
  jne    L41
L30:
  mov    $0xa,%edi
  call   <ft_putchar@plt>
  add    $0x8,%rbp
  cmpq   $0x0,0x0(%rbp)
  je     L38
L8:
  mov    0x0(%rbp),%rax
  movzbl (%rax),%edi
  mov    $0x1,%ebx
  test   %dil,%dil
  jne    L41
  jmp    L30
```

assistant: ```c
void ft_print_words_tables(char **tab) {
  int i;
  int k;
  i = 0;
  while (tab[i]) {
    k = 0;
    while (tab[i][k]) {
      ft_putchar(tab[i][k]);
      k++;
    }
    ft_putchar('\n');
    tab++;
  }
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<ft_print_words_tables>:
  endbr64
  mov    (%rdi),%rax
  test   %rax,%rax
  je     L25
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  sub    $0x8,%rsp
  nopl   (%rax)
L17:
  movsbl (%rax),%edi
  mov    $0x1,%ebx
  test   %dil,%dil
  je     L31
  nopl   (%rax)
L34:
  call   <ft_putchar@plt>
  mov    0x0(%rbp),%rax
  movsbl (%rax,%rbx,1),%edi
  add    $0x1,%rbx
  test   %dil,%dil
  jne    L34
L31:
  mov    $0xa,%edi
  add    $0x8,%rbp
  call   <ft_putchar@plt>
  mov    0x0(%rbp),%rax
  test   %rax,%rax
  jne    L17
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
L25:
  ret
```

assistant: ```c
void ft_print_words_tables(char **tab) {
  int i;
  int k;
  i = 0;
  while (tab[i]) {
    k = 0;
    while (tab[i][k]) {
      ft_putchar(tab[i][k]);
      k++;
    }
    ft_putchar('\n');
    tab++;
  }
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<ft_print_words_tables>:
  endbr64
  cmpq   $0x0,(%rdi)
  je     L19
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  sub    $0x8,%rsp
  nopl   0x0(%rax,%rax,1)
L14:
  mov    0x0(%rbp),%rax
  mov    $0x1,%ebx
  movsbl (%rax),%edi
  test   %dil,%dil
  je     L18
  nopl   0x0(%rax)
L6:
  call   <ft_putchar@plt>
  mov    0x0(%rbp),%rax
  movsbl (%rax,%rbx,1),%edi
  add    $0x1,%rbx
  test   %dil,%dil
  jne    L6
L18:
  mov    $0xa,%edi
  add    $0x8,%rbp
  call   <ft_putchar@plt>
  cmpq   $0x0,0x0(%rbp)
  jne    L14
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
L19:
  ret
```

assistant: ```c
void ft_print_words_tables(char **tab) {
  int i;
  int k;
  i = 0;
  while (tab[i]) {
    k = 0;
    while (tab[i][k]) {
      ft_putchar(tab[i][k]);
      k++;
    }
    ft_putchar('\n');
    tab++;
  }
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<mod_rhs>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L6
  mov    $0x1,%eax
  jmp    L14
L6:
  mov    -0x8(%rbp),%rax
L14:
  pop    %rbp
  ret
```

assistant: ```c
unsigned long int mod_rhs(const long int rhs) {
  if (rhs == 0)
    return 1;
  return rhs;
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<mod_rhs>:
  endbr64
  mov    %rdi,%rax
  test   %rdi,%rdi
  mov    $0x1,%edx
  cmove  %rdx,%rax
  ret
```

assistant: ```c
unsigned long int mod_rhs(const long int rhs) {
  if (rhs == 0)
    return 1;
  return rhs;
}
```
user: Translate the below assembly code into C programming language:

```asm
<mod_rhs>:
  endbr64
  mov    %rdi,%rax
  test   %rdi,%rdi
  mov    $0x1,%edx
  cmove  %rdx,%rax
  ret
```

assistant: ```c
unsigned long int mod_rhs(const long int rhs) {
  if (rhs == 0)
    return 1;
  return rhs;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<mod_rhs>:
  endbr64
  mov    %rdi,%rax
  test   %rdi,%rdi
  mov    $0x1,%edx
  cmove  %rdx,%rax
  ret
```

assistant: ```c
unsigned long int mod_rhs(const long int rhs) {
  if (rhs == 0)
    return 1;
  return rhs;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<cbstore>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %rdi,-0x8(%rbp)
  mov    %rsi,-0x10(%rbp)
  movabs $0xffffffff7ffffffc,%rax
  and    -0x8(%rbp),%rax
  mov    $0x80000000,%edx
  or     %rdx,%rax
  mov    $0xcf8,%esi
  mov    %rax,%rdi
  call   <outl@plt>
  mov    -0x8(%rbp),%rax
  and    $0x3,%eax
  add    $0xcfc,%eax
  mov    %eax,%edx
  mov    -0x10(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <outb@plt>
  nop
  leave
  ret
```

assistant: ```c
void cbstore(long cfgadr, long value) {
  outl((cfgadr | 0x80000000) & ~3, 0xcf8);
  outb(value, 0xcfc + (cfgadr & 3));
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<cbstore>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%rbx
  mov    %rsi,%rbp
  movabs $0xffffffff7ffffffc,%rdi
  and    %rbx,%rdi
  bts    $0x1f,%rdi
  mov    $0xcf8,%esi
  call   <outl@plt>
  and    $0x3,%ebx
  lea    0xcfc(%rbx),%esi
  mov    %rbp,%rdi
  call   <outb@plt>
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
```

assistant: ```c
void cbstore(long cfgadr, long value) {
  outl((cfgadr | 0x80000000) & ~3, 0xcf8);
  outb(value, 0xcfc + (cfgadr & 3));
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<cbstore>:
  endbr64
  push   %rbp
  mov    %rsi,%rbp
  mov    $0xcf8,%esi
  push   %rbx
  mov    %rdi,%rbx
  movabs $0xffffffff7ffffffc,%rdi
  and    %rbx,%rdi
  and    $0x3,%ebx
  bts    $0x1f,%rdi
  sub    $0x8,%rsp
  call   <outl@plt>
  add    $0x8,%rsp
  lea    0xcfc(%rbx),%esi
  mov    %rbp,%rdi
  pop    %rbx
  pop    %rbp
  jmp    1060 <outb@plt>
```

assistant: ```c
void cbstore(long cfgadr, long value) {
  outl((cfgadr | 0x80000000) & ~3, 0xcf8);
  outb(value, 0xcfc + (cfgadr & 3));
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<cbstore>:
  endbr64
  push   %rbp
  mov    %rsi,%rbp
  mov    $0xcf8,%esi
  push   %rbx
  mov    %rdi,%rbx
  movabs $0xffffffff7ffffffc,%rdi
  and    %rbx,%rdi
  and    $0x3,%ebx
  bts    $0x1f,%rdi
  sub    $0x8,%rsp
  call   <outl@plt>
  add    $0x8,%rsp
  lea    0xcfc(%rbx),%esi
  mov    %rbp,%rdi
  pop    %rbx
  pop    %rbp
  jmp    1060 <outb@plt>
```

assistant: ```c
void cbstore(long cfgadr, long value) {
  outl((cfgadr | 0x80000000) & ~3, 0xcf8);
  outb(value, 0xcfc + (cfgadr & 3));
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<getindex>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  movl   $0x0,-0x4(%rbp)
  jmp    L21
L29:
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    -0x20(%rbp),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L25
  mov    -0x4(%rbp),%eax
  jmp    L19
L25:
  addl   $0x1,-0x4(%rbp)
L21:
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  test   %rax,%rax
  jne    L29
  mov    $0xffffffff,%eax
L19:
  leave
  ret
```

assistant: ```c
int getindex(const char *words[], const char *word) {
  int i = 0;
  while (words[i]) {
    if (strcmp(words[i], word) == 0)
      return i;
    i++;
  }
  return -1;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<getindex>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%rbp
  mov    (%rdi),%rdi
  test   %rdi,%rdi
  je     L13
  mov    %rsi,%r12
  mov    $0x0,%ebx
L3:
  mov    %ebx,%r13d
  mov    %r12,%rsi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L30
  add    $0x1,%rbx
  mov    0x0(%rbp,%rbx,8),%rdi
  test   %rdi,%rdi
  jne    L3
  mov    $0xffffffff,%r13d
L30:
  mov    %r13d,%eax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L13:
  mov    $0xffffffff,%r13d
  jmp    L30
```

assistant: ```c
int getindex(const char *words[], const char *word) {
  int i = 0;
  while (words[i]) {
    if (strcmp(words[i], word) == 0)
      return i;
    i++;
  }
  return -1;
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<getindex>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    (%rdi),%rdi
  test   %rdi,%rdi
  je     L31
  mov    %rsi,%r12
  xor    %ebx,%ebx
  jmp    L12
L26:
  add    $0x1,%rbx
  mov    0x0(%rbp,%rbx,8),%rdi
  test   %rdi,%rdi
  je     L31
L12:
  mov    %r12,%rsi
  mov    %ebx,%r13d
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L26
  add    $0x8,%rsp
  mov    %r13d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L31:
  add    $0x8,%rsp
  mov    $0xffffffff,%r13d
  pop    %rbx
  mov    %r13d,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

assistant: ```c
int getindex(const char *words[], const char *word) {
  int i = 0;
  while (words[i]) {
    if (strcmp(words[i], word) == 0)
      return i;
    i++;
  }
  return -1;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<getindex>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    (%rdi),%rdi
  test   %rdi,%rdi
  je     L24
  mov    %rsi,%r12
  xor    %ebx,%ebx
  jmp    L31
L13:
  add    $0x1,%rbx
  mov    0x0(%rbp,%rbx,8),%rdi
  test   %rdi,%rdi
  je     L24
L31:
  mov    %r12,%rsi
  mov    %ebx,%r13d
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L13
  add    $0x8,%rsp
  mov    %r13d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L24:
  add    $0x8,%rsp
  mov    $0xffffffff,%r13d
  pop    %rbx
  mov    %r13d,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

assistant: ```c
int getindex(const char *words[], const char *word) {
  int i = 0;
  while (words[i]) {
    if (strcmp(words[i], word) == 0)
      return i;
    i++;
  }
  return -1;
}
```
user: What is the c source code of the assembly code below?

```asm
<wps_pin_checksum>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,-0x14(%rbp)
  movl   $0x0,-0x4(%rbp)
  jmp    L2
L5:
  mov    -0x14(%rbp),%ecx
  mov    %ecx,%edx
  mov    $0xcccccccd,%eax
  imul   %rdx,%rax
  shr    $0x20,%rax
  mov    %eax,%edx
  shr    $0x3,%edx
  mov    %edx,%eax
  shl    $0x2,%eax
  add    %edx,%eax
  add    %eax,%eax
  sub    %eax,%ecx
  mov    %ecx,%edx
  mov    %edx,%eax
  add    %eax,%eax
  add    %edx,%eax
  add    %eax,-0x4(%rbp)
  mov    -0x14(%rbp),%eax
  mov    %eax,%edx
  mov    $0xcccccccd,%eax
  imul   %rdx,%rax
  shr    $0x20,%rax
  shr    $0x3,%eax
  mov    %eax,-0x14(%rbp)
  mov    -0x14(%rbp),%ecx
  mov    %ecx,%edx
  mov    $0xcccccccd,%eax
  imul   %rdx,%rax
  shr    $0x20,%rax
  mov    %eax,%edx
  shr    $0x3,%edx
  mov    %edx,%eax
  shl    $0x2,%eax
  add    %edx,%eax
  add    %eax,%eax
  sub    %eax,%ecx
  mov    %ecx,%edx
  add    %edx,-0x4(%rbp)
  mov    -0x14(%rbp),%eax
  mov    %eax,%edx
  mov    $0xcccccccd,%eax
  imul   %rdx,%rax
  shr    $0x20,%rax
  shr    $0x3,%eax
  mov    %eax,-0x14(%rbp)
L2:
  cmpl   $0x0,-0x14(%rbp)
  jne    L5
  mov    -0x4(%rbp),%ecx
  mov    %ecx,%edx
  mov    $0xcccccccd,%eax
  imul   %rdx,%rax
  shr    $0x20,%rax
  mov    %eax,%edx
  shr    $0x3,%edx
  mov    %edx,%eax
  shl    $0x2,%eax
  add    %edx,%eax
  add    %eax,%eax
  sub    %eax,%ecx
  mov    %ecx,%edx
  mov    $0xa,%eax
  sub    %edx,%eax
  mov    %eax,%ecx
  mov    %ecx,%edx
  mov    $0xcccccccd,%eax
  imul   %rdx,%rax
  shr    $0x20,%rax
  mov    %eax,%edx
  shr    $0x3,%edx
  mov    %edx,%eax
  shl    $0x2,%eax
  add    %edx,%eax
  add    %eax,%eax
  sub    %eax,%ecx
  mov    %ecx,%edx
  mov    %edx,%eax
  pop    %rbp
  ret
```

assistant: ```c
unsigned int wps_pin_checksum(unsigned int pin) {
  unsigned int acc = 0;
  while (pin) {
    acc += 3 * (pin % 10);
    pin /= 10;
    acc += pin % 10;
    pin /= 10;
  }
  return (10 - acc % 10) % 10;
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<wps_pin_checksum>:
  endbr64
  mov    %edi,%ecx
  test   %edi,%edi
  je     L3
  mov    $0x0,%r8d
  mov    $0xcccccccd,%r9d
L18:
  mov    %ecx,%eax
  imul   %r9,%rax
  shr    $0x23,%rax
  lea    (%rax,%rax,4),%edx
  add    %edx,%edx
  mov    %ecx,%esi
  sub    %edx,%esi
  lea    (%rsi,%rsi,2),%esi
  mov    %eax,%edx
  imul   %r9,%rdx
  shr    $0x23,%rdx
  lea    (%rdx,%rdx,4),%edi
  add    %edi,%edi
  sub    %edi,%eax
  add    %esi,%eax
  add    %eax,%r8d
  mov    %ecx,%eax
  mov    %edx,%ecx
  cmp    $0x63,%eax
  ja     L18
L22:
  mov    %r8d,%eax
  mov    $0xcccccccd,%edx
  imul   %rdx,%rax
  shr    $0x23,%rax
  lea    (%rax,%rax,4),%eax
  add    %eax,%eax
  sub    %r8d,%eax
  lea    0xa(%rax),%ecx
  mov    %ecx,%eax
  imul   %rdx,%rax
  shr    $0x23,%rax
  lea    (%rax,%rax,4),%edx
  add    %edx,%edx
  mov    %ecx,%eax
  sub    %edx,%eax
  ret
L3:
  mov    %edi,%r8d
  jmp    L22
```

assistant: ```c
unsigned int wps_pin_checksum(unsigned int pin) {
  unsigned int acc = 0;
  while (pin) {
    acc += 3 * (pin % 10);
    pin /= 10;
    acc += pin % 10;
    pin /= 10;
  }
  return (10 - acc % 10) % 10;
}
```
user: What is the c source code of the assembly code below:

```asm
<wps_pin_checksum>:
  endbr64
  mov    %edi,%esi
  xor    %eax,%eax
  test   %edi,%edi
  je     L2
  mov    $0xcccccccd,%r9d
  nopw   0x0(%rax,%rax,1)
L3:
  mov    %esi,%edx
  mov    %esi,%edi
  imul   %r9,%rdx
  shr    $0x23,%rdx
  lea    (%rdx,%rdx,4),%ecx
  add    %ecx,%ecx
  sub    %ecx,%edi
  mov    %edx,%ecx
  imul   %r9,%rcx
  lea    (%rdi,%rdi,2),%edi
  shr    $0x23,%rcx
  lea    (%rcx,%rcx,4),%r8d
  add    %r8d,%r8d
  sub    %r8d,%edx
  add    %edi,%edx
  add    %edx,%eax
  mov    %esi,%edx
  mov    %ecx,%esi
  cmp    $0x63,%edx
  ja     L3
  mov    %eax,%edx
  imul   %r9,%rdx
  shr    $0x23,%rdx
  lea    (%rdx,%rdx,4),%edx
  add    %edx,%edx
  sub    %eax,%edx
  lea    0xa(%rdx),%eax
  mov    %rax,%rcx
  imul   %r9,%rax
  shr    $0x23,%rax
  lea    (%rax,%rax,4),%edx
  mov    %ecx,%eax
  add    %edx,%edx
  sub    %edx,%eax
  ret
  nopl   0x0(%rax,%rax,1)
L2:
  ret
```

assistant: ```c
unsigned int wps_pin_checksum(unsigned int pin) {
  unsigned int acc = 0;
  while (pin) {
    acc += 3 * (pin % 10);
    pin /= 10;
    acc += pin % 10;
    pin /= 10;
  }
  return (10 - acc % 10) % 10;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<wps_pin_checksum>:
  endbr64
  mov    %edi,%esi
  xor    %eax,%eax
  test   %edi,%edi
  je     L17
  mov    $0xcccccccd,%r9d
  nopw   0x0(%rax,%rax,1)
L10:
  mov    %esi,%edx
  mov    %esi,%edi
  imul   %r9,%rdx
  shr    $0x23,%rdx
  lea    (%rdx,%rdx,4),%ecx
  add    %ecx,%ecx
  sub    %ecx,%edi
  mov    %edx,%ecx
  imul   %r9,%rcx
  lea    (%rdi,%rdi,2),%edi
  shr    $0x23,%rcx
  lea    (%rcx,%rcx,4),%r8d
  add    %r8d,%r8d
  sub    %r8d,%edx
  add    %edi,%edx
  add    %edx,%eax
  mov    %esi,%edx
  mov    %ecx,%esi
  cmp    $0x63,%edx
  ja     L10
  mov    %eax,%edx
  imul   %r9,%rdx
  shr    $0x23,%rdx
  lea    (%rdx,%rdx,4),%edx
  add    %edx,%edx
  sub    %eax,%edx
  lea    0xa(%rdx),%eax
  mov    %rax,%rcx
  imul   %r9,%rax
  shr    $0x23,%rax
  lea    (%rax,%rax,4),%edx
  mov    %ecx,%eax
  add    %edx,%edx
  sub    %edx,%eax
  ret
  nopl   0x0(%rax,%rax,1)
L17:
  ret
```

assistant: ```c
unsigned int wps_pin_checksum(unsigned int pin) {
  unsigned int acc = 0;
  while (pin) {
    acc += 3 * (pin % 10);
    pin /= 10;
    acc += pin % 10;
    pin /= 10;
  }
  return (10 - acc % 10) % 10;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<open_sf_source>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %esi,-0x3c(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    D18(%rip),%rax
  mov    (%rax),%ecx
  mov    D9(%rip),%rax
  mov    (%rax),%eax
  mov    $0x0,%edx
  mov    %ecx,%esi
  mov    %eax,%edi
  call   <socket@plt>
  mov    %eax,-0x24(%rbp)
  cmpl   $0x0,-0x24(%rbp)
  jns    L85
  mov    -0x24(%rbp),%eax
  jmp    L29
L85:
  mov    -0x38(%rbp),%rax
  mov    %rax,%rdi
  call   <gethostbyname@plt>
  mov    %rax,-0x20(%rbp)
  cmpq   $0x0,-0x20(%rbp)
  jne    L42
  mov    -0x24(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  mov    $0xffffffff,%eax
  jmp    L29
L42:
  mov    -0x20(%rbp),%rax
  mov    0x10(%rax),%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x20(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x20(%rbp),%rax
  mov    0x8(%rax),%rax
  mov    (%rax),%eax
  lea    -0x14(%rbp),%rcx
  add    $0x4,%rcx
  mov    %eax,%esi
  mov    %rcx,%rdi
  call   <memcpy@plt>
  mov    -0x3c(%rbp),%eax
  mov    %eax,%edi
  call   <htons@plt>
  mov    %eax,-0x14(%rbp)
  lea    -0x14(%rbp),%rcx
  mov    -0x24(%rbp),%eax
  mov    $0xc,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <connect@plt>
  test   %rax,%rax
  jns    L2
  mov    -0x24(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  mov    $0xffffffff,%eax
  jmp    L29
L2:
  mov    -0x24(%rbp),%eax
  mov    %eax,%edi
  call   <init_sf_source@plt>
  test   %rax,%rax
  jns    L19
  mov    -0x24(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  mov    $0xffffffff,%eax
  jmp    L29
L19:
  mov    -0x24(%rbp),%eax
L29:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L28
  call   <__stack_chk_fail@plt>
L28:
  leave
  ret
```

assistant: ```c
int open_sf_source(const char *host, int port) {
  int fd = socket(AF_INET, SOCK_STREAM, 0);
  struct hostent *entry;
  struct sockaddr_in addr;
  if (fd < 0)
    return fd;
  entry = gethostbyname(host);
  if (!entry) {
    close(fd);
    return -1;
  }
  addr.sin_family = entry->h_addrtype;
  memcpy(&addr.sin_addr, entry->h_addr_list[0], entry->h_length);
  addr.sin_port = htons(port);
  if (connect(fd, (struct sockaddr *)&addr, sizeof addr) < 0) {
    close(fd);
    return -1;
  }
  if (init_sf_source(fd) < 0) {
    close(fd);
    return -1;
  }
  return fd;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<open_sf_source>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x20,%rsp
  mov    %rdi,%rbp
  mov    %esi,%r12d
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  mov    $0x0,%edx
  mov    D6(%rip),%rax
  mov    (%rax),%esi
  mov    D10(%rip),%rax
  mov    (%rax),%edi
  call   <socket@plt>
  mov    %eax,%ebx
  test   %eax,%eax
  js     L15
  mov    %rbp,%rdi
  call   <gethostbyname@plt>
  test   %rax,%rax
  je     L76
  mov    0x10(%rax),%edx
  mov    %edx,0x14(%rsp)
  mov    0x8(%rax),%rcx
  lea    0xc(%rsp),%rbp
  lea    0x10(%rsp),%rdi
  mov    (%rax),%edx
  mov    (%rcx),%esi
  call   <memcpy@plt>
  mov    %r12d,%edi
  call   <htons@plt>
  mov    %eax,0xc(%rsp)
  mov    $0xc,%edx
  mov    %rbp,%rsi
  mov    %ebx,%edi
  call   <connect@plt>
  test   %rax,%rax
  js     L62
  mov    %ebx,%edi
  call   <init_sf_source@plt>
  test   %rax,%rax
  js     L63
L15:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L19
  mov    %ebx,%eax
  add    $0x20,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L76:
  mov    %ebx,%edi
  call   <close@plt>
  mov    $0xffffffff,%ebx
  jmp    L15
L62:
  mov    %ebx,%edi
  call   <close@plt>
  mov    $0xffffffff,%ebx
  jmp    L15
L63:
  mov    %ebx,%edi
  call   <close@plt>
  mov    $0xffffffff,%ebx
  jmp    L15
L19:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int open_sf_source(const char *host, int port) {
  int fd = socket(AF_INET, SOCK_STREAM, 0);
  struct hostent *entry;
  struct sockaddr_in addr;
  if (fd < 0)
    return fd;
  entry = gethostbyname(host);
  if (!entry) {
    close(fd);
    return -1;
  }
  addr.sin_family = entry->h_addrtype;
  memcpy(&addr.sin_addr, entry->h_addr_list[0], entry->h_length);
  addr.sin_port = htons(port);
  if (connect(fd, (struct sockaddr *)&addr, sizeof addr) < 0) {
    close(fd);
    return -1;
  }
  if (init_sf_source(fd) < 0) {
    close(fd);
    return -1;
  }
  return fd;
}
```