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

```asm
<main>:
  endbr64
  push   %rbp
  xor    %eax,%eax
  lea    D4(%rip),%rbp
  call   <UART0_Port_Init@plt>
  xor    %eax,%eax
  call   <UART0_Set_BaudRate@plt>
  xor    %eax,%eax
  call   <UART0_Set_Format@plt>
  lea    D23(%rip),%rdi
  call   <UART0_SendString@plt>
  lea    D31(%rip),%rdi
  call   <UART0_SendString@plt>
  mov    %rbp,%rdi
  call   <UART0_SendString@plt>
  mov    $0x7b,%edi
  call   <UART0_SendData8@plt>
  mov    %rbp,%rdi
  call   <UART0_SendString@plt>
  mov    $0xff,%edi
  call   <UART0_SendData8@plt>
  mov    %rbp,%rdi
  call   <UART0_SendString@plt>
  lea    D33(%rip),%rdi
  call   <UART0_SendString@plt>
  mov    %rbp,%rdi
  call   <UART0_SendString@plt>
  mov    $0x1234,%edi
  call   <UART0_SendData32@plt>
  mov    %rbp,%rdi
  call   <UART0_SendString@plt>
  mov    $0x1234abcd,%edi
  call   <UART0_SendData32@plt>
  mov    %rbp,%rdi
  call   <UART0_SendString@plt>
  mov    $0xabcd,%edi
  call   <UART0_SendData32@plt>
  mov    %rbp,%rdi
  call   <UART0_SendString@plt>
  mov    $0x1234abcd,%edi
  call   <UART0_SendData32@plt>
  mov    %rbp,%rdi
  call   <UART0_SendString@plt>
  mov    $0x1,%edi
  call   <UART0_SendData32@plt>
  mov    %rbp,%rdi
  call   <UART0_SendString@plt>
  nopl   0x0(%rax,%rax,1)
L9:
  xor    %eax,%eax
  call   <UART0_GetChar@plt>
  lea    0x1(%rax),%edi
  movsbl %dil,%edi
  call   <UART0_PutChar@plt>
  jmp    L9
```

tool_calls: name: read_data
arguments: data_label: D4
type_guessed: string
name: read_data
arguments: data_label: D23
type_guessed: string
name: read_data
arguments: data_label: D31
type_guessed: string
name: read_data
arguments: data_label: D33
type_guessed: string

tool: D4: 


tool: D23: Hello World!


tool: D31: Send Data 8:

tool: D33: Send Data 32:

assistant: ```c
int main() {
  char data;
  UART0_Port_Init();
  UART0_Set_BaudRate();
  UART0_Set_Format();
  UART0_SendString("Hello World!\n\r");
  UART0_SendString("Send Data 8:");
  UART0_SendString("\n\r");
  UART0_SendData8(123);
  UART0_SendString("\n\r");
  UART0_SendData8(0xFF);
  UART0_SendString("\n\r");
  UART0_SendString("Send Data 32:");
  UART0_SendString("\n\r");
  UART0_SendData32(0x1234);
  UART0_SendString("\n\r");
  UART0_SendData32(0x1234ABCD);
  UART0_SendString("\n\r");
  UART0_SendData32(0xABCD);
  UART0_SendString("\n\r");
  UART0_SendData32(0x1234ABCD);
  UART0_SendString("\n\r");
  UART0_SendData32(0x1);
  UART0_SendString("\n\r");
  while (1) {
    data = UART0_GetChar();
    UART0_PutChar(data + 1);
  }
  return 0;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<main>:
  endbr64
  push   %rbp
  xor    %eax,%eax
  lea    D39(%rip),%rbp
  call   <UART0_Port_Init@plt>
  xor    %eax,%eax
  call   <UART0_Set_BaudRate@plt>
  xor    %eax,%eax
  call   <UART0_Set_Format@plt>
  lea    D33(%rip),%rdi
  call   <UART0_SendString@plt>
  lea    D24(%rip),%rdi
  call   <UART0_SendString@plt>
  mov    %rbp,%rdi
  call   <UART0_SendString@plt>
  mov    $0x7b,%edi
  call   <UART0_SendData8@plt>
  mov    %rbp,%rdi
  call   <UART0_SendString@plt>
  mov    $0xff,%edi
  call   <UART0_SendData8@plt>
  mov    %rbp,%rdi
  call   <UART0_SendString@plt>
  lea    D7(%rip),%rdi
  call   <UART0_SendString@plt>
  mov    %rbp,%rdi
  call   <UART0_SendString@plt>
  mov    $0x1234,%edi
  call   <UART0_SendData32@plt>
  mov    %rbp,%rdi
  call   <UART0_SendString@plt>
  mov    $0x1234abcd,%edi
  call   <UART0_SendData32@plt>
  mov    %rbp,%rdi
  call   <UART0_SendString@plt>
  mov    $0xabcd,%edi
  call   <UART0_SendData32@plt>
  mov    %rbp,%rdi
  call   <UART0_SendString@plt>
  mov    $0x1234abcd,%edi
  call   <UART0_SendData32@plt>
  mov    %rbp,%rdi
  call   <UART0_SendString@plt>
  mov    $0x1,%edi
  call   <UART0_SendData32@plt>
  mov    %rbp,%rdi
  call   <UART0_SendString@plt>
  nopl   0x0(%rax,%rax,1)
L4:
  xor    %eax,%eax
  call   <UART0_GetChar@plt>
  lea    0x1(%rax),%edi
  movsbl %dil,%edi
  call   <UART0_PutChar@plt>
  jmp    L4
```

