ylfeng/ReF-Decompile-dataset huggingface dataset:
user: Demonstrate the C code that generates the assembly output below:

```asm
<clCreateCommandQueue>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %rdx,-0x38(%rbp)
  mov    %rcx,-0x40(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x28(%rbp),%rax
  mov    %eax,-0x20(%rbp)
  mov    -0x30(%rbp),%rax
  mov    %eax,-0x1c(%rbp)
  mov    -0x38(%rbp),%rax
  mov    %eax,-0x18(%rbp)
  mov    -0x40(%rbp),%rax
  mov    %eax,-0x14(%rbp)
  lea    -0x20(%rbp),%rax
  mov    %rax,%rdx
  mov    $0x3f1,%esi
  mov    $0x145,%edi
  call   <syscall@plt>
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L4
  call   <__stack_chk_fail@plt>
L4:
  leave
  ret
```

assistant: ```c
cl_command_queue clCreateCommandQueue(cl_context context, cl_device_id device, cl_command_queue_properties properties, cl_int *errcode_ret) {
  unsigned int sys_args[4];
  sys_args[0] = (unsigned int)context;
  sys_args[1] = (unsigned int)device;
  sys_args[2] = (unsigned int)properties;
  sys_args[3] = (unsigned int)errcode_ret;
  return (cl_command_queue)syscall(325, 1009, sys_args);
}
```
user: Translate the below assembly code into C programming language:

```asm
<clCreateCommandQueue>:
  endbr64
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  mov    %edi,(%rsp)
  mov    %esi,0x4(%rsp)
  mov    %edx,0x8(%rsp)
  mov    %ecx,0xc(%rsp)
  mov    %rsp,%rdx
  mov    $0x3f1,%esi
  mov    $0x145,%edi
  call   <syscall@plt>
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L5
  add    $0x28,%rsp
  ret
L5:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
cl_command_queue clCreateCommandQueue(cl_context context, cl_device_id device, cl_command_queue_properties properties, cl_int *errcode_ret) {
  unsigned int sys_args[4];
  sys_args[0] = (unsigned int)context;
  sys_args[1] = (unsigned int)device;
  sys_args[2] = (unsigned int)properties;
  sys_args[3] = (unsigned int)errcode_ret;
  return (cl_command_queue)syscall(325, 1009, sys_args);
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<clCreateCommandQueue>:
  endbr64
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  mov    %edi,(%rsp)
  mov    $0x145,%edi
  mov    %esi,0x4(%rsp)
  mov    $0x3f1,%esi
  mov    %edx,0x8(%rsp)
  mov    %rsp,%rdx
  mov    %ecx,0xc(%rsp)
  call   <syscall@plt>
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L6
  add    $0x28,%rsp
  ret
L6:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
cl_command_queue clCreateCommandQueue(cl_context context, cl_device_id device, cl_command_queue_properties properties, cl_int *errcode_ret) {
  unsigned int sys_args[4];
  sys_args[0] = (unsigned int)context;
  sys_args[1] = (unsigned int)device;
  sys_args[2] = (unsigned int)properties;
  sys_args[3] = (unsigned int)errcode_ret;
  return (cl_command_queue)syscall(325, 1009, sys_args);
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<clCreateCommandQueue>:
  endbr64
  sub    $0x28,%rsp
  movq   %rdi,%xmm0
  movq   %rsi,%xmm2
  mov    $0x145,%edi
  movq   %rdx,%xmm1
  movq   %rcx,%xmm3
  punpcklqdq %xmm2,%xmm0
  mov    %rsp,%rdx
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  punpcklqdq %xmm3,%xmm1
  mov    $0x3f1,%esi
  shufps $0x88,%xmm1,%xmm0
  movaps %xmm0,(%rsp)
  call   <syscall@plt>
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L9
  add    $0x28,%rsp
  ret
L9:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
cl_command_queue clCreateCommandQueue(cl_context context, cl_device_id device, cl_command_queue_properties properties, cl_int *errcode_ret) {
  unsigned int sys_args[4];
  sys_args[0] = (unsigned int)context;
  sys_args[1] = (unsigned int)device;
  sys_args[2] = (unsigned int)properties;
  sys_args[3] = (unsigned int)errcode_ret;
  return (cl_command_queue)syscall(325, 1009, sys_args);
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<hash_string>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,-0x14(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %edx,-0x18(%rbp)
  movl   $0x0,-0x4(%rbp)
  jmp    L13
L1:
  mov    -0x4(%rbp),%eax
  shl    $0x4,%eax
  mov    %eax,%ecx
  mov    -0x20(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x20(%rbp)
  movzbl (%rax),%eax
  movsbl %al,%eax
  add    %ecx,%eax
  mov    %eax,-0x4(%rbp)
L13:
  mov    -0x14(%rbp),%eax
  lea    -0x1(%rax),%edx
  mov    %edx,-0x14(%rbp)
  test   %eax,%eax
  jne    L1
  mov    -0x4(%rbp),%eax
  mov    $0x0,%edx
  divl   -0x18(%rbp)
  mov    %edx,%eax
  pop    %rbp
  ret
```

