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

```asm
<dact_mzlib2_decompress>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%r13
  mov    %rsi,%rbp
  mov    %edx,%r12d
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    (%rdx,%rdx,1),%edi
  movslq %edi,%rdi
  mov    %rdi,(%rsp)
  call   <malloc@plt>
  mov    %rax,%rbx
  mov    %rsp,%rsi
  mov    %r12d,%ecx
  mov    %r13,%rdx
  mov    %rax,%rdi
  call   <uncompress@plt>
  mov    %eax,%edx
  mov    $0x0,%eax
  mov    D13(%rip),%rcx
  cmp    %edx,(%rcx)
  jne    L30
  movzbl (%rbx),%edi
  shl    $0x8,%edi
  movzbl 0x1(%rbx),%eax
  or     %eax,%edi
  lea    0x2(%rdi),%esi
  cmp    $0x1ff,%edi
  setbe  %r10b
  cmp    $0x2,%esi
  jbe    L37
  lea    -0x1(%rdi),%eax
  shr    %eax
  lea    0x1(%rax),%r8d
  add    %r8,%r8
  mov    $0x0,%ecx
  lea    D26(%rip),%r9
L61:
  mov    %ecx,%eax
  shr    $0x1f,%eax
  add    %ecx,%eax
  sar    %eax
  cltq
  movzbl 0x2(%rbx,%rcx,1),%edx
  shl    $0x8,%edx
  movzbl 0x3(%rbx,%rcx,1),%r11d
  or     %r11d,%edx
  movslq %edx,%rdx
  mov    %rdx,(%r9,%rax,8)
  add    $0x2,%rcx
  cmp    %r8,%rcx
  jne    L61
L37:
  movslq %esi,%rsi
  mov    (%rsp),%r8
  cmp    %r8,%rsi
  jae    L0
  movzbl %r10b,%r10d
  mov    $0x2,%ecx
  sub    %r10,%rcx
  mov    %rcx,%r11
  mov    $0x0,%r12d
  lea    D26(%rip),%r9
  jmp    L51
L75:
  movzbl (%rbx,%rsi,1),%eax
  shl    $0x8,%eax
  movzbl 0x1(%rbx,%rsi,1),%edx
  or     %edx,%eax
  cltq
L31:
  mov    (%r9,%rax,8),%rdx
  lea    0x1(%r12),%eax
  mov    %r12d,%r10d
  movzbl %dh,%ecx
  mov    %cl,0x0(%rbp,%r10,1)
  add    $0x2,%r12d
  mov    %eax,%eax
  mov    %dl,0x0(%rbp,%rax,1)
  add    %r11,%rsi
  cmp    %r8,%rsi
  jae    L48
L51:
  cmp    $0x1ff,%edi
  ja     L75
  movzbl (%rbx,%rsi,1),%eax
  jmp    L31
L0:
  mov    $0x0,%r12d
L48:
  mov    %rbx,%rdi
  call   <free@plt>
  mov    %r12d,%eax
L30:
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L52
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L52:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int dact_mzlib2_decompress(unsigned char *curr_block, unsigned char *out_block, int blk_size, int bufsize) {
  static uint16_t lookup_table[65536];
  uint16_t curr_val, repl_val;
  unsigned long dest_size = (blk_size * 2);
  unsigned char *tmp_block;
  unsigned int m = 0, hdrsize;
  int retval, i, low_byte = 0;
  tmp_block = malloc(dest_size);
  retval = uncompress(tmp_block, &dest_size, curr_block, blk_size);
  if (retval != Z_OK)
    return (0);
  hdrsize = ((unsigned int)(((tmp_block[0] << 8) | tmp_block[1]))) + 2;
  if ((hdrsize - 2) < 0x200)
    low_byte = 1;
  for (i = 2; i < hdrsize; i += 2) {
    lookup_table[(i - 2) / 2] = ((tmp_block[i] << 8) | tmp_block[i + 1]);
  }
  for (i = hdrsize; i < (dest_size); i += (2 - low_byte)) {
    if (low_byte) {
      curr_val = tmp_block[i];
    } else {
      curr_val = ((tmp_block[i] << 8) | tmp_block[i + 1]);
    }
    repl_val = lookup_table[curr_val];
    out_block[m++] = repl_val >> 8;
    out_block[m++] = repl_val & 0xff;
  }
  free(tmp_block);
  return (m);
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<dact_mzlib2_decompress>:
  endbr64
  push   %r13
  mov    %rdi,%r13
  lea    (%rdx,%rdx,1),%edi
  push   %r12
  movslq %edi,%rdi
  mov    %edx,%r12d
  push   %rbp
  push   %rbx
  mov    %rsi,%rbx
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  mov    %rdi,(%rsp)
  call   <malloc@plt>
  mov    %r12d,%ecx
  mov    %r13,%rdx
  mov    %rsp,%rsi
  mov    %rax,%rdi
  mov    %rax,%rbp
  xor    %r12d,%r12d
  call   <uncompress@plt>
  mov    D9(%rip),%rdx
  cmp    %eax,(%rdx)
  jne    L65
  movzwl 0x0(%rbp),%esi
  xor    %r11d,%r11d
  rol    $0x8,%si
  movzwl %si,%r10d
  cmp    $0x1ff,%si
  lea    0x2(%r10),%r8d
  setbe  %r11b
  test   %r10d,%r10d
  je     L15
  lea    -0x1(%r10),%eax
  xor    %edx,%edx
  lea    D24(%rip),%rcx
  shr    %eax
  lea    0x1(%rax),%r9d
  add    %r9,%r9
  nopl   0x0(%rax,%rax,1)
L18:
  movzbl 0x2(%rbp,%rdx,1),%eax
  movzbl 0x3(%rbp,%rdx,1),%r12d
  mov    %edx,%edi
  add    $0x2,%rdx
  sar    %edi
  shl    $0x8,%eax
  movslq %edi,%rdi
  or     %r12d,%eax
  cltq
  mov    %rax,(%rcx,%rdi,8)
  cmp    %rdx,%r9
  jne    L18
L15:
  mov    (%rsp),%r9
  xor    %r12d,%r12d
  cmp    %r8,%r9
  jbe    L41
  mov    $0x2,%r8d
  lea    0x2(%r10),%edx
  xor    %edi,%edi
  sub    %r11d,%r8d
  lea    D24(%rip),%rcx
  movslq %r8d,%r8
  nopl   0x0(%rax)
L36:
  movzbl 0x0(%rbp,%rdx,1),%eax
  cmp    $0x1ff,%si
  jbe    L6
  movzbl 0x1(%rbp,%rdx,1),%r10d
  shl    $0x8,%eax
  or     %r10d,%eax
  cltq
L6:
  mov    (%rcx,%rax,8),%r10
  lea    0x1(%rdi),%r13d
  mov    %edi,%r11d
  add    %r8,%rdx
  add    $0x2,%edi
  mov    %r10,%rax
  movzbl %ah,%eax
  mov    %al,(%rbx,%r11,1)
  mov    %r13d,%eax
  mov    %r10b,(%rbx,%rax,1)
  cmp    %r9,%rdx
  jb     L36
  mov    %edi,%r12d
L41:
  mov    %rbp,%rdi
  call   <free@plt>
L65:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L25
  add    $0x18,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L25:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int dact_mzlib2_decompress(unsigned char *curr_block, unsigned char *out_block, int blk_size, int bufsize) {
  static uint16_t lookup_table[65536];
  uint16_t curr_val, repl_val;
  unsigned long dest_size = (blk_size * 2);
  unsigned char *tmp_block;
  unsigned int m = 0, hdrsize;
  int retval, i, low_byte = 0;
  tmp_block = malloc(dest_size);
  retval = uncompress(tmp_block, &dest_size, curr_block, blk_size);
  if (retval != Z_OK)
    return (0);
  hdrsize = ((unsigned int)(((tmp_block[0] << 8) | tmp_block[1]))) + 2;
  if ((hdrsize - 2) < 0x200)
    low_byte = 1;
  for (i = 2; i < hdrsize; i += 2) {
    lookup_table[(i - 2) / 2] = ((tmp_block[i] << 8) | tmp_block[i + 1]);
  }
  for (i = hdrsize; i < (dest_size); i += (2 - low_byte)) {
    if (low_byte) {
      curr_val = tmp_block[i];
    } else {
      curr_val = ((tmp_block[i] << 8) | tmp_block[i + 1]);
    }
    repl_val = lookup_table[curr_val];
    out_block[m++] = repl_val >> 8;
    out_block[m++] = repl_val & 0xff;
  }
  free(tmp_block);
  return (m);
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %edi,-0x4(%rbp)
  mov    %rsi,-0x10(%rbp)
  movsd  D9(%rip),%xmm0
  mov    D35(%rip),%rax
  movapd %xmm0,%xmm1
  movq   %rax,%xmm0
  call   <pow@plt>
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  movsd  D26(%rip),%xmm1
  subsd  %xmm1,%xmm0
  cvttsd2si %xmm0,%rax
  mov    %rax,%rdi
  call   <fabs@plt>
  movsd  D6(%rip),%xmm1
  comisd %xmm0,%xmm1
  jbe    L14
  mov    $0x0,%eax
  jmp    L12
L14:
  mov    $0x1,%eax
L12:
  leave
  ret
```