tool_calls: name: extract_symbolic_data
arguments: tag: D39
datatype: string
name: extract_symbolic_data
arguments: tag: D33
datatype: string
name: extract_symbolic_data
arguments: tag: D24
datatype: string
name: extract_symbolic_data
arguments: tag: D7
datatype: string

tool: D39: 


tool: D33: Hello World!


tool: D24: Send Data 8:

tool: D7: Send Data 32:

assistant: ```c
int main() {
  char data;
  UART0_Port_Init();
  UART0_Set_BaudRate();
  UART0_Set_Format();
  UART0_SendString("Hello World!\n\r");
  UART0_SendString("Send Data 8:");
  UART0_SendString("\n\r");
  UART0_SendData8(123);
  UART0_SendString("\n\r");
  UART0_SendData8(0xFF);
  UART0_SendString("\n\r");
  UART0_SendString("Send Data 32:");
  UART0_SendString("\n\r");
  UART0_SendData32(0x1234);
  UART0_SendString("\n\r");
  UART0_SendData32(0x1234ABCD);
  UART0_SendString("\n\r");
  UART0_SendData32(0xABCD);
  UART0_SendString("\n\r");
  UART0_SendData32(0x1234ABCD);
  UART0_SendString("\n\r");
  UART0_SendData32(0x1);
  UART0_SendString("\n\r");
  while (1) {
    data = UART0_GetChar();
    UART0_PutChar(data + 1);
  }
  return 0;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<StringsAreEqual>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <GetStringLength@plt>
  mov    %eax,-0xc(%rbp)
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <GetStringLength@plt>
  mov    %eax,-0x8(%rbp)
  mov    -0x8(%rbp),%ecx
  mov    -0x20(%rbp),%rdx
  mov    -0xc(%rbp),%esi
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <StringsAreEqual2@plt>
  mov    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  leave
  ret
```

assistant: ```c
int StringsAreEqual(char *first, char *second) {
  int length = GetStringLength(first);
  int length2 = GetStringLength(second);
  int output = StringsAreEqual2(first, length, second, length2);
  return output;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<StringsAreEqual>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  mov    %rsi,%rbp
  call   <GetStringLength@plt>
  mov    %eax,%r12d
  mov    %rbp,%rdi
  call   <GetStringLength@plt>
  mov    %eax,%ecx
  mov    %rbp,%rdx
  mov    %r12d,%esi
  mov    %rbx,%rdi
  call   <StringsAreEqual2@plt>
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
int StringsAreEqual(char *first, char *second) {
  int length = GetStringLength(first);
  int length2 = GetStringLength(second);
  int output = StringsAreEqual2(first, length, second, length2);
  return output;
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<StringsAreEqual>:
  endbr64
  push   %r13
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  mov    %rdi,%rbp
  call   <GetStringLength@plt>
  mov    %r12,%rdi
  mov    %eax,%r13d
  call   <GetStringLength@plt>
  mov    %r12,%rdx
  mov    %r13d,%esi
  mov    %rbp,%rdi
  mov    %eax,%ecx
  pop    %rbp
  pop    %r12
  pop    %r13
  jmp    1070 <StringsAreEqual2@plt>
```

