ylfeng/ReF-Decompile-dataset huggingface dataset:
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<_i2c_write_read>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  mov    %rdx,-0x28(%rbp)
  mov    %ecx,-0x20(%rbp)
  mov    %r8d,-0x2c(%rbp)
  cmpl   $0x0,-0x1c(%rbp)
  je     L19
  mov    -0x2c(%rbp),%eax
  mov    %eax,%edi
  call   <_i2c_start@plt>
  mov    $0x7d3c,%edi
  call   <_i2c_get@plt>
  and    $0xf0,%ah
  mov    %eax,-0x4(%rbp)
  mov    -0x1c(%rbp),%eax
  shl    $0x8,%eax
  or     %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  mov    %eax,%esi
  mov    $0x7d3c,%edi
  call   <_i2c_set@plt>
  mov    $0x7d40,%edi
  call   <_i2c_get@plt>
  mov    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  mov    %eax,%esi
  mov    $0x7d40,%edi
  call   <_i2c_set@plt>
  mov    $0xa0,%esi
  mov    $0x7d44,%edi
  call   <_i2c_set@plt>
  mov    -0x1c(%rbp),%edx
  mov    -0x18(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <_i2c_write@plt>
  mov    $0x7d38,%edi
  call   <_i2c_get@plt>
  and    $0xfffffff8,%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  or     $0x3,%eax
  mov    %eax,%esi
  mov    $0x7d38,%edi
  call   <_i2c_set@plt>
  mov    $0x0,%eax
  call   <_i2c_wait@plt>
L19:
  cmpl   $0x0,-0x20(%rbp)
  je     L9
  mov    $0xa1,%esi
  mov    $0x7d44,%edi
  call   <_i2c_set@plt>
  mov    $0x7d3c,%edi
  call   <_i2c_get@plt>
  and    $0xf0,%ah
  mov    %eax,-0x4(%rbp)
  mov    -0x20(%rbp),%eax
  shl    $0x8,%eax
  or     %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  mov    %eax,%esi
  mov    $0x7d3c,%edi
  call   <_i2c_set@plt>
  mov    $0x7d38,%edi
  call   <_i2c_get@plt>
  and    $0xfffffff8,%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  or     $0x7,%eax
  mov    %eax,%esi
  mov    $0x7d38,%edi
  call   <_i2c_set@plt>
  mov    $0x0,%eax
  call   <_i2c_wait@plt>
  mov    -0x20(%rbp),%edx
  mov    -0x28(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <_i2c_read@plt>
  mov    $0x0,%eax
  call   <_i2c_stop@plt>
L9:
  nop
  leave
  ret
```

assistant: ```c
void _i2c_write_read(unsigned char *write_buf, int num_write, unsigned char *read_buf, int num_read, unsigned int connector) {
  unsigned int tmp;
  if (num_write) {
    _i2c_start(connector);
    tmp = _i2c_get(0x7d3c) & (~(0xf << 8));
    tmp |= num_write << 8;
    _i2c_set(0x7d3c, tmp);
    tmp = _i2c_get(0x7d40);
    _i2c_set(0x7d40, tmp);
    _i2c_set(0x7d44, 0xA0);
    _i2c_write(write_buf, num_write);
    tmp = _i2c_get(0x7d38) & (~0x7);
    _i2c_set(0x7d38, tmp | (1 << 0) | (1 << 1));
    _i2c_wait();
  }
  if (num_read) {
    _i2c_set(0x7d44, 0xA0 | 1);
    tmp = _i2c_get(0x7d3c) & (~(0xf << 8));
    tmp |= num_read << 8;
    _i2c_set(0x7d3c, tmp);
    tmp = _i2c_get(0x7d38) & (~0x7);
    _i2c_set(0x7d38, tmp | (1 << 0) | (1 << 1) | (1 << 2));
    _i2c_wait();
    _i2c_read(read_buf, num_read);
    _i2c_stop();
  }
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<_i2c_write_read>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdx,%r12
  mov    %ecx,%ebx
  test   %esi,%esi
  jne    L24
L2:
  test   %ebx,%ebx
  jne    L10
L0:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L24:
  mov    %rdi,%r13
  mov    %esi,%ebp
  mov    %r8d,%edi
  call   <_i2c_start@plt>
  mov    $0x7d3c,%edi
  call   <_i2c_get@plt>
  and    $0xf0,%ah
  mov    %ebp,%esi
  shl    $0x8,%esi
  or     %eax,%esi
  mov    $0x7d3c,%edi
  call   <_i2c_set@plt>
  mov    $0x7d40,%edi
  call   <_i2c_get@plt>
  mov    %eax,%esi
  mov    $0x7d40,%edi
  call   <_i2c_set@plt>
  mov    $0xa0,%esi
  mov    $0x7d44,%edi
  call   <_i2c_set@plt>
  mov    %ebp,%esi
  mov    %r13,%rdi
  call   <_i2c_write@plt>
  mov    $0x7d38,%edi
  call   <_i2c_get@plt>
  and    $0xfffffff8,%eax
  mov    %eax,%esi
  or     $0x3,%esi
  mov    $0x7d38,%edi
  call   <_i2c_set@plt>
  mov    $0x0,%eax
  call   <_i2c_wait@plt>
  jmp    L2
L10:
  mov    $0xa1,%esi
  mov    $0x7d44,%edi
  call   <_i2c_set@plt>
  mov    $0x7d3c,%edi
  call   <_i2c_get@plt>
  and    $0xf0,%ah
  mov    %ebx,%esi
  shl    $0x8,%esi
  or     %eax,%esi
  mov    $0x7d3c,%edi
  call   <_i2c_set@plt>
  mov    $0x7d38,%edi
  call   <_i2c_get@plt>
  or     $0x7,%eax
  mov    %eax,%esi
  mov    $0x7d38,%edi
  call   <_i2c_set@plt>
  mov    $0x0,%eax
  call   <_i2c_wait@plt>
  mov    %ebx,%esi
  mov    %r12,%rdi
  call   <_i2c_read@plt>
  mov    $0x0,%eax
  call   <_i2c_stop@plt>
  jmp    L0
```

assistant: ```c
void _i2c_write_read(unsigned char *write_buf, int num_write, unsigned char *read_buf, int num_read, unsigned int connector) {
  unsigned int tmp;
  if (num_write) {
    _i2c_start(connector);
    tmp = _i2c_get(0x7d3c) & (~(0xf << 8));
    tmp |= num_write << 8;
    _i2c_set(0x7d3c, tmp);
    tmp = _i2c_get(0x7d40);
    _i2c_set(0x7d40, tmp);
    _i2c_set(0x7d44, 0xA0);
    _i2c_write(write_buf, num_write);
    tmp = _i2c_get(0x7d38) & (~0x7);
    _i2c_set(0x7d38, tmp | (1 << 0) | (1 << 1));
    _i2c_wait();
  }
  if (num_read) {
    _i2c_set(0x7d44, 0xA0 | 1);
    tmp = _i2c_get(0x7d3c) & (~(0xf << 8));
    tmp |= num_read << 8;
    _i2c_set(0x7d3c, tmp);
    tmp = _i2c_get(0x7d38) & (~0x7);
    _i2c_set(0x7d38, tmp | (1 << 0) | (1 << 1) | (1 << 2));
    _i2c_wait();
    _i2c_read(read_buf, num_read);
    _i2c_stop();
  }
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<_i2c_write_read>:
  endbr64
  push   %r14
  push   %r13
  mov    %rdx,%r13
  push   %r12
  push   %rbp
  mov    %ecx,%ebp
  sub    $0x8,%rsp
  test   %esi,%esi
  jne    L15
  test   %ebp,%ebp
  jne    L7
L17:
  add    $0x8,%rsp
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopl   0x0(%rax)
L15:
  mov    %rdi,%r14
  mov    %r8d,%edi
  mov    %esi,%r12d
  call   <_i2c_start@plt>
  mov    $0x7d3c,%edi
  call   <_i2c_get@plt>
  mov    %r12d,%esi
  mov    $0x7d3c,%edi
  and    $0xf0,%ah
  shl    $0x8,%esi
  or     %eax,%esi
  call   <_i2c_set@plt>
  mov    $0x7d40,%edi
  call   <_i2c_get@plt>
  mov    $0x7d40,%edi
  mov    %eax,%esi
  call   <_i2c_set@plt>
  mov    $0xa0,%esi
  mov    $0x7d44,%edi
  call   <_i2c_set@plt>
  mov    %r12d,%esi
  mov    %r14,%rdi
  call   <_i2c_write@plt>
  mov    $0x7d38,%edi
  call   <_i2c_get@plt>
  mov    $0x7d38,%edi
  and    $0xfffffff8,%eax
  mov    %eax,%esi
  or     $0x3,%esi
  call   <_i2c_set@plt>
  xor    %eax,%eax
  call   <_i2c_wait@plt>
  test   %ebp,%ebp
  je     L17
L7:
  mov    $0xa1,%esi
  mov    $0x7d44,%edi
  call   <_i2c_set@plt>
  mov    $0x7d3c,%edi
  call   <_i2c_get@plt>
  mov    %ebp,%esi
  mov    $0x7d3c,%edi
  and    $0xf0,%ah
  shl    $0x8,%esi
  or     %eax,%esi
  call   <_i2c_set@plt>
  mov    $0x7d38,%edi
  call   <_i2c_get@plt>
  mov    $0x7d38,%edi
  or     $0x7,%eax
  mov    %eax,%esi
  call   <_i2c_set@plt>
  xor    %eax,%eax
  call   <_i2c_wait@plt>
  mov    %ebp,%esi
  mov    %r13,%rdi
  call   <_i2c_read@plt>
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  jmp    1100 <_i2c_stop@plt>
```

assistant: ```c
void _i2c_write_read(unsigned char *write_buf, int num_write, unsigned char *read_buf, int num_read, unsigned int connector) {
  unsigned int tmp;
  if (num_write) {
    _i2c_start(connector);
    tmp = _i2c_get(0x7d3c) & (~(0xf << 8));
    tmp |= num_write << 8;
    _i2c_set(0x7d3c, tmp);
    tmp = _i2c_get(0x7d40);
    _i2c_set(0x7d40, tmp);
    _i2c_set(0x7d44, 0xA0);
    _i2c_write(write_buf, num_write);
    tmp = _i2c_get(0x7d38) & (~0x7);
    _i2c_set(0x7d38, tmp | (1 << 0) | (1 << 1));
    _i2c_wait();
  }
  if (num_read) {
    _i2c_set(0x7d44, 0xA0 | 1);
    tmp = _i2c_get(0x7d3c) & (~(0xf << 8));
    tmp |= num_read << 8;
    _i2c_set(0x7d3c, tmp);
    tmp = _i2c_get(0x7d38) & (~0x7);
    _i2c_set(0x7d38, tmp | (1 << 0) | (1 << 1) | (1 << 2));
    _i2c_wait();
    _i2c_read(read_buf, num_read);
    _i2c_stop();
  }
}
```
user: What is the c source code of the assembly code below:

```asm
<_i2c_write_read>:
  endbr64
  push   %r14
  push   %r13
  mov    %rdx,%r13
  push   %r12
  push   %rbp
  mov    %ecx,%ebp
  sub    $0x8,%rsp
  test   %esi,%esi
  jne    L13
  test   %ebp,%ebp
  jne    L22
L23:
  add    $0x8,%rsp
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopl   0x0(%rax)
L13:
  mov    %rdi,%r14
  mov    %r8d,%edi
  mov    %esi,%r12d
  call   <_i2c_start@plt>
  mov    $0x7d3c,%edi
  call   <_i2c_get@plt>
  mov    %r12d,%esi
  mov    $0x7d3c,%edi
  and    $0xf0,%ah
  shl    $0x8,%esi
  or     %eax,%esi
  call   <_i2c_set@plt>
  mov    $0x7d40,%edi
  call   <_i2c_get@plt>
  mov    $0x7d40,%edi
  mov    %eax,%esi
  call   <_i2c_set@plt>
  mov    $0xa0,%esi
  mov    $0x7d44,%edi
  call   <_i2c_set@plt>
  mov    %r12d,%esi
  mov    %r14,%rdi
  call   <_i2c_write@plt>
  mov    $0x7d38,%edi
  call   <_i2c_get@plt>
  mov    $0x7d38,%edi
  and    $0xfffffff8,%eax
  mov    %eax,%esi
  or     $0x3,%esi
  call   <_i2c_set@plt>
  xor    %eax,%eax
  call   <_i2c_wait@plt>
  test   %ebp,%ebp
  je     L23
L22:
  mov    $0xa1,%esi
  mov    $0x7d44,%edi
  call   <_i2c_set@plt>
  mov    $0x7d3c,%edi
  call   <_i2c_get@plt>
  mov    %ebp,%esi
  mov    $0x7d3c,%edi
  and    $0xf0,%ah
  shl    $0x8,%esi
  or     %eax,%esi
  call   <_i2c_set@plt>
  mov    $0x7d38,%edi
  call   <_i2c_get@plt>
  mov    $0x7d38,%edi
  or     $0x7,%eax
  mov    %eax,%esi
  call   <_i2c_set@plt>
  xor    %eax,%eax
  call   <_i2c_wait@plt>
  mov    %ebp,%esi
  mov    %r13,%rdi
  call   <_i2c_read@plt>
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  jmp    1100 <_i2c_stop@plt>
```

assistant: ```c
void _i2c_write_read(unsigned char *write_buf, int num_write, unsigned char *read_buf, int num_read, unsigned int connector) {
  unsigned int tmp;
  if (num_write) {
    _i2c_start(connector);
    tmp = _i2c_get(0x7d3c) & (~(0xf << 8));
    tmp |= num_write << 8;
    _i2c_set(0x7d3c, tmp);
    tmp = _i2c_get(0x7d40);
    _i2c_set(0x7d40, tmp);
    _i2c_set(0x7d44, 0xA0);
    _i2c_write(write_buf, num_write);
    tmp = _i2c_get(0x7d38) & (~0x7);
    _i2c_set(0x7d38, tmp | (1 << 0) | (1 << 1));
    _i2c_wait();
  }
  if (num_read) {
    _i2c_set(0x7d44, 0xA0 | 1);
    tmp = _i2c_get(0x7d3c) & (~(0xf << 8));
    tmp |= num_read << 8;
    _i2c_set(0x7d3c, tmp);
    tmp = _i2c_get(0x7d38) & (~0x7);
    _i2c_set(0x7d38, tmp | (1 << 0) | (1 << 1) | (1 << 2));
    _i2c_wait();
    _i2c_read(read_buf, num_read);
    _i2c_stop();
  }
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<Error>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %rdi,-0x8(%rbp)
  mov    $0x0,%eax
  call   <endwin@plt>
  mov    -0x8(%rbp),%rax
  mov    %rax,%rsi
  lea    D7(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  nop
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: label: D7
type: string

tool: D7: %s


assistant: ```c
void Error(char *x) {
  endwin();
  printf("%s\n", x);
  exit(1);
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<Error>:
  endbr64
  push   %rbx
  mov    %rdi,%rbx
  mov    $0x0,%eax
  call   <endwin@plt>
  mov    %rbx,%rsi
  lea    D1(%rip),%rdi
  call   <printf@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  pop    %rbx
  ret
```

tool_calls: name: parse_data
arguments: label: D1
type_infered: string

tool: D1: %s


assistant: ```c
void Error(char *x) {
  endwin();
  printf("%s\n", x);
  exit(1);
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<Error>:
  endbr64
  push   %rbp
  xor    %eax,%eax
  mov    %rdi,%rbp
  call   <endwin@plt>
  mov    %rbp,%rsi
  lea    D2(%rip),%rdi
  call   <printf@plt>
  mov    $0x1,%edi
  pop    %rbp
  jmp    1090 <exit@plt>
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D2
type_infered: string

tool: D2: %s


assistant: ```c
void Error(char *x) {
  endwin();
  printf("%s\n", x);
  exit(1);
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<Error>:
  endbr64
  push   %rbp
  xor    %eax,%eax
  mov    %rdi,%rbp
  call   <endwin@plt>
  mov    %rbp,%rsi
  lea    D3(%rip),%rdi
  call   <printf@plt>
  mov    $0x1,%edi
  pop    %rbp
  jmp    1090 <exit@plt>
```

tool_calls: name: unpack_data
arguments: data_tag: D3
type_infered: string

tool: D3: %s


assistant: ```c
void Error(char *x) {
  endwin();
  printf("%s\n", x);
  exit(1);
}
```
user: What is the c source code of the assembly code below:

```asm
<bitset_set_range>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  mov    %edx,-0x20(%rbp)
  mov    -0x1c(%rbp),%eax
  cmp    -0x20(%rbp),%eax
  je     L0
  mov    -0x1c(%rbp),%eax
  lea    0x3f(%rax),%edx
  test   %eax,%eax
  cmovs  %edx,%eax
  sar    $0x6,%eax
  mov    %eax,-0x8(%rbp)
  mov    -0x20(%rbp),%eax
  sub    $0x1,%eax
  lea    0x3f(%rax),%edx
  test   %eax,%eax
  cmovs  %edx,%eax
  sar    $0x6,%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x8(%rbp),%eax
  cmp    -0x4(%rbp),%eax
  jne    L59
  mov    -0x8(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x1c(%rbp),%eax
  and    $0x3f,%eax
  mov    $0xffffffffffffffff,%rsi
  mov    %eax,%ecx
  shl    %cl,%rsi
  mov    -0x20(%rbp),%eax
  neg    %eax
  and    $0x3f,%eax
  mov    $0xffffffffffffffff,%rdi
  mov    %eax,%ecx
  shr    %cl,%rdi
  mov    %rdi,%rax
  mov    %rsi,%rcx
  and    %rax,%rcx
  mov    -0x8(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rsi
  mov    -0x18(%rbp),%rax
  add    %rsi,%rax
  or     %rcx,%rdx
  mov    %rdx,(%rax)
  jmp    L12
L59:
  mov    -0x8(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x1c(%rbp),%eax
  and    $0x3f,%eax
  mov    $0xffffffffffffffff,%rsi
  mov    %eax,%ecx
  shl    %cl,%rsi
  mov    %rsi,%rcx
  mov    -0x8(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rsi
  mov    -0x18(%rbp),%rax
  add    %rsi,%rax
  or     %rcx,%rdx
  mov    %rdx,(%rax)
  mov    -0x8(%rbp),%eax
  add    $0x1,%eax
  mov    %eax,-0xc(%rbp)
  jmp    L2
L38:
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movq   $0xffffffffffffffff,(%rax)
  addl   $0x1,-0xc(%rbp)
L2:
  mov    -0xc(%rbp),%eax
  cmp    -0x4(%rbp),%eax
  jl     L38
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x20(%rbp),%eax
  neg    %eax
  and    $0x3f,%eax
  mov    $0xffffffffffffffff,%rsi
  mov    %eax,%ecx
  shr    %cl,%rsi
  mov    %rsi,%rcx
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rsi
  mov    -0x18(%rbp),%rax
  add    %rsi,%rax
  or     %rcx,%rdx
  mov    %rdx,(%rax)
  jmp    L12
L0:
  nop
L12:
  pop    %rbp
  ret
```

assistant: ```c
void bitset_set_range(uint64_t *bitmap, uint32_t start, uint32_t end) {
  if (start == end)
    return;
  uint32_t firstword = start / 64;
  uint32_t endword = (end - 1) / 64;
  if (firstword == endword) {
    bitmap[firstword] |= ((~(0ULL)) << (start % 64)) & ((~(0ULL)) >> ((~end + 1) % 64));
    return;
  }
  bitmap[firstword] |= (~(0ULL)) << (start % 64);
  for (uint32_t i = firstword + 1; i < endword; i++)
    bitmap[i] = ~(0ULL);
  bitmap[endword] |= (~(0ULL)) >> ((~end + 1) % 64);
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<bitset_set_range>:
  endbr64
  mov    %esi,%r8d
  mov    %edx,%esi
  cmp    %edx,%r8d
  je     L12
  lea    0x3f(%r8),%eax
  test   %r8d,%r8d
  cmovns %r8d,%eax
  sar    $0x6,%eax
  lea    0x3e(%rdx),%edx
  mov    %esi,%ecx
  sub    $0x1,%ecx
  cmovns %ecx,%edx
  sar    $0x6,%edx
  cmp    %edx,%eax
  je     L30
  movslq %eax,%r10
  mov    $0xffffffffffffffff,%r9
  mov    %r8d,%ecx
  shl    %cl,%r9
  or     %r9,(%rdi,%r10,8)
  add    $0x1,%eax
  cmp    %eax,%edx
  jle    L17
  cltq
L10:
  movq   $0xffffffffffffffff,(%rdi,%rax,8)
  add    $0x1,%rax
  cmp    %eax,%edx
  jg     L10
L17:
  movslq %edx,%rdx
  mov    %esi,%ecx
  neg    %ecx
  mov    $0xffffffffffffffff,%rax
  shr    %cl,%rax
  or     %rax,(%rdi,%rdx,8)
L12:
  ret
L30:
  cltq
  neg    %esi
  mov    %esi,%ecx
  mov    $0xffffffffffffffff,%rdx
  mov    %rdx,%rsi
  shr    %cl,%rsi
  mov    %r8d,%ecx
  shl    %cl,%rdx
  and    %rdx,%rsi
  or     %rsi,(%rdi,%rax,8)
  ret
```

assistant: ```c
void bitset_set_range(uint64_t *bitmap, uint32_t start, uint32_t end) {
  if (start == end)
    return;
  uint32_t firstword = start / 64;
  uint32_t endword = (end - 1) / 64;
  if (firstword == endword) {
    bitmap[firstword] |= ((~(0ULL)) << (start % 64)) & ((~(0ULL)) >> ((~end + 1) % 64));
    return;
  }
  bitmap[firstword] |= (~(0ULL)) << (start % 64);
  for (uint32_t i = firstword + 1; i < endword; i++)
    bitmap[i] = ~(0ULL);
  bitmap[endword] |= (~(0ULL)) >> ((~end + 1) % 64);
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<bitset_set_range>:
  endbr64
  cmp    %edx,%esi
  je     L20
  mov    %edx,%eax
  test   %esi,%esi
  lea    0x3f(%rsi),%edx
  mov    %esi,%ecx
  cmovns %esi,%edx
  mov    %eax,%esi
  push   %r12
  push   %rbp
  sar    $0x6,%edx
  sub    $0x1,%esi
  push   %rbx
  mov    %rdi,%rbx
  mov    %edx,%r9d
  lea    0x3e(%rax),%edx
  cmovns %esi,%edx
  neg    %eax
  sar    $0x6,%edx
  mov    %edx,%ebp
  movslq %r9d,%rdx
  shl    $0x3,%rdx
  lea    (%rdi,%rdx,1),%r10
  mov    $0xffffffffffffffff,%rdi
  mov    %rdi,%r8
  mov    (%r10),%rsi
  shl    %cl,%r8
  mov    %eax,%ecx
  shr    %cl,%rdi
  mov    %rdi,%r12
  cmp    %ebp,%r9d
  je     L19
  or     %r8,%rsi
  lea    0x1(%r9),%eax
  mov    %rsi,(%r10)
  cmp    %eax,%ebp
  jle    L16
  lea    -0x2(%rbp),%eax
  lea    0x8(%rbx,%rdx,1),%rdi
  mov    $0xff,%esi
  sub    %r9d,%eax
  lea    0x8(,%rax,8),%r8
  mov    %r8,%rdx
  call   <memset@plt>
L16:
  movslq %ebp,%rdx
  or     %r12,(%rbx,%rdx,8)
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax)
L20:
  ret
  nopl   0x0(%rax)
L19:
  and    %rdi,%r8
  or     %rsi,%r8
  mov    %r8,(%r10)
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
void bitset_set_range(uint64_t *bitmap, uint32_t start, uint32_t end) {
  if (start == end)
    return;
  uint32_t firstword = start / 64;
  uint32_t endword = (end - 1) / 64;
  if (firstword == endword) {
    bitmap[firstword] |= ((~(0ULL)) << (start % 64)) & ((~(0ULL)) >> ((~end + 1) % 64));
    return;
  }
  bitmap[firstword] |= (~(0ULL)) << (start % 64);
  for (uint32_t i = firstword + 1; i < endword; i++)
    bitmap[i] = ~(0ULL);
  bitmap[endword] |= (~(0ULL)) >> ((~end + 1) % 64);
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<bitset_set_range>:
  endbr64
  cmp    %edx,%esi
  je     L12
  mov    %edx,%eax
  test   %esi,%esi
  lea    0x3f(%rsi),%edx
  mov    %esi,%ecx
  cmovns %esi,%edx
  mov    %eax,%esi
  push   %r12
  push   %rbp
  sar    $0x6,%edx
  sub    $0x1,%esi
  push   %rbx
  mov    %rdi,%rbx
  mov    %edx,%r9d
  lea    0x3e(%rax),%edx
  cmovns %esi,%edx
  neg    %eax
  sar    $0x6,%edx
  mov    %edx,%ebp
  movslq %r9d,%rdx
  shl    $0x3,%rdx
  lea    (%rdi,%rdx,1),%r10
  mov    $0xffffffffffffffff,%rdi
  mov    %rdi,%r8
  mov    (%r10),%rsi
  shl    %cl,%r8
  mov    %eax,%ecx
  shr    %cl,%rdi
  mov    %rdi,%r12
  cmp    %ebp,%r9d
  je     L13
  or     %r8,%rsi
  lea    0x1(%r9),%eax
  mov    %rsi,(%r10)
  cmp    %eax,%ebp
  jle    L14
  lea    -0x2(%rbp),%eax
  lea    0x8(%rbx,%rdx,1),%rdi
  mov    $0xff,%esi
  sub    %r9d,%eax
  lea    0x8(,%rax,8),%r8
  mov    %r8,%rdx
  call   <memset@plt>
L14:
  movslq %ebp,%rdx
  or     %r12,(%rbx,%rdx,8)
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax)
L12:
  ret
  nopl   0x0(%rax)
L13:
  and    %rdi,%r8
  or     %rsi,%r8
  mov    %r8,(%r10)
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
void bitset_set_range(uint64_t *bitmap, uint32_t start, uint32_t end) {
  if (start == end)
    return;
  uint32_t firstword = start / 64;
  uint32_t endword = (end - 1) / 64;
  if (firstword == endword) {
    bitmap[firstword] |= ((~(0ULL)) << (start % 64)) & ((~(0ULL)) >> ((~end + 1) % 64));
    return;
  }
  bitmap[firstword] |= (~(0ULL)) << (start % 64);
  for (uint32_t i = firstword + 1; i < endword; i++)
    bitmap[i] = ~(0ULL);
  bitmap[endword] |= (~(0ULL)) >> ((~end + 1) % 64);
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<parse_net>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %rdx,-0x48(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x20,-0x10(%rbp)
  movl   $0x0,-0xc(%rbp)
  lea    -0x14(%rbp),%r8
  lea    -0x18(%rbp),%rdi
  lea    -0x1c(%rbp),%rcx
  lea    -0x20(%rbp),%rdx
  mov    -0x38(%rbp),%rax
  lea    -0x24(%rbp),%rsi
  push   %rsi
  lea    -0x10(%rbp),%rsi
  push   %rsi
  mov    %r8,%r9
  mov    %rdi,%r8
  lea    D11(%rip),%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <sscanf@plt>
  add    $0x10,%rsp
  cmp    $0x5,%eax
  je     L23
  lea    -0x14(%rbp),%r8
  lea    -0x18(%rbp),%rdi
  lea    -0x1c(%rbp),%rcx
  lea    -0x20(%rbp),%rdx
  mov    -0x38(%rbp),%rax
  sub    $0x8,%rsp
  lea    -0x24(%rbp),%rsi
  push   %rsi
  mov    %r8,%r9
  mov    %rdi,%r8
  lea    D12(%rip),%rsi
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <sscanf@plt>
  add    $0x10,%rsp
  cmp    $0x4,%eax
  jne    L5
L23:
  mov    -0x20(%rbp),%eax
  mov    %eax,%edi
  call   <isbyte@plt>
  test   %rax,%rax
  je     L5
  mov    -0x1c(%rbp),%eax
  mov    %eax,%edi
  call   <isbyte@plt>
  test   %rax,%rax
  je     L5
  mov    -0x18(%rbp),%eax
  mov    %eax,%edi
  call   <isbyte@plt>
  test   %rax,%rax
  je     L5
  mov    -0x14(%rbp),%eax
  mov    %eax,%edi
  call   <isbyte@plt>
  test   %rax,%rax
  je     L5
  mov    -0x10(%rbp),%eax
  test   %eax,%eax
  js     L5
  mov    -0x10(%rbp),%eax
  cmp    $0x20,%eax
  jg     L5
  mov    -0x24(%rbp),%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x20(%rbp),%eax
  shl    $0x18,%eax
  mov    %eax,%edx
  mov    -0x1c(%rbp),%eax
  shl    $0x10,%eax
  or     %eax,%edx
  mov    -0x18(%rbp),%eax
  shl    $0x8,%eax
  or     %eax,%edx
  mov    -0x14(%rbp),%eax
  or     %eax,%edx
  mov    -0x40(%rbp),%rax
  mov    %edx,(%rax)
  mov    -0x10(%rbp),%eax
  test   %eax,%eax
  je     L11
  mov    -0x10(%rbp),%edx
  mov    $0x20,%eax
  sub    %edx,%eax
  mov    $0xffffffff,%edx
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    %edx,%eax
  mov    %eax,%edx
  jmp    L13
L11:
  mov    $0x0,%edx
L13:
  mov    -0x48(%rbp),%rax
  mov    %edx,(%rax)
L5:
  mov    -0xc(%rbp),%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L14
  call   <__stack_chk_fail@plt>
L14:
  leave
  ret
```

tool_calls: name: unpack_data
arguments: data_label: D11
type_guessed: string
name: unpack_data
arguments: data_label: D12
type_guessed: string

tool: D11: %d.%d.%d.%d/%d%n

tool: D12: %d.%d.%d.%d%n

assistant: ```c
int parse_net(const char *spec, uint32_t *net, uint32_t *mask) {
  int n, a, b, c, d, slash = 32, len = 0;
  if ((sscanf(spec, "%d.%d.%d.%d/%d%n", &a, &b, &c, &d, &slash, &n) == 5 || sscanf(spec, "%d.%d.%d.%d%n", &a, &b, &c, &d, &n) == 4) && isbyte(a) && isbyte(b) && isbyte(c) && isbyte(d) && slash >= 0 && slash < 33) {
    len = n;
    *net = ((uint32_t)a << 24) | ((uint32_t)b << 16) | ((uint32_t)c << 8) | d;
    *mask = slash ? 0xffffffffU << (32 - slash) : 0;
  }
  return len;
}
```