ylfeng/ReF-Decompile-dataset huggingface dataset:
user: 下面的汇编指令对应的C源代码是什么：

```asm
<DrawBoxBmp>:
  endbr64
  push   %rbx
  mov    %rdi,%r11
  mov    %esi,%edi
  lea    (%rsi,%rcx,1),%esi
  cmp    %esi,%edi
  jge    L1
  movslq %edi,%rax
  lea    (%rdx,%rdx,4),%r10d
  shl    $0x7,%r10d
  movslq %r10d,%r10
  lea    (%r11,%r10,2),%rbx
  lea    (%rdx,%r8,1),%r10d
  lea    (%r10,%r10,4),%r10d
  shl    $0x7,%r10d
  movslq %r10d,%r10
  lea    (%r11,%r10,2),%r10
L19:
  mov    %r9w,(%rbx,%rax,2)
  mov    %r9w,(%r10,%rax,2)
  add    $0x1,%rax
  cmp    %eax,%esi
  jg     L19
L1:
  lea    (%rdx,%r8,1),%eax
  cmp    %eax,%edx
  jge    L8
  movslq %edi,%rdi
  lea    (%rdx,%rdx,4),%eax
  shl    $0x7,%eax
  cltq
  add    %rdi,%rax
  lea    (%r11,%rax,2),%rax
  lea    -0x1(%r8),%esi
  movslq %edx,%rdx
  add    %rsi,%rdx
  lea    (%rdx,%rdx,4),%rdx
  shl    $0x7,%rdx
  add    %rdi,%rdx
  lea    0x500(%r11,%rdx,2),%rsi
  movslq %ecx,%rdx
L39:
  mov    %r9w,(%rax)
  mov    %r9w,(%rax,%rdx,2)
  add    $0x500,%rax
  cmp    %rsi,%rax
  jne    L39
L8:
  pop    %rbx
  ret
```

assistant: ```c
void DrawBoxBmp(unsigned short *buffer, int x, int y, int dx, int dy, unsigned short color) {
  int i, j, idx;
  for (i = x; i < x + dx; i++) {
    idx = i + y * 640;
    buffer[idx] = color;
    idx = i + (y + dy) * 640;
    buffer[idx] = color;
  }
  for (j = y; j < y + dy; j++) {
    idx = x + j * 640;
    buffer[idx] = color;
    idx = (x + dx) + j * 640;
    buffer[idx] = color;
  }
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<DrawBoxBmp>:
  endbr64
  mov    %rdi,%r11
  movslq %esi,%rdi
  movslq %edx,%rsi
  movslq %ecx,%rdx
  lea    (%rdi,%rdx,1),%ecx
  push   %rbp
  lea    (%rsi,%r8,1),%ebp
  push   %rbx
  cmp    %ecx,%edi
  jge    L29
  lea    (%rsi,%rsi,4),%r10d
  movslq %edi,%rax
  shl    $0x7,%r10d
  movslq %r10d,%r10
  lea    (%r11,%r10,2),%rbx
  lea    0x0(%rbp,%rbp,4),%r10d
  shl    $0x7,%r10d
  movslq %r10d,%r10
  lea    (%r11,%r10,2),%r10
  nop
L32:
  mov    %r9w,(%rbx,%rax,2)
  mov    %r9w,(%r10,%rax,2)
  add    $0x1,%rax
  cmp    %eax,%ecx
  jg     L32
L29:
  cmp    %ebp,%esi
  jge    L23
  lea    -0x1(%r8),%ecx
  lea    (%rsi,%rsi,4),%eax
  add    %rsi,%rcx
  shl    $0x7,%eax
  lea    (%rcx,%rcx,4),%rcx
  cltq
  shl    $0x7,%rcx
  add    %rdi,%rax
  add    %rdi,%rcx
  lea    (%r11,%rax,2),%rax
  lea    0x500(%r11,%rcx,2),%rcx
  nop
L12:
  mov    %r9w,(%rax)
  mov    %r9w,(%rax,%rdx,2)
  add    $0x500,%rax
  cmp    %rcx,%rax
  jne    L12
L23:
  pop    %rbx
  pop    %rbp
  ret
```

