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

```asm
<single_read_write>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %ecx,%ebx
  test   %ecx,%ecx
  jle    L21
  mov    %edi,%r12d
  mov    %esi,%r13d
  mov    %rdx,%rbp
  xor    %r14d,%r14d
  jmp    L31
L13:
  call   <read@plt>
  test   %eax,%eax
  jle    L45
L46:
  add    %eax,%r14d
  cmp    %r14d,%ebx
  jle    L21
L31:
  mov    %ebx,%edx
  movslq %r14d,%rsi
  mov    %r13d,%edi
  sub    %r14d,%edx
  add    %rbp,%rsi
  test   %r12d,%r12d
  jne    L13
  call   <write@plt>
  test   %eax,%eax
  jg     L46
L45:
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  cs nopw 0x0(%rax,%rax,1)
L21:
  mov    %ebx,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
```

assistant: ```c
int single_read_write(int is_read, int fd, char *buf, int count) {
  int tmp = 0;
  int ret;
  while (tmp < count) {
    if (is_read) {
      ret = read(fd, buf + tmp, count - tmp);
    } else {
      ret = write(fd, buf + tmp, count - tmp);
    }
    if (ret <= 0)
      return ret;
    tmp += ret;
  }
  return count;
}
```
user: 这段汇编代码用C语言表示是什么样的？

