ylfeng/ReF-Decompile-dataset huggingface dataset:
user: What would the C source look like for the assembly code provided here?

```asm
<rsa_encrypt>:
  endbr64
  test   %rcx,%rcx
  jle    L2
  push   %rbx
  mov    %rsi,%r10
  mov    %rdx,%rbx
  mov    %rcx,%r11
  xor    %esi,%esi
  jmp    L7
  nopw   0x0(%rax,%rax,1)
L51:
  mov    %rdx,(%r8,%rsi,8)
  add    $0x1,%rsi
  cmp    %rsi,%r11
  je     L10
L7:
  movsbq (%rbx,%rsi,1),%r9
  mov    $0x1,%edx
  test   %r10,%r10
  je     L51
  mov    %r9,%rdx
  cmp    $0x1,%r10
  jle    L51
  mov    $0x1,%ecx
  nopw   0x0(%rax,%rax,1)
L36:
  mov    %rdx,%rax
  add    $0x1,%rcx
  imul   %r9,%rax
  cqto
  idiv   %rdi
  cmp    %rcx,%r10
  jne    L36
  mov    %rdx,(%r8,%rsi,8)
  add    $0x1,%rsi
  cmp    %rsi,%r11
  jne    L7
L10:
  pop    %rbx
  ret
L2:
  ret
```

assistant: ```c
void rsa_encrypt(long long n, long long e, char *mw, long long mLength, long long *cw) {
  long long i = 0, j = 0;
  long temInt = 0;
  for (i = 0; i < mLength; i++) {
    temInt = mw[i];
    if (e != 0) {
      for (j = 1; j < e; j++) {
        temInt = (temInt * mw[i]) % n;
      }
    } else {
      temInt = 1;
    }
    cw[i] = (long long)temInt;
  }
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<ieee80211_has_a4>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %edi,-0x14(%rbp)
  mov    $0x300,%edi
  call   <__cpu_to_le16@plt>
  mov    %eax,-0x4(%rbp)
  mov    -0x14(%rbp),%eax
  and    -0x4(%rbp),%eax
  cmp    %eax,-0x4(%rbp)
  sete   %al
  movzbl %al,%eax
  leave
  ret
```

assistant: ```c
int ieee80211_has_a4(__le16 fc) {
  __le16 tmp = __cpu_to_le16(0x0100 | 0x0200);
  return (fc & tmp) == tmp;
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<ieee80211_has_a4>:
  endbr64
  push   %rbx
  mov    %edi,%ebx
  mov    $0x300,%edi
  call   <__cpu_to_le16@plt>
  and    %eax,%ebx
  cmp    %eax,%ebx
  sete   %al
  movzbl %al,%eax
  pop    %rbx
  ret
```

assistant: ```c
int ieee80211_has_a4(__le16 fc) {
  __le16 tmp = __cpu_to_le16(0x0100 | 0x0200);
  return (fc & tmp) == tmp;
}
```
user: Translate the below assembly code into C programming language:

```asm
<ieee80211_has_a4>:
  endbr64
  push   %rbx
  mov    %edi,%ebx
  mov    $0x300,%edi
  call   <__cpu_to_le16@plt>
  and    %eax,%ebx
  cmp    %eax,%ebx
  pop    %rbx
  sete   %al
  movzbl %al,%eax
  ret
```

assistant: ```c
int ieee80211_has_a4(__le16 fc) {
  __le16 tmp = __cpu_to_le16(0x0100 | 0x0200);
  return (fc & tmp) == tmp;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<ieee80211_has_a4>:
  endbr64
  push   %rbx
  mov    %edi,%ebx
  mov    $0x300,%edi
  call   <__cpu_to_le16@plt>
  and    %eax,%ebx
  cmp    %eax,%ebx
  pop    %rbx
  sete   %al
  movzbl %al,%eax
  ret
```