assistant: ```c
void DrawBoxBmp(unsigned short *buffer, int x, int y, int dx, int dy, unsigned short color) {
  int i, j, idx;
  for (i = x; i < x + dx; i++) {
    idx = i + y * 640;
    buffer[idx] = color;
    idx = i + (y + dy) * 640;
    buffer[idx] = color;
  }
  for (j = y; j < y + dy; j++) {
    idx = x + j * 640;
    buffer[idx] = color;
    idx = (x + dx) + j * 640;
    buffer[idx] = color;
  }
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<write_serial_data_until_is_empty>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %edi,%eax
  mov    %esi,%edx
  mov    %ax,-0x4(%rbp)
  mov    %edx,%eax
  mov    %al,-0x8(%rbp)
  jmp    L19
L18:
  nop
L19:
  movzwl -0x4(%rbp),%eax
  mov    %eax,%edi
  call   <is_serial_ready_to_write@plt>
  test   %eax,%eax
  je     L18
  movsbl -0x8(%rbp),%edx
  movzwl -0x4(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <write_port@plt>
  nop
  leave
  ret
```

assistant: ```c
void write_serial_data_until_is_empty(unsigned short com, char data) {
  while (!is_serial_ready_to_write(com)) {
    continue;
  }
  write_port((com), data);
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<write_serial_data_until_is_empty>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %esi,%ebx
  movzwl %di,%ebp
L3:
  mov    %ebp,%edi
  call   <is_serial_ready_to_write@plt>
  test   %eax,%eax
  je     L3
  movsbl %bl,%esi
  mov    %ebp,%edi
  call   <write_port@plt>
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
```

assistant: ```c
void write_serial_data_until_is_empty(unsigned short com, char data) {
  while (!is_serial_ready_to_write(com)) {
    continue;
  }
  write_port((com), data);
}
```
user: 这段汇编代码用C语言表示是什么样的？

```asm
<write_serial_data_until_is_empty>:
  endbr64
  push   %rbp
  movzwl %di,%ebp
  push   %rbx
  mov    %esi,%ebx
  sub    $0x8,%rsp
L7:
  mov    %ebp,%edi
  call   <is_serial_ready_to_write@plt>
  test   %eax,%eax
  je     L7
  add    $0x8,%rsp
  movsbl %bl,%esi
  mov    %ebp,%edi
  pop    %rbx
  pop    %rbp
  jmp    1060 <write_port@plt>
```

assistant: ```c
void write_serial_data_until_is_empty(unsigned short com, char data) {
  while (!is_serial_ready_to_write(com)) {
    continue;
  }
  write_port((com), data);
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<write_serial_data_until_is_empty>:
  endbr64
  push   %rbp
  movzwl %di,%ebp
  push   %rbx
  mov    %esi,%ebx
  sub    $0x8,%rsp
L8:
  mov    %ebp,%edi
  call   <is_serial_ready_to_write@plt>
  test   %eax,%eax
  je     L8
  add    $0x8,%rsp
  movsbl %bl,%esi
  mov    %ebp,%edi
  pop    %rbx
  pop    %rbp
  jmp    1060 <write_port@plt>
```

assistant: ```c
void write_serial_data_until_is_empty(unsigned short com, char data) {
  while (!is_serial_ready_to_write(com)) {
    continue;
  }
  write_port((com), data);
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<next>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,%eax
  mov    %al,-0x4(%rbp)
  movsbl -0x4(%rbp),%eax
  cmp    $0x28,%eax
  jne    L8
  mov    $0x29,%eax
  jmp    L15
L8:
  mov    $0x0,%eax
L15:
  pop    %rbp
  ret
```

assistant: ```c
char next(char c) {
  switch (c) {
  case '(':
    return ')';
  default:
    return '\0';
  }
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<next>:
  endbr64
  cmp    $0x28,%dil
  mov    $0x29,%eax
  mov    $0x0,%edx
  cmovne %edx,%eax
  ret
```