tool_calls: name: unpack_data
arguments: tag: D9
data_type: byte[8]
name: unpack_data
arguments: tag: D35
data_type: f64
name: unpack_data
arguments: tag: D26
data_type: f64
name: unpack_data
arguments: tag: D6
data_type: f64

tool: {"D9": [0x00,0x00,0x00,0x00,0x00,0x00,0x04,0xc0]}

tool: D35: 2.5

tool: D26: 0.10119

tool: D6: 0.01

assistant: ```c
int main(int argc, char const *argv[]) {
  if (fabs(pow(2.5, -2.5) - 0.10119) < 0.01) {
    return 0;
  }
  return 1;
}
```
user: Translate the below assembly code into C programming language:

```asm
<main>:
  endbr64
  sub    $0x8,%rsp
  movsd  D18(%rip),%xmm1
  movsd  D22(%rip),%xmm0
  call   <pow@plt>
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  subsd  D25(%rip),%xmm0
  cvttsd2si %xmm0,%rdi
  call   <fabs@plt>
  movsd  D30(%rip),%xmm1
  comisd %xmm0,%xmm1
  setbe  %al
  movzbl %al,%eax
  add    $0x8,%rsp
  ret
```

tool_calls: name: unpack_data
arguments: data_label: D18
type: byte[8]
name: unpack_data
arguments: data_label: D22
type: f64
name: unpack_data
arguments: data_label: D25
type: f64
name: unpack_data
arguments: data_label: D30
type: f64