assistant: ```c
int ieee80211_has_a4(__le16 fc) {
  __le16 tmp = __cpu_to_le16(0x0100 | 0x0200);
  return (fc & tmp) == tmp;
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<print_rot13>:
  endbr64
  push   %rbx
  mov    %rdi,%rbx
  movzbl (%rdi),%edi
  test   %dil,%dil
  jne    L112
L107:
  pop    %rbx
  ret
L55:
  add    $0xd,%edi
  mov    %dil,(%rbx)
  movsbl %dil,%edi
  call   <putchar@plt>
  jmp    L108
L81:
  sub    $0xd,%edi
  mov    %dil,(%rbx)
  movsbl %dil,%edi
  call   <putchar@plt>
  jmp    L108
L110:
  movzbl (%rbx),%edi
  lea    -0x61(%rdi),%eax
  cmp    $0xc,%al
  jbe    L138
  lea    -0x6e(%rdi),%eax
  cmp    $0xc,%al
  jbe    L82
  cmp    $0x20,%dil
  je     L28
L108:
  add    $0x1,%rbx
  movzbl (%rbx),%edi
  test   %dil,%dil
  je     L107
L112:
  movsbl %dil,%edi
  call   <isupper@plt>
  test   %rax,%rax
  je     L110
  movzbl (%rbx),%edi
  lea    -0x41(%rdi),%eax
  cmp    $0xc,%al
  jbe    L55
  lea    -0x4e(%rdi),%eax
  cmp    $0xc,%al
  jbe    L81
  cmp    $0x20,%dil
  jne    L108
  mov    $0x20,%edi
  call   <putchar@plt>
  jmp    L108
L138:
  add    $0xd,%edi
  mov    %dil,(%rbx)
  movsbl %dil,%edi
  call   <putchar@plt>
  jmp    L108
L82:
  sub    $0xd,%edi
  mov    %dil,(%rbx)
  movsbl %dil,%edi
  call   <putchar@plt>
  jmp    L108
L28:
  mov    $0x20,%edi
  call   <putchar@plt>
  jmp    L108
```

assistant: ```c
void print_rot13(char word[64]) {
  int i;
  for (i = 0; word[i] != '\0'; i++) {
    if (isupper(word[i])) {
      if (word[i] >= 'A' && word[i] <= 'M') {
        word[i] += 13;
        printf("%c", word[i]);
      } else if (word[i] >= 'N' && word[i] <= 'Z') {
        word[i] -= 13;
        printf("%c", word[i]);
      } else if (word[i] == ' ') {
        printf(" ");
      }
    } else {
      if (word[i] >= 'a' && word[i] <= 'm') {
        word[i] += 13;
        printf("%c", word[i]);
      } else if (word[i] >= 'n' && word[i] <= 'z') {
        word[i] -= 13;
        printf("%c", word[i]);
      } else if (word[i] == ' ') {
        printf(" ");
      }
    }
  }
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<print_rot13>:
  endbr64
  push   %rbx
  mov    %rdi,%rbx
  movsbl (%rdi),%edi
  test   %dil,%dil
  jne    L54
  jmp    L42
  nopw   0x0(%rax,%rax,1)
L52:
  lea    -0x41(%rdi),%eax
  cmp    $0xc,%al
  jbe    L93
  lea    -0x4e(%rdi),%eax
  cmp    $0xc,%al
  jbe    L112
L38:
  cmp    $0x20,%dil
  je     L89
L11:
  movsbl 0x1(%rbx),%edi
  add    $0x1,%rbx
  test   %dil,%dil
  je     L42
L54:
  call   <isupper@plt>
  movzbl (%rbx),%edi
  test   %rax,%rax
  jne    L52
  lea    -0x61(%rdi),%eax
  cmp    $0xc,%al
  jbe    L93
  lea    -0x6e(%rdi),%eax
  cmp    $0xc,%al
  ja     L38
L112:
  sub    $0xd,%edi
  add    $0x1,%rbx
  mov    %dil,-0x1(%rbx)
  movzbl %dil,%edi
  call   <putchar@plt>
  movsbl (%rbx),%edi
  test   %dil,%dil
  jne    L54
L42:
  pop    %rbx
  ret
  nopw   0x0(%rax,%rax,1)
L93:
  add    $0xd,%edi
  mov    %dil,(%rbx)
  movzbl %dil,%edi
  call   <putchar@plt>
  jmp    L11
  nopl   0x0(%rax)
L89:
  mov    $0x20,%edi
  call   <putchar@plt>
  jmp    L11
```