assistant: ```c
char next(char c) {
  switch (c) {
  case '(':
    return ')';
  default:
    return '\0';
  }
}
```
user: Translate the below assembly code into C programming language:

```asm
<next>:
  endbr64
  cmp    $0x28,%dil
  mov    $0x0,%edx
  mov    $0x29,%eax
  cmovne %edx,%eax
  ret
```

assistant: ```c
char next(char c) {
  switch (c) {
  case '(':
    return ')';
  default:
    return '\0';
  }
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<next>:
  endbr64
  cmp    $0x28,%dil
  mov    $0x0,%edx
  mov    $0x29,%eax
  cmovne %edx,%eax
  ret
```

assistant: ```c
char next(char c) {
  switch (c) {
  case '(':
    return ')';
  default:
    return '\0';
  }
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<oml_strndup>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    -0x20(%rbp),%rdx
  mov    -0x18(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <memchr@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  je     L12
  mov    -0x8(%rbp),%rax
  sub    -0x18(%rbp),%rax
  jmp    L13
L12:
  mov    -0x20(%rbp),%rax
L13:
  mov    -0x18(%rbp),%rdx
  mov    %rax,%rsi
  mov    %rdx,%rdi
  call   <oml_memdupz@plt>
  leave
  ret
```

assistant: ```c
char *oml_strndup(const char *str, size_t len) {
  char *p = memchr(str, '\0', len);
  return oml_memdupz(str, p ? (size_t)(p - str) : len);
}
```
user: What is the c source code of the assembly code below:

```asm
<oml_strndup>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%rbp
  mov    %rsi,%rbx
  mov    %rsi,%rdx
  mov    $0x0,%esi
  call   <memchr@plt>
  mov    %rax,%rdx
  sub    %rbp,%rdx
  test   %rax,%rax
  cmovne %rdx,%rbx
  mov    %rbx,%rsi
  mov    %rbp,%rdi
  call   <oml_memdupz@plt>
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
```

assistant: ```c
char *oml_strndup(const char *str, size_t len) {
  char *p = memchr(str, '\0', len);
  return oml_memdupz(str, p ? (size_t)(p - str) : len);
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<oml_strndup>:
  endbr64
  push   %r12
  mov    %rsi,%rdx
  mov    %rdi,%r12
  push   %rbp
  mov    %rsi,%rbp
  xor    %esi,%esi
  sub    $0x8,%rsp
  call   <memchr@plt>
  mov    %r12,%rdi
  mov    %rax,%rdx
  sub    %r12,%rdx
  test   %rax,%rax
  cmovne %rdx,%rbp
  add    $0x8,%rsp
  mov    %rbp,%rsi
  pop    %rbp
  pop    %r12
  jmp    1060 <oml_memdupz@plt>
```

assistant: ```c
char *oml_strndup(const char *str, size_t len) {
  char *p = memchr(str, '\0', len);
  return oml_memdupz(str, p ? (size_t)(p - str) : len);
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<oml_strndup>:
  endbr64
  push   %r12
  mov    %rsi,%rdx
  mov    %rdi,%r12
  push   %rbp
  mov    %rsi,%rbp
  xor    %esi,%esi
  sub    $0x8,%rsp
  call   <memchr@plt>
  mov    %r12,%rdi
  mov    %rax,%rdx
  sub    %r12,%rdx
  test   %rax,%rax
  cmovne %rdx,%rbp
  add    $0x8,%rsp
  mov    %rbp,%rsi
  pop    %rbp
  pop    %r12
  jmp    1060 <oml_memdupz@plt>
```

assistant: ```c
char *oml_strndup(const char *str, size_t len) {
  char *p = memchr(str, '\0', len);
  return oml_memdupz(str, p ? (size_t)(p - str) : len);
}
```
user: 这段汇编代码用C语言表示是什么样的？

