ylfeng/ReF-Decompile-dataset huggingface dataset:
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<wspr_ascii_to_alpha>:
  endbr64
  cmp    $0x20,%dil
  je     L7
  sub    $0x41,%edi
  cmp    $0x19,%dil
  mov    $0x0,%eax
  cmovbe %edi,%eax
  ret
L7:
  mov    $0x1a,%eax
  ret
```

assistant: ```c
uint8_t wspr_ascii_to_alpha(uint8_t c) {
  if (c == ' ') {
    return 26;
  }
  if (c >= 'A' && c <= 'Z') {
    return c - 'A';
  }
  return 0;
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<wspr_ascii_to_alpha>:
  endbr64
  cmp    $0x20,%dil
  je     L3
  sub    $0x41,%edi
  xor    %eax,%eax
  cmp    $0x19,%dil
  cmovbe %edi,%eax
  ret
  nopw   0x0(%rax,%rax,1)
L3:
  mov    $0x1a,%eax
  ret
```

assistant: ```c
uint8_t wspr_ascii_to_alpha(uint8_t c) {
  if (c == ' ') {
    return 26;
  }
  if (c >= 'A' && c <= 'Z') {
    return c - 'A';
  }
  return 0;
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<wspr_ascii_to_alpha>:
  endbr64
  cmp    $0x20,%dil
  je     L4
  sub    $0x41,%edi
  xor    %eax,%eax
  cmp    $0x19,%dil
  cmovbe %edi,%eax
  ret
  nopw   0x0(%rax,%rax,1)
L4:
  mov    $0x1a,%eax
  ret
```

assistant: ```c
uint8_t wspr_ascii_to_alpha(uint8_t c) {
  if (c == ' ') {
    return 26;
  }
  if (c >= 'A' && c <= 'Z') {
    return c - 'A';
  }
  return 0;
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<t5b>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %rdi,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,%ecx
  mov    $0x63,%edx
  mov    $0x27,%esi
  lea    D2(%rip),%rax
  mov    %rax,%rdi
  call   <fexpect@plt>
  addq   $0x4,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,%ecx
  mov    $0x62,%edx
  mov    $0x28,%esi
  lea    D2(%rip),%rax
  mov    %rax,%rdi
  call   <fexpect@plt>
  addq   $0x4,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,%ecx
  mov    $0x61,%edx
  mov    $0x29,%esi
  lea    D2(%rip),%rax
  mov    %rax,%rdi
  call   <fexpect@plt>
  nop
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: tag: D2
type: string

tool: D2: /scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/8l/8cc/refs/heads/master/test/function.c

assistant: ```c
void t5b(int p[]) {
  fexpect("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/8l/8cc/refs/heads/master/test/function.c", 39, 99, *p);
  ;
  p = p + 1;
  fexpect("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/8l/8cc/refs/heads/master/test/function.c", 40, 98, *p);
  ;
  p = p + 1;
  fexpect("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/8l/8cc/refs/heads/master/test/function.c", 41, 97, *p);
  ;
}
```
user: What is the c source code of the assembly code below:

```asm
<t5b>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%rbx
  mov    (%rdi),%ecx
  mov    $0x63,%edx
  mov    $0x27,%esi
  lea    D1(%rip),%rbp
  mov    %rbp,%rdi
  call   <fexpect@plt>
  mov    0x4(%rbx),%ecx
  mov    $0x62,%edx
  mov    $0x28,%esi
  mov    %rbp,%rdi
  call   <fexpect@plt>
  mov    0x8(%rbx),%ecx
  mov    $0x61,%edx
  mov    $0x29,%esi
  mov    %rbp,%rdi
  call   <fexpect@plt>
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
```

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

tool: D1: /scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/8l/8cc/refs/heads/master/test/function.c

assistant: ```c
void t5b(int p[]) {
  fexpect("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/8l/8cc/refs/heads/master/test/function.c", 39, 99, *p);
  ;
  p = p + 1;
  fexpect("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/8l/8cc/refs/heads/master/test/function.c", 40, 98, *p);
  ;
  p = p + 1;
  fexpect("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/8l/8cc/refs/heads/master/test/function.c", 41, 97, *p);
  ;
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<t5b>:
  endbr64
  push   %rbp
  lea    D0(%rip),%rbp
  mov    $0x63,%edx
  mov    $0x27,%esi
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x8,%rsp
  mov    (%rdi),%ecx
  mov    %rbp,%rdi
  call   <fexpect@plt>
  mov    0x4(%rbx),%ecx
  mov    %rbp,%rdi
  mov    $0x62,%edx
  mov    $0x28,%esi
  call   <fexpect@plt>
  mov    0x8(%rbx),%ecx
  add    $0x8,%rsp
  mov    %rbp,%rdi
  pop    %rbx
  mov    $0x61,%edx
  mov    $0x29,%esi
  pop    %rbp
  jmp    1050 <fexpect@plt>
```

tool_calls: name: read_data
arguments: tag: D0
data_type: string

tool: D0: /scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/8l/8cc/refs/heads/master/test/function.c

assistant: ```c
void t5b(int p[]) {
  fexpect("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/8l/8cc/refs/heads/master/test/function.c", 39, 99, *p);
  ;
  p = p + 1;
  fexpect("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/8l/8cc/refs/heads/master/test/function.c", 40, 98, *p);
  ;
  p = p + 1;
  fexpect("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/8l/8cc/refs/heads/master/test/function.c", 41, 97, *p);
  ;
}
```
user: What is the c source code of the assembly code below:

```asm
<t5b>:
  endbr64
  push   %rbp
  lea    D5(%rip),%rbp
  mov    $0x63,%edx
  mov    $0x27,%esi
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x8,%rsp
  mov    (%rdi),%ecx
  mov    %rbp,%rdi
  call   <fexpect@plt>
  mov    0x4(%rbx),%ecx
  mov    %rbp,%rdi
  mov    $0x62,%edx
  mov    $0x28,%esi
  call   <fexpect@plt>
  mov    0x8(%rbx),%ecx
  add    $0x8,%rsp
  mov    %rbp,%rdi
  pop    %rbx
  mov    $0x61,%edx
  mov    $0x29,%esi
  pop    %rbp
  jmp    1050 <fexpect@plt>
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D5
type: string

tool: D5: /scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/8l/8cc/refs/heads/master/test/function.c

assistant: ```c
void t5b(int p[]) {
  fexpect("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/8l/8cc/refs/heads/master/test/function.c", 39, 99, *p);
  ;
  p = p + 1;
  fexpect("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/8l/8cc/refs/heads/master/test/function.c", 40, 98, *p);
  ;
  p = p + 1;
  fexpect("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/8l/8cc/refs/heads/master/test/function.c", 41, 97, *p);
  ;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<str_err>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,-0x4(%rbp)
  cmpl   $0x80,-0x4(%rbp)
  je     L10
  cmpl   $0x81,-0x4(%rbp)
  jne    L0
  lea    D11(%rip),%rax
  jmp    L8
L10:
  lea    D25(%rip),%rax
  jmp    L8
L0:
  lea    D8(%rip),%rax
L8:
  pop    %rbp
  ret
```

tool_calls: name: parse_data
arguments: label: D11
data_type: string
name: parse_data
arguments: label: D25
data_type: string
name: parse_data
arguments: label: D8
data_type: string

tool: D11: EACCES

tool: D25: EAGAIN

tool: D8: ???

assistant: ```c
const char *str_err(int err) {
  switch (err) {
  case EACCES:
    return "EACCES";
  case EAGAIN:
    return "EAGAIN";
  default:
    return "???";
  }
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<str_err>:
  endbr64
  lea    D19(%rip),%rax
  cmp    $0x80,%edi
  je     L1
  cmp    $0x81,%edi
  lea    D3(%rip),%rax
  lea    D10(%rip),%rdx
  cmove  %rdx,%rax
L1:
  ret
```

tool_calls: name: retrieve_data
arguments: data_label: D19
type: string
name: retrieve_data
arguments: data_label: D3
type: string
name: retrieve_data
arguments: data_label: D10
type: string

tool: D19: EAGAIN

tool: D3: ???

tool: D10: EACCES

assistant: ```c
const char *str_err(int err) {
  switch (err) {
  case EACCES:
    return "EACCES";
  case EAGAIN:
    return "EAGAIN";
  default:
    return "???";
  }
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<str_err>:
  endbr64
  lea    D15(%rip),%rax
  cmp    $0x80,%edi
  je     L7
  cmp    $0x81,%edi
  lea    D1(%rip),%rax
  lea    D5(%rip),%rdx
  cmove  %rdx,%rax
L7:
  ret
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D15
datatype: string
name: extract_symbolic_data
arguments: data_tag: D1
datatype: string
name: extract_symbolic_data
arguments: data_tag: D5
datatype: string

tool: D15: EAGAIN

tool: D1: ???

tool: D5: EACCES

assistant: ```c
const char *str_err(int err) {
  switch (err) {
  case EACCES:
    return "EACCES";
  case EAGAIN:
    return "EAGAIN";
  default:
    return "???";
  }
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<str_err>:
  endbr64
  lea    D29(%rip),%rax
  cmp    $0x80,%edi
  je     L3
  cmp    $0x81,%edi
  lea    D25(%rip),%rax
  lea    D6(%rip),%rdx
  cmove  %rdx,%rax
L3:
  ret
```

tool_calls: name: retrieve_data
arguments: tag: D29
type_guessed: string
name: retrieve_data
arguments: tag: D25
type_guessed: string
name: retrieve_data
arguments: tag: D6
type_guessed: string

tool: D29: EAGAIN

tool: D25: ???

tool: D6: EACCES

assistant: ```c
const char *str_err(int err) {
  switch (err) {
  case EACCES:
    return "EACCES";
  case EAGAIN:
    return "EAGAIN";
  default:
    return "???";
  }
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<REVbase_hash>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,%eax
  mov    %esi,-0x18(%rbp)
  mov    %al,-0x14(%rbp)
  movl   $0x0,-0x4(%rbp)
  movzbl -0x14(%rbp),%eax
  sub    $0x41,%eax
  cmp    $0x18,%eax
  ja     L27
  mov    %eax,%eax
  lea    0x0(,%rax,4),%rdx
  lea    D10(%rip),%rax
  mov    (%rdx,%rax,1),%eax
  cltq
  lea    D10(%rip),%rdx
  add    %rdx,%rax
  notrack jmp *%rax
  movl   $0x1,-0x4(%rbp)
  movb   $0x3,-0x14(%rbp)
  jmp    L24
  movl   $0x1,-0x4(%rbp)
  movb   $0x2,-0x14(%rbp)
  jmp    L24
  movb   $0x1,-0x14(%rbp)
  jmp    L24
  movl   $0x1,-0x4(%rbp)
  movb   $0x0,-0x14(%rbp)
  jmp    L24
  movl   $0x1,-0x4(%rbp)
  movb   $0x3,-0x14(%rbp)
  jmp    L24
L27:
  movl   $0x2,-0x4(%rbp)
  movb   $0x3,-0x14(%rbp)
L24:
  shll   $0x2,-0x18(%rbp)
  movzbl -0x14(%rbp),%eax
  add    %eax,-0x18(%rbp)
  mov    -0x18(%rbp),%eax
  pop    %rbp
  ret
```

assistant: ```c
int REVbase_hash(unsigned char a, int b) {
  int base_status = 0;
  switch (a) {
  case 'A':
  case 'M':
  case 'R':
    base_status = 1;
  case 'W':
    a = 3;
    break;
  case 'C':
  case 'Y':
    base_status = 1;
  case 'S':
    a = 2;
    break;
  case 'G':
    a = 1;
    break;
  case 'T':
    base_status = 1;
  case 'K':
    a = 0;
    break;
  case 'N':
    base_status = 1;
    a = 3;
    break;
  default:
    base_status = 2;
    a = 3;
  }
  b = b << 2;
  b = b + a;
  return b;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<REVbase_hash>:
  endbr64
  lea    -0x43(%rdi),%ecx
  cmp    $0x16,%cl
  ja     L39
  mov    $0x1,%eax
  shl    %cl,%rax
  test   $0x410001,%eax
  jne    L42
  test   $0x20100,%eax
  jne    L19
  cmp    $0x4,%cl
  setne  %al
  lea    0x1(%rax,%rax,1),%eax
L44:
  movzbl %al,%eax
  lea    (%rax,%rsi,4),%eax
  ret
L39:
  mov    $0x3,%eax
  jmp    L44
L42:
  mov    $0x2,%eax
  jmp    L44
L19:
  mov    $0x0,%eax
  jmp    L44
```

assistant: ```c
int REVbase_hash(unsigned char a, int b) {
  int base_status = 0;
  switch (a) {
  case 'A':
  case 'M':
  case 'R':
    base_status = 1;
  case 'W':
    a = 3;
    break;
  case 'C':
  case 'Y':
    base_status = 1;
  case 'S':
    a = 2;
    break;
  case 'G':
    a = 1;
    break;
  case 'T':
    base_status = 1;
  case 'K':
    a = 0;
    break;
  case 'N':
    base_status = 1;
    a = 3;
    break;
  default:
    base_status = 2;
    a = 3;
  }
  b = b << 2;
  b = b + a;
  return b;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<REVbase_hash>:
  endbr64
  lea    -0x43(%rdi),%ecx
  cmp    $0x16,%cl
  ja     L28
  mov    $0x1,%eax
  shl    %cl,%rax
  test   $0x410001,%eax
  jne    L32
  test   $0x20100,%eax
  jne    L26
  xor    %eax,%eax
  cmp    $0x4,%cl
  setne  %al
  lea    0x1(%rax,%rax,1),%eax
L35:
  lea    (%rax,%rsi,4),%eax
  ret
  nopw   0x0(%rax,%rax,1)
L28:
  mov    $0x3,%eax
  lea    (%rax,%rsi,4),%eax
  ret
  nopl   0x0(%rax)
L32:
  mov    $0x2,%eax
  lea    (%rax,%rsi,4),%eax
  ret
  nopl   0x0(%rax)
L26:
  xor    %eax,%eax
  jmp    L35
```

assistant: ```c
int REVbase_hash(unsigned char a, int b) {
  int base_status = 0;
  switch (a) {
  case 'A':
  case 'M':
  case 'R':
    base_status = 1;
  case 'W':
    a = 3;
    break;
  case 'C':
  case 'Y':
    base_status = 1;
  case 'S':
    a = 2;
    break;
  case 'G':
    a = 1;
    break;
  case 'T':
    base_status = 1;
  case 'K':
    a = 0;
    break;
  case 'N':
    base_status = 1;
    a = 3;
    break;
  default:
    base_status = 2;
    a = 3;
  }
  b = b << 2;
  b = b + a;
  return b;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<REVbase_hash>:
  endbr64
  lea    -0x43(%rdi),%ecx
  cmp    $0x16,%cl
  ja     L25
  mov    $0x1,%eax
  shl    %cl,%rax
  test   $0x410001,%eax
  jne    L11
  test   $0x20100,%eax
  jne    L36
  xor    %eax,%eax
  cmp    $0x4,%cl
  setne  %al
  lea    0x1(%rax,%rax,1),%eax
L29:
  lea    (%rax,%rsi,4),%eax
  ret
  nopw   0x0(%rax,%rax,1)
L25:
  mov    $0x3,%eax
  lea    (%rax,%rsi,4),%eax
  ret
  nopl   0x0(%rax)
L11:
  mov    $0x2,%eax
  lea    (%rax,%rsi,4),%eax
  ret
  nopl   0x0(%rax)
L36:
  xor    %eax,%eax
  jmp    L29
```

assistant: ```c
int REVbase_hash(unsigned char a, int b) {
  int base_status = 0;
  switch (a) {
  case 'A':
  case 'M':
  case 'R':
    base_status = 1;
  case 'W':
    a = 3;
    break;
  case 'C':
  case 'Y':
    base_status = 1;
  case 'S':
    a = 2;
    break;
  case 'G':
    a = 1;
    break;
  case 'T':
    base_status = 1;
  case 'K':
    a = 0;
    break;
  case 'N':
    base_status = 1;
    a = 3;
    break;
  default:
    base_status = 2;
    a = 3;
  }
  b = b << 2;
  b = b + a;
  return b;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<insert_sort>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %esi,-0x2c(%rbp)
  mov    $0x0,%edi
  call   <time@plt>
  mov    %rax,-0x10(%rbp)
  mov    -0x28(%rbp),%rax
  mov    (%rax),%edx
  mov    -0x28(%rbp),%rax
  add    $0x4,%rax
  mov    (%rax),%eax
  cmp    %eax,%edx
  jle    L19
  mov    -0x28(%rbp),%rax
  mov    (%rax),%eax
  mov    %eax,-0x14(%rbp)
  mov    -0x28(%rbp),%rax
  mov    0x4(%rax),%edx
  mov    -0x28(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x28(%rbp),%rax
  lea    0x4(%rax),%rdx
  mov    -0x14(%rbp),%eax
  mov    %eax,(%rdx)
L19:
  movl   $0x1,-0x18(%rbp)
  jmp    L38
L18:
  mov    -0x18(%rbp),%eax
  cltq
  add    $0x1,%rax
  lea    0x0(,%rax,4),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x18(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rcx
  mov    -0x28(%rbp),%rax
  add    %rcx,%rax
  mov    (%rax),%eax
  cmp    %eax,%edx
  jge    L12
  mov    -0x18(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    -0x28(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <insert_sort0@plt>
L12:
  addl   $0x1,-0x18(%rbp)
L38:
  mov    -0x18(%rbp),%eax
  add    $0x1,%eax
  cmp    %eax,-0x2c(%rbp)
  jg     L18
  mov    $0x0,%edi
  call   <time@plt>
  mov    %rax,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  mov    %eax,%edx
  mov    -0x10(%rbp),%rax
  mov    %eax,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  leave
  ret
```

assistant: ```c
int insert_sort(int *arr, int len) {
  time_t t_old, t_new;
  t_old = time(NULL);
  if (arr[0] > arr[1]) {
    int tmp = arr[0];
    arr[0] = arr[1];
    arr[1] = tmp;
  }
  int i = 1;
  for (; i + 1 < len; i++) {
    if (arr[i + 1] < arr[i]) {
      insert_sort0(arr, i + 1);
    }
  }
  t_new = time(NULL);
  return (int)(t_new - t_old);
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<insert_sort>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%rbp
  mov    %esi,%ebx
  mov    $0x0,%edi
  call   <time@plt>
  mov    %rax,%r13
  mov    0x0(%rbp),%eax
  mov    0x4(%rbp),%edx
  cmp    %edx,%eax
  jle    L36
  mov    %edx,0x0(%rbp)
  mov    %eax,0x4(%rbp)
L36:
  cmp    $0x2,%ebx
  jle    L41
  lea    -0x2(%rbx),%r12d
  mov    $0x0,%ebx
  jmp    L17
L37:
  add    $0x1,%rbx
  cmp    %rbx,%r12
  je     L41
L17:
  lea    0x2(%rbx),%esi
  mov    0x4(%rbp,%rbx,4),%eax
  cmp    %eax,0x8(%rbp,%rbx,4)
  jge    L37
  mov    %rbp,%rdi
  call   <insert_sort0@plt>
  jmp    L37
L41:
  mov    $0x0,%edi
  call   <time@plt>
  sub    %r13d,%eax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

assistant: ```c
int insert_sort(int *arr, int len) {
  time_t t_old, t_new;
  t_old = time(NULL);
  if (arr[0] > arr[1]) {
    int tmp = arr[0];
    arr[0] = arr[1];
    arr[1] = tmp;
  }
  int i = 1;
  for (; i + 1 < len; i++) {
    if (arr[i + 1] < arr[i]) {
      insert_sort0(arr, i + 1);
    }
  }
  t_new = time(NULL);
  return (int)(t_new - t_old);
}
```
user: 这段汇编代码用C语言表示是什么样的？

```asm
<insert_sort>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  xor    %edi,%edi
  push   %rbx
  mov    %esi,%ebx
  sub    $0x8,%rsp
  call   <time@plt>
  mov    0x4(%rbp),%edx
  mov    %rax,%r13
  mov    0x0(%rbp),%eax
  cmp    %edx,%eax
  jle    L30
  mov    %edx,0x0(%rbp)
  mov    %eax,0x4(%rbp)
L30:
  cmp    $0x2,%ebx
  jle    L8
  lea    -0x2(%rbx),%r12d
  xor    %ebx,%ebx
  jmp    L36
  nopw   0x0(%rax,%rax,1)
L27:
  add    $0x1,%rbx
  cmp    %rbx,%r12
  je     L8
L36:
  mov    0x4(%rbp,%rbx,4),%eax
  lea    0x2(%rbx),%esi
  cmp    %eax,0x8(%rbp,%rbx,4)
  jge    L27
  mov    %rbp,%rdi
  add    $0x1,%rbx
  call   <insert_sort0@plt>
  cmp    %rbx,%r12
  jne    L36
L8:
  xor    %edi,%edi
  call   <time@plt>
  add    $0x8,%rsp
  pop    %rbx
  sub    %r13d,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

assistant: ```c
int insert_sort(int *arr, int len) {
  time_t t_old, t_new;
  t_old = time(NULL);
  if (arr[0] > arr[1]) {
    int tmp = arr[0];
    arr[0] = arr[1];
    arr[1] = tmp;
  }
  int i = 1;
  for (; i + 1 < len; i++) {
    if (arr[i + 1] < arr[i]) {
      insert_sort0(arr, i + 1);
    }
  }
  t_new = time(NULL);
  return (int)(t_new - t_old);
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<insert_sort>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  xor    %edi,%edi
  push   %rbx
  mov    %esi,%ebx
  sub    $0x8,%rsp
  call   <time@plt>
  movq   0x0(%rbp),%xmm0
  mov    %rax,%r13
  pshufd $0xe5,%xmm0,%xmm2
  movd   %xmm0,%edx
  movd   %xmm2,%eax
  pshufd $0xe1,%xmm0,%xmm1
  cmp    %eax,%edx
  jle    L1
  movq   %xmm1,0x0(%rbp)
L1:
  cmp    $0x2,%ebx
  jle    L54
  lea    -0x2(%rbx),%r12d
  xor    %ebx,%ebx
  jmp    L28
  nopw   0x0(%rax,%rax,1)
L4:
  add    $0x1,%rbx
  cmp    %r12,%rbx
  je     L54
L28:
  mov    0x4(%rbp,%rbx,4),%eax
  lea    0x2(%rbx),%esi
  cmp    %eax,0x8(%rbp,%rbx,4)
  jge    L4
  mov    %rbp,%rdi
  add    $0x1,%rbx
  call   <insert_sort0@plt>
  cmp    %r12,%rbx
  jne    L28
L54:
  xor    %edi,%edi
  call   <time@plt>
  add    $0x8,%rsp
  pop    %rbx
  sub    %r13d,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

assistant: ```c
int insert_sort(int *arr, int len) {
  time_t t_old, t_new;
  t_old = time(NULL);
  if (arr[0] > arr[1]) {
    int tmp = arr[0];
    arr[0] = arr[1];
    arr[1] = tmp;
  }
  int i = 1;
  for (; i + 1 < len; i++) {
    if (arr[i + 1] < arr[i]) {
      insert_sort0(arr, i + 1);
    }
  }
  t_new = time(NULL);
  return (int)(t_new - t_old);
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<canontoken>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    -0x28(%rbp),%rax
  mov    %rax,-0x10(%rbp)
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x14(%rbp)
  mov    D20(%rip),%eax
  cmp    %eax,-0x14(%rbp)
  jl     L36
  mov    -0x14(%rbp),%eax
  add    $0xb,%eax
  mov    %eax,D42(%rip)
  mov    D42(%rip),%edx
  mov    D42(%rip),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <grealloc@plt>
  mov    %rax,D21(%rip)
  mov    D21(%rip),%rax
  test   %rax,%rax
  jne    L36
  mov    $0x0,%eax
  jmp    L55
L36:
  mov    D21(%rip),%rax
  mov    %rax,-0x8(%rbp)
  jmp    L50
L52:
  movzbl -0x15(%rbp),%eax
  mov    %eax,%edi
  call   <isupper@plt>
  test   %rax,%rax
  je     L45
  movzbl -0x15(%rbp),%eax
  mov    %eax,%edi
  call   <tolower@plt>
  mov    %al,-0x15(%rbp)
L45:
  mov    -0x8(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  movzbl -0x15(%rbp),%edx
  mov    %dl,(%rax)
L50:
  mov    -0x10(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x10(%rbp)
  movzbl (%rax),%eax
  mov    %al,-0x15(%rbp)
  cmpb   $0x0,-0x15(%rbp)
  jne    L52
  mov    -0x8(%rbp),%rax
  movb   $0x0,(%rax)
  mov    D21(%rip),%rax
L55:
  leave
  ret
```

assistant: ```c
char *canontoken(char *str) {
  static unsigned char *canon;
  static int allocated;
  unsigned char c, *p, *q;
  int len;
  p = (unsigned char *)str;
  len = strlen(str);
  if (len >= allocated) {
    allocated = len + 1 + 10;
    canon = grealloc(canon, allocated);
    if (!canon)
      return NULL;
  }
  q = (unsigned char *)canon;
  while ((c = *p++)) {
    if (isupper(c))
      c = tolower(c);
    *q++ = c;
  }
  *q = '\0';
  return (char *)canon;
}
```
user: 这段汇编代码用C语言表示是什么样的?

```asm
<canontoken>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%rbx
  call   <strlen@plt>
  cmp    %eax,D36(%rip)
  jle    L69
L2:
  mov    D15(%rip),%rbp
  lea    0x1(%rbx),%r12
  movzbl (%rbx),%ebx
  test   %bl,%bl
  jne    L27
L35:
  movb   $0x0,0x0(%rbp)
  mov    D15(%rip),%rax
L39:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L69:
  lea    0xb(%rax),%esi
  mov    %esi,D4(%rip)
  mov    D15(%rip),%rdi
  call   <grealloc@plt>
  mov    %rax,D4(%rip)
  test   %rax,%rax
  jne    L2
  jmp    L39
L7:
  add    $0x1,%rbp
  mov    %bl,-0x1(%rbp)
  add    $0x1,%r12
  movzbl -0x1(%r12),%ebx
  test   %bl,%bl
  je     L35
L27:
  movzbl %bl,%r13d
  mov    %r13d,%edi
  call   <isupper@plt>
  test   %rax,%rax
  je     L7
  mov    %r13d,%edi
  call   <tolower@plt>
  mov    %eax,%ebx
  jmp    L7
```

assistant: ```c
char *canontoken(char *str) {
  static unsigned char *canon;
  static int allocated;
  unsigned char c, *p, *q;
  int len;
  p = (unsigned char *)str;
  len = strlen(str);
  if (len >= allocated) {
    allocated = len + 1 + 10;
    canon = grealloc(canon, allocated);
    if (!canon)
      return NULL;
  }
  q = (unsigned char *)canon;
  while ((c = *p++)) {
    if (isupper(c))
      c = tolower(c);
    *q++ = c;
  }
  *q = '\0';
  return (char *)canon;
}
```