assistant: ```c
void print_rot13(char word[64]) {
  int i;
  for (i = 0; word[i] != '\0'; i++) {
    if (isupper(word[i])) {
      if (word[i] >= 'A' && word[i] <= 'M') {
        word[i] += 13;
        printf("%c", word[i]);
      } else if (word[i] >= 'N' && word[i] <= 'Z') {
        word[i] -= 13;
        printf("%c", word[i]);
      } else if (word[i] == ' ') {
        printf(" ");
      }
    } else {
      if (word[i] >= 'a' && word[i] <= 'm') {
        word[i] += 13;
        printf("%c", word[i]);
      } else if (word[i] >= 'n' && word[i] <= 'z') {
        word[i] -= 13;
        printf("%c", word[i]);
      } else if (word[i] == ' ') {
        printf(" ");
      }
    }
  }
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<print_rot13>:
  endbr64
  push   %rbx
  mov    %rdi,%rbx
  movsbl (%rdi),%edi
  test   %dil,%dil
  jne    L21
  jmp    L27
  nopw   0x0(%rax,%rax,1)
L113:
  lea    -0x41(%rdi),%eax
  cmp    $0xc,%al
  jbe    L117
  lea    -0x4e(%rdi),%eax
  cmp    $0xc,%al
  jbe    L62
L29:
  cmp    $0x20,%dil
  je     L36
L119:
  movsbl 0x1(%rbx),%edi
  add    $0x1,%rbx
  test   %dil,%dil
  je     L27
L21:
  call   <isupper@plt>
  movzbl (%rbx),%edi
  test   %rax,%rax
  jne    L113
  lea    -0x61(%rdi),%eax
  cmp    $0xc,%al
  jbe    L117
  lea    -0x6e(%rdi),%eax
  cmp    $0xc,%al
  ja     L29
L62:
  sub    $0xd,%edi
  add    $0x1,%rbx
  mov    %dil,-0x1(%rbx)
  movzbl %dil,%edi
  call   <putchar@plt>
  movsbl (%rbx),%edi
  test   %dil,%dil
  jne    L21
L27:
  pop    %rbx
  ret
  nopw   0x0(%rax,%rax,1)
L117:
  add    $0xd,%edi
  mov    %dil,(%rbx)
  movzbl %dil,%edi
  call   <putchar@plt>
  jmp    L119
  nopl   0x0(%rax)
L36:
  mov    $0x20,%edi
  call   <putchar@plt>
  jmp    L119
```

assistant: ```c
void print_rot13(char word[64]) {
  int i;
  for (i = 0; word[i] != '\0'; i++) {
    if (isupper(word[i])) {
      if (word[i] >= 'A' && word[i] <= 'M') {
        word[i] += 13;
        printf("%c", word[i]);
      } else if (word[i] >= 'N' && word[i] <= 'Z') {
        word[i] -= 13;
        printf("%c", word[i]);
      } else if (word[i] == ' ') {
        printf(" ");
      }
    } else {
      if (word[i] >= 'a' && word[i] <= 'm') {
        word[i] += 13;
        printf("%c", word[i]);
      } else if (word[i] >= 'n' && word[i] <= 'z') {
        word[i] -= 13;
        printf("%c", word[i]);
      } else if (word[i] == ' ') {
        printf(" ");
      }
    }
  }
}
```
user: What is the c source code of the assembly code below?