assistant: ```c
int StringsAreEqual(char *first, char *second) {
  int length = GetStringLength(first);
  int length2 = GetStringLength(second);
  int output = StringsAreEqual2(first, length, second, length2);
  return output;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<StringsAreEqual>:
  endbr64
  push   %r13
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  mov    %rdi,%rbp
  call   <GetStringLength@plt>
  mov    %r12,%rdi
  mov    %eax,%r13d
  call   <GetStringLength@plt>
  mov    %r12,%rdx
  mov    %r13d,%esi
  mov    %rbp,%rdi
  mov    %eax,%ecx
  pop    %rbp
  pop    %r12
  pop    %r13
  jmp    1070 <StringsAreEqual2@plt>
```

assistant: ```c
int StringsAreEqual(char *first, char *second) {
  int length = GetStringLength(first);
  int length2 = GetStringLength(second);
  int output = StringsAreEqual2(first, length, second, length2);
  return output;
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<strpbrk>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    -0x18(%rbp),%rax
  mov    %rax,-0x8(%rbp)
  jmp    L12
L18:
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%edx
  mov    -0x20(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  je     L8
  mov    -0x8(%rbp),%rax
  jmp    L34
L8:
  addq   $0x1,-0x8(%rbp)
L12:
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L18
  mov    $0x0,%eax
L34:
  leave
  ret
```

assistant: ```c
char *strpbrk(const char *str, const char *set) {
  char *result = (char *)str;
  for (; result[0] != '\0'; result++)
    if (strchr(set, result[0]) != 0)
      return result;
  return 0;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<strpbrk>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%rbx
  mov    %rsi,%rbp
  movzbl (%rdi),%esi
  test   %sil,%sil
  je     L23
L14:
  movsbl %sil,%esi
  mov    %rbp,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  jne    L27
  add    $0x1,%rbx
  movzbl (%rbx),%esi
  test   %sil,%sil
  jne    L14
  jmp    L8
L23:
  mov    $0x0,%eax
  jmp    L8
L27:
  mov    %rbx,%rax
L8:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
```

assistant: ```c
char *strpbrk(const char *str, const char *set) {
  char *result = (char *)str;
  for (; result[0] != '\0'; result++)
    if (strchr(set, result[0]) != 0)
      return result;
  return 0;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<strpbrk>:
  endbr64
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  sub    $0x8,%rsp
  movsbl (%rdi),%esi
  test   %sil,%sil
  je     L26
  mov    %rdi,%rbx
  jmp    L17
  nopw   0x0(%rax,%rax,1)
L8:
  movsbl 0x1(%rbx),%esi
  add    $0x1,%rbx
  test   %sil,%sil
  je     L26
L17:
  mov    %rbp,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  je     L8
  add    $0x8,%rsp
  mov    %rbx,%rax
  pop    %rbx
  pop    %rbp
  ret
  nopl   0x0(%rax)
L26:
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  ret
```

assistant: ```c
char *strpbrk(const char *str, const char *set) {
  char *result = (char *)str;
  for (; result[0] != '\0'; result++)
    if (strchr(set, result[0]) != 0)
      return result;
  return 0;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<strpbrk>:
  endbr64
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  sub    $0x8,%rsp
  movsbl (%rdi),%esi
  test   %sil,%sil
  je     L29
  mov    %rdi,%rbx
  jmp    L17
  nopw   0x0(%rax,%rax,1)
L21:
  movsbl 0x1(%rbx),%esi
  add    $0x1,%rbx
  test   %sil,%sil
  je     L29
L17:
  mov    %rbp,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  je     L21
  add    $0x8,%rsp
  mov    %rbx,%rax
  pop    %rbx
  pop    %rbp
  ret
  nopl   0x0(%rax)
L29:
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  ret
```

assistant: ```c
char *strpbrk(const char *str, const char *set) {
  char *result = (char *)str;
  for (; result[0] != '\0'; result++)
    if (strchr(set, result[0]) != 0)
      return result;
  return 0;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<uname_get_host_name>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <uname@plt>
  mov    -0x10(%rbp),%rcx
  mov    -0x18(%rbp),%rax
  mov    $0x40,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncpy@plt>
  mov    -0x20(%rbp),%rax
  mov    $0x40,%edx
  lea    D9(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncpy@plt>
  mov    -0x18(%rbp),%rax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L0
  call   <__stack_chk_fail@plt>
L0:
  leave
  ret
```

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