assistant: ```c
int hash_string(int len, char *str, unsigned int m) {
  unsigned int key = 0;
  while (len--)
    key = (key << 4) + *(str++);
  return (int)(key % m);
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<hash_string>:
  endbr64
  mov    %edx,%r8d
  test   %edi,%edi
  je     L16
  mov    %edi,%edi
  add    %rsi,%rdi
  mov    $0x0,%eax
L10:
  shl    $0x4,%eax
  add    $0x1,%rsi
  movsbl -0x1(%rsi),%ecx
  add    %ecx,%eax
  cmp    %rdi,%rsi
  jne    L10
L3:
  mov    $0x0,%edx
  div    %r8d
  mov    %edx,%eax
  ret
L16:
  mov    $0x0,%eax
  jmp    L3
```

assistant: ```c
int hash_string(int len, char *str, unsigned int m) {
  unsigned int key = 0;
  while (len--)
    key = (key << 4) + *(str++);
  return (int)(key % m);
}
```
user: What is the c source code of the assembly code below?

```asm
<hash_string>:
  endbr64
  mov    %edx,%r8d
  test   %edi,%edi
  je     L13
  mov    %edi,%edi
  xor    %eax,%eax
  add    %rsi,%rdi
  nopw   0x0(%rax,%rax,1)
L18:
  movsbl (%rsi),%ecx
  shl    $0x4,%eax
  add    $0x1,%rsi
  add    %ecx,%eax
  cmp    %rdi,%rsi
  jne    L18
  xor    %edx,%edx
  div    %r8d
  mov    %edx,%r9d
  mov    %r9d,%eax
  ret
  nopl   (%rax)
L13:
  xor    %r9d,%r9d
  mov    %r9d,%eax
  ret
```

assistant: ```c
int hash_string(int len, char *str, unsigned int m) {
  unsigned int key = 0;
  while (len--)
    key = (key << 4) + *(str++);
  return (int)(key % m);
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<hash_string>:
  endbr64
  mov    %edx,%r8d
  test   %edi,%edi
  je     L19
  mov    %edi,%edi
  xor    %eax,%eax
  add    %rsi,%rdi
  nopw   0x0(%rax,%rax,1)
L12:
  movsbl (%rsi),%ecx
  shl    $0x4,%eax
  add    $0x1,%rsi
  add    %ecx,%eax
  cmp    %rdi,%rsi
  jne    L12
  xor    %edx,%edx
  div    %r8d
  mov    %edx,%r9d
  mov    %r9d,%eax
  ret
  nopl   (%rax)
L19:
  xor    %r9d,%r9d
  mov    %r9d,%eax
  ret
```