```asm
<tiger>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x140,%rsp
  mov    %rdi,-0x128(%rbp)
  mov    %esi,-0x12c(%rbp)
  mov    %rdx,-0x138(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x138(%rbp),%rax
  movl   $0x89abcdef,(%rax)
  mov    -0x138(%rbp),%rax
  add    $0x4,%rax
  movl   $0x76543210,(%rax)
  mov    -0x138(%rbp),%rax
  add    $0x8,%rax
  movl   $0xc3b2e187,(%rax)
  mov    -0x12c(%rbp),%eax
  mov    %eax,-0x118(%rbp)
  jmp    L2
L92:
  mov    -0x138(%rbp),%rdx
  mov    -0x128(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <tiger_compress@plt>
  addq   $0x20,-0x128(%rbp)
  subl   $0x40,-0x118(%rbp)
L2:
  cmpl   $0x3f,-0x118(%rbp)
  jg     L92
  movl   $0x0,-0x114(%rbp)
  jmp    L86
L39:
  mov    -0x114(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x128(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x114(%rbp),%eax
  cltq
  mov    %edx,-0x110(%rbp,%rax,4)
  addl   $0x1,-0x114(%rbp)
L86:
  mov    -0x114(%rbp),%eax
  cmp    -0x118(%rbp),%eax
  jl     L39
  mov    -0x114(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x114(%rbp)
  cltq
  movl   $0x1,-0x110(%rbp,%rax,4)
  jmp    L54
L107:
  mov    -0x114(%rbp),%eax
  cltq
  movl   $0x0,-0x110(%rbp,%rax,4)
  addl   $0x1,-0x114(%rbp)
L54:
  mov    -0x114(%rbp),%eax
  and    $0x7,%eax
  test   %eax,%eax
  jne    L107
  cmpl   $0x38,-0x114(%rbp)
  jle    L75
  jmp    L27
L100:
  mov    -0x114(%rbp),%eax
  cltq
  movl   $0x0,-0x110(%rbp,%rax,4)
  addl   $0x1,-0x114(%rbp)
L27:
  cmpl   $0x3f,-0x114(%rbp)
  jle    L100
  mov    -0x138(%rbp),%rdx
  lea    -0x110(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <tiger_compress@plt>
  movl   $0x0,-0x114(%rbp)
  jmp    L75
L3:
  mov    -0x114(%rbp),%eax
  cltq
  movl   $0x0,-0x110(%rbp,%rax,4)
  addl   $0x1,-0x114(%rbp)
L75:
  cmpl   $0x37,-0x114(%rbp)
  jle    L3
  lea    -0x110(%rbp),%rax
  add    $0xe0,%rax
  mov    -0x12c(%rbp),%edx
  shl    $0x3,%edx
  mov    %edx,(%rax)
  mov    -0x138(%rbp),%rdx
  lea    -0x110(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <tiger_compress@plt>
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L82
  call   <__stack_chk_fail@plt>
L82:
  leave
  ret
```