tool: {"D18": [0x00,0x00,0x00,0x00,0x00,0x00,0x04,0xc0]}

tool: D22: 2.5

tool: D25: 0.10119

tool: D30: 0.01

assistant: ```c
int main(int argc, char const *argv[]) {
  if (fabs(pow(2.5, -2.5) - 0.10119) < 0.01) {
    return 0;
  }
  return 1;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<main>:
  endbr64
  sub    $0x8,%rsp
  movsd  D12(%rip),%xmm1
  movsd  D4(%rip),%xmm0
  call   <pow@plt>
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  subsd  D27(%rip),%xmm0
  cvttsd2si %xmm0,%rdi
  call   <fabs@plt>
  movsd  D29(%rip),%xmm1
  xor    %eax,%eax
  comisd %xmm0,%xmm1
  setbe  %al
  add    $0x8,%rsp
  ret
```

tool_calls: name: parse_data
arguments: tag: D12
datatype: byte[8]
name: parse_data
arguments: tag: D4
datatype: f64
name: parse_data
arguments: tag: D27
datatype: f64
name: parse_data
arguments: tag: D29
datatype: f64

tool: {"D12": [0x00,0x00,0x00,0x00,0x00,0x00,0x04,0xc0]}

tool: D4: 2.5

tool: D27: 0.10119

tool: D29: 0.01

assistant: ```c
int main(int argc, char const *argv[]) {
  if (fabs(pow(2.5, -2.5) - 0.10119) < 0.01) {
    return 0;
  }
  return 1;
}
```
user: Translate the below assembly code into C programming language:

```asm
<main>:
  endbr64
  sub    $0x8,%rsp
  movsd  D24(%rip),%xmm1
  movsd  D14(%rip),%xmm0
  call   <pow@plt>
  pxor   %xmm0,%xmm0
  cvtsi2sd %rax,%xmm0
  subsd  D27(%rip),%xmm0
  cvttsd2si %xmm0,%rdi
  call   <fabs@plt>
  movsd  D16(%rip),%xmm1
  xor    %eax,%eax
  comisd %xmm0,%xmm1
  setbe  %al
  add    $0x8,%rsp
  ret
```