assistant: ```c
int hash_string(int len, char *str, unsigned int m) {
  unsigned int key = 0;
  while (len--)
    key = (key << 4) + *(str++);
  return (int)(key % m);
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<i2c_write_data40>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %edi,-0x14(%rbp)
  mov    %esi,-0x18(%rbp)
  mov    %edx,-0x1c(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x18(%rbp),%eax
  mov    %eax,-0x10(%rbp)
  mov    -0x1c(%rbp),%eax
  mov    %eax,-0xc(%rbp)
  lea    -0x10(%rbp),%rcx
  mov    -0x14(%rbp),%eax
  mov    $0x5,%edx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <write@plt>
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L7
  call   <__stack_chk_fail@plt>
L7:
  leave
  ret
```

assistant: ```c
ssize_t i2c_write_data40(int fd, uint32_t low, uint32_t high) {
  uint32_t buffer[2];
  buffer[0] = low;
  buffer[1] = high;
  return write(fd, buffer, 5);
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<i2c_write_data40>:
  endbr64
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  mov    %esi,(%rsp)
  mov    %edx,0x4(%rsp)
  mov    %rsp,%rsi
  mov    $0x5,%edx
  call   <write@plt>
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L1
  add    $0x18,%rsp
  ret
L1:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
ssize_t i2c_write_data40(int fd, uint32_t low, uint32_t high) {
  uint32_t buffer[2];
  buffer[0] = low;
  buffer[1] = high;
  return write(fd, buffer, 5);
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<i2c_write_data40>:
  endbr64
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  mov    %esi,(%rsp)
  mov    %rsp,%rsi
  mov    %edx,0x4(%rsp)
  mov    $0x5,%edx
  call   <write@plt>
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L1
  add    $0x18,%rsp
  ret
L1:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
ssize_t i2c_write_data40(int fd, uint32_t low, uint32_t high) {
  uint32_t buffer[2];
  buffer[0] = low;
  buffer[1] = high;
  return write(fd, buffer, 5);
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<i2c_write_data40>:
  endbr64
  sub    $0x18,%rsp
  movd   %esi,%xmm0
  movd   %edx,%xmm1
  mov    $0x5,%edx
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  punpckldq %xmm1,%xmm0
  mov    %rsp,%rsi
  movq   %xmm0,(%rsp)
  call   <write@plt>
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L6
  add    $0x18,%rsp
  ret
L6:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
ssize_t i2c_write_data40(int fd, uint32_t low, uint32_t high) {
  uint32_t buffer[2];
  buffer[0] = low;
  buffer[1] = high;
  return write(fd, buffer, 5);
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<DetectCodeType>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  movl   $0x0,-0x10(%rbp)
  jmp    L168
L163:
  cmpl   $0x1b,-0xc(%rbp)
  jne    L32
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <getc@plt>
  mov    %eax,-0x8(%rbp)
  cmpl   $0x24,-0x8(%rbp)
  jne    L265
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <getc@plt>
  mov    %eax,-0x4(%rbp)
  cmpl   $0x42,-0x4(%rbp)
  jne    L94
  movl   $0x1,-0x10(%rbp)
  jmp    L168
L94:
  cmpl   $0x40,-0x4(%rbp)
  jne    L168
  movl   $0x2,-0x10(%rbp)
  jmp    L168
L265:
  cmpl   $0x4b,-0x8(%rbp)
  jne    L168
  movl   $0x3,-0x10(%rbp)
  jmp    L168
L32:
  cmpl   $0x80,-0xc(%rbp)
  jle    L168
  cmpl   $0xfe,-0xc(%rbp)
  jg     L168
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <getc@plt>
  mov    %eax,-0x8(%rbp)
  cmpl   $0x80,-0xc(%rbp)
  jle    L249
  cmpl   $0x9f,-0xc(%rbp)
  jg     L249
  cmpl   $0x3f,-0x8(%rbp)
  jle    L249
  cmpl   $0xa0,-0x8(%rbp)
  jg     L249
  movl   $0x5,-0x10(%rbp)
  jmp    L168
L249:
  cmpl   $0xa0,-0xc(%rbp)
  jle    L113
  cmpl   $0xfe,-0xc(%rbp)
  jg     L113
  cmpl   $0xa0,-0x8(%rbp)
  jle    L113
  cmpl   $0xfe,-0x8(%rbp)
  jg     L113
  movl   $0x4,-0x10(%rbp)
  jmp    L168
L113:
  cmpl   $0x8e,-0xc(%rbp)
  jne    L168
  cmpl   $0xa0,-0x8(%rbp)
  jle    L168
  cmpl   $0xdf,-0x8(%rbp)
  jg     L168
  movl   $0x4,-0x10(%rbp)
L168:
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <getc@plt>
  mov    %eax,-0xc(%rbp)
  mov    D1(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,-0xc(%rbp)
  je     L217
  cmpl   $0x0,-0x10(%rbp)
  je     L163
  cmpl   $0x4,-0x10(%rbp)
  je     L163
L217:
  mov    -0x10(%rbp),%eax
  leave
  ret
```