assistant: ```c
void tiger(uint64_t *str, uint64_t length, uint64_t res[3]) {
  uint64_t i, j;
  uint8_t temp[64];
  res[0] = 0x0123456789ABCDEFULL;
  res[1] = 0xFEDCBA9876543210ULL;
  res[2] = 0xF096A5B4C3B2E187ULL;
  for (i = length; i >= 64; i -= 64) {
    tiger_compress(str, res);
    str += 8;
  }
  for (j = 0; j < i; j++)
    temp[j] = ((uint8_t *)str)[j];
  temp[j++] = 0x01;
  for (; j & 7; j++)
    temp[j] = 0;
  if (j > 56) {
    for (; j < 64; j++)
      temp[j] = 0;
    tiger_compress(((uint64_t *)temp), res);
    j = 0;
  }
  for (; j < 56; j++)
    temp[j] = 0;
  ((uint64_t *)(&(temp[56])))[0] = ((uint64_t)length) << 3;
  tiger_compress(((uint64_t *)temp), res);
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<tiger>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x110,%rsp
  mov    %rdi,%r12
  mov    %esi,%ebp
  mov    %rdx,%rbx
  mov    %fs:0x28,%rax
  mov    %rax,0x108(%rsp)
  xor    %eax,%eax
  movl   $0x89abcdef,(%rdx)
  movl   $0x76543210,0x4(%rdx)
  movl   $0xc3b2e187,0x8(%rdx)
  cmp    $0x3f,%esi
  jle    L76
  lea    -0x40(%rsi),%r14d
  shr    $0x6,%r14d
  lea    0x1(%r14),%r13d
  mov    %r13d,%r13d
  shl    $0x5,%r13
  add    %rdi,%r13
L64:
  mov    %rbx,%rsi
  mov    %r12,%rdi
  call   <tiger_compress@plt>
  add    $0x20,%r12
  cmp    %r13,%r12
  jne    L64
  neg    %r14d
  shl    $0x6,%r14d
  lea    -0x40(%rbp,%r14,1),%edi
L134:
  test   %edi,%edi
  jle    L87
  mov    %edi,%eax
  mov    %edi,%esi
  mov    $0x0,%edx
L135:
  mov    0x0(%r13,%rdx,4),%ecx
  mov    %ecx,(%rsp,%rdx,4)
  add    $0x1,%rdx
  cmp    %rsi,%rdx
  jne    L135
  add    $0x1,%eax
  movslq %edi,%rdi
  movl   $0x1,(%rsp,%rdi,4)
  test   $0x7,%al
  je     L46
L130:
  add    $0x1,%eax
  movslq %eax,%rdx
L24:
  movl   $0x0,-0x4(%rsp,%rdx,4)
  mov    %edx,%eax
  add    $0x1,%rdx
  test   $0x7,%al
  jne    L24
L46:
  cmp    $0x38,%eax
  jle    L149
  cmp    $0x3f,%eax
  jg     L114
  cltq
L100:
  movl   $0x0,(%rsp,%rax,4)
  add    $0x1,%rax
  cmp    $0x3f,%eax
  jle    L100
L114:
  mov    %rsp,%rdi
  mov    %rbx,%rsi
  call   <tiger_compress@plt>
  mov    $0x0,%eax
L86:
  cltq
L5:
  movl   $0x0,(%rsp,%rax,4)
  add    $0x1,%rax
  cmp    $0x37,%eax
  jle    L5
L111:
  shl    $0x3,%ebp
  mov    %ebp,0xe0(%rsp)
  mov    %rsp,%rdi
  mov    %rbx,%rsi
  call   <tiger_compress@plt>
  mov    0x108(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L30
  add    $0x110,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L76:
  mov    %esi,%edi
  mov    %r12,%r13
  jmp    L134
L149:
  cmp    $0x37,%eax
  jle    L86
  jmp    L111
L87:
  movl   $0x1,(%rsp)
  mov    $0x1,%eax
  jmp    L130
L30:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void tiger(uint64_t *str, uint64_t length, uint64_t res[3]) {
  uint64_t i, j;
  uint8_t temp[64];
  res[0] = 0x0123456789ABCDEFULL;
  res[1] = 0xFEDCBA9876543210ULL;
  res[2] = 0xF096A5B4C3B2E187ULL;
  for (i = length; i >= 64; i -= 64) {
    tiger_compress(str, res);
    str += 8;
  }
  for (j = 0; j < i; j++)
    temp[j] = ((uint8_t *)str)[j];
  temp[j++] = 0x01;
  for (; j & 7; j++)
    temp[j] = 0;
  if (j > 56) {
    for (; j < 64; j++)
      temp[j] = 0;
    tiger_compress(((uint64_t *)temp), res);
    j = 0;
  }
  for (; j < 56; j++)
    temp[j] = 0;
  ((uint64_t *)(&(temp[56])))[0] = ((uint64_t)length) << 3;
  tiger_compress(((uint64_t *)temp), res);
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<memmove>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %rdx,-0x38(%rbp)
  mov    -0x28(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x30(%rbp),%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  cmp    -0x10(%rbp),%rax
  jae    L6
  movq   $0x0,-0x20(%rbp)
  jmp    L46
L36:
  mov    -0x8(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  mov    -0x10(%rbp),%rcx
  mov    -0x20(%rbp),%rdx
  add    %rcx,%rdx
  movzbl (%rax),%eax
  mov    %al,(%rdx)
  addq   $0x1,-0x20(%rbp)
L46:
  mov    -0x20(%rbp),%rax
  cmp    -0x38(%rbp),%rax
  jb     L36
  jmp    L35
L6:
  mov    -0x38(%rbp),%rax
  mov    %rax,-0x18(%rbp)
  jmp    L34
L33:
  mov    -0x18(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    -0x18(%rbp),%rdx
  lea    -0x1(%rdx),%rcx
  mov    -0x10(%rbp),%rdx
  add    %rcx,%rdx
  movzbl (%rax),%eax
  mov    %al,(%rdx)
  subq   $0x1,-0x18(%rbp)
L34:
  cmpq   $0x0,-0x18(%rbp)
  jne    L33
L35:
  mov    -0x28(%rbp),%rax
  pop    %rbp
  ret
```

