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

```asm
<is_alpha>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,%eax
  mov    %al,-0x14(%rbp)
  cmpb   $0x60,-0x14(%rbp)
  jle    L25
  cmpb   $0x7a,-0x14(%rbp)
  jle    L45
L25:
  cmpb   $0x40,-0x14(%rbp)
  jle    L44
  cmpb   $0x5a,-0x14(%rbp)
  jg     L44
L45:
  mov    $0x1,%eax
  jmp    L41
L44:
  mov    $0x0,%eax
L41:
  mov    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  pop    %rbp
  ret
```

assistant: ```c
bool is_alpha(char c) {
  bool result = (((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')));
  return result;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<is_alpha>:
  endbr64
  and    $0xffffffdf,%edi
  sub    $0x41,%edi
  cmp    $0x19,%dil
  setbe  %al
  movzbl %al,%eax
  ret
```

assistant: ```c
bool is_alpha(char c) {
  bool result = (((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')));
  return result;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<is_alpha>:
  endbr64
  and    $0xffffffdf,%edi
  xor    %eax,%eax
  sub    $0x41,%edi
  cmp    $0x19,%dil
  setbe  %al
  ret
```

assistant: ```c
bool is_alpha(char c) {
  bool result = (((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')));
  return result;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<is_alpha>:
  endbr64
  and    $0xffffffdf,%edi
  xor    %eax,%eax
  sub    $0x41,%edi
  cmp    $0x19,%dil
  setbe  %al
  ret
```

assistant: ```c
bool is_alpha(char c) {
  bool result = (((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')));
  return result;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  movb   $0x44,-0x11(%rbp)
  movl   $0xa,-0x10(%rbp)
  movss  D7(%rip),%xmm0
  movss  %xmm0,-0xc(%rbp)
  movsd  D35(%rip),%xmm0
  movsd  %xmm0,-0x8(%rbp)
  movsbl -0x11(%rbp),%eax
  mov    %eax,%esi
  lea    D19(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    -0x10(%rbp),%eax
  movsbl %al,%eax
  mov    %eax,%esi
  lea    D27(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  movss  -0xc(%rbp),%xmm0
  cvttss2si %xmm0,%eax
  movsbl %al,%eax
  mov    %eax,%esi
  lea    D37(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  movsd  -0x8(%rbp),%xmm0
  cvttsd2si %xmm0,%eax
  movsbl %al,%eax
  mov    %eax,%esi
  lea    D51(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  pxor   %xmm2,%xmm2
  cvtss2sd -0xc(%rbp),%xmm2
  movq   %xmm2,%rcx
  movsbl -0x11(%rbp),%eax
  movsd  -0x8(%rbp),%xmm0
  mov    -0x10(%rbp),%edx
  movapd %xmm0,%xmm1
  movq   %rcx,%xmm0
  mov    %eax,%esi
  lea    D23(%rip),%rax
  mov    %rax,%rdi
  mov    $0x2,%eax
  call   <printf@plt>
  mov    $0x0,%eax
  leave
  ret
```

tool_calls: name: unpack_data
arguments: data_label: D7
type_guessed: f32
name: unpack_data
arguments: data_label: D35
type_guessed: f64
name: unpack_data
arguments: data_label: D19
type_guessed: string
name: unpack_data
arguments: data_label: D27
type_guessed: string
name: unpack_data
arguments: data_label: D37
type_guessed: string
name: unpack_data
arguments: data_label: D51
type_guessed: string
name: unpack_data
arguments: data_label: D23
type_guessed: string

tool: D7: 15.3

tool: D35: 1000

tool: D19: Imprimindo um char: %c


tool: D27: Imprimindo um int: %d


tool: D37: Imprimindo um float: %f


tool: D51: Imprimindo um double: %lf


tool: D23: Imprimindo todos: %c - %d - %f - %lf