assistant: ```c
int DetectCodeType(FILE *in) {
  int p1, p2, p3, whatcode;
  whatcode = 0;
  while (((p1 = getc(in)) != EOF) && ((whatcode == 0) || (whatcode == 4))) {
    if (p1 == 27) {
      p2 = getc(in);
      if (p2 == '$') {
        p3 = getc(in);
        if (p3 == 'B')
          whatcode = 1;
        else if (p3 == '@')
          whatcode = 2;
      } else if (p2 == 'K')
        whatcode = 3;
    } else if ((p1 >= 129) && (p1 <= 254)) {
      p2 = getc(in);
      if (((p1 >= 129) && (p1 <= 159)) && ((p2 >= 64) && (p2 <= 160)))
        whatcode = 5;
      else if (((p1 >= 161) && (p1 <= 254)) && ((p2 >= 161) && (p2 <= 254)))
        whatcode = 4;
      else if (((p1 == 142)) && ((p2 >= 161) && (p2 <= 223)))
        whatcode = 4;
    }
  }
  return whatcode;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<DetectCodeType>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbp
  mov    $0x0,%r12d
  mov    $0x4,%r13d
  jmp    L80
L101:
  mov    %rbp,%rdi
  call   <getc@plt>
  cmp    $0x24,%eax
  je     L91
  cmp    $0x4b,%eax
  mov    $0x3,%eax
  cmove  %eax,%r12d
L80:
  mov    %rbp,%rdi
  call   <getc@plt>
  mov    %eax,%ebx
  mov    D0(%rip),%rax
  cmp    %ebx,(%rax)
  je     L51
  test   $0xfffffffb,%r12d
  jne    L51
  cmp    $0x1b,%ebx
  je     L101
  lea    -0x81(%rbx),%r14d
  cmp    $0x7d,%r14d
  ja     L80
  mov    %rbp,%rdi
  call   <getc@plt>
  cmp    $0x1e,%r14d
  ja     L38
  lea    -0x40(%rax),%edx
  cmp    $0x60,%edx
  jbe    L113
L8:
  cmp    $0x8e,%ebx
  jne    L80
  sub    $0xa1,%eax
  cmp    $0x3e,%eax
  cmovbe %r13d,%r12d
  jmp    L80
L91:
  mov    %rbp,%rdi
  call   <getc@plt>
  cmp    $0x42,%eax
  je     L46
  cmp    $0x40,%eax
  mov    $0x2,%eax
  cmove  %eax,%r12d
  jmp    L80
L38:
  lea    -0xa1(%rbx),%edx
  cmp    $0x5d,%edx
  ja     L8
  lea    -0xa1(%rax),%edx
  cmp    $0x5d,%edx
  ja     L8
  mov    $0x4,%r12d
  jmp    L80
L46:
  mov    $0x1,%r12d
  jmp    L80
L113:
  mov    $0x5,%r12d
  jmp    L80
L51:
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
```