assistant: ```c
void *memmove(void *dst, const void *src, size_t n) {
  unsigned char *to = (unsigned char *)dst;
  const unsigned char *from = (const unsigned char *)src;
  if (from < to) {
    for (size_t i = 0; i < n; i++) {
      to[i] = from[i];
    }
  } else {
    for (size_t i = n; i > 0; i--) {
      to[i - 1] = from[i - 1];
    }
  }
  return dst;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<memmove>:
  endbr64
  mov    %rdi,%rax
  cmp    %rsi,%rdi
  ja     L39
  test   %rdx,%rdx
  je     L13
L29:
  sub    $0x1,%rdx
  movzbl (%rsi,%rdx,1),%ecx
  mov    %cl,(%rax,%rdx,1)
  jne    L29
L31:
  ret
L13:
  ret
L39:
  test   %rdx,%rdx
  je     L31
  mov    $0x0,%ecx
L23:
  movzbl (%rsi,%rcx,1),%edi
  mov    %dil,(%rax,%rcx,1)
  add    $0x1,%rcx
  cmp    %rcx,%rdx
  jne    L23
  ret
```

assistant: ```c
void *memmove(void *dst, const void *src, size_t n) {
  unsigned char *to = (unsigned char *)dst;
  const unsigned char *from = (const unsigned char *)src;
  if (from < to) {
    for (size_t i = 0; i < n; i++) {
      to[i] = from[i];
    }
  } else {
    for (size_t i = n; i > 0; i--) {
      to[i - 1] = from[i - 1];
    }
  }
  return dst;
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<memmove>:
  endbr64
  mov    %rdi,%rax
  cmp    %rsi,%rdi
  ja     L19
  test   %rdx,%rdx
  je     L0
  nopl   0x0(%rax)
L6:
  sub    $0x1,%rdx
  movzbl (%rsi,%rdx,1),%ecx
  mov    %cl,(%rax,%rdx,1)
  jne    L6
L24:
  ret
  cs nopw 0x0(%rax,%rax,1)
L19:
  test   %rdx,%rdx
  je     L24
  xor    %ecx,%ecx
  nopw   0x0(%rax,%rax,1)
L5:
  movzbl (%rsi,%rcx,1),%edi
  mov    %dil,(%rax,%rcx,1)
  add    $0x1,%rcx
  cmp    %rcx,%rdx
  jne    L5
  ret
  nopw   0x0(%rax,%rax,1)
L0:
  ret
```