tool_calls: name: parse_data
arguments: label: D24
data_type: byte[8]
name: parse_data
arguments: label: D14
data_type: f64
name: parse_data
arguments: label: D27
data_type: f64
name: parse_data
arguments: label: D16
data_type: f64

tool: {"D24": [0x00,0x00,0x00,0x00,0x00,0x00,0x04,0xc0]}

tool: D14: 2.5

tool: D27: 0.10119

tool: D16: 0.01

assistant: ```c
int main(int argc, char const *argv[]) {
  if (fabs(pow(2.5, -2.5) - 0.10119) < 0.01) {
    return 0;
  }
  return 1;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<monotonic_bias>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    -0x18(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,-0xc(%rbp)
  movl   $0x0,-0x10(%rbp)
  mov    -0x18(%rbp),%rax
  add    $0x4,%rax
  mov    %rax,-0x8(%rbp)
  jmp    L26
L2:
  mov    -0x8(%rbp),%rax
  mov    (%rax),%eax
  cmp    %eax,-0xc(%rbp)
  jg     L13
  addl   $0x1,-0x10(%rbp)
  jmp    L34
L13:
  subl   $0x1,-0x10(%rbp)
L34:
  mov    -0x8(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,-0xc(%rbp)
  addq   $0x4,-0x8(%rbp)
L26:
  mov    -0x8(%rbp),%rax
  cmp    -0x20(%rbp),%rax
  jbe    L2
  mov    -0x10(%rbp),%eax
  pop    %rbp
  ret
```

assistant: ```c
int monotonic_bias(int *start, int *end) {
  int *left;
  int bias;
  int prev;
  prev = *start;
  bias = 0;
  for (left = start + 1; left <= end; left++) {
    if (prev <= *left)
      bias++;
    else
      bias--;
    prev = *left;
  }
  return bias;
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<monotonic_bias>:
  endbr64
  mov    (%rdi),%edx
  add    $0x4,%rdi
  cmp    %rsi,%rdi
  ja     L12
  mov    $0x0,%eax
L10:
  mov    %edx,%r8d
  mov    (%rdi),%edx
  lea    0x1(%rax),%ecx
  sub    $0x1,%eax
  cmp    %r8d,%edx
  cmovge %ecx,%eax
  add    $0x4,%rdi
  cmp    %rdi,%rsi
  jae    L10
  ret
L12:
  mov    $0x0,%eax
  ret
```

assistant: ```c
int monotonic_bias(int *start, int *end) {
  int *left;
  int bias;
  int prev;
  prev = *start;
  bias = 0;
  for (left = start + 1; left <= end; left++) {
    if (prev <= *left)
      bias++;
    else
      bias--;
    prev = *left;
  }
  return bias;
}
```
user: 这段汇编代码用C语言表示是什么样的：

```asm
<monotonic_bias>:
  endbr64
  mov    (%rdi),%edx
  add    $0x4,%rdi
  xor    %eax,%eax
  cmp    %rsi,%rdi
  ja     L8
  nopl   0x0(%rax)
L15:
  mov    %edx,%r8d
  mov    (%rdi),%edx
  lea    0x1(%rax),%ecx
  sub    $0x1,%eax
  cmp    %r8d,%edx
  cmovge %ecx,%eax
  add    $0x4,%rdi
  cmp    %rdi,%rsi
  jae    L15
  ret
  nopl   0x0(%rax,%rax,1)
L8:
  ret
```

assistant: ```c
int monotonic_bias(int *start, int *end) {
  int *left;
  int bias;
  int prev;
  prev = *start;
  bias = 0;
  for (left = start + 1; left <= end; left++) {
    if (prev <= *left)
      bias++;
    else
      bias--;
    prev = *left;
  }
  return bias;
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<monotonic_bias>:
  endbr64
  mov    (%rdi),%edx
  add    $0x4,%rdi
  xor    %eax,%eax
  cmp    %rsi,%rdi
  ja     L19
  nopl   0x0(%rax)
L1:
  mov    %edx,%r8d
  mov    (%rdi),%edx
  lea    0x1(%rax),%ecx
  sub    $0x1,%eax
  cmp    %edx,%r8d
  cmovle %ecx,%eax
  add    $0x4,%rdi
  cmp    %rdi,%rsi
  jae    L1
  ret
  nopl   0x0(%rax,%rax,1)
L19:
  ret
```

