ylfeng/ReF-Decompile-dataset huggingface dataset:
user: 请从给定的汇编指令推导出C源代码:

```asm
<UARTIntRegister>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%rbx
  mov    %rsi,%rbp
  call   <UARTBaseValid@plt>
  mov    %eax,%edi
  call   <DEBUG_ASSERT@plt>
  mov    %rbx,%rdi
  call   <UARTIntNumberGet@plt>
  mov    %rax,%rbx
  mov    %rbp,%rsi
  mov    %rax,%rdi
  call   <IntRegister@plt>
  mov    %rbx,%rdi
  call   <IntEnable@plt>
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
```

assistant: ```c
void UARTIntRegister(unsigned long ulBase, void (*pfnHandler)(void)) {
  unsigned long ulInt;
  DEBUG_ASSERT(UARTBaseValid(ulBase));
  ulInt = UARTIntNumberGet(ulBase);
  IntRegister(ulInt, pfnHandler);
  IntEnable(ulInt);
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<UARTIntRegister>:
  endbr64
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  mov    %rdi,%rbp
  sub    $0x8,%rsp
  call   <UARTBaseValid@plt>
  mov    %eax,%edi
  call   <DEBUG_ASSERT@plt>
  mov    %rbp,%rdi
  call   <UARTIntNumberGet@plt>
  mov    %r12,%rsi
  mov    %rax,%rdi
  mov    %rax,%rbp
  call   <IntRegister@plt>
  add    $0x8,%rsp
  mov    %rbp,%rdi
  pop    %rbp
  pop    %r12
  jmp    10d0 <IntEnable@plt>
```

assistant: ```c
void UARTIntRegister(unsigned long ulBase, void (*pfnHandler)(void)) {
  unsigned long ulInt;
  DEBUG_ASSERT(UARTBaseValid(ulBase));
  ulInt = UARTIntNumberGet(ulBase);
  IntRegister(ulInt, pfnHandler);
  IntEnable(ulInt);
}
```
user: 这段汇编代码用C语言表示是什么样的?

```asm
<UARTIntRegister>:
  endbr64
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  mov    %rdi,%rbp
  sub    $0x8,%rsp
  call   <UARTBaseValid@plt>
  mov    %eax,%edi
  call   <DEBUG_ASSERT@plt>
  mov    %rbp,%rdi
  call   <UARTIntNumberGet@plt>
  mov    %r12,%rsi
  mov    %rax,%rdi
  mov    %rax,%rbp
  call   <IntRegister@plt>
  add    $0x8,%rsp
  mov    %rbp,%rdi
  pop    %rbp
  pop    %r12
  jmp    10d0 <IntEnable@plt>
```

assistant: ```c
void UARTIntRegister(unsigned long ulBase, void (*pfnHandler)(void)) {
  unsigned long ulInt;
  DEBUG_ASSERT(UARTBaseValid(ulBase));
  ulInt = UARTIntNumberGet(ulBase);
  IntRegister(ulInt, pfnHandler);
  IntEnable(ulInt);
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<htsstr_unescape>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  mov    %rax,-0x8(%rbp)
  jmp    L39
L19:
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x5c,%al
  jne    L114
  mov    -0x8(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  cmp    $0x62,%al
  jne    L126
  mov    -0x8(%rbp),%rax
  movb   $0x8,(%rax)
  jmp    L128
L126:
  mov    -0x8(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  cmp    $0x66,%al
  jne    L100
  mov    -0x8(%rbp),%rax
  movb   $0xc,(%rax)
  jmp    L128
L100:
  mov    -0x8(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  cmp    $0x6e,%al
  jne    L63
  mov    -0x8(%rbp),%rax
  movb   $0xa,(%rax)
  jmp    L128
L63:
  mov    -0x8(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  cmp    $0x72,%al
  jne    L59
  mov    -0x8(%rbp),%rax
  movb   $0xd,(%rax)
  jmp    L128
L59:
  mov    -0x8(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  cmp    $0x74,%al
  jne    L142
  mov    -0x8(%rbp),%rax
  movb   $0x9,(%rax)
  jmp    L128
L142:
  mov    -0x8(%rbp),%rax
  movzbl 0x1(%rax),%edx
  mov    -0x8(%rbp),%rax
  mov    %dl,(%rax)
L128:
  mov    -0x8(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L45
  mov    -0x8(%rbp),%rax
  add    $0x2,%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  lea    0x1(%rax),%rdx
  mov    -0x8(%rbp),%rax
  lea    0x2(%rax),%rcx
  mov    -0x8(%rbp),%rax
  add    $0x1,%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memmove@plt>
  jmp    L45
L114:
  nop
L45:
  addq   $0x1,-0x8(%rbp)
L39:
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L19
  mov    -0x18(%rbp),%rax
  leave
  ret
```

