ylfeng/ReF-Decompile-dataset huggingface dataset:
user: 这段汇编代码用C语言表示是什么样的?

```asm
<f5>:
  endbr64
  mov    $0x2c,%eax
  ret
```

assistant: ```c
int f5(void) {
  int v5i = 6, v5j = 7, v5k = 9, v5l = 0, v5n = 0, v5p = 0;
#pragma omp parallel
  {
#pragma omp master
    v5p++;
#pragma omp sections private(v5i) firstprivate(v5k) reduction(+ : v5l)
    {
#pragma omp section
      {
        int v5m = v5j + v5k;
        v5i = 8;
        v5k = 10;
        v5l++;
        v5n = v5m + v5i;
      }
#pragma omp section
      {
        int v5o = v5j + v5k;
        v5i = 10;
        v5k = 11;
        v5l++;
      }
    }
  }
  return v5i + v5j + v5l + v5n + v5p;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<mem_put_be24_as_int>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  mov    -0x18(%rbp),%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x1c(%rbp),%eax
  sar    $0x10,%eax
  mov    %eax,%edx
  mov    -0x8(%rbp),%rax
  mov    %dl,(%rax)
  mov    -0x1c(%rbp),%eax
  sar    $0x8,%eax
  mov    %eax,%edx
  mov    -0x8(%rbp),%rax
  add    $0x1,%rax
  mov    %dl,(%rax)
  mov    -0x8(%rbp),%rax
  add    $0x2,%rax
  mov    -0x1c(%rbp),%edx
  mov    %dl,(%rax)
  nop
  pop    %rbp
  ret
```

assistant: ```c
void mem_put_be24_as_int(void *vmem, int val) {
  unsigned char *mem = (unsigned char *)vmem;
  mem[0] = (val >> 16) & 0xff;
  mem[1] = (val >> 8) & 0xff;
  mem[2] = (val >> 0) & 0xff;
}
```
user: 这段汇编代码用C语言表示是什么样的？

```asm
<mem_put_be24_as_int>:
  endbr64
  mov    %esi,%eax
  mov    %esi,%edx
  sar    $0x10,%edx
  mov    %dl,(%rdi)
  movzbl %ah,%ecx
  mov    %cl,0x1(%rdi)
  mov    %sil,0x2(%rdi)
  ret
```

assistant: ```c
void mem_put_be24_as_int(void *vmem, int val) {
  unsigned char *mem = (unsigned char *)vmem;
  mem[0] = (val >> 16) & 0xff;
  mem[1] = (val >> 8) & 0xff;
  mem[2] = (val >> 0) & 0xff;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<mem_put_be24_as_int>:
  endbr64
  mov    %esi,%eax
  rol    $0x8,%si
  sar    $0x10,%eax
  mov    %si,0x1(%rdi)
  mov    %al,(%rdi)
  ret
```

assistant: ```c
void mem_put_be24_as_int(void *vmem, int val) {
  unsigned char *mem = (unsigned char *)vmem;
  mem[0] = (val >> 16) & 0xff;
  mem[1] = (val >> 8) & 0xff;
  mem[2] = (val >> 0) & 0xff;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<mem_put_be24_as_int>:
  endbr64
  mov    %esi,%eax
  rol    $0x8,%si
  sar    $0x10,%eax
  mov    %si,0x1(%rdi)
  mov    %al,(%rdi)
  ret
```

assistant: ```c
void mem_put_be24_as_int(void *vmem, int val) {
  unsigned char *mem = (unsigned char *)vmem;
  mem[0] = (val >> 16) & 0xff;
  mem[1] = (val >> 8) & 0xff;
  mem[2] = (val >> 0) & 0xff;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<convert_trailing_zeros_to_spaces>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %eax,-0x4(%rbp)
  movl   $0x0,-0xc(%rbp)
  jmp    L96
L38:
  mov    -0xc(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x2e,%al
  jne    L40
  mov    -0x4(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,-0x8(%rbp)
  jmp    L41
L13:
  mov    -0x8(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x2e,%al
  je     L20
  mov    -0x8(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x30,%al
  jne    L6
L20:
  mov    -0x8(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0x2e,%al
  jne    L51
  mov    -0x8(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movb   $0x20,(%rax)
  jmp    L55
L51:
  mov    -0x8(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movb   $0x20,(%rax)
  subl   $0x1,-0x8(%rbp)
L41:
  cmpl   $0x0,-0x8(%rbp)
  jns    L13
  jmp    L89
L6:
  nop
L55:
  jmp    L89
L40:
  addl   $0x1,-0xc(%rbp)
L96:
  mov    -0xc(%rbp),%eax
  cmp    -0x4(%rbp),%eax
  jl     L38
  nop
L89:
  nop
  leave
  ret
```