assistant: ```c
int monotonic_bias(int *start, int *end) {
  int *left;
  int bias;
  int prev;
  prev = *start;
  bias = 0;
  for (left = start + 1; left <= end; left++) {
    if (prev <= *left)
      bias++;
    else
      bias--;
    prev = *left;
  }
  return bias;
}
```
user: What is the c source code of the assembly code below?

```asm
<vec_i32_asc_compare>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    -0x18(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x20(%rbp),%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x10(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x8(%rbp),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  jge    L1
  mov    $0xffffffff,%eax
  jmp    L14
L1:
  mov    -0x10(%rbp),%rax
  mov    (%rax),%rdx
  mov    -0x8(%rbp),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  jle    L18
  mov    $0x1,%eax
  jmp    L14
L18:
  mov    $0x0,%eax
L14:
  pop    %rbp
  ret
```

assistant: ```c
int vec_i32_asc_compare(const void *p1, const void *p2) {
  const int32_t *pp1 = (const int32_t *)p1;
  const int32_t *pp2 = (const int32_t *)p2;
  if (*pp1 < *pp2)
    return -1;
  if (*pp1 > *pp2)
    return 1;
  return 0;
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<vec_i32_asc_compare>:
  endbr64
  mov    (%rdi),%rcx
  mov    (%rsi),%rdx
  mov    $0xffffffff,%eax
  cmp    %rdx,%rcx
  jl     L9
  setg   %al
  movzbl %al,%eax
L9:
  ret
```

assistant: ```c
int vec_i32_asc_compare(const void *p1, const void *p2) {
  const int32_t *pp1 = (const int32_t *)p1;
  const int32_t *pp2 = (const int32_t *)p2;
  if (*pp1 < *pp2)
    return -1;
  if (*pp1 > *pp2)
    return 1;
  return 0;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<vec_i32_asc_compare>:
  endbr64
  mov    (%rsi),%rax
  cmp    %rax,(%rdi)
  mov    $0xffffffff,%edx
  setg   %al
  movzbl %al,%eax
  cmovl  %edx,%eax
  ret
```

assistant: ```c
int vec_i32_asc_compare(const void *p1, const void *p2) {
  const int32_t *pp1 = (const int32_t *)p1;
  const int32_t *pp2 = (const int32_t *)p2;
  if (*pp1 < *pp2)
    return -1;
  if (*pp1 > *pp2)
    return 1;
  return 0;
}
```
user: Translate the below assembly code into C programming language:

```asm
<vec_i32_asc_compare>:
  endbr64
  mov    (%rsi),%rax
  cmp    %rax,(%rdi)
  mov    $0xffffffff,%edx
  setg   %al
  movzbl %al,%eax
  cmovl  %edx,%eax
  ret
```

assistant: ```c
int vec_i32_asc_compare(const void *p1, const void *p2) {
  const int32_t *pp1 = (const int32_t *)p1;
  const int32_t *pp2 = (const int32_t *)p2;
  if (*pp1 < *pp2)
    return -1;
  if (*pp1 > *pp2)
    return 1;
  return 0;
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<sift_down>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %edx,-0x34(%rbp)
  mov    -0x34(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x10(%rbp)
  mov    -0x28(%rbp),%rax
  movsd  (%rax),%xmm0
  movsd  %xmm0,-0x8(%rbp)
  mov    -0x30(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,-0xc(%rbp)
  movl   $0x0,-0x14(%rbp)
  movl   $0x1,-0x18(%rbp)
  jmp    L29
L46:
  mov    -0x18(%rbp),%eax
  cmp    -0x10(%rbp),%eax
  jge    L26
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  mov    -0x18(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  comisd %xmm1,%xmm0
  jbe    L26
  addl   $0x1,-0x18(%rbp)
L26:
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  movsd  -0x8(%rbp),%xmm0
  comisd %xmm1,%xmm0
  jae    L7
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rax,%rdx
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rcx
  mov    -0x28(%rbp),%rax
  add    %rcx,%rax
  movsd  (%rdx),%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  add    %rdx,%rax
  mov    -0x14(%rbp),%edx
  movslq %edx,%rdx
  lea    0x0(,%rdx,4),%rcx
  mov    -0x30(%rbp),%rdx
  add    %rcx,%rdx
  mov    (%rax),%eax
  mov    %eax,(%rdx)
  mov    -0x18(%rbp),%eax
  mov    %eax,-0x14(%rbp)
  mov    -0x18(%rbp),%eax
  add    %eax,%eax
  add    $0x1,%eax
  mov    %eax,-0x18(%rbp)
L29:
  mov    -0x18(%rbp),%eax
  cmp    -0x10(%rbp),%eax
  jle    L46
  jmp    L28
L7:
  nop
L28:
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movsd  -0x8(%rbp),%xmm0
  movsd  %xmm0,(%rax)
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x30(%rbp),%rax
  add    %rax,%rdx
  mov    -0xc(%rbp),%eax
  mov    %eax,(%rdx)
  nop
  pop    %rbp
  ret
```