```asm
<Q_fabs>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  movss  %xmm0,-0x14(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    -0x14(%rbp),%rax
  mov    (%rax),%eax
  and    $0x7fffffff,%eax
  mov    %eax,-0xc(%rbp)
  lea    -0xc(%rbp),%rax
  movss  (%rax),%xmm0
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L8
  call   <__stack_chk_fail@plt>
L8:
  leave
  ret
```

assistant: ```c
float Q_fabs(float f) {
  int tmp = (*(int *)&f) & 0x7FFFFFFF;
  return *(float *)&tmp;
}
```
user: 这段汇编代码用C语言表示是什么样的?

```asm
<Q_fabs>:
  endbr64
  movd   %xmm0,%eax
  and    $0x7fffffff,%eax
  movd   %eax,%xmm0
  ret
```

assistant: ```c
float Q_fabs(float f) {
  int tmp = (*(int *)&f) & 0x7FFFFFFF;
  return *(float *)&tmp;
}
```
user: 这段汇编代码用C语言表示是什么样的：

```asm
<Q_fabs>:
  endbr64
  movd   %xmm0,%eax
  and    $0x7fffffff,%eax
  movd   %eax,%xmm0
  ret
```

assistant: ```c
float Q_fabs(float f) {
  int tmp = (*(int *)&f) & 0x7FFFFFFF;
  return *(float *)&tmp;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<Q_fabs>:
  endbr64
  movd   %xmm0,%eax
  and    $0x7fffffff,%eax
  movd   %eax,%xmm0
  ret
```

assistant: ```c
float Q_fabs(float f) {
  int tmp = (*(int *)&f) & 0x7FFFFFFF;
  return *(float *)&tmp;
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<heapSort>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  mov    -0x1c(%rbp),%edx
  mov    -0x18(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <heapify@plt>
  movl   $0x0,-0x4(%rbp)
  jmp    L1
L16:
  mov    -0x1c(%rbp),%eax
  sub    $0x1,%eax
  sub    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  mov    -0x18(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <swap@plt>
  mov    -0x1c(%rbp),%eax
  sub    -0x4(%rbp),%eax
  lea    -0x1(%rax),%ecx
  mov    -0x18(%rbp),%rax
  mov    $0x0,%edx
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <bubble_down@plt>
  addl   $0x1,-0x4(%rbp)
L1:
  mov    -0x4(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jl     L16
  nop
  nop
  leave
  ret
```

assistant: ```c
void heapSort(int *A, int size) {
  int i;
  heapify(A, size);
  for (i = 0; i < size; i++) {
    swap(&A[0], &A[size - 1 - i]);
    bubble_down(A, size - i - 1, 0);
  }
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<heapSort>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%r12
  mov    %esi,%ebx
  call   <heapify@plt>
  test   %ebx,%ebx
  jle    L12
  movslq %ebx,%rax
  lea    -0x4(%r12,%rax,4),%rbp
  sub    $0x1,%ebx
L8:
  mov    %rbp,%rsi
  mov    %r12,%rdi
  call   <swap@plt>
  mov    $0x0,%edx
  mov    %ebx,%esi
  mov    %r12,%rdi
  call   <bubble_down@plt>
  sub    $0x4,%rbp
  sub    $0x1,%ebx
  cmp    $0xffffffff,%ebx
  jne    L8
L12:
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
void heapSort(int *A, int size) {
  int i;
  heapify(A, size);
  for (i = 0; i < size; i++) {
    swap(&A[0], &A[size - 1 - i]);
    bubble_down(A, size - i - 1, 0);
  }
}
```
user: What is the c source code of the assembly code below?