assistant: ```c
int main() {
  char myChar = 'D';
  int numInt = 10;
  float numFloat = 15.3;
  double numDouble = 1000;
  printf("Imprimindo um char: %c\n", myChar);
  printf("Imprimindo um int: %d\n", numInt);
  printf("Imprimindo um float: %f\n", numFloat);
  printf("Imprimindo um double: %lf\n", numDouble);
  printf("Imprimindo todos: %c - %d - %f - %lf\n", myChar, numInt, numFloat, numDouble);
  return 0;
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<main>:
  endbr64
  sub    $0x8,%rsp
  mov    $0x44,%esi
  lea    D45(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0xa,%esi
  lea    D53(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0xf,%esi
  lea    D54(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x7f,%esi
  lea    D49(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  movsd  D35(%rip),%xmm1
  movsd  D56(%rip),%xmm0
  mov    $0xa,%edx
  mov    $0x44,%esi
  lea    D34(%rip),%rdi
  mov    $0x2,%eax
  call   <printf@plt>
  mov    $0x0,%eax
  add    $0x8,%rsp
  ret
```

tool_calls: name: retrieve_data
arguments: data_label: D45
type: string
name: retrieve_data
arguments: data_label: D53
type: string
name: retrieve_data
arguments: data_label: D54
type: string
name: retrieve_data
arguments: data_label: D49
type: string
name: retrieve_data
arguments: data_label: D35
type: f64
name: retrieve_data
arguments: data_label: D56
type: byte[8]
name: retrieve_data
arguments: data_label: D34
type: string

tool: D45: Imprimindo um char: %c


tool: D53: Imprimindo um int: %d


tool: D54: Imprimindo um float: %f


tool: D49: Imprimindo um double: %lf


tool: D35: 1000

tool: {"D56": [0x00,0x00,0x00,0xa0,0x99,0x99,0x2e,0x40]}

tool: D34: Imprimindo todos: %c - %d - %f - %lf