assistant: ```c
int DetectCodeType(FILE *in) {
  int p1, p2, p3, whatcode;
  whatcode = 0;
  while (((p1 = getc(in)) != EOF) && ((whatcode == 0) || (whatcode == 4))) {
    if (p1 == 27) {
      p2 = getc(in);
      if (p2 == '$') {
        p3 = getc(in);
        if (p3 == 'B')
          whatcode = 1;
        else if (p3 == '@')
          whatcode = 2;
      } else if (p2 == 'K')
        whatcode = 3;
    } else if ((p1 >= 129) && (p1 <= 254)) {
      p2 = getc(in);
      if (((p1 >= 129) && (p1 <= 159)) && ((p2 >= 64) && (p2 <= 160)))
        whatcode = 5;
      else if (((p1 >= 161) && (p1 <= 254)) && ((p2 >= 161) && (p2 <= 254)))
        whatcode = 4;
      else if (((p1 == 142)) && ((p2 >= 161) && (p2 <= 223)))
        whatcode = 4;
    }
  }
  return whatcode;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<DetectCodeType>:
  endbr64
  push   %r15
  push   %r14
  mov    $0x4,%r14d
  push   %r13
  push   %r12
  xor    %r12d,%r12d
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    D3(%rip),%r13
  nopl   (%rax)
L49:
  mov    %rbp,%rdi
  call   <getc@plt>
  mov    %eax,%ebx
  cmp    %eax,0x0(%r13)
  je     L141
L56:
  test   $0xfffffffb,%r12d
  jne    L141
  cmp    $0x1b,%ebx
  je     L69
  lea    -0x81(%rbx),%r15d
  cmp    $0x7d,%r15d
  ja     L49
  mov    %rbp,%rdi
  call   <getc@plt>
  cmp    $0x1e,%r15d
  ja     L34
  lea    -0x40(%rax),%edx
  cmp    $0x60,%edx
  ja     L0
  mov    %rbp,%rdi
  mov    $0x5,%r12d
  call   <getc@plt>
  mov    %eax,%ebx
  cmp    %eax,0x0(%r13)
  jne    L56
L141:
  add    $0x8,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L69:
  mov    %rbp,%rdi
  call   <getc@plt>
  cmp    $0x24,%eax
  je     L63
  cmp    $0x4b,%eax
  mov    $0x3,%eax
  cmove  %eax,%r12d
  jmp    L49
  cs nopw 0x0(%rax,%rax,1)
L34:
  lea    -0xa1(%rbx),%edx
  cmp    $0x5d,%edx
  ja     L0
  lea    -0xa1(%rax),%edx
  cmp    $0x5d,%edx
  jbe    L27
L0:
  cmp    $0x8e,%ebx
  jne    L49
  sub    $0xa1,%eax
  cmp    $0x3e,%eax
  cmovbe %r14d,%r12d
  jmp    L49
  nopl   0x0(%rax,%rax,1)
L27:
  mov    $0x4,%r12d
  jmp    L49
  nopl   0x0(%rax,%rax,1)
L63:
  mov    %rbp,%rdi
  call   <getc@plt>
  cmp    $0x42,%eax
  je     L48
  cmp    $0x40,%eax
  mov    $0x2,%eax
  cmove  %eax,%r12d
  jmp    L49
  cs nopw 0x0(%rax,%rax,1)
L48:
  mov    $0x1,%r12d
  jmp    L49
```

assistant: ```c
int DetectCodeType(FILE *in) {
  int p1, p2, p3, whatcode;
  whatcode = 0;
  while (((p1 = getc(in)) != EOF) && ((whatcode == 0) || (whatcode == 4))) {
    if (p1 == 27) {
      p2 = getc(in);
      if (p2 == '$') {
        p3 = getc(in);
        if (p3 == 'B')
          whatcode = 1;
        else if (p3 == '@')
          whatcode = 2;
      } else if (p2 == 'K')
        whatcode = 3;
    } else if ((p1 >= 129) && (p1 <= 254)) {
      p2 = getc(in);
      if (((p1 >= 129) && (p1 <= 159)) && ((p2 >= 64) && (p2 <= 160)))
        whatcode = 5;
      else if (((p1 >= 161) && (p1 <= 254)) && ((p2 >= 161) && (p2 <= 254)))
        whatcode = 4;
      else if (((p1 == 142)) && ((p2 >= 161) && (p2 <= 223)))
        whatcode = 4;
    }
  }
  return whatcode;
}
```
user: Translate the below assembly code into C programming language:

```asm
<DetectCodeType>:
  endbr64
  push   %r15
  push   %r14
  mov    $0x4,%r14d
  push   %r13
  push   %r12
  xor    %r12d,%r12d
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    D4(%rip),%r13
  nopl   (%rax)
L20:
  mov    %rbp,%rdi
  call   <getc@plt>
  mov    %eax,%ebx
  cmp    %eax,0x0(%r13)
  je     L99
L159:
  test   $0xfffffffb,%r12d
  jne    L99
  cmp    $0x1b,%ebx
  je     L52
  lea    -0x81(%rbx),%r15d
  cmp    $0x7d,%r15d
  ja     L20
  mov    %rbp,%rdi
  call   <getc@plt>
  cmp    $0x1e,%r15d
  ja     L73
  lea    -0x40(%rax),%edx
  cmp    $0x60,%edx
  ja     L153
  mov    %rbp,%rdi
  mov    $0x5,%r12d
  call   <getc@plt>
  mov    %eax,%ebx
  cmp    %eax,0x0(%r13)
  jne    L159
L99:
  add    $0x8,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L52:
  mov    %rbp,%rdi
  call   <getc@plt>
  cmp    $0x24,%eax
  je     L53
  cmp    $0x4b,%eax
  mov    $0x3,%eax
  cmove  %eax,%r12d
  jmp    L20
  cs nopw 0x0(%rax,%rax,1)
L73:
  lea    -0xa1(%rbx),%edx
  cmp    $0x5d,%edx
  ja     L153
  lea    -0xa1(%rax),%edx
  cmp    $0x5d,%edx
  jbe    L142
L153:
  cmp    $0x8e,%ebx
  jne    L20
  sub    $0xa1,%eax
  cmp    $0x3e,%eax
  cmovbe %r14d,%r12d
  jmp    L20
  nopl   0x0(%rax,%rax,1)
L142:
  mov    $0x4,%r12d
  jmp    L20
  nopl   0x0(%rax,%rax,1)
L53:
  mov    %rbp,%rdi
  call   <getc@plt>
  cmp    $0x42,%eax
  je     L59
  cmp    $0x40,%eax
  mov    $0x2,%eax
  cmove  %eax,%r12d
  jmp    L20
  cs nopw 0x0(%rax,%rax,1)
L59:
  mov    $0x1,%r12d
  jmp    L20
```