```asm
<heapSort>:
  endbr64
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  push   %rbx
  mov    %esi,%ebx
  call   <heapify@plt>
  test   %ebx,%ebx
  jle    L0
  sub    $0x1,%ebx
  movslq %ebx,%rax
  lea    (%r12,%rax,4),%rbp
L17:
  mov    %rbp,%rsi
  mov    %r12,%rdi
  sub    $0x4,%rbp
  call   <swap@plt>
  xor    %edx,%edx
  mov    %ebx,%esi
  mov    %r12,%rdi
  call   <bubble_down@plt>
  sub    $0x1,%ebx
  jae    L17
L0:
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
void heapSort(int *A, int size) {
  int i;
  heapify(A, size);
  for (i = 0; i < size; i++) {
    swap(&A[0], &A[size - 1 - i]);
    bubble_down(A, size - i - 1, 0);
  }
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<heapSort>:
  endbr64
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  push   %rbx
  mov    %esi,%ebx
  call   <heapify@plt>
  test   %ebx,%ebx
  jle    L7
  sub    $0x1,%ebx
  movslq %ebx,%rax
  lea    (%r12,%rax,4),%rbp
L9:
  mov    %rbp,%rsi
  mov    %r12,%rdi
  sub    $0x4,%rbp
  call   <swap@plt>
  xor    %edx,%edx
  mov    %ebx,%esi
  mov    %r12,%rdi
  call   <bubble_down@plt>
  sub    $0x1,%ebx
  jae    L9
L7:
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
void heapSort(int *A, int size) {
  int i;
  heapify(A, size);
  for (i = 0; i < size; i++) {
    swap(&A[0], &A[size - 1 - i]);
    bubble_down(A, size - i - 1, 0);
  }
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<getbin>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %edi,-0x24(%rbp)
  mov    %esi,-0x28(%rbp)
  mov    %edx,-0x2c(%rbp)
  mov    %ecx,-0x30(%rbp)
  mov    -0x30(%rbp),%ecx
  mov    -0x2c(%rbp),%edx
  mov    -0x28(%rbp),%esi
  mov    -0x24(%rbp),%eax
  mov    %ecx,%r9d
  mov    %edx,%r8d
  mov    $0x0,%ecx
  mov    $0x0,%edx
  mov    %eax,%edi
  call   <pointdist@plt>
  mov    %eax,-0xc(%rbp)
  mov    -0x30(%rbp),%ecx
  mov    -0x2c(%rbp),%edx
  mov    -0x2c(%rbp),%eax
  mov    %ecx,%r9d
  mov    %edx,%r8d
  mov    $0x0,%ecx
  mov    $0x0,%edx
  mov    $0x0,%esi
  mov    %eax,%edi
  call   <pointdist@plt>
  mov    %eax,-0x8(%rbp)
  mov    -0x30(%rbp),%ecx
  mov    -0x2c(%rbp),%edx
  mov    -0x30(%rbp),%eax
  mov    %ecx,%r9d
  mov    %edx,%r8d
  mov    $0x0,%ecx
  mov    $0x0,%edx
  mov    %eax,%esi
  mov    $0x0,%edi
  call   <pointdist@plt>
  mov    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%edx
  mov    -0x8(%rbp),%eax
  cmp    %eax,%edx
  cmovge %edx,%eax
  mov    %eax,-0x14(%rbp)
  cmpl   $0x0,-0x14(%rbp)
  jne    L8
  movl   $0x1,-0x14(%rbp)
L8:
  mov    -0xc(%rbp),%edx
  mov    %edx,%eax
  shl    $0x2,%eax
  add    %edx,%eax
  shl    $0x2,%eax
  cltd
  idivl  -0x14(%rbp)
  mov    %eax,-0x10(%rbp)
  cmpl   $0x13,-0x10(%rbp)
  jle    L23
  movl   $0x13,-0x10(%rbp)
L23:
  cmpl   $0x0,-0x10(%rbp)
  jns    L14
  movl   $0x0,-0x10(%rbp)
L14:
  mov    -0x10(%rbp),%eax
  leave
  ret
```