assistant: ```c
char *htsstr_unescape(char *str) {
  char *s;
  for (s = str; *s; s++) {
    if (*s != '\\')
      continue;
    if (*(s + 1) == 'b')
      *s = '\b';
    else if (*(s + 1) == 'f')
      *s = '\f';
    else if (*(s + 1) == 'n')
      *s = '\n';
    else if (*(s + 1) == 'r')
      *s = '\r';
    else if (*(s + 1) == 't')
      *s = '\t';
    else
      *s = *(s + 1);
    if (*(s + 1)) {
      memmove(s + 1, s + 2, strlen(s + 2) + 1);
    }
  }
  return str;
}
```
user: Translate the below assembly code into C programming language:

```asm
<htsstr_unescape>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%r12
  movzbl (%rdi),%eax
  test   %al,%al
  je     L115
  lea    0x1(%rdi),%rbx
  mov    $0x8,%r13d
  jmp    L55
L75:
  mov    %al,-0x1(%rbx)
  test   %al,%al
  jne    L121
L122:
  add    $0x1,%rbx
  movzbl -0x1(%rbx),%eax
  test   %al,%al
  je     L115
L55:
  cmp    $0x5c,%al
  jne    L122
  mov    %rbx,%rbp
  movzbl (%rbx),%eax
  cmp    $0x62,%al
  je     L76
  cmp    $0x66,%al
  je     L10
  cmp    $0x6e,%al
  je     L92
  cmp    $0x72,%al
  je     L4
  cmp    $0x74,%al
  jne    L75
  mov    $0x9,%eax
  jmp    L69
L76:
  mov    %r13d,%eax
L69:
  mov    %al,-0x1(%rbp)
L121:
  lea    0x1(%rbx),%r14
  mov    %r14,%rdi
  call   <strlen@plt>
  lea    0x1(%rax),%rdx
  mov    %r14,%rsi
  mov    %rbp,%rdi
  call   <memmove@plt>
  jmp    L122
L10:
  mov    $0xc,%eax
  jmp    L69
L92:
  mov    $0xa,%eax
  jmp    L69
L4:
  mov    $0xd,%eax
  jmp    L69
L115:
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
```