tool: D9: Unknown

assistant: ```c
char *uname_get_host_name(char *hostname, char *domain) {
  struct utsname buf;
  uname(&buf);
  strncpy(hostname, buf.nodename, 64);
  strncpy(domain, "Unknown", 64);
  return hostname;
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<uname_get_host_name>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%rbx
  mov    %rsi,%rbp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  mov    %rsp,%rdi
  call   <uname@plt>
  mov    $0x40,%edx
  mov    (%rsp),%rsi
  mov    %rbx,%rdi
  call   <strncpy@plt>
  mov    $0x40,%edx
  lea    D6(%rip),%rsi
  mov    %rbp,%rdi
  call   <strncpy@plt>
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L5
  mov    %rbx,%rax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  ret
L5:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: label: D6
type_infered: string

tool: D6: Unknown

assistant: ```c
char *uname_get_host_name(char *hostname, char *domain) {
  struct utsname buf;
  uname(&buf);
  strncpy(hostname, buf.nodename, 64);
  strncpy(domain, "Unknown", 64);
  return hostname;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<uname_get_host_name>:
  endbr64
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  mov    %rsi,%rbp
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  mov    %rsp,%rdi
  call   <uname@plt>
  mov    (%rsp),%rsi
  mov    $0x40,%edx
  mov    %r12,%rdi
  call   <strncpy@plt>
  mov    $0x40,%edx
  lea    D2(%rip),%rsi
  mov    %rbp,%rdi
  call   <strncpy@plt>
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L7
  add    $0x18,%rsp
  mov    %r12,%rax
  pop    %rbp
  pop    %r12
  ret
L7:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: tag: D2
type_infered: string

tool: D2: Unknown

assistant: ```c
char *uname_get_host_name(char *hostname, char *domain) {
  struct utsname buf;
  uname(&buf);
  strncpy(hostname, buf.nodename, 64);
  strncpy(domain, "Unknown", 64);
  return hostname;
}
```
user: 这段汇编代码用C语言表示是什么样的:

```asm
<uname_get_host_name>:
  endbr64
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  mov    %rsi,%rbp
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  mov    %rsp,%rdi
  call   <uname@plt>
  mov    (%rsp),%rsi
  mov    $0x40,%edx
  mov    %r12,%rdi
  call   <strncpy@plt>
  mov    $0x40,%edx
  lea    D5(%rip),%rsi
  mov    %rbp,%rdi
  call   <strncpy@plt>
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L2
  add    $0x18,%rsp
  mov    %r12,%rax
  pop    %rbp
  pop    %r12
  ret
L2:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: data_tag: D5
type_guessed: string

tool: D5: Unknown

assistant: ```c
char *uname_get_host_name(char *hostname, char *domain) {
  struct utsname buf;
  uname(&buf);
  strncpy(hostname, buf.nodename, 64);
  strncpy(domain, "Unknown", 64);
  return hostname;
}
```
user: Translate the below assembly code into C programming language:

```asm
<RandomFunc>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x18(%rbp),%rax
  movzwl (%rax),%eax
  sub    $0xa4d,%ax
  mov    %ax,-0xa(%rbp)
  movw   $0x0,-0xc(%rbp)
  nop
  movzwl -0xa(%rbp),%eax
  lea    0x705d(%rax),%edx
  mov    -0x20(%rbp),%rax
  mov    %dx,(%rax)
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L9
  call   <__stack_chk_fail@plt>
L9:
  leave
  ret
```

assistant: ```c
void RandomFunc(unsigned short input[1], unsigned short output[1]) {
  unsigned short state[1];
  unsigned short local2;
  unsigned short local1;
  char copy11;
  {
    state[0UL] = (input[0UL] + 914778474UL) - (unsigned short)29623;
    local1 = 0UL;
    while (local1 < (unsigned short)0) {
      local2 = 0UL;
      while (local2 < (unsigned short)0) {
        if (state[0UL] < local2 + local1) {
          copy11 = *((char *)(&state[0UL]) + 1);
          *((char *)(&state[0UL]) + 1) = *((char *)(&state[0UL]) + 0);
          *((char *)(&state[0UL]) + 0) = copy11;
        }
        local2++;
      }
      local1++;
    }
    output[0UL] = state[0UL] + (unsigned short)28765;
  }
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<RandomFunc>:
  endbr64
  movzwl (%rdi),%eax
  add    $0x6610,%ax
  mov    %ax,(%rsi)
  ret
```

assistant: ```c
void RandomFunc(unsigned short input[1], unsigned short output[1]) {
  unsigned short state[1];
  unsigned short local2;
  unsigned short local1;
  char copy11;
  {
    state[0UL] = (input[0UL] + 914778474UL) - (unsigned short)29623;
    local1 = 0UL;
    while (local1 < (unsigned short)0) {
      local2 = 0UL;
      while (local2 < (unsigned short)0) {
        if (state[0UL] < local2 + local1) {
          copy11 = *((char *)(&state[0UL]) + 1);
          *((char *)(&state[0UL]) + 1) = *((char *)(&state[0UL]) + 0);
          *((char *)(&state[0UL]) + 0) = copy11;
        }
        local2++;
      }
      local1++;
    }
    output[0UL] = state[0UL] + (unsigned short)28765;
  }
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<RandomFunc>:
  endbr64
  movzwl (%rdi),%eax
  add    $0x6610,%ax
  mov    %ax,(%rsi)
  ret
```

assistant: ```c
void RandomFunc(unsigned short input[1], unsigned short output[1]) {
  unsigned short state[1];
  unsigned short local2;
  unsigned short local1;
  char copy11;
  {
    state[0UL] = (input[0UL] + 914778474UL) - (unsigned short)29623;
    local1 = 0UL;
    while (local1 < (unsigned short)0) {
      local2 = 0UL;
      while (local2 < (unsigned short)0) {
        if (state[0UL] < local2 + local1) {
          copy11 = *((char *)(&state[0UL]) + 1);
          *((char *)(&state[0UL]) + 1) = *((char *)(&state[0UL]) + 0);
          *((char *)(&state[0UL]) + 0) = copy11;
        }
        local2++;
      }
      local1++;
    }
    output[0UL] = state[0UL] + (unsigned short)28765;
  }
}
```
user: Translate the below assembly code into C programming language:

```asm
<RandomFunc>:
  endbr64
  movzwl (%rdi),%eax
  add    $0x6610,%ax
  mov    %ax,(%rsi)
  ret
```

assistant: ```c
void RandomFunc(unsigned short input[1], unsigned short output[1]) {
  unsigned short state[1];
  unsigned short local2;
  unsigned short local1;
  char copy11;
  {
    state[0UL] = (input[0UL] + 914778474UL) - (unsigned short)29623;
    local1 = 0UL;
    while (local1 < (unsigned short)0) {
      local2 = 0UL;
      while (local2 < (unsigned short)0) {
        if (state[0UL] < local2 + local1) {
          copy11 = *((char *)(&state[0UL]) + 1);
          *((char *)(&state[0UL]) + 1) = *((char *)(&state[0UL]) + 0);
          *((char *)(&state[0UL]) + 0) = copy11;
        }
        local2++;
      }
      local1++;
    }
    output[0UL] = state[0UL] + (unsigned short)28765;
  }
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<set_bit>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %edx,-0x34(%rbp)
  mov    %ecx,-0x38(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    -0x11(%rbp),%rcx
  lea    -0x10(%rbp),%rdx
  mov    -0x34(%rbp),%esi
  mov    -0x30(%rbp),%rax
  mov    %rax,%rdi
  call   <get_byte_and_offset@plt>
  cmpl   $0x0,-0x38(%rbp)
  je     L5
  mov    -0x10(%rbp),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%edx
  movzbl -0x11(%rbp),%eax
  movzbl %al,%eax
  mov    $0x1,%esi
  mov    %eax,%ecx
  shl    %cl,%esi
  mov    %esi,%eax
  mov    %eax,%esi
  mov    -0x10(%rbp),%rcx
  mov    -0x28(%rbp),%rax
  add    %rcx,%rax
  or     %esi,%edx
  mov    %dl,(%rax)
  jmp    L20
L5:
  mov    -0x10(%rbp),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%edx
  movzbl -0x11(%rbp),%eax
  movzbl %al,%eax
  mov    $0x1,%esi
  mov    %eax,%ecx
  shl    %cl,%esi
  mov    %esi,%eax
  not    %eax
  mov    %eax,%esi
  mov    -0x10(%rbp),%rcx
  mov    -0x28(%rbp),%rax
  add    %rcx,%rax
  and    %esi,%edx
  mov    %dl,(%rax)
L20:
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L28
  call   <__stack_chk_fail@plt>
L28:
  leave
  ret
```

assistant: ```c
void set_bit(unsigned char *bytes, size_t bytes_len, uint64_t index, unsigned val) {
  size_t byte;
  unsigned char offset;
  get_byte_and_offset(bytes_len, index, &byte, &offset);
  ;
  if (val) {
    bytes[byte] |= (1U << offset);
  } else {
    bytes[byte] &= ~(1U << offset);
  }
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<set_bit>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,%rbx
  mov    %rsi,%rdi
  mov    %edx,%esi
  mov    %ecx,%ebp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  lea    0xf(%rsp),%rcx
  lea    0x10(%rsp),%rdx
  call   <get_byte_and_offset@plt>
  test   %ebp,%ebp
  je     L23
  add    0x10(%rsp),%rbx
  movzbl 0xf(%rsp),%ecx
  mov    $0x1,%eax
  shl    %cl,%eax
  or     %al,(%rbx)
L1:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L5
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  ret
L23:
  add    0x10(%rsp),%rbx
  movzbl 0xf(%rsp),%ecx
  mov    $0xfffffffe,%eax
  rol    %cl,%eax
  and    %al,(%rbx)
  jmp    L1
L5:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void set_bit(unsigned char *bytes, size_t bytes_len, uint64_t index, unsigned val) {
  size_t byte;
  unsigned char offset;
  get_byte_and_offset(bytes_len, index, &byte, &offset);
  ;
  if (val) {
    bytes[byte] |= (1U << offset);
  } else {
    bytes[byte] &= ~(1U << offset);
  }
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<set_bit>:
  endbr64
  push   %rbp
  mov    %ecx,%ebp
  push   %rbx
  mov    %rdi,%rbx
  mov    %rsi,%rdi
  mov    %edx,%esi
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  lea    0xf(%rsp),%rcx
  lea    0x10(%rsp),%rdx
  call   <get_byte_and_offset@plt>
  movzbl 0xf(%rsp),%ecx
  add    0x10(%rsp),%rbx
  test   %ebp,%ebp
  je     L20
  mov    $0x1,%eax
  shl    %cl,%eax
  or     %al,(%rbx)
L18:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L24
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  ret
  nopl   0x0(%rax)
L20:
  mov    $0xfffffffe,%eax
  rol    %cl,%eax
  and    %al,(%rbx)
  jmp    L18
L24:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void set_bit(unsigned char *bytes, size_t bytes_len, uint64_t index, unsigned val) {
  size_t byte;
  unsigned char offset;
  get_byte_and_offset(bytes_len, index, &byte, &offset);
  ;
  if (val) {
    bytes[byte] |= (1U << offset);
  } else {
    bytes[byte] &= ~(1U << offset);
  }
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<set_bit>:
  endbr64
  push   %rbp
  mov    %ecx,%ebp
  push   %rbx
  mov    %rdi,%rbx
  mov    %rsi,%rdi
  mov    %edx,%esi
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  lea    0xf(%rsp),%rcx
  lea    0x10(%rsp),%rdx
  call   <get_byte_and_offset@plt>
  movzbl 0xf(%rsp),%ecx
  add    0x10(%rsp),%rbx
  test   %ebp,%ebp
  je     L11
  mov    $0x1,%eax
  shl    %cl,%eax
  or     %al,(%rbx)
L16:
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L26
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  ret
  nopl   0x0(%rax)
L11:
  mov    $0xfffffffe,%eax
  rol    %cl,%eax
  and    %al,(%rbx)
  jmp    L16
L26:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void set_bit(unsigned char *bytes, size_t bytes_len, uint64_t index, unsigned val) {
  size_t byte;
  unsigned char offset;
  get_byte_and_offset(bytes_len, index, &byte, &offset);
  ;
  if (val) {
    bytes[byte] |= (1U << offset);
  } else {
    bytes[byte] &= ~(1U << offset);
  }
}
```