assistant: ```c
int DetectCodeType(FILE *in) {
  int p1, p2, p3, whatcode;
  whatcode = 0;
  while (((p1 = getc(in)) != EOF) && ((whatcode == 0) || (whatcode == 4))) {
    if (p1 == 27) {
      p2 = getc(in);
      if (p2 == '$') {
        p3 = getc(in);
        if (p3 == 'B')
          whatcode = 1;
        else if (p3 == '@')
          whatcode = 2;
      } else if (p2 == 'K')
        whatcode = 3;
    } else if ((p1 >= 129) && (p1 <= 254)) {
      p2 = getc(in);
      if (((p1 >= 129) && (p1 <= 159)) && ((p2 >= 64) && (p2 <= 160)))
        whatcode = 5;
      else if (((p1 >= 161) && (p1 <= 254)) && ((p2 >= 161) && (p2 <= 254)))
        whatcode = 4;
      else if (((p1 == 142)) && ((p2 >= 161) && (p2 <= 223)))
        whatcode = 4;
    }
  }
  return whatcode;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<ft_putnbr>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %edi,-0x14(%rbp)
  movl   $0x0,-0x4(%rbp)
  cmpl   $0x0,-0x14(%rbp)
  je     L39
  cmpl   $0x0,-0x14(%rbp)
  jns    L28
  mov    $0x2d,%edi
  call   <ft_putchar@plt>
  mov    -0x14(%rbp),%eax
  add    $0x9,%eax
  cmp    $0x12,%eax
  jbe    L42
  mov    -0x14(%rbp),%eax
  movslq %eax,%rdx
  imul   $0x66666667,%rdx,%rdx
  shr    $0x20,%rdx
  sar    $0x2,%edx
  sar    $0x1f,%eax
  sub    %edx,%eax
  mov    %eax,%edi
  call   <ft_putnbr>
L42:
  mov    -0x14(%rbp),%eax
  not    %eax
  mov    %eax,%ecx
  movslq %ecx,%rax
  imul   $0x66666667,%rax,%rax
  shr    $0x20,%rax
  sar    $0x2,%eax
  mov    %ecx,%esi
  sar    $0x1f,%esi
  sub    %esi,%eax
  mov    %eax,%edx
  mov    %edx,%eax
  shl    $0x2,%eax
  add    %edx,%eax
  add    %eax,%eax
  sub    %eax,%ecx
  mov    %ecx,%edx
  lea    0x31(%rdx),%eax
  mov    %eax,%edi
  call   <ft_putchar@plt>
  jmp    L37
L28:
  mov    -0x14(%rbp),%eax
  add    $0x9,%eax
  cmp    $0x12,%eax
  jbe    L56
  mov    -0x14(%rbp),%eax
  movslq %eax,%rdx
  imul   $0x66666667,%rdx,%rdx
  shr    $0x20,%rdx
  sar    $0x2,%edx
  sar    $0x1f,%eax
  mov    %eax,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  mov    %eax,%edi
  call   <ft_putnbr>
L56:
  mov    -0x14(%rbp),%ecx
  movslq %ecx,%rax
  imul   $0x66666667,%rax,%rax
  shr    $0x20,%rax
  sar    $0x2,%eax
  mov    %ecx,%esi
  sar    $0x1f,%esi
  sub    %esi,%eax
  mov    %eax,%edx
  mov    %edx,%eax
  shl    $0x2,%eax
  add    %edx,%eax
  add    %eax,%eax
  sub    %eax,%ecx
  mov    %ecx,%edx
  lea    0x30(%rdx),%eax
  mov    %eax,%edi
  call   <ft_putchar@plt>
  jmp    L37
L39:
  mov    $0x30,%edi
  call   <ft_putchar@plt>
L37:
  leave
  ret
```

assistant: ```c
void ft_putnbr(int nb) {
  int neg;
  neg = 0;
  if (nb) {
    if (nb < 0) {
      ft_putchar('-');
      if (nb / 10)
        ft_putnbr(nb / -10);
      ft_putchar((-(nb + 1) % 10) + 49);
    } else {
      if (nb / 10)
        ft_putnbr(nb / 10);
      ft_putchar(nb % 10 + 48);
    }
    return;
  }
  ft_putchar('0');
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<ft_putnbr>:
  endbr64
  push   %rbx
  test   %edi,%edi
  je     L64
  mov    %edi,%ebx
  js     L2
  lea    0x9(%rdi),%eax
  cmp    $0x12,%eax
  ja     L0
L76:
  movslq %ebx,%rax
  imul   $0x66666667,%rax,%rax
  sar    $0x22,%rax
  mov    %ebx,%edx
  sar    $0x1f,%edx
  sub    %edx,%eax
  lea    (%rax,%rax,4),%eax
  add    %eax,%eax
  sub    %eax,%ebx
  lea    0x30(%rbx),%edi
  call   <ft_putchar@plt>
  jmp    L61
L2:
  mov    $0x2d,%edi
  call   <ft_putchar@plt>
  lea    0x9(%rbx),%eax
  cmp    $0x12,%eax
  ja     L75
L38:
  not    %ebx
  movslq %ebx,%rax
  imul   $0x66666667,%rax,%rax
  sar    $0x22,%rax
  mov    %ebx,%edx
  sar    $0x1f,%edx
  sub    %edx,%eax
  lea    (%rax,%rax,4),%eax
  add    %eax,%eax
  sub    %eax,%ebx
  lea    0x31(%rbx),%edi
  call   <ft_putchar@plt>
  jmp    L61
L75:
  movslq %ebx,%rax
  imul   $0x66666667,%rax,%rax
  sar    $0x22,%rax
  mov    %ebx,%edi
  sar    $0x1f,%edi
  sub    %eax,%edi
  call   <ft_putnbr>
  jmp    L38
L0:
  movslq %edi,%rdi
  imul   $0x66666667,%rdi,%rdi
  sar    $0x22,%rdi
  mov    %ebx,%eax
  sar    $0x1f,%eax
  sub    %eax,%edi
  call   <ft_putnbr>
  jmp    L76
L64:
  mov    $0x30,%edi
  call   <ft_putchar@plt>
L61:
  pop    %rbx
  ret
```