assistant: ```c
void convert_trailing_zeros_to_spaces(char *str) {
  int i, j, len;
  len = strlen(str);
  for (i = 0; i < len; i++) {
    if (str[i] == '.') {
      for (j = (len - 1); j >= 0; j--) {
        if ((str[j] != '.') && (str[j] != '0')) {
          break;
        }
        if (str[j] == '.') {
          str[j] = ' ';
          break;
        }
        str[j] = ' ';
      }
      break;
    }
  }
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<convert_trailing_zeros_to_spaces>:
  endbr64
  push   %rbx
  mov    %rdi,%rbx
  call   <strlen@plt>
  test   %eax,%eax
  jle    L4
  lea    -0x1(%rax),%esi
  lea    0x1(%rbx,%rsi,1),%rcx
  mov    %rbx,%rdx
L46:
  cmpb   $0x2e,(%rdx)
  je     L33
  add    $0x1,%rdx
  cmp    %rcx,%rdx
  jne    L46
L4:
  pop    %rbx
  ret
L33:
  lea    -0x1(%rax),%edx
  movslq %edx,%rdx
  add    %rbx,%rdx
  cltq
  lea    -0x2(%rbx,%rax,1),%rdi
  sub    %rsi,%rdi
L13:
  movzbl (%rdx),%eax
  lea    -0x2e(%rax),%ecx
  test   $0xfd,%cl
  jne    L4
  cmp    $0x2e,%al
  je     L44
  movb   $0x20,(%rdx)
  sub    $0x1,%rdx
  cmp    %rdi,%rdx
  jne    L13
  jmp    L4
L44:
  movb   $0x20,(%rdx)
  jmp    L4
```

assistant: ```c
void convert_trailing_zeros_to_spaces(char *str) {
  int i, j, len;
  len = strlen(str);
  for (i = 0; i < len; i++) {
    if (str[i] == '.') {
      for (j = (len - 1); j >= 0; j--) {
        if ((str[j] != '.') && (str[j] != '0')) {
          break;
        }
        if (str[j] == '.') {
          str[j] = ' ';
          break;
        }
        str[j] = ' ';
      }
      break;
    }
  }
}
```
user: 这段汇编代码用C语言表示是什么样的?

```asm
<convert_trailing_zeros_to_spaces>:
  endbr64
  push   %rbx
  mov    %rdi,%rbx
  call   <strlen@plt>
  test   %eax,%eax
  jle    L33
  lea    -0x1(%rax),%edi
  mov    %rbx,%rdx
  mov    %rdi,%rcx
  lea    0x1(%rbx,%rdi,1),%rsi
  jmp    L54
  nopl   0x0(%rax)
L59:
  add    $0x1,%rdx
  cmp    %rsi,%rdx
  je     L33
L54:
  cmpb   $0x2e,(%rdx)
  jne    L59
  cltq
  movslq %ecx,%rdx
  lea    -0x2(%rbx,%rax,1),%rsi
  add    %rbx,%rdx
  sub    %rdi,%rsi
  cs nopw 0x0(%rax,%rax,1)
L25:
  movzbl (%rdx),%eax
  lea    -0x2e(%rax),%ecx
  and    $0xfd,%ecx
  jne    L33
  movb   $0x20,(%rdx)
  cmp    $0x2e,%al
  je     L33
  sub    $0x1,%rdx
  cmp    %rsi,%rdx
  jne    L25
L33:
  pop    %rbx
  ret
```

assistant: ```c
void convert_trailing_zeros_to_spaces(char *str) {
  int i, j, len;
  len = strlen(str);
  for (i = 0; i < len; i++) {
    if (str[i] == '.') {
      for (j = (len - 1); j >= 0; j--) {
        if ((str[j] != '.') && (str[j] != '0')) {
          break;
        }
        if (str[j] == '.') {
          str[j] = ' ';
          break;
        }
        str[j] = ' ';
      }
      break;
    }
  }
}
```
user: 这段汇编代码用C语言表示是什么样的：