assistant: ```c
void sift_down(double *heap, int *ndx, int nn) {
  int n = nn - 1;
  int j, jold, ia;
  double a;
  a = heap[0];
  ia = ndx[0];
  jold = 0;
  j = 1;
  while (j <= n) {
    if (j < n && heap[j] < heap[j + 1])
      j++;
    if (a >= heap[j])
      break;
    heap[jold] = heap[j];
    ndx[jold] = ndx[j];
    jold = j;
    j = 2 * j + 1;
  }
  heap[jold] = a;
  ndx[jold] = ia;
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<sift_down>:
  endbr64
  mov    %rsi,%r9
  sub    $0x1,%edx
  movsd  (%rdi),%xmm1
  mov    (%rsi),%r10d
  test   %edx,%edx
  jle    L44
  mov    $0x0,%esi
  mov    $0x1,%eax
  jmp    L34
L50:
  movslq %ecx,%r8
  movsd  (%rdi,%r8,8),%xmm0
  comisd %xmm0,%xmm1
  jae    L33
  movslq %esi,%rax
  movsd  %xmm0,(%rdi,%rax,8)
  mov    (%r9,%r8,4),%esi
  mov    %esi,(%r9,%rax,4)
  lea    0x1(%rcx,%rcx,1),%eax
  cmp    %eax,%edx
  jl     L53
  mov    %ecx,%esi
L34:
  mov    %eax,%ecx
  cmp    %eax,%edx
  jle    L50
  movslq %eax,%r8
  movsd  0x8(%rdi,%r8,8),%xmm0
  lea    0x1(%rax),%ecx
  comisd (%rdi,%r8,8),%xmm0
  cmovbe %eax,%ecx
  jmp    L50
L53:
  mov    %ecx,%esi
L33:
  movslq %esi,%rax
  movsd  %xmm1,(%rdi,%rax,8)
  mov    %r10d,(%r9,%rax,4)
  ret
L44:
  mov    $0x0,%esi
  jmp    L33
```

assistant: ```c
void sift_down(double *heap, int *ndx, int nn) {
  int n = nn - 1;
  int j, jold, ia;
  double a;
  a = heap[0];
  ia = ndx[0];
  jold = 0;
  j = 1;
  while (j <= n) {
    if (j < n && heap[j] < heap[j + 1])
      j++;
    if (a >= heap[j])
      break;
    heap[jold] = heap[j];
    ndx[jold] = ndx[j];
    jold = j;
    j = 2 * j + 1;
  }
  heap[jold] = a;
  ndx[jold] = ia;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<sift_down>:
  endbr64
  lea    -0x1(%rdx),%r10d
  push   %rbp
  movsd  (%rdi),%xmm2
  mov    %rsi,%r9
  push   %rbx
  mov    (%rsi),%ebx
  test   %r10d,%r10d
  jle    L18
  xor    %eax,%eax
  mov    $0x1,%ecx
  jmp    L9
  nopl   (%rax)
L65:
  lea    (%r9,%rsi,4),%rsi
  movsd  %xmm0,(%rcx)
  mov    (%rsi),%ecx
  mov    %ecx,(%rax)
  lea    0x1(%rdx,%rdx,1),%ecx
  cmp    %ecx,%r10d
  jl     L24
  movslq %edx,%rax
L9:
  movslq %ecx,%rsi
  mov    %ecx,%edx
  lea    0x0(,%rsi,8),%r8
  lea    (%rdi,%r8,1),%r11
  movsd  (%r11),%xmm0
  cmp    %ecx,%r10d
  jle    L43
  lea    0x8(%rdi,%r8,1),%rcx
  lea    0x1(%rsi),%rbp
  movsd  (%rcx),%xmm1
  comisd %xmm0,%xmm1
  jbe    L43
  add    $0x1,%edx
  movapd %xmm1,%xmm0
  mov    %rcx,%r11
  mov    %rbp,%rsi
L43:
  comisd %xmm0,%xmm2
  lea    (%rdi,%rax,8),%rcx
  lea    (%r9,%rax,4),%rax
  jb     L65
L12:
  movsd  %xmm2,(%rcx)
  mov    %ebx,(%rax)
  pop    %rbx
  pop    %rbp
  ret
  nopw   0x0(%rax,%rax,1)
L24:
  mov    %rsi,%rax
  mov    %r11,%rcx
  movsd  %xmm2,(%rcx)
  mov    %ebx,(%rax)
  pop    %rbx
  pop    %rbp
  ret
L18:
  mov    %rsi,%rax
  mov    %rdi,%rcx
  jmp    L12
```