assistant: ```c
char *htsstr_unescape(char *str) {
  char *s;
  for (s = str; *s; s++) {
    if (*s != '\\')
      continue;
    if (*(s + 1) == 'b')
      *s = '\b';
    else if (*(s + 1) == 'f')
      *s = '\f';
    else if (*(s + 1) == 'n')
      *s = '\n';
    else if (*(s + 1) == 'r')
      *s = '\r';
    else if (*(s + 1) == 't')
      *s = '\t';
    else
      *s = *(s + 1);
    if (*(s + 1)) {
      memmove(s + 1, s + 2, strlen(s + 2) + 1);
    }
  }
  return str;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<htsstr_unescape>:
  endbr64
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  push   %rbx
  movzbl (%rdi),%edx
  test   %dl,%dl
  je     L145
  mov    %rdi,%rbx
  nopl   (%rax)
L133:
  movzbl 0x1(%rbx),%eax
  add    $0x1,%rbx
  cmp    $0x5c,%dl
  jne    L18
  cmp    $0x62,%al
  je     L123
  cmp    $0x66,%al
  je     L89
  cmp    $0x6e,%al
  je     L146
  cmp    $0x72,%al
  je     L140
  cmp    $0x74,%al
  je     L117
  mov    %al,-0x1(%rbx)
  test   %al,%al
  jne    L125
L145:
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax,%rax,1)
L18:
  mov    %eax,%edx
L36:
  test   %dl,%dl
  jne    L133
  jmp    L145
  nopl   0x0(%rax,%rax,1)
L123:
  movb   $0x8,-0x1(%rbx)
L125:
  lea    0x1(%rbx),%rbp
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  lea    0x1(%rax),%rdx
  call   <memmove@plt>
  movzbl (%rbx),%edx
  jmp    L36
  nopl   0x0(%rax)
L89:
  movb   $0xc,-0x1(%rbx)
  jmp    L125
  xchg   %ax,%ax
L146:
  movb   $0xa,-0x1(%rbx)
  jmp    L125
  cs nopw 0x0(%rax,%rax,1)
L140:
  movb   $0xd,-0x1(%rbx)
  jmp    L125
  cs nopw 0x0(%rax,%rax,1)
L117:
  movb   $0x9,-0x1(%rbx)
  jmp    L125
```

assistant: ```c
char *htsstr_unescape(char *str) {
  char *s;
  for (s = str; *s; s++) {
    if (*s != '\\')
      continue;
    if (*(s + 1) == 'b')
      *s = '\b';
    else if (*(s + 1) == 'f')
      *s = '\f';
    else if (*(s + 1) == 'n')
      *s = '\n';
    else if (*(s + 1) == 'r')
      *s = '\r';
    else if (*(s + 1) == 't')
      *s = '\t';
    else
      *s = *(s + 1);
    if (*(s + 1)) {
      memmove(s + 1, s + 2, strlen(s + 2) + 1);
    }
  }
  return str;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<htsstr_unescape>:
  endbr64
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  push   %rbx
  movzbl (%rdi),%edx
  test   %dl,%dl
  je     L119
  mov    %rdi,%rbx
  nopl   (%rax)
L26:
  movzbl 0x1(%rbx),%eax
  add    $0x1,%rbx
  cmp    $0x5c,%dl
  jne    L44
  cmp    $0x62,%al
  je     L106
  cmp    $0x66,%al
  je     L149
  cmp    $0x6e,%al
  je     L84
  cmp    $0x72,%al
  je     L35
  cmp    $0x74,%al
  je     L115
  mov    %al,-0x1(%rbx)
  test   %al,%al
  jne    L108
L119:
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax,%rax,1)
L44:
  mov    %eax,%edx
L74:
  test   %dl,%dl
  jne    L26
  jmp    L119
  nopl   0x0(%rax,%rax,1)
L106:
  movb   $0x8,-0x1(%rbx)
L108:
  lea    0x1(%rbx),%rbp
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  lea    0x1(%rax),%rdx
  call   <memmove@plt>
  movzbl (%rbx),%edx
  jmp    L74
  nopl   0x0(%rax)
L149:
  movb   $0xc,-0x1(%rbx)
  jmp    L108
  xchg   %ax,%ax
L84:
  movb   $0xa,-0x1(%rbx)
  jmp    L108
  cs nopw 0x0(%rax,%rax,1)
L35:
  movb   $0xd,-0x1(%rbx)
  jmp    L108
  cs nopw 0x0(%rax,%rax,1)
L115:
  movb   $0x9,-0x1(%rbx)
  jmp    L108
```