assistant: ```c
void ft_putnbr(int nb) {
  int neg;
  neg = 0;
  if (nb) {
    if (nb < 0) {
      ft_putchar('-');
      if (nb / 10)
        ft_putnbr(nb / -10);
      ft_putchar((-(nb + 1) % 10) + 49);
    } else {
      if (nb / 10)
        ft_putnbr(nb / 10);
      ft_putchar(nb % 10 + 48);
    }
    return;
  }
  ft_putchar('0');
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<ft_putnbr>:
  endbr64
  test   %edi,%edi
  je     L24
  push   %r12
  lea    0x9(%rdi),%r12d
  push   %rbp
  push   %rbx
  mov    %edi,%ebx
  js     L55
  movslq %edi,%rbp
  cmp    $0x12,%r12d
  ja     L29
L41:
  imul   $0x66666667,%rbp,%rax
  mov    %ebx,%edx
  sar    $0x1f,%edx
  sar    $0x22,%rax
  sub    %edx,%eax
  lea    (%rax,%rax,4),%eax
  add    %eax,%eax
  sub    %eax,%ebx
  lea    0x30(%rbx),%edi
  pop    %rbx
  pop    %rbp
  pop    %r12
  jmp    1050 <ft_putchar@plt>
  nopw   0x0(%rax,%rax,1)
L24:
  mov    $0x30,%edi
  jmp    1050 <ft_putchar@plt>
  nopw   0x0(%rax,%rax,1)
L55:
  mov    $0x2d,%edi
  call   <ft_putchar@plt>
  cmp    $0x12,%r12d
  ja     L57
L26:
  not    %ebx
  mov    $0xcccccccd,%edx
  mov    %ebx,%eax
  imul   %rdx,%rax
  shr    $0x23,%rax
  lea    (%rax,%rax,4),%eax
  add    %eax,%eax
  sub    %eax,%ebx
  lea    0x31(%rbx),%edi
  pop    %rbx
  pop    %rbp
  pop    %r12
  jmp    1050 <ft_putchar@plt>
  nopl   0x0(%rax)
L29:
  imul   $0x66666667,%rbp,%rdi
  mov    %ebx,%eax
  sar    $0x1f,%eax
  sar    $0x22,%rdi
  sub    %eax,%edi
  call   <ft_putnbr>
  jmp    L41
  nopl   0x0(%rax)
L57:
  movslq %ebx,%rax
  mov    %ebx,%edi
  imul   $0x66666667,%rax,%rax
  sar    $0x1f,%edi
  sar    $0x22,%rax
  sub    %eax,%edi
  call   <ft_putnbr>
  jmp    L26
```

assistant: ```c
void ft_putnbr(int nb) {
  int neg;
  neg = 0;
  if (nb) {
    if (nb < 0) {
      ft_putchar('-');
      if (nb / 10)
        ft_putnbr(nb / -10);
      ft_putchar((-(nb + 1) % 10) + 49);
    } else {
      if (nb / 10)
        ft_putnbr(nb / 10);
      ft_putchar(nb % 10 + 48);
    }
    return;
  }
  ft_putchar('0');
}
```