assistant: ```c
void sift_down(double *heap, int *ndx, int nn) {
  int n = nn - 1;
  int j, jold, ia;
  double a;
  a = heap[0];
  ia = ndx[0];
  jold = 0;
  j = 1;
  while (j <= n) {
    if (j < n && heap[j] < heap[j + 1])
      j++;
    if (a >= heap[j])
      break;
    heap[jold] = heap[j];
    ndx[jold] = ndx[j];
    jold = j;
    j = 2 * j + 1;
  }
  heap[jold] = a;
  ndx[jold] = ia;
}
```
user: 这段汇编代码用C语言表示是什么样的:

```asm
<sift_down>:
  endbr64
  lea    -0x1(%rdx),%r10d
  push   %rbp
  movsd  (%rdi),%xmm2
  mov    %rsi,%r9
  push   %rbx
  mov    (%rsi),%ebx
  test   %r10d,%r10d
  jle    L39
  xor    %eax,%eax
  mov    $0x1,%ecx
  jmp    L48
  nopl   (%rax)
L51:
  lea    (%r9,%rsi,4),%rsi
  movsd  %xmm0,(%rcx)
  mov    (%rsi),%ecx
  mov    %ecx,(%rax)
  lea    0x1(%rdx,%rdx,1),%ecx
  cmp    %ecx,%r10d
  jl     L68
  movslq %edx,%rax
L48:
  movslq %ecx,%rsi
  mov    %ecx,%edx
  lea    0x0(,%rsi,8),%r8
  lea    (%rdi,%r8,1),%r11
  movsd  (%r11),%xmm0
  cmp    %ecx,%r10d
  jle    L43
  lea    0x8(%rdi,%r8,1),%rcx
  lea    0x1(%rsi),%rbp
  movsd  (%rcx),%xmm1
  comisd %xmm0,%xmm1
  jbe    L43
  add    $0x1,%edx
  movapd %xmm1,%xmm0
  mov    %rcx,%r11
  mov    %rbp,%rsi
L43:
  comisd %xmm0,%xmm2
  lea    (%rdi,%rax,8),%rcx
  lea    (%r9,%rax,4),%rax
  jb     L51
L58:
  movsd  %xmm2,(%rcx)
  mov    %ebx,(%rax)
  pop    %rbx
  pop    %rbp
  ret
  nopw   0x0(%rax,%rax,1)
L68:
  mov    %rsi,%rax
  mov    %r11,%rcx
  movsd  %xmm2,(%rcx)
  mov    %ebx,(%rax)
  pop    %rbx
  pop    %rbp
  ret
L39:
  mov    %rsi,%rax
  mov    %rdi,%rcx
  jmp    L58
```

assistant: ```c
void sift_down(double *heap, int *ndx, int nn) {
  int n = nn - 1;
  int j, jold, ia;
  double a;
  a = heap[0];
  ia = ndx[0];
  jold = 0;
  j = 1;
  while (j <= n) {
    if (j < n && heap[j] < heap[j + 1])
      j++;
    if (a >= heap[j])
      break;
    heap[jold] = heap[j];
    ndx[jold] = ndx[j];
    jold = j;
    j = 2 * j + 1;
  }
  heap[jold] = a;
  ndx[jold] = ia;
}
```