```asm
<convert_trailing_zeros_to_spaces>:
  endbr64
  push   %rbx
  mov    %rdi,%rbx
  call   <strlen@plt>
  test   %eax,%eax
  jle    L60
  lea    -0x1(%rax),%edi
  mov    %rbx,%rdx
  mov    %rdi,%rcx
  lea    0x1(%rbx,%rdi,1),%rsi
  jmp    L59
  nopl   0x0(%rax)
L15:
  add    $0x1,%rdx
  cmp    %rsi,%rdx
  je     L60
L59:
  cmpb   $0x2e,(%rdx)
  jne    L15
  cltq
  movslq %ecx,%rdx
  lea    -0x2(%rbx,%rax,1),%rsi
  add    %rbx,%rdx
  sub    %rdi,%rsi
  cs nopw 0x0(%rax,%rax,1)
L63:
  movzbl (%rdx),%eax
  lea    -0x2e(%rax),%ecx
  and    $0xfd,%ecx
  jne    L60
  movb   $0x20,(%rdx)
  cmp    $0x2e,%al
  je     L60
  sub    $0x1,%rdx
  cmp    %rsi,%rdx
  jne    L63
L60:
  pop    %rbx
  ret
```

assistant: ```c
void convert_trailing_zeros_to_spaces(char *str) {
  int i, j, len;
  len = strlen(str);
  for (i = 0; i < len; i++) {
    if (str[i] == '.') {
      for (j = (len - 1); j >= 0; j--) {
        if ((str[j] != '.') && (str[j] != '0')) {
          break;
        }
        if (str[j] == '.') {
          str[j] = ' ';
          break;
        }
        str[j] = ' ';
      }
      break;
    }
  }
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<ZERO_EXTEND_L_W>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %edi,-0x4(%rbp)
  mov    $0xf,%edi
  call   <addbyte@plt>
  mov    $0xb7,%edi
  call   <addbyte@plt>
  mov    -0x4(%rbp),%eax
  or     $0xc0,%al
  mov    %eax,%edx
  mov    -0x4(%rbp),%eax
  shl    $0x3,%eax
  or     %edx,%eax
  mov    %eax,%edi
  call   <addbyte@plt>
  mov    -0x4(%rbp),%eax
  leave
  ret
```

assistant: ```c
int ZERO_EXTEND_L_W(int reg) {
  addbyte(0x0f);
  addbyte(0xb7);
  addbyte(0xc0 | reg | (reg << 3));
  return reg;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<ZERO_EXTEND_L_W>:
  endbr64
  push   %rbx
  mov    %edi,%ebx
  mov    $0xf,%edi
  call   <addbyte@plt>
  mov    $0xb7,%edi
  call   <addbyte@plt>
  lea    0x0(,%rbx,8),%edi
  or     %ebx,%edi
  or     $0xc0,%dil
  call   <addbyte@plt>
  mov    %ebx,%eax
  pop    %rbx
  ret
```

assistant: ```c
int ZERO_EXTEND_L_W(int reg) {
  addbyte(0x0f);
  addbyte(0xb7);
  addbyte(0xc0 | reg | (reg << 3));
  return reg;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<ZERO_EXTEND_L_W>:
  endbr64
  push   %r12
  mov    %edi,%r12d
  mov    $0xf,%edi
  call   <addbyte@plt>
  mov    $0xb7,%edi
  call   <addbyte@plt>
  lea    0x0(,%r12,8),%edi
  or     %r12d,%edi
  or     $0xc0,%dil
  call   <addbyte@plt>
  mov    %r12d,%eax
  pop    %r12
  ret
```

assistant: ```c
int ZERO_EXTEND_L_W(int reg) {
  addbyte(0x0f);
  addbyte(0xb7);
  addbyte(0xc0 | reg | (reg << 3));
  return reg;
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<ZERO_EXTEND_L_W>:
  endbr64
  push   %r12
  mov    %edi,%r12d
  mov    $0xf,%edi
  call   <addbyte@plt>
  mov    $0xb7,%edi
  call   <addbyte@plt>
  lea    0x0(,%r12,8),%edi
  or     %r12d,%edi
  or     $0xc0,%dil
  call   <addbyte@plt>
  mov    %r12d,%eax
  pop    %r12
  ret
```