assistant: ```c
int main() {
  char myChar = 'D';
  int numInt = 10;
  float numFloat = 15.3;
  double numDouble = 1000;
  printf("Imprimindo um char: %c\n", myChar);
  printf("Imprimindo um int: %d\n", numInt);
  printf("Imprimindo um float: %f\n", numFloat);
  printf("Imprimindo um double: %lf\n", numDouble);
  printf("Imprimindo todos: %c - %d - %f - %lf\n", myChar, numInt, numFloat, numDouble);
  return 0;
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<main>:
  endbr64
  sub    $0x8,%rsp
  mov    $0x44,%esi
  lea    D47(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0xa,%esi
  lea    D56(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0xf,%esi
  lea    D46(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0x7f,%esi
  lea    D57(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0xa,%edx
  mov    $0x44,%esi
  movsd  D45(%rip),%xmm1
  movsd  D2(%rip),%xmm0
  lea    D53(%rip),%rdi
  mov    $0x2,%eax
  call   <printf@plt>
  xor    %eax,%eax
  add    $0x8,%rsp
  ret
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D47
data_type: string
name: extract_symbolic_data
arguments: data_tag: D56
data_type: string
name: extract_symbolic_data
arguments: data_tag: D46
data_type: string
name: extract_symbolic_data
arguments: data_tag: D57
data_type: string
name: extract_symbolic_data
arguments: data_tag: D45
data_type: f64
name: extract_symbolic_data
arguments: data_tag: D2
data_type: byte[8]
name: extract_symbolic_data
arguments: data_tag: D53
data_type: string

tool: D47: Imprimindo um char: %c


tool: D56: Imprimindo um int: %d


tool: D46: Imprimindo um float: %f


tool: D57: Imprimindo um double: %lf


tool: D45: 1000

tool: {"D2": [0x00,0x00,0x00,0xa0,0x99,0x99,0x2e,0x40]}

tool: D53: Imprimindo todos: %c - %d - %f - %lf


assistant: ```c
int main() {
  char myChar = 'D';
  int numInt = 10;
  float numFloat = 15.3;
  double numDouble = 1000;
  printf("Imprimindo um char: %c\n", myChar);
  printf("Imprimindo um int: %d\n", numInt);
  printf("Imprimindo um float: %f\n", numFloat);
  printf("Imprimindo um double: %lf\n", numDouble);
  printf("Imprimindo todos: %c - %d - %f - %lf\n", myChar, numInt, numFloat, numDouble);
  return 0;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<main>:
  endbr64
  sub    $0x8,%rsp
  mov    $0x44,%esi
  lea    D29(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0xa,%esi
  lea    D2(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0xf,%esi
  lea    D35(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0x7f,%esi
  lea    D18(%rip),%rdi
  xor    %eax,%eax
  call   <printf@plt>
  mov    $0xa,%edx
  mov    $0x44,%esi
  movsd  D31(%rip),%xmm1
  movsd  D3(%rip),%xmm0
  lea    D47(%rip),%rdi
  mov    $0x2,%eax
  call   <printf@plt>
  xor    %eax,%eax
  add    $0x8,%rsp
  ret
```

tool_calls: name: disassemble_data
arguments: label: D29
type_infered: string
name: disassemble_data
arguments: label: D2
type_infered: string
name: disassemble_data
arguments: label: D35
type_infered: string
name: disassemble_data
arguments: label: D18
type_infered: string
name: disassemble_data
arguments: label: D31
type_infered: f64
name: disassemble_data
arguments: label: D3
type_infered: byte[8]
name: disassemble_data
arguments: label: D47
type_infered: string

tool: D29: Imprimindo um char: %c


tool: D2: Imprimindo um int: %d


tool: D35: Imprimindo um float: %f


tool: D18: Imprimindo um double: %lf


tool: D31: 1000

tool: {"D3": [0x00,0x00,0x00,0xa0,0x99,0x99,0x2e,0x40]}

tool: D47: Imprimindo todos: %c - %d - %f - %lf


assistant: ```c
int main() {
  char myChar = 'D';
  int numInt = 10;
  float numFloat = 15.3;
  double numDouble = 1000;
  printf("Imprimindo um char: %c\n", myChar);
  printf("Imprimindo um int: %d\n", numInt);
  printf("Imprimindo um float: %f\n", numFloat);
  printf("Imprimindo um double: %lf\n", numDouble);
  printf("Imprimindo todos: %c - %d - %f - %lf\n", myChar, numInt, numFloat, numDouble);
  return 0;
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<interupt_signal>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    $0x0,%eax
  call   <clear_memory@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  nop
  pop    %rbp
  ret
```

assistant: ```c
void interupt_signal() {
  clear_memory();
  exit(1);
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<interupt_signal>:
  endbr64
  sub    $0x8,%rsp
  mov    $0x0,%eax
  call   <clear_memory@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  add    $0x8,%rsp
  ret
```

assistant: ```c
void interupt_signal() {
  clear_memory();
  exit(1);
}
```
user: 这段汇编代码用C语言表示是什么样的？

```asm
<interupt_signal>:
  endbr64
  sub    $0x8,%rsp
  xor    %eax,%eax
  call   <clear_memory@plt>
  mov    $0x1,%edi
  add    $0x8,%rsp
  jmp    1070 <exit@plt>
```

assistant: ```c
void interupt_signal() {
  clear_memory();
  exit(1);
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<interupt_signal>:
  endbr64
  sub    $0x8,%rsp
  xor    %eax,%eax
  call   <clear_memory@plt>
  mov    $0x1,%edi
  add    $0x8,%rsp
  jmp    1070 <exit@plt>
```

assistant: ```c
void interupt_signal() {
  clear_memory();
  exit(1);
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<_stripexe>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  mov    $0x2e,%esi
  mov    %rax,%rdi
  call   <strrchr@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  je     L9
  mov    -0x8(%rbp),%rax
  lea    D8(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcasecmp@plt>
  test   %eax,%eax
  jne    L9
  mov    -0x8(%rbp),%rax
  movb   $0x0,(%rax)
L9:
  nop
  leave
  ret
```

tool_calls: name: unpack_data
arguments: data_label: D8
data_type: string

tool: D8: .exe

assistant: ```c
void _stripexe(char *filename) {
  char *ptr;
  ptr = strrchr(filename, '.');
  if (ptr && !strcasecmp(ptr, ".exe"))
    *ptr = '\0';
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<_stripexe>:
  endbr64
  push   %rbx
  mov    $0x2e,%esi
  call   <strrchr@plt>
  test   %rax,%rax
  je     L1
  mov    %rax,%rbx
  lea    D4(%rip),%rsi
  mov    %rax,%rdi
  call   <strcasecmp@plt>
  test   %eax,%eax
  jne    L1
  movb   $0x0,(%rbx)
L1:
  pop    %rbx
  ret
```

tool_calls: name: parse_data
arguments: data_label: D4
type: string

tool: D4: .exe

assistant: ```c
void _stripexe(char *filename) {
  char *ptr;
  ptr = strrchr(filename, '.');
  if (ptr && !strcasecmp(ptr, ".exe"))
    *ptr = '\0';
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<_stripexe>:
  endbr64
  push   %rbx
  mov    $0x2e,%esi
  call   <strrchr@plt>
  test   %rax,%rax
  je     L5
  lea    D4(%rip),%rsi
  mov    %rax,%rdi
  mov    %rax,%rbx
  call   <strcasecmp@plt>
  test   %eax,%eax
  jne    L5
  movb   $0x0,(%rbx)
L5:
  pop    %rbx
  ret
```

tool_calls: name: parse_data
arguments: data_label: D4
type_guessed: string

tool: D4: .exe

assistant: ```c
void _stripexe(char *filename) {
  char *ptr;
  ptr = strrchr(filename, '.');
  if (ptr && !strcasecmp(ptr, ".exe"))
    *ptr = '\0';
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<_stripexe>:
  endbr64
  push   %rbx
  mov    $0x2e,%esi
  call   <strrchr@plt>
  test   %rax,%rax
  je     L9
  lea    D3(%rip),%rsi
  mov    %rax,%rdi
  mov    %rax,%rbx
  call   <strcasecmp@plt>
  test   %eax,%eax
  jne    L9
  movb   $0x0,(%rbx)
L9:
  pop    %rbx
  ret
```

tool_calls: name: retrieve_data
arguments: data_label: D3
data_type: string

tool: D3: .exe

assistant: ```c
void _stripexe(char *filename) {
  char *ptr;
  ptr = strrchr(filename, '.');
  if (ptr && !strcasecmp(ptr, ".exe"))
    *ptr = '\0';
}
```
user: Translate the below assembly code into C programming language:

```asm
<WriteInt16>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  mov    %edx,-0x20(%rbp)
  mov    $0x0,%eax
  call   <CheckEnd@plt>
  test   %rax,%rax
  je     L39
  mov    -0x1c(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    -0x20(%rbp),%edx
  mov    %dl,(%rax)
  mov    -0x1c(%rbp),%eax
  cltq
  lea    0x1(%rax),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x1c(%rbp),%eax
  add    $0x2,%eax
  jmp    L38
L39:
  movl   $0x2,-0x4(%rbp)
  mov    -0x1c(%rbp),%edx
  mov    -0x4(%rbp),%eax
  add    %edx,%eax
  sub    $0x1,%eax
  mov    %eax,-0x8(%rbp)
  jmp    L27
L18:
  mov    -0x4(%rbp),%eax
  sub    $0x1,%eax
  sub    -0x8(%rbp),%eax
  shl    $0x3,%eax
  mov    -0x20(%rbp),%edx
  mov    %eax,%ecx
  sar    %cl,%edx
  mov    %edx,%ecx
  mov    -0x8(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    %ecx,%edx
  mov    %dl,(%rax)
  subl   $0x1,-0x8(%rbp)
L27:
  mov    -0x8(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jge    L18
  mov    -0x1c(%rbp),%eax
  add    $0x2,%eax
L38:
  leave
  ret
```

assistant: ```c
int WriteInt16(uint8_t *ptr, int ofs, int16_t val) {
  if (CheckEnd()) {
    ptr[ofs] = val & 0xff;
    ptr[ofs + 1] = (val << 8) & 0xff;
    return ofs + 2;
  } else {
    int len = 2;
    int i = ofs + len - 1;
    for (; i >= ofs; --i) {
      ptr[i] = (char)((val >> (len - 1 - i) * 8) & 0xff);
    }
    return (ofs + 2);
  }
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<WriteInt16>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%r12
  mov    %esi,%ebx
  mov    %edx,%ebp
  mov    $0x0,%eax
  call   <CheckEnd@plt>
  test   %rax,%rax
  je     L0
  movslq %ebx,%rax
  mov    %bpl,(%r12,%rax,1)
  movb   $0x0,0x1(%r12,%rax,1)
  lea    0x2(%rbx),%eax
  jmp    L10
L0:
  lea    0x1(%rbx),%eax
  cltq
  mov    %ebx,%ecx
  neg    %ecx
  shl    $0x3,%ecx
  mov    %ebp,%edx
  sar    %cl,%edx
  mov    %dl,(%r12,%rax,1)
  movslq %ebx,%rax
  mov    $0x1,%ecx
  sub    %ebx,%ecx
  shl    $0x3,%ecx
  sar    %cl,%ebp
  mov    %bpl,(%r12,%rax,1)
  lea    0x2(%rbx),%eax
L10:
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
int WriteInt16(uint8_t *ptr, int ofs, int16_t val) {
  if (CheckEnd()) {
    ptr[ofs] = val & 0xff;
    ptr[ofs + 1] = (val << 8) & 0xff;
    return ofs + 2;
  } else {
    int len = 2;
    int i = ofs + len - 1;
    for (; i >= ofs; --i) {
      ptr[i] = (char)((val >> (len - 1 - i) * 8) & 0xff);
    }
    return (ofs + 2);
  }
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<WriteInt16>:
  endbr64
  push   %r12
  xor    %eax,%eax
  mov    %rdi,%r12
  push   %rbp
  mov    %edx,%ebp
  push   %rbx
  mov    %esi,%ebx
  call   <CheckEnd@plt>
  lea    0x2(%rbx),%r8d
  mov    %rax,%r9
  movslq %ebx,%rax
  lea    (%r12,%rax,1),%rdx
  test   %r9,%r9
  je     L0
  mov    %bpl,(%rdx)
  movb   $0x0,0x1(%r12,%rax,1)
  mov    %r8d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopw   0x0(%rax,%rax,1)
L0:
  mov    %ebx,%ecx
  mov    %ebp,%esi
  lea    0x1(%rbx),%eax
  neg    %ecx
  cltq
  shl    $0x3,%ecx
  sar    %cl,%esi
  mov    $0x1,%ecx
  sub    %ebx,%ecx
  mov    %sil,(%r12,%rax,1)
  mov    %r8d,%eax
  shl    $0x3,%ecx
  sar    %cl,%ebp
  mov    %bpl,(%rdx)
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
int WriteInt16(uint8_t *ptr, int ofs, int16_t val) {
  if (CheckEnd()) {
    ptr[ofs] = val & 0xff;
    ptr[ofs + 1] = (val << 8) & 0xff;
    return ofs + 2;
  } else {
    int len = 2;
    int i = ofs + len - 1;
    for (; i >= ofs; --i) {
      ptr[i] = (char)((val >> (len - 1 - i) * 8) & 0xff);
    }
    return (ofs + 2);
  }
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<WriteInt16>:
  endbr64
  push   %r12
  xor    %eax,%eax
  mov    %rdi,%r12
  push   %rbp
  mov    %edx,%ebp
  push   %rbx
  mov    %esi,%ebx
  call   <CheckEnd@plt>
  lea    0x2(%rbx),%r8d
  mov    %rax,%r9
  movslq %ebx,%rax
  lea    (%r12,%rax,1),%rdx
  test   %r9,%r9
  je     L6
  mov    %bpl,(%rdx)
  movb   $0x0,0x1(%r12,%rax,1)
  mov    %r8d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopw   0x0(%rax,%rax,1)
L6:
  mov    %ebx,%ecx
  mov    %ebp,%esi
  lea    0x1(%rbx),%eax
  neg    %ecx
  cltq
  shl    $0x3,%ecx
  sar    %cl,%esi
  mov    $0x1,%ecx
  sub    %ebx,%ecx
  mov    %sil,(%r12,%rax,1)
  mov    %r8d,%eax
  shl    $0x3,%ecx
  sar    %cl,%ebp
  mov    %bpl,(%rdx)
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
int WriteInt16(uint8_t *ptr, int ofs, int16_t val) {
  if (CheckEnd()) {
    ptr[ofs] = val & 0xff;
    ptr[ofs + 1] = (val << 8) & 0xff;
    return ofs + 2;
  } else {
    int len = 2;
    int i = ofs + len - 1;
    for (; i >= ofs; --i) {
      ptr[i] = (char)((val >> (len - 1 - i) * 8) & 0xff);
    }
    return (ofs + 2);
  }
}
```
user: What is the c source code of the assembly code below?

```asm
<findchangingcolor>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x8(%rbp)
  mov    %esi,-0xc(%rbp)
  mov    %edx,-0x10(%rbp)
  mov    %ecx,-0x14(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L34
  mov    -0x10(%rbp),%eax
  jmp    L37
L34:
  mov    -0x10(%rbp),%edx
  mov    -0xc(%rbp),%ecx
  mov    -0x8(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <findchanging@plt>
  mov    %eax,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  cmp    -0x10(%rbp),%eax
  jge    L25
  mov    -0xc(%rbp),%edx
  mov    -0x8(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <getbit@plt>
  cmp    %eax,-0x14(%rbp)
  je     L25
  mov    -0x10(%rbp),%edx
  mov    -0xc(%rbp),%ecx
  mov    -0x8(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <findchanging@plt>
  mov    %eax,-0xc(%rbp)
L25:
  mov    -0xc(%rbp),%eax
L37:
  leave
  ret
```

assistant: ```c
int findchangingcolor(const unsigned char *line, int x, int w, int color) {
  if (!line)
    return w;
  x = findchanging(line, x, w);
  if (x < w && getbit(line, x) != color)
    x = findchanging(line, x, w);
  return x;
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<findchangingcolor>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %edx,%ebp
  test   %rdi,%rdi
  je     L26
  mov    %rdi,%r12
  mov    %edx,%ebx
  mov    %ecx,%r13d
  call   <findchanging@plt>
  mov    %eax,%ebp
  cmp    %eax,%ebx
  jg     L5
L26:
  mov    %ebp,%eax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L5:
  mov    %eax,%esi
  mov    %r12,%rdi
  call   <getbit@plt>
  cmp    %r13d,%eax
  je     L26
  mov    %ebx,%edx
  mov    %ebp,%esi
  mov    %r12,%rdi
  call   <findchanging@plt>
  mov    %eax,%ebp
  jmp    L26
```

assistant: ```c
int findchangingcolor(const unsigned char *line, int x, int w, int color) {
  if (!line)
    return w;
  x = findchanging(line, x, w);
  if (x < w && getbit(line, x) != color)
    x = findchanging(line, x, w);
  return x;
}
```
user: What is the c source code of the assembly code below?

```asm
<findchangingcolor>:
  endbr64
  push   %r13
  push   %r12
  mov    %edx,%r12d
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  test   %rdi,%rdi
  je     L21
  mov    %rdi,%rbp
  mov    %ecx,%ebx
  call   <findchanging@plt>
  mov    %eax,%r13d
  cmp    %eax,%r12d
  jg     L9
L11:
  add    $0x8,%rsp
  mov    %r13d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  cs nopw 0x0(%rax,%rax,1)
L9:
  mov    %eax,%esi
  mov    %rbp,%rdi
  call   <getbit@plt>
  cmp    %ebx,%eax
  je     L11
  add    $0x8,%rsp
  mov    %r12d,%edx
  mov    %r13d,%esi
  mov    %rbp,%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  jmp    1060 <findchanging@plt>
  cs nopw 0x0(%rax,%rax,1)
L21:
  add    $0x8,%rsp
  mov    %edx,%r13d
  pop    %rbx
  mov    %r13d,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

assistant: ```c
int findchangingcolor(const unsigned char *line, int x, int w, int color) {
  if (!line)
    return w;
  x = findchanging(line, x, w);
  if (x < w && getbit(line, x) != color)
    x = findchanging(line, x, w);
  return x;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<findchangingcolor>:
  endbr64
  push   %r13
  push   %r12
  mov    %edx,%r12d
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  test   %rdi,%rdi
  je     L10
  mov    %rdi,%rbp
  mov    %ecx,%ebx
  call   <findchanging@plt>
  mov    %eax,%r13d
  cmp    %eax,%r12d
  jg     L3
L12:
  add    $0x8,%rsp
  mov    %r13d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  cs nopw 0x0(%rax,%rax,1)
L3:
  mov    %eax,%esi
  mov    %rbp,%rdi
  call   <getbit@plt>
  cmp    %ebx,%eax
  je     L12
  add    $0x8,%rsp
  mov    %r12d,%edx
  mov    %r13d,%esi
  mov    %rbp,%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  jmp    1060 <findchanging@plt>
  cs nopw 0x0(%rax,%rax,1)
L10:
  add    $0x8,%rsp
  mov    %edx,%r13d
  pop    %rbx
  mov    %r13d,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

assistant: ```c
int findchangingcolor(const unsigned char *line, int x, int w, int color) {
  if (!line)
    return w;
  x = findchanging(line, x, w);
  if (x < w && getbit(line, x) != color)
    x = findchanging(line, x, w);
  return x;
}
```