```asm
<single_read_write>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %ecx,%ebx
  sub    $0x8,%rsp
  test   %ecx,%ecx
  jle    L73
  mov    %edi,%r13d
  mov    %esi,%ebp
  mov    %rdx,%r12
  test   %edi,%edi
  je     L76
  xor    %r13d,%r13d
  jmp    L22
  nopl   (%rax)
L14:
  add    %eax,%r13d
  cmp    %r13d,%ebx
  jle    L73
L22:
  mov    %ebx,%edx
  movslq %r13d,%rsi
  mov    %ebp,%edi
  sub    %r13d,%edx
  add    %r12,%rsi
  call   <read@plt>
  test   %eax,%eax
  jg     L14
L8:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L31:
  add    %eax,%r13d
  cmp    %r13d,%ebx
  jle    L73
L76:
  mov    %ebx,%edx
  movslq %r13d,%rsi
  mov    %ebp,%edi
  sub    %r13d,%edx
  add    %r12,%rsi
  call   <write@plt>
  test   %eax,%eax
  jg     L31
  jmp    L8
  nopl   0x0(%rax,%rax,1)
L73:
  add    $0x8,%rsp
  mov    %ebx,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

assistant: ```c
int single_read_write(int is_read, int fd, char *buf, int count) {
  int tmp = 0;
  int ret;
  while (tmp < count) {
    if (is_read) {
      ret = read(fd, buf + tmp, count - tmp);
    } else {
      ret = write(fd, buf + tmp, count - tmp);
    }
    if (ret <= 0)
      return ret;
    tmp += ret;
  }
  return count;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<mix32>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  shr    $0x10,%eax
  xor    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  imul   $0x85ebca6b,%eax,%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  shr    $0xd,%eax
  xor    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  imul   $0xc2b2ae35,%eax,%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  shr    $0x10,%eax
  xor    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  pop    %rbp
  ret
```

assistant: ```c
unsigned mix32(unsigned int h) {
  h ^= h >> 16;
  h *= 0x85ebca6b;
  h ^= h >> 13;
  h *= 0xc2b2ae35;
  h ^= h >> 16;
  return h;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<mix32>:
  endbr64
  mov    %edi,%eax
  shr    $0x10,%eax
  xor    %edi,%eax
  imul   $0x85ebca6b,%eax,%eax
  mov    %eax,%edx
  shr    $0xd,%edx
  xor    %eax,%edx
  imul   $0xc2b2ae35,%edx,%edx
  mov    %edx,%eax
  shr    $0x10,%eax
  xor    %edx,%eax
  ret
```

assistant: ```c
unsigned mix32(unsigned int h) {
  h ^= h >> 16;
  h *= 0x85ebca6b;
  h ^= h >> 13;
  h *= 0xc2b2ae35;
  h ^= h >> 16;
  return h;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<mix32>:
  endbr64
  mov    %edi,%eax
  shr    $0x10,%eax
  xor    %edi,%eax
  imul   $0x85ebca6b,%eax,%eax
  mov    %eax,%edx
  shr    $0xd,%edx
  xor    %eax,%edx
  imul   $0xc2b2ae35,%edx,%edx
  mov    %edx,%eax
  shr    $0x10,%eax
  xor    %edx,%eax
  ret
```

assistant: ```c
unsigned mix32(unsigned int h) {
  h ^= h >> 16;
  h *= 0x85ebca6b;
  h ^= h >> 13;
  h *= 0xc2b2ae35;
  h ^= h >> 16;
  return h;
}
```
user: What is the c source code of the assembly code below:

```asm
<mix32>:
  endbr64
  mov    %edi,%eax
  shr    $0x10,%eax
  xor    %edi,%eax
  imul   $0x85ebca6b,%eax,%eax
  mov    %eax,%edx
  shr    $0xd,%edx
  xor    %eax,%edx
  imul   $0xc2b2ae35,%edx,%edx
  mov    %edx,%eax
  shr    $0x10,%eax
  xor    %edx,%eax
  ret
```

assistant: ```c
unsigned mix32(unsigned int h) {
  h ^= h >> 16;
  h *= 0x85ebca6b;
  h ^= h >> 13;
  h *= 0xc2b2ae35;
  h ^= h >> 16;
  return h;
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<cli_vasprintf>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0xd0,%rsp
  mov    %rdi,-0xc8(%rbp)
  mov    %rsi,-0xd0(%rbp)
  mov    %rdx,-0xa0(%rbp)
  mov    %rcx,-0x98(%rbp)
  mov    %r8,-0x90(%rbp)
  mov    %r9,-0x88(%rbp)
  test   %al,%al
  je     L19
  movaps %xmm0,-0x80(%rbp)
  movaps %xmm1,-0x70(%rbp)
  movaps %xmm2,-0x60(%rbp)
  movaps %xmm3,-0x50(%rbp)
  movaps %xmm4,-0x40(%rbp)
  movaps %xmm5,-0x30(%rbp)
  movaps %xmm6,-0x20(%rbp)
  movaps %xmm7,-0x10(%rbp)
L19:
  mov    -0xd0(%rbp),%rdx
  mov    -0xb8(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <va_start@plt>
  mov    -0xb8(%rbp),%edx
  mov    -0xd0(%rbp),%rcx
  mov    -0xc8(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <vasprintf@plt>
  mov    %eax,-0xb4(%rbp)
  mov    -0xb8(%rbp),%eax
  mov    %eax,%edi
  call   <va_end@plt>
  cmpl   $0xffffffff,-0xb4(%rbp)
  jne    L17
  lea    D1(%rip),%rax
  mov    %rax,%rdi
  call   <cli_fatal@plt>
L17:
  mov    -0xb4(%rbp),%eax
  leave
  ret
```

tool_calls: name: parse_data
arguments: tag: D1
type: string

tool: D1: cli_vasprintf

assistant: ```c
int cli_vasprintf(char **out, const char *fmt, ...) {
  int l;
  va_list args;
  va_start(args, fmt);
  l = vasprintf(out, fmt, args);
  va_end(args);
  if (l == -1)
    cli_fatal("cli_vasprintf");
  return (l);
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<cli_vasprintf>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%r12
  mov    %rsi,%rbx
  mov    $0x0,%ebp
  mov    %ebp,%edi
  call   <va_start@plt>
  mov    %ebp,%edx
  mov    %rbx,%rsi
  mov    %r12,%rdi
  call   <vasprintf@plt>
  mov    %eax,%ebx
  mov    %ebp,%edi
  call   <va_end@plt>
  cmp    $0xffffffff,%ebx
  je     L12
L6:
  mov    %ebx,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L12:
  lea    D1(%rip),%rdi
  call   <cli_fatal@plt>
  jmp    L6
```

tool_calls: name: disassemble_data
arguments: data_label: D1
type_guessed: string

tool: D1: cli_vasprintf

assistant: ```c
int cli_vasprintf(char **out, const char *fmt, ...) {
  int l;
  va_list args;
  va_start(args, fmt);
  l = vasprintf(out, fmt, args);
  va_end(args);
  if (l == -1)
    cli_fatal("cli_vasprintf");
  return (l);
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<cli_vasprintf>:
  endbr64
  push   %r13
  mov    %rdi,%r13
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  xor    %ebp,%ebp
  mov    %ebp,%edi
  call   <va_start@plt>
  mov    %r12,%rsi
  mov    %r13,%rdi
  mov    %ebp,%edx
  call   <vasprintf@plt>
  mov    %ebp,%edi
  mov    %eax,%r12d
  call   <va_end@plt>
  cmp    $0xffffffff,%r12d
  je     L0
  mov    %r12d,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  xchg   %ax,%ax
L0:
  lea    D3(%rip),%rdi
  call   <cli_fatal@plt>
  mov    %r12d,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

tool_calls: name: unpack_data
arguments: data_label: D3
type: string

tool: D3: cli_vasprintf

assistant: ```c
int cli_vasprintf(char **out, const char *fmt, ...) {
  int l;
  va_list args;
  va_start(args, fmt);
  l = vasprintf(out, fmt, args);
  va_end(args);
  if (l == -1)
    cli_fatal("cli_vasprintf");
  return (l);
}
```
user: Translate the below assembly code into C programming language:

```asm
<cli_vasprintf>:
  endbr64
  push   %r13
  mov    %rdi,%r13
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  xor    %ebp,%ebp
  mov    %ebp,%edi
  call   <va_start@plt>
  mov    %r12,%rsi
  mov    %r13,%rdi
  mov    %ebp,%edx
  call   <vasprintf@plt>
  mov    %ebp,%edi
  mov    %eax,%r12d
  call   <va_end@plt>
  cmp    $0xffffffff,%r12d
  je     L1
  mov    %r12d,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  xchg   %ax,%ax
L1:
  lea    D1(%rip),%rdi
  call   <cli_fatal@plt>
  mov    %r12d,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

tool_calls: name: parse_data
arguments: data_tag: D1
type_guessed: string

tool: D1: cli_vasprintf

assistant: ```c
int cli_vasprintf(char **out, const char *fmt, ...) {
  int l;
  va_list args;
  va_start(args, fmt);
  l = vasprintf(out, fmt, args);
  va_end(args);
  if (l == -1)
    cli_fatal("cli_vasprintf");
  return (l);
}
```
user: Translate the below assembly code into C programming language:

```asm
<calcAddrB>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,-0x4(%rbp)
  shll   $0x2,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  and    $0x2000000,%eax
  test   %eax,%eax
  je     L8
  orl    $0xfc000000,-0x4(%rbp)
  jmp    L15
L8:
  andl   $0x3ffffff,-0x4(%rbp)
L15:
  mov    -0x4(%rbp),%eax
  add    $0x8,%eax
  pop    %rbp
  ret
```

assistant: ```c
unsigned int calcAddrB(unsigned int offset) {
  offset *= 4;
  if (offset & 0x02000000)
    offset |= 0xfc000000;
  else
    offset &= 0x03ffffff;
  return offset + 8;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<calcAddrB>:
  endbr64
  shl    $0x2,%edi
  mov    %edi,%edx
  or     $0xfc000000,%edx
  mov    %edi,%eax
  and    $0x3ffffff,%eax
  test   $0x2000000,%edi
  cmovne %edx,%eax
  add    $0x8,%eax
  ret
```

assistant: ```c
unsigned int calcAddrB(unsigned int offset) {
  offset *= 4;
  if (offset & 0x02000000)
    offset |= 0xfc000000;
  else
    offset &= 0x03ffffff;
  return offset + 8;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<calcAddrB>:
  endbr64
  shl    $0x2,%edi
  mov    %edi,%edx
  mov    %edi,%eax
  or     $0xfc000000,%edx
  and    $0x3ffffff,%eax
  and    $0x2000000,%edi
  cmovne %edx,%eax
  add    $0x8,%eax
  ret
```

assistant: ```c
unsigned int calcAddrB(unsigned int offset) {
  offset *= 4;
  if (offset & 0x02000000)
    offset |= 0xfc000000;
  else
    offset &= 0x03ffffff;
  return offset + 8;
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<calcAddrB>:
  endbr64
  shl    $0x2,%edi
  mov    %edi,%edx
  mov    %edi,%eax
  or     $0xfc000000,%edx
  and    $0x3ffffff,%eax
  and    $0x2000000,%edi
  cmovne %edx,%eax
  add    $0x8,%eax
  ret
```

assistant: ```c
unsigned int calcAddrB(unsigned int offset) {
  offset *= 4;
  if (offset & 0x02000000)
    offset |= 0xfc000000;
  else
    offset &= 0x03ffffff;
  return offset + 8;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<setFilenameAutomatically>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    $0x0,%eax
  call   <setFilenameFromEnvironment@plt>
  test   %eax,%eax
  je     L16
  mov    $0x0,%eax
  call   <setDefaultFilename@plt>
  jmp    L12
L16:
  nop
L12:
  pop    %rbp
  ret
```

assistant: ```c
void setFilenameAutomatically(void) {
  if (!setFilenameFromEnvironment())
    return;
  setDefaultFilename();
}
```
user: Translate the below assembly code into C programming language:

```asm
<setFilenameAutomatically>:
  endbr64
  sub    $0x8,%rsp
  mov    $0x0,%eax
  call   <setFilenameFromEnvironment@plt>
  test   %eax,%eax
  jne    L14
L3:
  add    $0x8,%rsp
  ret
L14:
  mov    $0x0,%eax
  call   <setDefaultFilename@plt>
  jmp    L3
```

assistant: ```c
void setFilenameAutomatically(void) {
  if (!setFilenameFromEnvironment())
    return;
  setDefaultFilename();
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<setFilenameAutomatically>:
  endbr64
  sub    $0x8,%rsp
  xor    %eax,%eax
  call   <setFilenameFromEnvironment@plt>
  test   %eax,%eax
  jne    L5
  add    $0x8,%rsp
  ret
  nopl   0x0(%rax,%rax,1)
L5:
  xor    %eax,%eax
  add    $0x8,%rsp
  jmp    1060 <setDefaultFilename@plt>
```

assistant: ```c
void setFilenameAutomatically(void) {
  if (!setFilenameFromEnvironment())
    return;
  setDefaultFilename();
}
```
user: What is the c source code of the assembly code below:

```asm
<setFilenameAutomatically>:
  endbr64
  sub    $0x8,%rsp
  xor    %eax,%eax
  call   <setFilenameFromEnvironment@plt>
  test   %eax,%eax
  jne    L4
  add    $0x8,%rsp
  ret
  nopl   0x0(%rax,%rax,1)
L4:
  xor    %eax,%eax
  add    $0x8,%rsp
  jmp    1060 <setDefaultFilename@plt>
```

assistant: ```c
void setFilenameAutomatically(void) {
  if (!setFilenameFromEnvironment())
    return;
  setDefaultFilename();
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<getCounter>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    D17(%rip),%eax
  lea    0x1(%rax),%edx
  mov    %edx,D4(%rip)
  pop    %rbp
  ret
```

assistant: ```c
int getCounter() {
  static int s_counter = 0;
  return s_counter++;
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<getCounter>:
  endbr64
  mov    D9(%rip),%eax
  lea    0x1(%rax),%edx
  mov    %edx,D7(%rip)
  ret
```

assistant: ```c
int getCounter() {
  static int s_counter = 0;
  return s_counter++;
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<getCounter>:
  endbr64
  mov    D9(%rip),%eax
  lea    0x1(%rax),%edx
  mov    %edx,D8(%rip)
  ret
```

assistant: ```c
int getCounter() {
  static int s_counter = 0;
  return s_counter++;
}
```
user: What is the c source code of the assembly code below:

```asm
<getCounter>:
  endbr64
  mov    D6(%rip),%eax
  lea    0x1(%rax),%edx
  mov    %edx,D9(%rip)
  ret
```

assistant: ```c
int getCounter() {
  static int s_counter = 0;
  return s_counter++;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<strip_eol>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  setne  %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  movq   $0x0,-0x8(%rbp)
  jmp    L28
L39:
  mov    -0x18(%rbp),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0xa,%al
  jne    L38
  mov    -0x18(%rbp),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  cmpq   $0x0,-0x8(%rbp)
  je     L56
  mov    -0x8(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0xd,%al
  jne    L56
  mov    -0x8(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
L56:
  mov    -0x18(%rbp),%rax
  jmp    L50
L38:
  addq   $0x1,-0x8(%rbp)
L28:
  mov    -0x18(%rbp),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L39
  mov    -0x18(%rbp),%rax
L50:
  leave
  ret
```

assistant: ```c
char *strip_eol(char *str) {
  size_t i;
  assert(str != NULL);
  for (i = 0; str[i] != '\0'; i++) {
    if (str[i] == '\n') {
      str[i] = '\0';
      if (i > 0 && str[i - 1] == '\r')
        str[i - 1] = '\0';
      return str;
    }
  }
  return str;
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<strip_eol>:
  endbr64
  push   %rbx
  mov    %rdi,%rbx
  test   %rdi,%rdi
  setne  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  movzbl (%rbx),%edx
  test   %dl,%dl
  je     L42
  mov    $0x0,%eax
L46:
  lea    (%rbx,%rax,1),%rcx
  cmp    $0xa,%dl
  je     L5
  add    $0x1,%rax
  movzbl (%rbx,%rax,1),%edx
  test   %dl,%dl
  jne    L46
L42:
  mov    %rbx,%rax
  pop    %rbx
  ret
L5:
  movb   $0x0,(%rcx)
  test   %rax,%rax
  je     L42
  lea    -0x1(%rbx,%rax,1),%rax
  cmpb   $0xd,(%rax)
  jne    L42
  movb   $0x0,(%rax)
  jmp    L42
```

assistant: ```c
char *strip_eol(char *str) {
  size_t i;
  assert(str != NULL);
  for (i = 0; str[i] != '\0'; i++) {
    if (str[i] == '\n') {
      str[i] = '\0';
      if (i > 0 && str[i - 1] == '\r')
        str[i - 1] = '\0';
      return str;
    }
  }
  return str;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<strip_eol>:
  endbr64
  push   %r12
  test   %rdi,%rdi
  mov    %rdi,%r12
  setne  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  movzbl (%r12),%edx
  test   %dl,%dl
  je     L43
  xor    %eax,%eax
  jmp    L50
  cs nopw 0x0(%rax,%rax,1)
L21:
  add    $0x1,%rax
  movzbl (%r12,%rax,1),%edx
  test   %dl,%dl
  je     L43
L50:
  lea    (%r12,%rax,1),%rcx
  cmp    $0xa,%dl
  jne    L21
  movb   $0x0,(%rcx)
  test   %rax,%rax
  je     L43
  lea    -0x1(%r12,%rax,1),%rax
  cmpb   $0xd,(%rax)
  je     L8
L43:
  mov    %r12,%rax
  pop    %r12
  ret
L8:
  movb   $0x0,(%rax)
  jmp    L43
```

assistant: ```c
char *strip_eol(char *str) {
  size_t i;
  assert(str != NULL);
  for (i = 0; str[i] != '\0'; i++) {
    if (str[i] == '\n') {
      str[i] = '\0';
      if (i > 0 && str[i - 1] == '\r')
        str[i - 1] = '\0';
      return str;
    }
  }
  return str;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<strip_eol>:
  endbr64
  push   %r12
  test   %rdi,%rdi
  mov    %rdi,%r12
  setne  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  movzbl (%r12),%edx
  test   %dl,%dl
  je     L7
  xor    %eax,%eax
  jmp    L40
  cs nopw 0x0(%rax,%rax,1)
L56:
  add    $0x1,%rax
  movzbl (%r12,%rax,1),%edx
  test   %dl,%dl
  je     L7
L40:
  lea    (%r12,%rax,1),%rcx
  cmp    $0xa,%dl
  jne    L56
  movb   $0x0,(%rcx)
  test   %rax,%rax
  je     L7
  lea    -0x1(%r12,%rax,1),%rax
  cmpb   $0xd,(%rax)
  je     L16
L7:
  mov    %r12,%rax
  pop    %r12
  ret
L16:
  movb   $0x0,(%rax)
  jmp    L7
```

assistant: ```c
char *strip_eol(char *str) {
  size_t i;
  assert(str != NULL);
  for (i = 0; str[i] != '\0'; i++) {
    if (str[i] == '\n') {
      str[i] = '\0';
      if (i > 0 && str[i - 1] == '\r')
        str[i - 1] = '\0';
      return str;
    }
  }
  return str;
}
```
user: 这段汇编代码用C语言表示是什么样的？

```asm
<rgbMapfromto>:
  endbr64
  mov    %esi,%ecx
  mov    %edx,%esi
  sub    %ecx,%esi
  test   %esi,%esi
  jg     L29
  jne    L4
  cmp    $0x5,%ecx
  je     L17
  mov    %edi,%eax
  and    $0xffffff,%eax
  cmp    $0x8,%ecx
  cmovne %edi,%eax
  ret
L29:
  mov    $0x1,%r8d
  shl    %cl,%r8d
  sub    $0x1,%r8d
  mov    %esi,%ecx
  shl    %cl,%edi
  shl    %cl,%r8d
  mov    %r8d,%r10d
  mov    %edx,%ecx
  shl    %cl,%r10d
  mov    %edi,%r9d
  mov    %esi,%ecx
  shl    %cl,%r9d
  mov    %r10d,%eax
  and    %r9d,%eax
  and    %r8d,%edi
  add    %edi,%eax
  shl    %cl,%r9d
  mov    %edx,%ecx
  shl    %cl,%r10d
  and    %r10d,%r9d
  add    %r9d,%eax
  ret
L17:
  mov    %edi,%eax
  and    $0x7fff,%eax
  ret
L4:
  mov    %edi,%eax
  test   %edi,%edi
  je     L39
  sub    %edx,%ecx
  mov    %ecx,%esi
  mov    $0x1,%r9d
  mov    %edx,%ecx
  shl    %cl,%r9d
  sub    $0x1,%r9d
  mov    %esi,%ecx
  shr    %cl,%edi
  mov    %r9d,%r10d
  mov    %edx,%ecx
  shl    %cl,%r10d
  mov    %edi,%r8d
  mov    %esi,%ecx
  shr    %cl,%r8d
  mov    %r8d,%eax
  and    %r10d,%eax
  and    %r9d,%edi
  add    %edi,%eax
  shr    %cl,%r8d
  mov    %edx,%ecx
  shl    %cl,%r10d
  and    %r10d,%r8d
  add    %r8d,%eax
  mov    $0x1,%edx
  cmove  %edx,%eax
L39:
  ret
```

assistant: ```c
int rgbMapfromto(int sourcePixel, int nBitsIn, int nBitsOut) {
  int srcPix;
  int d;
  int mask;
  int destPix;
  if ((d = nBitsOut - nBitsIn) > 0) {
    mask = (1 << nBitsIn) - 1;
    srcPix = sourcePixel << d;
    mask = mask << d;
    destPix = srcPix & mask;
    mask = mask << nBitsOut;
    srcPix = srcPix << d;
    return (destPix + (srcPix & mask)) + ((srcPix << d) & (mask << nBitsOut));
  } else {
    if (d == 0) {
      if (nBitsIn == 5) {
        return sourcePixel & 32767;
      }
      if (nBitsIn == 8) {
        return sourcePixel & 16777215;
      }
      return sourcePixel;
    }
    if (sourcePixel == 0) {
      return sourcePixel;
    }
    d = nBitsIn - nBitsOut;
    mask = (1 << nBitsOut) - 1;
    srcPix = ((unsigned)sourcePixel) >> d;
    destPix = srcPix & mask;
    mask = mask << nBitsOut;
    srcPix = ((unsigned)srcPix) >> d;
    destPix = (destPix + (srcPix & mask)) + ((((unsigned)srcPix) >> d) & (mask << nBitsOut));
    if (destPix == 0) {
      return 1;
    }
    return destPix;
  }
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<rgbMapfromto>:
  endbr64
  mov    %edx,%r8d
  mov    %esi,%ecx
  sub    %esi,%r8d
  test   %r8d,%r8d
  jg     L28
  jne    L10
  mov    %edi,%eax
  cmp    $0x5,%esi
  je     L3
  and    $0xffffff,%eax
  cmp    $0x8,%esi
  cmovne %edi,%eax
  ret
  nopw   0x0(%rax,%rax,1)
L10:
  xor    %eax,%eax
  test   %edi,%edi
  je     L4
  mov    $0x1,%r10d
  mov    %edx,%ecx
  sub    %edx,%esi
  mov    %r10d,%r11d
  shl    %cl,%r11d
  mov    %esi,%ecx
  sub    $0x1,%r11d
  shr    %cl,%edi
  mov    %edx,%ecx
  mov    %r11d,%r9d
  mov    %edi,%r8d
  and    %r11d,%edi
  shl    %cl,%r9d
  mov    %esi,%ecx
  shr    %cl,%r8d
  mov    %r8d,%eax
  shr    %cl,%r8d
  mov    %edx,%ecx
  and    %r9d,%eax
  shl    %cl,%r9d
  add    %edi,%eax
  and    %r9d,%r8d
  add    %r8d,%eax
  cmove  %r10d,%eax
L4:
  ret
  nopl   0x0(%rax)
L28:
  mov    $0x1,%esi
  shl    %cl,%esi
  mov    %r8d,%ecx
  sub    $0x1,%esi
  shl    %cl,%edi
  shl    %cl,%esi
  mov    %edx,%ecx
  mov    %edi,%r9d
  mov    %esi,%r10d
  and    %esi,%edi
  shl    %cl,%r10d
  mov    %r8d,%ecx
  shl    %cl,%r9d
  mov    %r10d,%eax
  and    %r9d,%eax
  shl    %cl,%r9d
  mov    %edx,%ecx
  shl    %cl,%r10d
  add    %edi,%eax
  and    %r10d,%r9d
  add    %r9d,%eax
  ret
  nopl   0x0(%rax,%rax,1)
L3:
  and    $0x7fff,%eax
  ret
```

assistant: ```c
int rgbMapfromto(int sourcePixel, int nBitsIn, int nBitsOut) {
  int srcPix;
  int d;
  int mask;
  int destPix;
  if ((d = nBitsOut - nBitsIn) > 0) {
    mask = (1 << nBitsIn) - 1;
    srcPix = sourcePixel << d;
    mask = mask << d;
    destPix = srcPix & mask;
    mask = mask << nBitsOut;
    srcPix = srcPix << d;
    return (destPix + (srcPix & mask)) + ((srcPix << d) & (mask << nBitsOut));
  } else {
    if (d == 0) {
      if (nBitsIn == 5) {
        return sourcePixel & 32767;
      }
      if (nBitsIn == 8) {
        return sourcePixel & 16777215;
      }
      return sourcePixel;
    }
    if (sourcePixel == 0) {
      return sourcePixel;
    }
    d = nBitsIn - nBitsOut;
    mask = (1 << nBitsOut) - 1;
    srcPix = ((unsigned)sourcePixel) >> d;
    destPix = srcPix & mask;
    mask = mask << nBitsOut;
    srcPix = ((unsigned)srcPix) >> d;
    destPix = (destPix + (srcPix & mask)) + ((((unsigned)srcPix) >> d) & (mask << nBitsOut));
    if (destPix == 0) {
      return 1;
    }
    return destPix;
  }
}
```