assistant: ```c
void *memmove(void *dst, const void *src, size_t n) {
  unsigned char *to = (unsigned char *)dst;
  const unsigned char *from = (const unsigned char *)src;
  if (from < to) {
    for (size_t i = 0; i < n; i++) {
      to[i] = from[i];
    }
  } else {
    for (size_t i = n; i > 0; i--) {
      to[i - 1] = from[i - 1];
    }
  }
  return dst;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<memmove>:
  endbr64
  mov    %rdi,%r8
  mov    %rdx,%rax
  cmp    %rsi,%rdi
  ja     L50
  test   %rdx,%rdx
  je     L9
  nopl   0x0(%rax)
L32:
  sub    $0x1,%rax
  movzbl (%rsi,%rax,1),%edx
  mov    %dl,(%r8,%rax,1)
  jne    L32
L9:
  mov    %r8,%rax
  ret
  nopw   0x0(%rax,%rax,1)
L50:
  test   %rdx,%rdx
  je     L9
  lea    0x1(%rsi),%rdi
  mov    %r8,%rcx
  lea    -0x1(%rdx),%rdx
  sub    %rdi,%rcx
  cmp    $0xe,%rcx
  jbe    L73
  cmp    $0x6,%rdx
  jbe    L73
  mov    %rax,%rcx
  cmp    $0xe,%rdx
  jbe    L129
  and    $0xfffffffffffffff0,%rcx
  xor    %edx,%edx
  nopw   0x0(%rax,%rax,1)
L36:
  movdqu (%rsi,%rdx,1),%xmm0
  movups %xmm0,(%r8,%rdx,1)
  add    $0x10,%rdx
  cmp    %rdx,%rcx
  jne    L36
  mov    %rax,%rdx
  and    $0xfffffffffffffff0,%rdx
  test   $0xf,%al
  je     L9
  mov    %rax,%rcx
  sub    %rdx,%rcx
  lea    -0x1(%rcx),%rdi
  cmp    $0x6,%rdi
  jbe    L51
L128:
  mov    (%rsi,%rdx,1),%rdi
  mov    %rdi,(%r8,%rdx,1)
  mov    %rcx,%rdi
  and    $0xfffffffffffffff8,%rdi
  add    %rdi,%rdx
  cmp    %rdi,%rcx
  je     L9
L51:
  movzbl (%rsi,%rdx,1),%ecx
  mov    %cl,(%r8,%rdx,1)
  lea    0x1(%rdx),%rcx
  cmp    %rcx,%rax
  jbe    L9
  movzbl 0x1(%rsi,%rdx,1),%ecx
  mov    %cl,0x1(%r8,%rdx,1)
  lea    0x2(%rdx),%rcx
  cmp    %rcx,%rax
  jbe    L9
  movzbl 0x2(%rsi,%rdx,1),%ecx
  mov    %cl,0x2(%r8,%rdx,1)
  lea    0x3(%rdx),%rcx
  cmp    %rcx,%rax
  jbe    L9
  movzbl 0x3(%rsi,%rdx,1),%ecx
  mov    %cl,0x3(%r8,%rdx,1)
  lea    0x4(%rdx),%rcx
  cmp    %rcx,%rax
  jbe    L9
  movzbl 0x4(%rsi,%rdx,1),%ecx
  mov    %cl,0x4(%r8,%rdx,1)
  lea    0x5(%rdx),%rcx
  cmp    %rcx,%rax
  jbe    L9
  movzbl 0x5(%rsi,%rdx,1),%ecx
  mov    %cl,0x5(%r8,%rdx,1)
  lea    0x6(%rdx),%rcx
  cmp    %rcx,%rax
  jbe    L9
  movzbl 0x6(%rsi,%rdx,1),%eax
  mov    %al,0x6(%r8,%rdx,1)
  mov    %r8,%rax
  ret
  nop
L73:
  xor    %edx,%edx
  nopw   0x0(%rax,%rax,1)
L86:
  movzbl (%rsi,%rdx,1),%ecx
  mov    %cl,(%r8,%rdx,1)
  add    $0x1,%rdx
  cmp    %rdx,%rax
  jne    L86
  jmp    L9
L129:
  xor    %edx,%edx
  jmp    L128
```