assistant: ```c
int ZERO_EXTEND_L_W(int reg) {
  addbyte(0x0f);
  addbyte(0xb7);
  addbyte(0xc0 | reg | (reg << 3));
  return reg;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  movl   $0x1,-0x4(%rbp)
  jmp    L2
L18:
  mov    -0x4(%rbp),%eax
  mov    %eax,%edi
  call   <first_divisor@plt>
  mov    %eax,%esi
  lea    D4(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  addl   $0x1,-0x4(%rbp)
L2:
  cmpl   $0xa,-0x4(%rbp)
  jle    L18
  mov    $0x0,%eax
  leave
  ret
```

tool_calls: name: retrieve_data
arguments: data_tag: D4
data_type: string

tool: D4: %d 


assistant: ```c
int main(void) {
  int i;
  for (i = 1; i < 11; i++)
    printf("%d \n", first_divisor(i));
  return 0;
}
```
user: 这段汇编代码用C语言表示是什么样的？

```asm
<main>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    $0x1,%ebx
  lea    D3(%rip),%rbp
L4:
  mov    %ebx,%edi
  call   <first_divisor@plt>
  mov    %eax,%esi
  mov    %rbp,%rdi
  call   <printf@plt>
  add    $0x1,%ebx
  cmp    $0xb,%ebx
  jne    L4
  mov    $0x0,%eax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
```

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

tool: D3: %d 


assistant: ```c
int main(void) {
  int i;
  for (i = 1; i < 11; i++)
    printf("%d \n", first_divisor(i));
  return 0;
}
```
user: 这段汇编代码用C语言表示是什么样的?