assistant: ```c
int getbin(int x0, int y0, int n1, int n2) {
  int d = pointdist(x0, y0, 0, 0, n1, n2);
  int maxd1 = pointdist(n1, 0, 0, 0, n1, n2);
  int maxd2 = pointdist(0, n2, 0, 0, n1, n2);
  int maxd = (maxd1 > maxd2) ? maxd1 : maxd2;
  if (maxd == 0)
    maxd = 1;
  int bin = 20 * d / maxd;
  if (bin >= 20)
    bin = 20 - 1;
  if (bin < 0)
    bin = 0;
  return bin;
}
```
user: 这段汇编代码用C语言表示是什么样的：

```asm
<getbin>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %edx,%r12d
  mov    %ecx,%ebp
  mov    %ecx,%r9d
  mov    %edx,%r8d
  mov    $0x0,%ecx
  mov    $0x0,%edx
  call   <pointdist@plt>
  mov    %eax,%r13d
  mov    %ebp,%r9d
  mov    %r12d,%r8d
  mov    $0x0,%ecx
  mov    $0x0,%edx
  mov    $0x0,%esi
  mov    %r12d,%edi
  call   <pointdist@plt>
  mov    %eax,%ebx
  mov    %ebp,%r9d
  mov    %r12d,%r8d
  mov    $0x0,%ecx
  mov    $0x0,%edx
  mov    %ebp,%esi
  mov    $0x0,%edi
  call   <pointdist@plt>
  cmp    %eax,%ebx
  cmovge %ebx,%eax
  mov    %eax,%ecx
  test   %eax,%eax
  mov    $0x1,%eax
  cmove  %eax,%ecx
  lea    0x0(%r13,%r13,4),%eax
  shl    $0x2,%eax
  cltd
  idiv   %ecx
  test   %eax,%eax
  mov    $0x0,%edx
  cmovs  %edx,%eax
  mov    $0x13,%edx
  cmp    %edx,%eax
  cmovg  %edx,%eax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

assistant: ```c
int getbin(int x0, int y0, int n1, int n2) {
  int d = pointdist(x0, y0, 0, 0, n1, n2);
  int maxd1 = pointdist(n1, 0, 0, 0, n1, n2);
  int maxd2 = pointdist(0, n2, 0, 0, n1, n2);
  int maxd = (maxd1 > maxd2) ? maxd1 : maxd2;
  if (maxd == 0)
    maxd = 1;
  int bin = 20 * d / maxd;
  if (bin >= 20)
    bin = 20 - 1;
  if (bin < 0)
    bin = 0;
  return bin;
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<getbin>:
  endbr64
  push   %r13
  mov    %ecx,%r9d
  mov    %edx,%r8d
  push   %r12
  mov    %edx,%r12d
  xor    %edx,%edx
  push   %rbp
  mov    %ecx,%ebp
  xor    %ecx,%ecx
  push   %rbx
  sub    $0x8,%rsp
  call   <pointdist@plt>
  mov    %ebp,%r9d
  mov    %r12d,%r8d
  xor    %ecx,%ecx
  xor    %edx,%edx
  xor    %esi,%esi
  mov    %r12d,%edi
  mov    %eax,%r13d
  call   <pointdist@plt>
  xor    %ecx,%ecx
  xor    %edx,%edx
  mov    %ebp,%r9d
  mov    %r12d,%r8d
  mov    %ebp,%esi
  xor    %edi,%edi
  mov    %eax,%ebx
  call   <pointdist@plt>
  cmp    %eax,%ebx
  cmovge %ebx,%eax
  test   %eax,%eax
  mov    %eax,%ecx
  mov    $0x1,%eax
  cmove  %eax,%ecx
  lea    0x0(%r13,%r13,4),%eax
  shl    $0x2,%eax
  cltd
  idiv   %ecx
  xor    %edx,%edx
  test   %eax,%eax
  cmovs  %edx,%eax
  mov    $0x13,%edx
  cmp    %edx,%eax
  cmovg  %edx,%eax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

assistant: ```c
int getbin(int x0, int y0, int n1, int n2) {
  int d = pointdist(x0, y0, 0, 0, n1, n2);
  int maxd1 = pointdist(n1, 0, 0, 0, n1, n2);
  int maxd2 = pointdist(0, n2, 0, 0, n1, n2);
  int maxd = (maxd1 > maxd2) ? maxd1 : maxd2;
  if (maxd == 0)
    maxd = 1;
  int bin = 20 * d / maxd;
  if (bin >= 20)
    bin = 20 - 1;
  if (bin < 0)
    bin = 0;
  return bin;
}
```
user: What is the c source code of the assembly code below?

```asm
<getbin>:
  endbr64
  push   %r13
  mov    %ecx,%r9d
  mov    %edx,%r8d
  push   %r12
  mov    %edx,%r12d
  xor    %edx,%edx
  push   %rbp
  mov    %ecx,%ebp
  xor    %ecx,%ecx
  push   %rbx
  sub    $0x8,%rsp
  call   <pointdist@plt>
  mov    %ebp,%r9d
  mov    %r12d,%r8d
  xor    %ecx,%ecx
  xor    %edx,%edx
  xor    %esi,%esi
  mov    %r12d,%edi
  mov    %eax,%r13d
  call   <pointdist@plt>
  xor    %ecx,%ecx
  xor    %edx,%edx
  mov    %ebp,%r9d
  mov    %r12d,%r8d
  mov    %ebp,%esi
  xor    %edi,%edi
  mov    %eax,%ebx
  call   <pointdist@plt>
  cmp    %eax,%ebx
  cmovge %ebx,%eax
  test   %eax,%eax
  mov    %eax,%ecx
  mov    $0x1,%eax
  cmove  %eax,%ecx
  lea    0x0(%r13,%r13,4),%eax
  shl    $0x2,%eax
  cltd
  idiv   %ecx
  xor    %edx,%edx
  test   %eax,%eax
  cmovs  %edx,%eax
  mov    $0x13,%edx
  cmp    %edx,%eax
  cmovg  %edx,%eax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

assistant: ```c
int getbin(int x0, int y0, int n1, int n2) {
  int d = pointdist(x0, y0, 0, 0, n1, n2);
  int maxd1 = pointdist(n1, 0, 0, 0, n1, n2);
  int maxd2 = pointdist(0, n2, 0, 0, n1, n2);
  int maxd = (maxd1 > maxd2) ? maxd1 : maxd2;
  if (maxd == 0)
    maxd = 1;
  int bin = 20 * d / maxd;
  if (bin >= 20)
    bin = 20 - 1;
  if (bin < 0)
    bin = 0;
  return bin;
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<heap_key>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  mov    %rdx,-0x28(%rbp)
  jmp    L29
L5:
  mov    -0x1c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x1c(%rbp),%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    -0x1c(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,8),%rcx
  mov    -0x18(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%rax
  mov    %rax,(%rdx)
  mov    -0x1c(%rbp),%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  mov    -0x8(%rbp),%rax
  mov    %rax,(%rdx)
  mov    -0x1c(%rbp),%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  mov    %eax,-0x1c(%rbp)
L29:
  cmpl   $0x0,-0x1c(%rbp)
  jle    L11
  mov    -0x1c(%rbp),%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x1c(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rcx
  mov    -0x18(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%rax
  mov    -0x28(%rbp),%rcx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   *%rcx
  test   %eax,%eax
  jne    L5
L11:
  nop
  leave
  ret
```

assistant: ```c
void heap_key(void **arr, int i, int (*func)(void *, void *)) {
  while (i > 0 && func(arr[i], arr[i / 2])) {
    void *temp = arr[i];
    arr[i] = arr[i / 2];
    arr[i / 2] = temp;
    i = i / 2;
  }
}
```
user: 这段汇编代码用C语言表示是什么样的？

```asm
<heap_key>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%rbp
  mov    %esi,%r13d
  mov    %rdx,%r12
  test   %esi,%esi
  jle    L3
L15:
  mov    %r13d,%ebx
  mov    %r13d,%eax
  shr    $0x1f,%eax
  add    %r13d,%eax
  sar    %eax
  mov    %eax,%r13d
  cltq
  lea    0x0(%rbp,%rax,8),%r15
  movslq %ebx,%rax
  lea    0x0(%rbp,%rax,8),%r14
  mov    (%r15),%rsi
  mov    (%r14),%rdi
  call   *%r12
  test   %eax,%eax
  je     L3
  mov    (%r14),%rax
  mov    (%r15),%rdx
  mov    %rdx,(%r14)
  mov    %rax,(%r15)
  cmp    $0x1,%ebx
  jg     L15
L3:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
void heap_key(void **arr, int i, int (*func)(void *, void *)) {
  while (i > 0 && func(arr[i], arr[i / 2])) {
    void *temp = arr[i];
    arr[i] = arr[i / 2];
    arr[i / 2] = temp;
    i = i / 2;
  }
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<heap_key>:
  endbr64
  test   %esi,%esi
  jle    L3
  movslq %esi,%rax
  push   %r14
  mov    %rdi,%r14
  push   %r13
  push   %r12
  mov    %rdx,%r12
  push   %rbp
  push   %rbx
  mov    %esi,%ebx
  mov    (%rdi,%rax,8),%rdi
  jmp    L10
  nopl   0x0(%rax)
L33:
  mov    0x0(%r13),%rdi
  mov    0x0(%rbp),%rax
  mov    %rax,0x0(%r13)
  mov    %rdi,0x0(%rbp)
  test   %ebx,%ebx
  je     L23
L10:
  movslq %ebx,%rax
  sar    %ebx
  movslq %ebx,%rdx
  lea    (%r14,%rax,8),%r13
  lea    (%r14,%rdx,8),%rbp
  mov    0x0(%rbp),%rsi
  call   *%r12
  test   %eax,%eax
  jne    L33
L23:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L3:
  ret
```

assistant: ```c
void heap_key(void **arr, int i, int (*func)(void *, void *)) {
  while (i > 0 && func(arr[i], arr[i / 2])) {
    void *temp = arr[i];
    arr[i] = arr[i / 2];
    arr[i / 2] = temp;
    i = i / 2;
  }
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<heap_key>:
  endbr64
  test   %esi,%esi
  jle    L36
  movslq %esi,%rax
  push   %r14
  mov    %rdi,%r14
  push   %r13
  push   %r12
  mov    %rdx,%r12
  push   %rbp
  push   %rbx
  mov    %esi,%ebx
  mov    (%rdi,%rax,8),%rdi
  jmp    L38
  nopl   0x0(%rax)
L26:
  mov    0x0(%r13),%rdi
  mov    0x0(%rbp),%rax
  mov    %rax,0x0(%r13)
  mov    %rdi,0x0(%rbp)
  test   %ebx,%ebx
  je     L7
L38:
  movslq %ebx,%rax
  sar    %ebx
  movslq %ebx,%rdx
  lea    (%r14,%rax,8),%r13
  lea    (%r14,%rdx,8),%rbp
  mov    0x0(%rbp),%rsi
  call   *%r12
  test   %eax,%eax
  jne    L26
L7:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L36:
  ret
```

assistant: ```c
void heap_key(void **arr, int i, int (*func)(void *, void *)) {
  while (i > 0 && func(arr[i], arr[i / 2])) {
    void *temp = arr[i];
    arr[i] = arr[i / 2];
    arr[i / 2] = temp;
    i = i / 2;
  }
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<initarray>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x8(%rbp)
  mov    %esi,-0xc(%rbp)
  jmp    L15
L1:
  mov    -0xc(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    %edx,-0xc(%rbp)
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movl   $0x0,(%rax)
L15:
  cmpl   $0x0,-0xc(%rbp)
  jns    L1
  nop
  nop
  pop    %rbp
  ret
```

assistant: ```c
void initarray(int arr[], int n) {
  while (n >= 0)
    arr[n--] = 0;
}
```