assistant: ```c
char *htsstr_unescape(char *str) {
  char *s;
  for (s = str; *s; s++) {
    if (*s != '\\')
      continue;
    if (*(s + 1) == 'b')
      *s = '\b';
    else if (*(s + 1) == 'f')
      *s = '\f';
    else if (*(s + 1) == 'n')
      *s = '\n';
    else if (*(s + 1) == 'r')
      *s = '\r';
    else if (*(s + 1) == 't')
      *s = '\t';
    else
      *s = *(s + 1);
    if (*(s + 1)) {
      memmove(s + 1, s + 2, strlen(s + 2) + 1);
    }
  }
  return str;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<busca_primo>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    -0x28(%rbp),%rax
  mov    (%rax),%eax
  sub    $0x1869e,%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  mov    %eax,-0x18(%rbp)
  mov    -0x28(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,-0x14(%rbp)
  movl   $0x0,-0x10(%rbp)
L31:
  movl   $0x1,-0x8(%rbp)
  mov    -0x4(%rbp),%eax
  mov    %eax,-0xc(%rbp)
  jmp    L41
L42:
  mov    -0x18(%rbp),%eax
  cltd
  idivl  -0xc(%rbp)
  mov    %edx,%eax
  test   %eax,%eax
  jne    L74
  movl   $0x0,-0x8(%rbp)
  jmp    L16
L74:
  addl   $0x1,-0xc(%rbp)
L41:
  mov    -0xc(%rbp),%eax
  cmp    -0x18(%rbp),%eax
  jl     L42
L16:
  cmpl   $0x0,-0x8(%rbp)
  je     L8
  mov    -0x18(%rbp),%eax
  mov    %eax,%edi
  call   <push@plt>
  addl   $0x1,-0x10(%rbp)
L8:
  subl   $0x1,-0x14(%rbp)
  mov    -0x4(%rbp),%eax
  sub    $0x2,%eax
  cmp    %eax,-0x14(%rbp)
  jne    L48
  mov    -0x10(%rbp),%eax
  cltq
  jmp    L60
L48:
  addl   $0x1,-0x18(%rbp)
  jmp    L31
L60:
  leave
  ret
```