```asm
<main>:
  endbr64
  push   %rbp
  lea    D9(%rip),%rbp
  push   %rbx
  mov    $0x1,%ebx
  sub    $0x8,%rsp
  cs nopw 0x0(%rax,%rax,1)
L3:
  mov    %ebx,%edi
  add    $0x1,%ebx
  call   <first_divisor@plt>
  mov    %rbp,%rdi
  mov    %eax,%esi
  call   <printf@plt>
  cmp    $0xb,%ebx
  jne    L3
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  ret
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D9
type_guessed: string

tool: D9: %d 


assistant: ```c
int main(void) {
  int i;
  for (i = 1; i < 11; i++)
    printf("%d \n", first_divisor(i));
  return 0;
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<main>:
  endbr64
  push   %rbp
  lea    D8(%rip),%rbp
  push   %rbx
  mov    $0x1,%ebx
  sub    $0x8,%rsp
  cs nopw 0x0(%rax,%rax,1)
L4:
  mov    %ebx,%edi
  add    $0x1,%ebx
  call   <first_divisor@plt>
  mov    %rbp,%rdi
  mov    %eax,%esi
  call   <printf@plt>
  cmp    $0xb,%ebx
  jne    L4
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  ret
```

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

tool: D8: %d 


assistant: ```c
int main(void) {
  int i;
  for (i = 1; i < 11; i++)
    printf("%d \n", first_divisor(i));
  return 0;
}
```
user: What is the c source code of the assembly code below?

```asm
<nl>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %edi,-0x14(%rbp)
  movl   $0x0,-0x4(%rbp)
  jmp    L17
L15:
  mov    $0x2d,%edi
  call   <putchar@plt>
  addl   $0x1,-0x4(%rbp)
L17:
  mov    -0x4(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jl     L15
  mov    $0xa,%edi
  call   <putchar@plt>
  nop
  leave
  ret
```

assistant: ```c
void nl(int k) {
  int j;
  for (j = 0; j < k; j++)
    putchar('-');
  putchar('\n');
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<nl>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  test   %edi,%edi
  jle    L8
  mov    %edi,%ebp
  mov    $0x0,%ebx
L5:
  mov    $0x2d,%edi
  call   <putchar@plt>
  add    $0x1,%ebx
  cmp    %ebx,%ebp
  jne    L5
L8:
  mov    $0xa,%edi
  call   <putchar@plt>
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
```

assistant: ```c
void nl(int k) {
  int j;
  for (j = 0; j < k; j++)
    putchar('-');
  putchar('\n');
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<nl>:
  endbr64
  test   %edi,%edi
  jle    L13
  push   %rbp
  mov    %edi,%ebp
  push   %rbx
  xor    %ebx,%ebx
  sub    $0x8,%rsp
  nopw   0x0(%rax,%rax,1)
L8:
  mov    $0x2d,%edi
  add    $0x1,%ebx
  call   <putchar@plt>
  cmp    %ebx,%ebp
  jne    L8
  add    $0x8,%rsp
  mov    $0xa,%edi
  pop    %rbx
  pop    %rbp
  jmp    1050 <putchar@plt>
  nopl   0x0(%rax)
L13:
  mov    $0xa,%edi
  jmp    1050 <putchar@plt>
```

assistant: ```c
void nl(int k) {
  int j;
  for (j = 0; j < k; j++)
    putchar('-');
  putchar('\n');
}
```
user: Translate the below assembly code into C programming language:

```asm
<nl>:
  endbr64
  test   %edi,%edi
  jle    L8
  push   %rbp
  mov    %edi,%ebp
  push   %rbx
  xor    %ebx,%ebx
  sub    $0x8,%rsp
  nopw   0x0(%rax,%rax,1)
L1:
  mov    $0x2d,%edi
  add    $0x1,%ebx
  call   <putchar@plt>
  cmp    %ebx,%ebp
  jne    L1
  add    $0x8,%rsp
  mov    $0xa,%edi
  pop    %rbx
  pop    %rbp
  jmp    1050 <putchar@plt>
  nopl   0x0(%rax)
L8:
  mov    $0xa,%edi
  jmp    1050 <putchar@plt>
```

assistant: ```c
void nl(int k) {
  int j;
  for (j = 0; j < k; j++)
    putchar('-');
  putchar('\n');
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<do_set_color>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %edi,-0x24(%rbp)
  mov    %esi,%eax
  mov    %al,-0x28(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  cmpl   $0x0,-0x24(%rbp)
  js     L49
  mov    $0x3b,%edi
  call   <term_add_byte@plt>
  movsbl -0x28(%rbp),%eax
  mov    %eax,%edi
  call   <term_add_byte@plt>
  cmpl   $0x7,-0x24(%rbp)
  jg     L35
  mov    -0x24(%rbp),%eax
  add    $0x30,%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <term_add_byte@plt>
  jmp    L58
L35:
  cmpl   $0xff,-0x24(%rbp)
  jg     L21
  mov    $0x4,%esi
  lea    D16(%rip),%rax
  mov    %rax,%rdi
  call   <term_add_bytes@plt>
  mov    -0x24(%rbp),%eax
  mov    %eax,%edi
  call   <term_add_uint@plt>
  jmp    L58
L21:
  lea    -0xc(%rbp),%rcx
  lea    -0x10(%rbp),%rdx
  lea    -0x14(%rbp),%rsi
  mov    -0x24(%rbp),%eax
  mov    %eax,%edi
  call   <color_split_rgb@plt>
  mov    $0x4,%esi
  lea    D11(%rip),%rax
  mov    %rax,%rdi
  call   <term_add_bytes@plt>
  mov    -0x14(%rbp),%eax
  mov    %eax,%edi
  call   <term_add_uint@plt>
  mov    $0x3b,%edi
  call   <term_add_byte@plt>
  mov    -0x10(%rbp),%eax
  mov    %eax,%edi
  call   <term_add_uint@plt>
  mov    $0x3b,%edi
  call   <term_add_byte@plt>
  mov    -0xc(%rbp),%eax
  mov    %eax,%edi
  call   <term_add_uint@plt>
  jmp    L58
L49:
  nop
L58:
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L60
  call   <__stack_chk_fail@plt>
L60:
  leave
  ret
```

tool_calls: name: parse_data
arguments: data_tag: D16
data_type: string
name: parse_data
arguments: data_tag: D11
data_type: string

tool: D16: 8;5;

tool: D11: 8;2;

assistant: ```c
void do_set_color(int32_t color, char ch) {
  if (color < 0) {
    return;
  }
  term_add_byte(';');
  term_add_byte(ch);
  if ((color < 8)) {
    term_add_byte('0' + color);
  } else if (color < 256) {
    term_add_bytes("8;5;", (sizeof(""
                                   "8;5;"
                                   "") -
                            1));
    term_add_uint(color);
  } else {
    uint8_t r, g, b;
    color_split_rgb(color, &r, &g, &b);
    term_add_bytes("8;2;", (sizeof(""
                                   "8;2;"
                                   "") -
                            1));
    term_add_uint(r);
    term_add_byte(';');
    term_add_uint(g);
    term_add_byte(';');
    term_add_uint(b);
  }
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<do_set_color>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  test   %edi,%edi
  js     L43
  mov    %edi,%ebx
  mov    %esi,%ebp
  mov    $0x3b,%edi
  call   <term_add_byte@plt>
  movsbl %bpl,%edi
  call   <term_add_byte@plt>
  cmp    $0x7,%ebx
  jle    L31
  cmp    $0xff,%ebx
  jg     L39
  mov    $0x4,%esi
  lea    D15(%rip),%rdi
  call   <term_add_bytes@plt>
  mov    %ebx,%edi
  call   <term_add_uint@plt>
L43:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L38
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  ret
L31:
  lea    0x30(%rbx),%edi
  movsbl %dil,%edi
  call   <term_add_byte@plt>
  jmp    L43
L39:
  lea    0x14(%rsp),%rcx
  lea    0x10(%rsp),%rdx
  lea    0xc(%rsp),%rsi
  mov    %ebx,%edi
  call   <color_split_rgb@plt>
  mov    $0x4,%esi
  lea    D5(%rip),%rdi
  call   <term_add_bytes@plt>
  mov    0xc(%rsp),%edi
  call   <term_add_uint@plt>
  mov    $0x3b,%edi
  call   <term_add_byte@plt>
  mov    0x10(%rsp),%edi
  call   <term_add_uint@plt>
  mov    $0x3b,%edi
  call   <term_add_byte@plt>
  mov    0x14(%rsp),%edi
  call   <term_add_uint@plt>
  jmp    L43
L38:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D15
type_guessed: string
name: extract_symbolic_data
arguments: data_label: D5
type_guessed: string

tool: D15: 8;5;

tool: D5: 8;2;

assistant: ```c
void do_set_color(int32_t color, char ch) {
  if (color < 0) {
    return;
  }
  term_add_byte(';');
  term_add_byte(ch);
  if ((color < 8)) {
    term_add_byte('0' + color);
  } else if (color < 256) {
    term_add_bytes("8;5;", (sizeof(""
                                   "8;5;"
                                   "") -
                            1));
    term_add_uint(color);
  } else {
    uint8_t r, g, b;
    color_split_rgb(color, &r, &g, &b);
    term_add_bytes("8;2;", (sizeof(""
                                   "8;2;"
                                   "") -
                            1));
    term_add_uint(r);
    term_add_byte(';');
    term_add_uint(g);
    term_add_byte(';');
    term_add_uint(b);
  }
}
```
user: 这段汇编代码用C语言表示是什么样的?

```asm
<do_set_color>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  test   %edi,%edi
  js     L6
  mov    %edi,%ebp
  mov    %esi,%ebx
  mov    $0x3b,%edi
  call   <term_add_byte@plt>
  movsbl %bl,%edi
  call   <term_add_byte@plt>
  cmp    $0x7,%ebp
  jle    L35
  cmp    $0xff,%ebp
  jg     L30
  mov    $0x4,%esi
  lea    D1(%rip),%rdi
  call   <term_add_bytes@plt>
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L19
  add    $0x28,%rsp
  mov    %ebp,%edi
  pop    %rbx
  pop    %rbp
  jmp    10d0 <term_add_uint@plt>
  nopl   0x0(%rax,%rax,1)
L30:
  lea    0x14(%rsp),%rcx
  lea    0x10(%rsp),%rdx
  mov    %ebp,%edi
  lea    0xc(%rsp),%rsi
  call   <color_split_rgb@plt>
  mov    $0x4,%esi
  lea    D4(%rip),%rdi
  call   <term_add_bytes@plt>
  mov    0xc(%rsp),%edi
  call   <term_add_uint@plt>
  mov    $0x3b,%edi
  call   <term_add_byte@plt>
  mov    0x10(%rsp),%edi
  call   <term_add_uint@plt>
  mov    $0x3b,%edi
  call   <term_add_byte@plt>
  mov    0x14(%rsp),%edi
  call   <term_add_uint@plt>
L6:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L19
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  ret
  nopl   (%rax)
L35:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L19
  lea    0x30(%rbp),%edi
  add    $0x28,%rsp
  pop    %rbx
  movzbl %dil,%edi
  pop    %rbp
  jmp    10a0 <term_add_byte@plt>
L19:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: label: D1
datatype: string
name: read_data
arguments: label: D4
datatype: string

tool: D1: 8;5;

tool: D4: 8;2;

assistant: ```c
void do_set_color(int32_t color, char ch) {
  if (color < 0) {
    return;
  }
  term_add_byte(';');
  term_add_byte(ch);
  if ((color < 8)) {
    term_add_byte('0' + color);
  } else if (color < 256) {
    term_add_bytes("8;5;", (sizeof(""
                                   "8;5;"
                                   "") -
                            1));
    term_add_uint(color);
  } else {
    uint8_t r, g, b;
    color_split_rgb(color, &r, &g, &b);
    term_add_bytes("8;2;", (sizeof(""
                                   "8;2;"
                                   "") -
                            1));
    term_add_uint(r);
    term_add_byte(';');
    term_add_uint(g);
    term_add_byte(';');
    term_add_uint(b);
  }
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<do_set_color>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  test   %edi,%edi
  js     L40
  mov    %edi,%ebp
  mov    %esi,%ebx
  mov    $0x3b,%edi
  call   <term_add_byte@plt>
  movsbl %bl,%edi
  call   <term_add_byte@plt>
  cmp    $0x7,%ebp
  jle    L37
  cmp    $0xff,%ebp
  jg     L34
  mov    $0x4,%esi
  lea    D14(%rip),%rdi
  call   <term_add_bytes@plt>
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L48
  add    $0x28,%rsp
  mov    %ebp,%edi
  pop    %rbx
  pop    %rbp
  jmp    10d0 <term_add_uint@plt>
  nopl   0x0(%rax,%rax,1)
L34:
  lea    0x14(%rsp),%rcx
  lea    0x10(%rsp),%rdx
  mov    %ebp,%edi
  lea    0xc(%rsp),%rsi
  call   <color_split_rgb@plt>
  mov    $0x4,%esi
  lea    D8(%rip),%rdi
  call   <term_add_bytes@plt>
  mov    0xc(%rsp),%edi
  call   <term_add_uint@plt>
  mov    $0x3b,%edi
  call   <term_add_byte@plt>
  mov    0x10(%rsp),%edi
  call   <term_add_uint@plt>
  mov    $0x3b,%edi
  call   <term_add_byte@plt>
  mov    0x14(%rsp),%edi
  call   <term_add_uint@plt>
L40:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L48
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  ret
  nopl   (%rax)
L37:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L48
  lea    0x30(%rbp),%edi
  add    $0x28,%rsp
  pop    %rbx
  movzbl %dil,%edi
  pop    %rbp
  jmp    10a0 <term_add_byte@plt>
L48:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: tag: D14
type_guessed: string
name: extract_symbolic_data
arguments: tag: D8
type_guessed: string

tool: D14: 8;5;

tool: D8: 8;2;

assistant: ```c
void do_set_color(int32_t color, char ch) {
  if (color < 0) {
    return;
  }
  term_add_byte(';');
  term_add_byte(ch);
  if ((color < 8)) {
    term_add_byte('0' + color);
  } else if (color < 256) {
    term_add_bytes("8;5;", (sizeof(""
                                   "8;5;"
                                   "") -
                            1));
    term_add_uint(color);
  } else {
    uint8_t r, g, b;
    color_split_rgb(color, &r, &g, &b);
    term_add_bytes("8;2;", (sizeof(""
                                   "8;2;"
                                   "") -
                            1));
    term_add_uint(r);
    term_add_byte(';');
    term_add_uint(g);
    term_add_byte(';');
    term_add_uint(b);
  }
}
```