assistant: ```c
void *memmove(void *dst, const void *src, size_t n) {
  unsigned char *to = (unsigned char *)dst;
  const unsigned char *from = (const unsigned char *)src;
  if (from < to) {
    for (size_t i = 0; i < n; i++) {
      to[i] = from[i];
    }
  } else {
    for (size_t i = n; i > 0; i--) {
      to[i - 1] = from[i - 1];
    }
  }
  return dst;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<createMVDCost>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %edi,-0x14(%rbp)
  mov    %esi,-0x18(%rbp)
  mov    %edx,-0x1c(%rbp)
  movl   $0x0,-0x4(%rbp)
  mov    -0x18(%rbp),%eax
  mov    %eax,%edx
  neg    %edx
  cmovns %edx,%eax
  mov    %eax,-0x18(%rbp)
  mov    -0x1c(%rbp),%eax
  mov    %eax,%edx
  neg    %edx
  cmovns %edx,%eax
  mov    %eax,-0x1c(%rbp)
  pxor   %xmm2,%xmm2
  cvtsi2ssl -0x14(%rbp),%xmm2
  movss  %xmm2,-0x20(%rbp)
  pxor   %xmm1,%xmm1
  cvtsi2ssl -0x18(%rbp),%xmm1
  movss  D76(%rip),%xmm0
  addss  %xmm0,%xmm1
  movd   %xmm1,%eax
  movd   %eax,%xmm0
  call   <log2@plt>
  add    %eax,%eax
  pxor   %xmm1,%xmm1
  cvtsi2ss %eax,%xmm1
  movss  D42(%rip),%xmm0
  addss  %xmm0,%xmm1
  cmpl   $0x0,-0x18(%rbp)
  je     L7
  movss  D76(%rip),%xmm0
  jmp    L31
L7:
  pxor   %xmm0,%xmm0
L31:
  addss  %xmm1,%xmm0
  movss  -0x20(%rbp),%xmm1
  mulss  %xmm0,%xmm1
  movss  D9(%rip),%xmm0
  addss  %xmm1,%xmm0
  cvttss2si %xmm0,%eax
  mov    %eax,-0x4(%rbp)
  pxor   %xmm3,%xmm3
  cvtsi2ssl -0x14(%rbp),%xmm3
  movss  %xmm3,-0x20(%rbp)
  pxor   %xmm1,%xmm1
  cvtsi2ssl -0x1c(%rbp),%xmm1
  movss  D76(%rip),%xmm0
  addss  %xmm0,%xmm1
  movd   %xmm1,%eax
  movd   %eax,%xmm0
  call   <log2@plt>
  add    %eax,%eax
  pxor   %xmm1,%xmm1
  cvtsi2ss %eax,%xmm1
  movss  D42(%rip),%xmm0
  addss  %xmm0,%xmm1
  cmpl   $0x0,-0x1c(%rbp)
  je     L6
  movss  D76(%rip),%xmm0
  jmp    L10
L6:
  pxor   %xmm0,%xmm0
L10:
  addss  %xmm1,%xmm0
  movss  -0x20(%rbp),%xmm1
  mulss  %xmm0,%xmm1
  movss  D9(%rip),%xmm0
  addss  %xmm0,%xmm1
  pxor   %xmm0,%xmm0
  cvtsi2ssl -0x4(%rbp),%xmm0
  addss  %xmm1,%xmm0
  cvttss2si %xmm0,%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  leave
  ret
```

tool_calls: name: read_data
arguments: data_label: D76
type: byte[4]
name: read_data
arguments: data_label: D42
type: byte[4]
name: read_data
arguments: data_label: D9
type: byte[4]

tool: {"D76": [0x00,0x00,0x80,0x3f]}

tool: {"D42": [0xd9,0xce,0x37,0x3f]}

tool: {"D9": [0x00,0x00,0x00,0x3f]}

assistant: ```c
int createMVDCost(int i_lambda, int x, int y) {
  int costs = 0;
  x = abs(x);
  y = abs(y);
  costs = i_lambda * (log2((float)x + 1) * 2 + 0.718f + !!(x)) + .5f;
  costs += i_lambda * (log2((float)y + 1) * 2 + 0.718f + !!(y)) + .5f;
  return costs;
}
```