assistant: ```c
void *busca_primo(void *argu) {
  int inicio = 2 + (*(int *)argu) - 100000;
  int candidato = inicio;
  int num = *((int *)argu);
  int cantidad = 0;
  while (1) {
    int factor;
    int is_prime = 1;
    for (factor = inicio; factor < candidato; ++factor)
      if (candidato % factor == 0) {
        is_prime = 0;
        break;
      }
    if (is_prime) {
      push(candidato);
      ++cantidad;
    }
    if (--num == (inicio - 2))
      return (void *)cantidad;
    ++candidato;
  }
  return NULL;
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<busca_primo>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    (%rdi),%r12d
  lea    -0x1869e(%r12),%ebp
  add    $0x1,%r12d
  mov    %ebp,%ebx
  mov    $0x0,%r13d
  jmp    L39
L63:
  mov    %ebx,%edi
  call   <push@plt>
  add    $0x1,%r13d
L7:
  cmp    %r12d,%ebx
  je     L32
  add    $0x1,%ebx
L39:
  cmp    %ebp,%ebx
  jle    L63
  mov    %ebx,%eax
  cltd
  idiv   %ebp
  test   %edx,%edx
  je     L7
  mov    %ebp,%ecx
L6:
  add    $0x1,%ecx
  cmp    %ecx,%ebx
  jle    L63
  mov    %ebx,%eax
  cltd
  idiv   %ecx
  test   %edx,%edx
  jne    L6
  jmp    L7
L32:
  movslq %r13d,%rax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

assistant: ```c
void *busca_primo(void *argu) {
  int inicio = 2 + (*(int *)argu) - 100000;
  int candidato = inicio;
  int num = *((int *)argu);
  int cantidad = 0;
  while (1) {
    int factor;
    int is_prime = 1;
    for (factor = inicio; factor < candidato; ++factor)
      if (candidato % factor == 0) {
        is_prime = 0;
        break;
      }
    if (is_prime) {
      push(candidato);
      ++cantidad;
    }
    if (--num == (inicio - 2))
      return (void *)cantidad;
    ++candidato;
  }
  return NULL;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<busca_primo>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  xor    %ebp,%ebp
  push   %rbx
  sub    $0x8,%rsp
  mov    (%rdi),%r13d
  lea    -0x1869e(%r13),%ebx
  add    $0x1,%r13d
  mov    %ebx,%r12d
  nopl   0x0(%rax)
L28:
  cmp    %ebx,%r12d
  jle    L45
  mov    %r12d,%eax
  cltd
  idiv   %ebx
  test   %edx,%edx
  je     L10
  mov    %ebx,%ecx
  jmp    L23
  nopl   0x0(%rax,%rax,1)
L37:
  mov    %r12d,%eax
  cltd
  idiv   %ecx
  test   %edx,%edx
  je     L10
L23:
  add    $0x1,%ecx
  cmp    %ecx,%r12d
  jg     L37
L45:
  mov    %r12d,%edi
  add    $0x1,%ebp
  call   <push@plt>
L10:
  cmp    %r13d,%r12d
  je     L29
  add    $0x1,%r12d
  jmp    L28
L29:
  add    $0x8,%rsp
  movslq %ebp,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

assistant: ```c
void *busca_primo(void *argu) {
  int inicio = 2 + (*(int *)argu) - 100000;
  int candidato = inicio;
  int num = *((int *)argu);
  int cantidad = 0;
  while (1) {
    int factor;
    int is_prime = 1;
    for (factor = inicio; factor < candidato; ++factor)
      if (candidato % factor == 0) {
        is_prime = 0;
        break;
      }
    if (is_prime) {
      push(candidato);
      ++cantidad;
    }
    if (--num == (inicio - 2))
      return (void *)cantidad;
    ++candidato;
  }
  return NULL;
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<busca_primo>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  xor    %ebp,%ebp
  push   %rbx
  sub    $0x8,%rsp
  mov    (%rdi),%r13d
  lea    -0x1869e(%r13),%ebx
  add    $0x1,%r13d
  mov    %ebx,%r12d
  nopl   0x0(%rax)
L54:
  cmp    %ebx,%r12d
  jle    L45
  mov    %r12d,%eax
  cltd
  idiv   %ebx
  test   %edx,%edx
  je     L8
  mov    %ebx,%ecx
  jmp    L5
  nopl   0x0(%rax,%rax,1)
L63:
  mov    %r12d,%eax
  cltd
  idiv   %ecx
  test   %edx,%edx
  je     L8
L5:
  add    $0x1,%ecx
  cmp    %ecx,%r12d
  jg     L63
L45:
  mov    %r12d,%edi
  add    $0x1,%ebp
  call   <push@plt>
L8:
  cmp    %r13d,%r12d
  je     L17
  add    $0x1,%r12d
  jmp    L54
L17:
  add    $0x8,%rsp
  movslq %ebp,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

assistant: ```c
void *busca_primo(void *argu) {
  int inicio = 2 + (*(int *)argu) - 100000;
  int candidato = inicio;
  int num = *((int *)argu);
  int cantidad = 0;
  while (1) {
    int factor;
    int is_prime = 1;
    for (factor = inicio; factor < candidato; ++factor)
      if (candidato % factor == 0) {
        is_prime = 0;
        break;
      }
    if (is_prime) {
      push(candidato);
      ++cantidad;
    }
    if (--num == (inicio - 2))
      return (void *)cantidad;
    ++candidato;
  }
  return NULL;
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<count_1s>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,-0x14(%rbp)
  movl   $0x0,-0x4(%rbp)
  jmp    L18
L13:
  addl   $0x1,-0x4(%rbp)
  mov    -0x14(%rbp),%eax
  sub    $0x1,%eax
  and    %eax,-0x14(%rbp)
L18:
  cmpl   $0x0,-0x14(%rbp)
  jne    L13
  mov    -0x4(%rbp),%eax
  pop    %rbp
  ret
```

assistant: ```c
int count_1s(uint64_t b) {
  int r;
  for (r = 0; b; r++, b &= b - 1)
    ;
  return r;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<count_1s>:
  endbr64
  test   %edi,%edi
  je     L6
  mov    $0x0,%edx
L2:
  add    $0x1,%edx
  lea    -0x1(%rdi),%eax
  and    %eax,%edi
  jne    L2
L24:
  mov    %edx,%eax
  ret
L6:
  mov    %edi,%edx
  jmp    L24
```

assistant: ```c
int count_1s(uint64_t b) {
  int r;
  for (r = 0; b; r++, b &= b - 1)
    ;
  return r;
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<count_1s>:
  endbr64
  xor    %r8d,%r8d
  test   %edi,%edi
  je     L12
  nopl   0x0(%rax,%rax,1)
L17:
  lea    -0x1(%rdi),%eax
  add    $0x1,%r8d
  and    %eax,%edi
  jne    L17
L12:
  mov    %r8d,%eax
  ret
```

assistant: ```c
int count_1s(uint64_t b) {
  int r;
  for (r = 0; b; r++, b &= b - 1)
    ;
  return r;
}
```
user: 这段汇编代码用C语言表示是什么样的？

```asm
<count_1s>:
  endbr64
  xor    %r8d,%r8d
  test   %edi,%edi
  je     L14
  nopl   0x0(%rax,%rax,1)
L10:
  lea    -0x1(%rdi),%eax
  add    $0x1,%r8d
  and    %eax,%edi
  jne    L10
L14:
  mov    %r8d,%eax
  ret
```

assistant: ```c
int count_1s(uint64_t b) {
  int r;
  for (r = 0; b; r++, b &= b - 1)
    ;
  return r;
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<SaveBMP>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x40,%rsp
  mov    %rdi,%r12
  mov    %rsi,%rbp
  mov    %rdx,%rbx
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  xor    %eax,%eax
  movabs $0x130364d42,%rax
  mov    %rax,0x2(%rsp)
  movl   $0x4360000,0xa(%rsp)
  movw   $0x0,0xe(%rsp)
  movabs $0x14000000028,%rax
  movabs $0x80001000000f0,%rdx
  mov    %rax,0x10(%rsp)
  mov    %rdx,0x18(%rsp)
  movq   $0x0,0x20(%rsp)
  movq   $0x0,0x28(%rsp)
  movq   $0x0,0x30(%rsp)
  lea    0x2(%rsp),%rsi
  mov    $0xe,%edx
  mov    %rbp,%rdi
  call   <gm_memcpy@plt>
  lea    0x10(%rsp),%rsi
  lea    0xe(%rbp),%rdi
  mov    $0x28,%edx
  call   <gm_memcpy@plt>
  lea    0x36(%rbp),%rax
  lea    0x300(%rbx),%rdi
L22:
  movzbl (%rbx),%edx
  movzbl 0x1(%rbx),%ecx
  add    $0x3,%rbx
  movzbl -0x1(%rbx),%esi
  mov    %sil,(%rax)
  mov    %cl,0x1(%rax)
  mov    %dl,0x2(%rax)
  movb   $0x0,0x3(%rax)
  add    $0x4,%rax
  cmp    %rbx,%rdi
  jne    L22
  lea    0x436(%rbp),%rdi
  lea    0x12c01(%r12),%rsi
  add    $0x13036,%rbp
L35:
  lea    -0x12c00(%rsi),%rax
  mov    %rdi,%rdx
L31:
  movzbl (%rax),%ecx
  mov    %cl,(%rdx)
  add    $0xf0,%rax
  add    $0x1,%rdx
  cmp    %rsi,%rax
  jne    L31
  add    $0x140,%rdi
  add    $0x1,%rsi
  cmp    %rbp,%rdi
  jne    L35
  mov    0x38(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L20
  mov    $0x13036,%eax
  add    $0x40,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L20:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int SaveBMP(unsigned char *src, unsigned char *dst, unsigned char *pal) {
  unsigned char HEADER[] = {'B', 'M', 0x036, 0x30, 0x1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00};
  unsigned char INFOHD[] = {40, 0, 0, 0, 0x40, 1, 0, 0, 0xf0, 0, 0, 0, 1, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  int total = 0, i, x, y;
  gm_memcpy(&dst[total], HEADER, sizeof(HEADER));
  total += sizeof(HEADER);
  ;
  gm_memcpy(&dst[total], INFOHD, sizeof(INFOHD));
  total += sizeof(INFOHD);
  ;
  for (i = 0; i < 256; i++) {
    unsigned char r, g, b;
    r = *pal++;
    g = *pal++;
    b = *pal++;
    dst[total++] = b;
    dst[total++] = g;
    dst[total++] = r;
    dst[total++] = 0;
  }
  for (y = 240 - 1; y >= 0; y--)
    for (x = 0; x < 320; x++)
      dst[total++] = src[(240 - y) + x * 240];
  return total;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<SaveBMP>:
  endbr64
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  mov    %rdx,%rbp
  mov    $0xe,%edx
  push   %rbx
  mov    %rdi,%rbx
  mov    %r12,%rdi
  sub    $0x40,%rsp
  movdqa D8(%rip),%xmm0
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  movabs $0x130364d42,%rax
  lea    0x2(%rsp),%rsi
  movl   $0x4360000,0xa(%rsp)
  movaps %xmm0,0x10(%rsp)
  pxor   %xmm0,%xmm0
  movaps %xmm0,0x20(%rsp)
  movq   $0x0,0x30(%rsp)
  mov    %rax,0x2(%rsp)
  xor    %eax,%eax
  mov    %ax,0xe(%rsp)
  call   <gm_memcpy@plt>
  lea    0xe(%r12),%rdi
  lea    0x10(%rsp),%rsi
  mov    $0x28,%edx
  call   <gm_memcpy@plt>
  lea    0x36(%r12),%rax
  lea    0x300(%rbp),%rdi
L31:
  movzbl 0x0(%rbp),%edx
  movzbl 0x1(%rbp),%ecx
  add    $0x3,%rbp
  add    $0x4,%rax
  movzbl -0x1(%rbp),%esi
  movb   $0x0,-0x1(%rax)
  mov    %cl,-0x3(%rax)
  mov    %sil,-0x4(%rax)
  mov    %dl,-0x2(%rax)
  cmp    %rbp,%rdi
  jne    L31
  lea    0x436(%r12),%rdi
  lea    0x12c01(%rbx),%rsi
  lea    0x13036(%r12),%r8
L10:
  lea    -0x12c00(%rsi),%rax
  mov    %rdi,%rdx
  nopw   0x0(%rax,%rax,1)
L9:
  movzbl (%rax),%ecx
  add    $0xf0,%rax
  add    $0x1,%rdx
  mov    %cl,-0x1(%rdx)
  cmp    %rsi,%rax
  jne    L9
  add    $0x140,%rdi
  lea    0x1(%rax),%rsi
  cmp    %r8,%rdi
  jne    L10
  mov    0x38(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L30
  add    $0x40,%rsp
  mov    $0x13036,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L30:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: unpack_data
arguments: tag: D8
datatype: byte[16]

tool: {"D8": [0x28,0x00,0x00,0x00,0x40,0x01,0x00,0x00,0xf0,0x00,0x00,0x00,0x01,0x00,0x08,0x00]}

assistant: ```c
int SaveBMP(unsigned char *src, unsigned char *dst, unsigned char *pal) {
  unsigned char HEADER[] = {'B', 'M', 0x036, 0x30, 0x1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00};
  unsigned char INFOHD[] = {40, 0, 0, 0, 0x40, 1, 0, 0, 0xf0, 0, 0, 0, 1, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  int total = 0, i, x, y;
  gm_memcpy(&dst[total], HEADER, sizeof(HEADER));
  total += sizeof(HEADER);
  ;
  gm_memcpy(&dst[total], INFOHD, sizeof(INFOHD));
  total += sizeof(INFOHD);
  ;
  for (i = 0; i < 256; i++) {
    unsigned char r, g, b;
    r = *pal++;
    g = *pal++;
    b = *pal++;
    dst[total++] = b;
    dst[total++] = g;
    dst[total++] = r;
    dst[total++] = 0;
  }
  for (y = 240 - 1; y >= 0; y--)
    for (x = 0; x < 320; x++)
      dst[total++] = src[(240 - y) + x * 240];
  return total;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<send_process_tfo>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %edi,-0x14(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %edx,-0x18(%rbp)
  mov    D6(%rip),%rax
  mov    (%rax),%edx
  mov    -0x20(%rbp),%rcx
  mov    -0x14(%rbp),%eax
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <sendmsg@plt>
  mov    %eax,-0x4(%rbp)
  cmpl   $0x0,-0x4(%rbp)
  je     L2
  mov    D10(%rip),%rax
  mov    (%rax),%rdx
  mov    D35(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,%rdx
  jne    L2
  mov    D42(%rip),%rax
  mov    (%rax),%ecx
  mov    -0x18(%rbp),%edx
  mov    -0x14(%rbp),%eax
  mov    %ecx,%esi
  mov    %eax,%edi
  call   <poll_one@plt>
  cmp    $0x1,%eax
  je     L33
  mov    D39(%rip),%rax
  mov    (%rax),%rdx
  mov    D10(%rip),%rax
  mov    %rdx,(%rax)
  mov    $0xffffffff,%eax
  jmp    L29
L33:
  mov    D53(%rip),%rax
  mov    (%rax),%edx
  mov    -0x20(%rbp),%rcx
  mov    -0x14(%rbp),%eax
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <sendmsg@plt>
  mov    %eax,-0x4(%rbp)
L2:
  mov    -0x4(%rbp),%eax
L29:
  leave
  ret
```

assistant: ```c
ssize_t send_process_tfo(int fd, struct msghdr *msg, int timeout_ms) {
  int ret = sendmsg(fd, msg, MSG_FASTOPEN);
  if (ret != 0 && errno == EINPROGRESS) {
    if (poll_one(fd, POLLOUT, timeout_ms) != 1) {
      errno = ETIMEDOUT;
      return -1;
    }
    ret = sendmsg(fd, msg, MSG_NOSIGNAL);
  }
  return ret;
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<send_process_tfo>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    %edi,%ebx
  mov    %rsi,%rbp
  mov    %edx,%r12d
  mov    D42(%rip),%rax
  mov    (%rax),%edx
  call   <sendmsg@plt>
  test   %eax,%eax
  je     L30
  mov    D18(%rip),%rcx
  mov    D20(%rip),%rdx
  mov    (%rdx),%rsi
  cmp    %rsi,(%rcx)
  je     L25
L30:
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L25:
  mov    %r12d,%edx
  mov    D60(%rip),%rax
  mov    (%rax),%esi
  mov    %ebx,%edi
  call   <poll_one@plt>
  cmp    $0x1,%eax
  jne    L42
  mov    D15(%rip),%rax
  mov    (%rax),%edx
  mov    %rbp,%rsi
  mov    %ebx,%edi
  call   <sendmsg@plt>
  jmp    L30
L42:
  mov    D48(%rip),%rax
  mov    (%rax),%rdx
  mov    D18(%rip),%rax
  mov    %rdx,(%rax)
  mov    $0xffffffff,%eax
  jmp    L30
```

assistant: ```c
ssize_t send_process_tfo(int fd, struct msghdr *msg, int timeout_ms) {
  int ret = sendmsg(fd, msg, MSG_FASTOPEN);
  if (ret != 0 && errno == EINPROGRESS) {
    if (poll_one(fd, POLLOUT, timeout_ms) != 1) {
      errno = ETIMEDOUT;
      return -1;
    }
    ret = sendmsg(fd, msg, MSG_NOSIGNAL);
  }
  return ret;
}
```