ylfeng/ReF-Decompile-dataset huggingface dataset:
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<u8_rune_length>:
  endbr64
  movzbl (%rdi),%edx
  xor    %eax,%eax
  test   %dl,%dl
  je     L141
  mov    $0x1,%eax
  jg     L141
  lea    0x3e(%rdx),%eax
  cmp    $0x1d,%al
  ja     L80
  cmpb   $0xc0,0x1(%rdi)
  mov    $0x2,%eax
  jl     L19
L78:
  lea    0xf(%rdx),%eax
  cmp    $0x2,%al
  ja     L155
  cmpb   $0xc0,0x1(%rdi)
  mov    $0xffffffff,%eax
  jge    L141
L62:
  cmpb   $0xc0,0x2(%rdi)
  jge    L141
  xor    %eax,%eax
  cmpb   $0xbf,0x3(%rdi)
  setle  %al
  lea    -0x1(%rax,%rax,4),%eax
  ret
L164:
  lea    0x1f(%rdx),%eax
  cmp    $0xb,%al
  ja     L137
  cmpb   $0xc0,0x1(%rdi)
  jl     L72
L15:
  mov    $0xffffffff,%eax
L141:
  ret
  nopl   0x0(%rax,%rax,1)
L80:
  cmp    $0xe0,%dl
  jne    L164
  movzbl 0x1(%rdi),%eax
  lea    0x60(%rax),%ecx
  mov    $0xffffffff,%eax
  cmp    $0x1f,%cl
  ja     L141
  xchg   %ax,%ax
L72:
  cmpb   $0xc0,0x2(%rdi)
  mov    $0x3,%eax
  jge    L78
  ret
  nopl   0x0(%rax)
L155:
  cmp    $0xf4,%dl
  jne    L15
  cmpb   $0x90,0x1(%rdi)
  jge    L15
  cmpb   $0xc0,0x2(%rdi)
  jge    L15
  xor    %eax,%eax
  cmpb   $0xbf,0x3(%rdi)
  setle  %al
  lea    -0x1(%rax,%rax,4),%eax
  ret
  nop
L137:
  cmp    $0xed,%dl
  jne    L123
  cmpb   $0xa0,0x1(%rdi)
  jl     L72
  jmp    L15
  nopl   (%rax)
L123:
  cmp    $0xf0,%dl
  jne    L78
  movzbl 0x1(%rdi),%eax
  lea    0x70(%rax),%edx
  mov    $0xffffffff,%eax
  cmp    $0x2f,%dl
  jbe    L62
  ret
  nop
L19:
  ret
```

assistant: ```c
int u8_rune_length(const char *p) {
  if (*p == '\x00')
    return 0;
  if (*p > '\x00' && *p <= '\x7f')
    return 1;
  if (*p >= '\xc2' && *p <= '\xdf' && *(p + 1) >= '\x80' && *(p + 1) <= '\xbf')
    return 2;
  if (*p == '\xe0' && *(p + 1) >= '\xa0' && *(p + 1) <= '\xbf' && *(p + 2) >= '\x80' && *(p + 2) <= '\xbf')
    return 3;
  if (*p >= '\xe1' && *p <= '\xec' && *(p + 1) >= '\x80' && *(p + 1) <= '\xbf' && *(p + 2) >= '\x80' && *(p + 2) <= '\xbf')
    return 3;
  if (*p == '\xed' && *(p + 1) >= '\x80' && *(p + 1) <= '\x9f' && *(p + 2) >= '\x80' && *(p + 2) <= '\xbf')
    return 3;
  if (*p == '\xf0' && *(p + 1) >= '\x90' && *(p + 1) <= '\xbf' && *(p + 2) >= '\x80' && *(p + 2) <= '\xbf' && *(p + 3) >= '\x80' && *(p + 3) <= '\xbf')
    return 4;
  if (*p >= '\xf1' && *p <= '\xf3' && *(p + 1) >= '\x80' && *(p + 1) <= '\xbf' && *(p + 2) >= '\x80' && *(p + 2) <= '\xbf' && *(p + 3) >= '\x80' && *(p + 3) <= '\xbf')
    return 4;
  if (*p == '\xf4' && *(p + 1) >= '\x80' && *(p + 1) <= '\x8f' && *(p + 2) >= '\x80' && *(p + 2) <= '\xbf' && *(p + 3) >= '\x80' && *(p + 3) <= '\xbf')
    return 4;
  return -1;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<u8_rune_length>:
  endbr64
  movzbl (%rdi),%edx
  xor    %eax,%eax
  test   %dl,%dl
  je     L160
  mov    $0x1,%eax
  jg     L160
  lea    0x3e(%rdx),%eax
  cmp    $0x1d,%al
  ja     L3
  cmpb   $0xc0,0x1(%rdi)
  mov    $0x2,%eax
  jl     L123
L165:
  lea    0xf(%rdx),%eax
  cmp    $0x2,%al
  ja     L154
  cmpb   $0xc0,0x1(%rdi)
  mov    $0xffffffff,%eax
  jge    L160
L49:
  cmpb   $0xc0,0x2(%rdi)
  jge    L160
  xor    %eax,%eax
  cmpb   $0xbf,0x3(%rdi)
  setle  %al
  lea    -0x1(%rax,%rax,4),%eax
  ret
L173:
  lea    0x1f(%rdx),%eax
  cmp    $0xb,%al
  ja     L104
  cmpb   $0xc0,0x1(%rdi)
  jl     L58
L98:
  mov    $0xffffffff,%eax
L160:
  ret
  nopl   0x0(%rax,%rax,1)
L3:
  cmp    $0xe0,%dl
  jne    L173
  movzbl 0x1(%rdi),%eax
  lea    0x60(%rax),%ecx
  mov    $0xffffffff,%eax
  cmp    $0x1f,%cl
  ja     L160
  xchg   %ax,%ax
L58:
  cmpb   $0xc0,0x2(%rdi)
  mov    $0x3,%eax
  jge    L165
  ret
  nopl   0x0(%rax)
L154:
  cmp    $0xf4,%dl
  jne    L98
  cmpb   $0x90,0x1(%rdi)
  jge    L98
  cmpb   $0xc0,0x2(%rdi)
  jge    L98
  xor    %eax,%eax
  cmpb   $0xbf,0x3(%rdi)
  setle  %al
  lea    -0x1(%rax,%rax,4),%eax
  ret
  nop
L104:
  cmp    $0xed,%dl
  jne    L108
  cmpb   $0xa0,0x1(%rdi)
  jl     L58
  jmp    L98
  nopl   (%rax)
L108:
  cmp    $0xf0,%dl
  jne    L165
  movzbl 0x1(%rdi),%eax
  lea    0x70(%rax),%edx
  mov    $0xffffffff,%eax
  cmp    $0x2f,%dl
  jbe    L49
  ret
  nop
L123:
  ret
```

assistant: ```c
int u8_rune_length(const char *p) {
  if (*p == '\x00')
    return 0;
  if (*p > '\x00' && *p <= '\x7f')
    return 1;
  if (*p >= '\xc2' && *p <= '\xdf' && *(p + 1) >= '\x80' && *(p + 1) <= '\xbf')
    return 2;
  if (*p == '\xe0' && *(p + 1) >= '\xa0' && *(p + 1) <= '\xbf' && *(p + 2) >= '\x80' && *(p + 2) <= '\xbf')
    return 3;
  if (*p >= '\xe1' && *p <= '\xec' && *(p + 1) >= '\x80' && *(p + 1) <= '\xbf' && *(p + 2) >= '\x80' && *(p + 2) <= '\xbf')
    return 3;
  if (*p == '\xed' && *(p + 1) >= '\x80' && *(p + 1) <= '\x9f' && *(p + 2) >= '\x80' && *(p + 2) <= '\xbf')
    return 3;
  if (*p == '\xf0' && *(p + 1) >= '\x90' && *(p + 1) <= '\xbf' && *(p + 2) >= '\x80' && *(p + 2) <= '\xbf' && *(p + 3) >= '\x80' && *(p + 3) <= '\xbf')
    return 4;
  if (*p >= '\xf1' && *p <= '\xf3' && *(p + 1) >= '\x80' && *(p + 1) <= '\xbf' && *(p + 2) >= '\x80' && *(p + 2) <= '\xbf' && *(p + 3) >= '\x80' && *(p + 3) <= '\xbf')
    return 4;
  if (*p == '\xf4' && *(p + 1) >= '\x80' && *(p + 1) <= '\x8f' && *(p + 2) >= '\x80' && *(p + 2) <= '\xbf' && *(p + 3) >= '\x80' && *(p + 3) <= '\xbf')
    return 4;
  return -1;
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    D42(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  lea    -0x14(%rbp),%rax
  mov    %rax,%rsi
  lea    D43(%rip),%rax
  mov    %rax,%rdi
  call   <scanf@plt>
  lea    D24(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  lea    -0x10(%rbp),%rax
  mov    %rax,%rsi
  lea    D43(%rip),%rax
  mov    %rax,%rdi
  call   <scanf@plt>
  mov    -0x14(%rbp),%edx
  mov    -0x10(%rbp),%eax
  add    %edx,%eax
  mov    %eax,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  mov    %eax,%esi
  lea    D12(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x0,%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L4
  call   <__stack_chk_fail@plt>
L4:
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: tag: D42
data_type: string
name: disassemble_data
arguments: tag: D43
data_type: string
name: disassemble_data
arguments: tag: D24
data_type: string
name: disassemble_data
arguments: tag: D12
data_type: string

tool: D42: Enter first integer

tool: D43: %d

tool: D24: Enter second integer

tool: D12: Sum is %d


assistant: ```c
int main(void) {
  int integer1;
  int integer2;
  int sum;
  printf("Enter first integer\n");
  scanf("%d", &integer1);
  printf("Enter second integer\n");
  scanf("%d", &integer2);
  sum = integer1 + integer2;
  printf("Sum is %d\n", sum);
  return 0;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<main>:
  endbr64
  push   %rbx
  sub    $0x10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    D17(%rip),%rdi
  call   <puts@plt>
  mov    %rsp,%rsi
  lea    D39(%rip),%rbx
  mov    %rbx,%rdi
  call   <scanf@plt>
  lea    D12(%rip),%rdi
  call   <puts@plt>
  lea    0x4(%rsp),%rsi
  mov    %rbx,%rdi
  call   <scanf@plt>
  mov    0x4(%rsp),%esi
  add    (%rsp),%esi
  lea    D29(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L4
  mov    $0x0,%eax
  add    $0x10,%rsp
  pop    %rbx
  ret
L4:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: data_tag: D17
data_type: string
name: parse_data
arguments: data_tag: D39
data_type: string
name: parse_data
arguments: data_tag: D12
data_type: string
name: parse_data
arguments: data_tag: D29
data_type: string

tool: D17: Enter first integer

tool: D39: %d

tool: D12: Enter second integer

tool: D29: Sum is %d


assistant: ```c
int main(void) {
  int integer1;
  int integer2;
  int sum;
  printf("Enter first integer\n");
  scanf("%d", &integer1);
  printf("Enter second integer\n");
  scanf("%d", &integer2);
  sum = integer1 + integer2;
  printf("Sum is %d\n", sum);
  return 0;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<main>:
  endbr64
  push   %rbp
  lea    D18(%rip),%rdi
  lea    D39(%rip),%rbp
  sub    $0x10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  call   <puts@plt>
  mov    %rsp,%rsi
  mov    %rbp,%rdi
  call   <scanf@plt>
  lea    D0(%rip),%rdi
  call   <puts@plt>
  lea    0x4(%rsp),%rsi
  mov    %rbp,%rdi
  call   <scanf@plt>
  mov    0x4(%rsp),%esi
  xor    %eax,%eax
  add    (%rsp),%esi
  lea    D5(%rip),%rdi
  call   <printf@plt>
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L5
  add    $0x10,%rsp
  xor    %eax,%eax
  pop    %rbp
  ret
L5:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: data_tag: D18
data_type: string
name: read_data
arguments: data_tag: D39
data_type: string
name: read_data
arguments: data_tag: D0
data_type: string
name: read_data
arguments: data_tag: D5
data_type: string

tool: D18: Enter first integer

tool: D39: %d

tool: D0: Enter second integer

tool: D5: Sum is %d


assistant: ```c
int main(void) {
  int integer1;
  int integer2;
  int sum;
  printf("Enter first integer\n");
  scanf("%d", &integer1);
  printf("Enter second integer\n");
  scanf("%d", &integer2);
  sum = integer1 + integer2;
  printf("Sum is %d\n", sum);
  return 0;
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<main>:
  endbr64
  push   %rbp
  lea    D25(%rip),%rdi
  lea    D28(%rip),%rbp
  sub    $0x10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  call   <puts@plt>
  mov    %rsp,%rsi
  mov    %rbp,%rdi
  call   <scanf@plt>
  lea    D12(%rip),%rdi
  call   <puts@plt>
  lea    0x4(%rsp),%rsi
  mov    %rbp,%rdi
  call   <scanf@plt>
  mov    0x4(%rsp),%esi
  xor    %eax,%eax
  add    (%rsp),%esi
  lea    D27(%rip),%rdi
  call   <printf@plt>
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L4
  add    $0x10,%rsp
  xor    %eax,%eax
  pop    %rbp
  ret
L4:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: label: D25
type: string
name: retrieve_data
arguments: label: D28
type: string
name: retrieve_data
arguments: label: D12
type: string
name: retrieve_data
arguments: label: D27
type: string

tool: D25: Enter first integer

tool: D28: %d

tool: D12: Enter second integer

tool: D27: Sum is %d


assistant: ```c
int main(void) {
  int integer1;
  int integer2;
  int sum;
  printf("Enter first integer\n");
  scanf("%d", &integer1);
  printf("Enter second integer\n");
  scanf("%d", &integer2);
  sum = integer1 + integer2;
  printf("Sum is %d\n", sum);
  return 0;
}
```
user: 这段汇编代码用C语言表示是什么样的？

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %edi,-0x4(%rbp)
  mov    %rsi,-0x10(%rbp)
  mov    $0x0,%eax
  call   <fork@plt>
  test   %rax,%rax
  jne    L5
  lea    D26(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  jmp    L8
L5:
  mov    $0x0,%eax
  call   <fork@plt>
  test   %rax,%rax
  jne    L8
  lea    D18(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
L8:
  lea    D28(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    $0x0,%eax
  leave
  ret
```

tool_calls: name: read_data
arguments: data_label: D26
data_type: string
name: read_data
arguments: data_label: D18
data_type: string
name: read_data
arguments: data_label: D28
data_type: string

tool: D26: child1 hello


tool: D18: child2 hello


tool: D28: hello


assistant: ```c
int main(int argc, char *argv[]) {
  if (fork() == 0) {
    printf("child1 hello\n");
  } else if (fork() == 0) {
    printf("child2 hello\n");
  }
  printf("hello\n");
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<main>:
  endbr64
  sub    $0x8,%rsp
  mov    $0x0,%eax
  call   <fork@plt>
  test   %rax,%rax
  jne    L10
  lea    D28(%rip),%rdi
  call   <printf@plt>
L23:
  lea    D3(%rip),%rdi
  call   <printf@plt>
  mov    $0x0,%eax
  add    $0x8,%rsp
  ret
L10:
  mov    $0x0,%eax
  call   <fork@plt>
  test   %rax,%rax
  jne    L23
  lea    D24(%rip),%rdi
  call   <printf@plt>
  jmp    L23
```

tool_calls: name: retrieve_data
arguments: data_label: D28
type_infered: string
name: retrieve_data
arguments: data_label: D3
type_infered: string
name: retrieve_data
arguments: data_label: D24
type_infered: string

tool: D28: child1 hello


tool: D3: hello


tool: D24: child2 hello


assistant: ```c
int main(int argc, char *argv[]) {
  if (fork() == 0) {
    printf("child1 hello\n");
  } else if (fork() == 0) {
    printf("child2 hello\n");
  }
  printf("hello\n");
}
```
user: What is the c source code of the assembly code below?

```asm
<main>:
  endbr64
  sub    $0x8,%rsp
  xor    %eax,%eax
  call   <fork@plt>
  test   %rax,%rax
  jne    L17
  lea    D11(%rip),%rdi
  call   <printf@plt>
L23:
  lea    D9(%rip),%rdi
  call   <printf@plt>
  xor    %eax,%eax
  add    $0x8,%rsp
  ret
L17:
  xor    %eax,%eax
  call   <fork@plt>
  test   %rax,%rax
  jne    L23
  lea    D8(%rip),%rdi
  call   <printf@plt>
  jmp    L23
```

tool_calls: name: extract_symbolic_data
arguments: label: D11
type_guessed: string
name: extract_symbolic_data
arguments: label: D9
type_guessed: string
name: extract_symbolic_data
arguments: label: D8
type_guessed: string

tool: D11: child1 hello


tool: D9: hello


tool: D8: child2 hello


assistant: ```c
int main(int argc, char *argv[]) {
  if (fork() == 0) {
    printf("child1 hello\n");
  } else if (fork() == 0) {
    printf("child2 hello\n");
  }
  printf("hello\n");
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<main>:
  endbr64
  sub    $0x8,%rsp
  xor    %eax,%eax
  call   <fork@plt>
  test   %rax,%rax
  jne    L10
  lea    D5(%rip),%rdi
  call   <printf@plt>
L27:
  lea    D10(%rip),%rdi
  call   <printf@plt>
  xor    %eax,%eax
  add    $0x8,%rsp
  ret
L10:
  xor    %eax,%eax
  call   <fork@plt>
  test   %rax,%rax
  jne    L27
  lea    D17(%rip),%rdi
  call   <printf@plt>
  jmp    L27
```

tool_calls: name: read_data
arguments: data_tag: D5
type_guessed: string
name: read_data
arguments: data_tag: D10
type_guessed: string
name: read_data
arguments: data_tag: D17
type_guessed: string

tool: D5: child1 hello


tool: D10: hello


tool: D17: child2 hello


assistant: ```c
int main(int argc, char *argv[]) {
  if (fork() == 0) {
    printf("child1 hello\n");
  } else if (fork() == 0) {
    printf("child2 hello\n");
  }
  printf("hello\n");
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<strlen1>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  movl   $0x0,-0x8(%rbp)
  movl   $0x0,-0x4(%rbp)
  jmp    L0
L7:
  addl   $0x1,-0x8(%rbp)
  addl   $0x1,-0x4(%rbp)
L0:
  mov    -0x4(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L7
  mov    -0x8(%rbp),%eax
  pop    %rbp
  ret
```

assistant: ```c
int strlen1(char *str) {
  int len = 0, i;
  for (i = 0; str[i] != '\0'; ++i)
    len++;
  return len;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<strlen1>:
  endbr64
  cmpb   $0x0,(%rdi)
  je     L23
  mov    $0x1,%eax
L22:
  mov    %eax,%edx
  add    $0x1,%rax
  cmpb   $0x0,-0x1(%rdi,%rax,1)
  jne    L22
L11:
  mov    %edx,%eax
  ret
L23:
  mov    $0x0,%edx
  jmp    L11
```

assistant: ```c
int strlen1(char *str) {
  int len = 0, i;
  for (i = 0; str[i] != '\0'; ++i)
    len++;
  return len;
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<strlen1>:
  endbr64
  cmpb   $0x0,(%rdi)
  je     L0
  mov    $0x1,%eax
  xchg   %ax,%ax
L3:
  mov    %eax,%r8d
  add    $0x1,%rax
  cmpb   $0x0,-0x1(%rdi,%rax,1)
  jne    L3
  mov    %r8d,%eax
  ret
  nopw   0x0(%rax,%rax,1)
L0:
  xor    %r8d,%r8d
  mov    %r8d,%eax
  ret
```

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

```asm
<strlen1>:
  endbr64
  cmpb   $0x0,(%rdi)
  je     L14
  mov    $0x1,%eax
  xchg   %ax,%ax
L2:
  mov    %eax,%r8d
  add    $0x1,%rax
  cmpb   $0x0,-0x1(%rdi,%rax,1)
  jne    L2
  mov    %r8d,%eax
  ret
  nopw   0x0(%rax,%rax,1)
L14:
  xor    %r8d,%r8d
  mov    %r8d,%eax
  ret
```

assistant: ```c
int strlen1(char *str) {
  int len = 0, i;
  for (i = 0; str[i] != '\0'; ++i)
    len++;
  return len;
}
```
user: What is the c source code of the assembly code below:

```asm
<set_port_attr>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %edi,-0x24(%rbp)
  mov    %esi,-0x28(%rbp)
  mov    %edx,-0x2c(%rbp)
  mov    %rcx,-0x38(%rbp)
  mov    %r8d,%eax
  mov    %r9d,-0x3c(%rbp)
  mov    %al,-0x30(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    -0x20(%rbp),%rdx
  mov    -0x24(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <tcgetattr@plt>
  mov    -0x28(%rbp),%edx
  lea    -0x20(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <set_baudrate@plt>
  mov    -0x10(%rbp),%edx
  mov    D52(%rip),%rax
  mov    (%rax),%eax
  not    %eax
  and    %edx,%eax
  mov    %eax,-0x10(%rbp)
  mov    -0x2c(%rbp),%edx
  lea    -0x20(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <set_data_bit@plt>
  movsbl -0x30(%rbp),%edx
  lea    -0x20(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <set_parity@plt>
  mov    -0x38(%rbp),%rdx
  lea    -0x20(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <set_stopbit@plt>
  movl   $0x0,-0x18(%rbp)
  mov    -0x14(%rbp),%eax
  mov    %eax,-0x14(%rbp)
  mov    -0x18(%rbp),%edx
  mov    D31(%rip),%rax
  mov    (%rax),%eax
  not    %eax
  and    %edx,%eax
  mov    %eax,-0x18(%rbp)
  mov    -0x20(%rbp),%rdx
  mov    D57(%rip),%rax
  mov    (%rax),%rax
  shl    $0x2,%rax
  add    %rax,%rdx
  mov    -0x3c(%rbp),%eax
  mov    %eax,(%rdx)
  mov    -0x20(%rbp),%rdx
  mov    D5(%rip),%rax
  mov    (%rax),%rax
  shl    $0x2,%rax
  add    %rax,%rdx
  mov    0x10(%rbp),%eax
  mov    %eax,(%rdx)
  mov    D16(%rip),%rax
  mov    (%rax),%edx
  mov    -0x24(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <tcflush@plt>
  mov    D39(%rip),%rax
  mov    (%rax),%ecx
  lea    -0x20(%rbp),%rdx
  mov    -0x24(%rbp),%eax
  mov    %ecx,%esi
  mov    %eax,%edi
  call   <tcsetattr@plt>
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L0
  call   <__stack_chk_fail@plt>
L0:
  leave
  ret
```

assistant: ```c
int set_port_attr(int fd, int baudrate, int databit, const char *stopbit, char parity, int vtime, int vmin) {
  struct termios opt;
  tcgetattr(fd, &opt);
  set_baudrate(&opt, baudrate);
  opt.c_cflag &= ~CRTSCTS;
  set_data_bit(&opt, databit);
  set_parity(&opt, parity);
  set_stopbit(&opt, stopbit);
  opt.c_oflag = 0;
  opt.c_lflag |= 0;
  opt.c_oflag &= ~OPOST;
  opt.c_cc[VTIME] = vtime;
  opt.c_cc[VMIN] = vmin;
  tcflush(fd, TCIFLUSH);
  return (tcsetattr(fd, TCSANOW, &opt));
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<set_port_attr>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %edi,%ebp
  mov    %esi,%r15d
  mov    %edx,%r14d
  mov    %rcx,0x8(%rsp)
  mov    %r8d,%r12d
  mov    %r9d,%r13d
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  lea    0x10(%rsp),%rbx
  mov    %rbx,%rsi
  call   <tcgetattr@plt>
  mov    %r15d,%esi
  mov    %rbx,%rdi
  call   <set_baudrate@plt>
  mov    D26(%rip),%rax
  mov    (%rax),%eax
  not    %eax
  and    %eax,0x20(%rsp)
  mov    %r14d,%esi
  mov    %rbx,%rdi
  call   <set_data_bit@plt>
  movsbl %r12b,%esi
  mov    %rbx,%rdi
  call   <set_parity@plt>
  mov    0x8(%rsp),%rsi
  mov    %rbx,%rdi
  call   <set_stopbit@plt>
  movl   $0x0,0x18(%rsp)
  mov    D5(%rip),%rax
  mov    (%rax),%rdx
  mov    0x10(%rsp),%rax
  mov    %r13d,(%rax,%rdx,4)
  mov    D36(%rip),%rax
  mov    (%rax),%rdx
  mov    0x70(%rsp),%ecx
  mov    0x10(%rsp),%rax
  mov    %ecx,(%rax,%rdx,4)
  mov    D34(%rip),%rax
  mov    (%rax),%esi
  mov    %ebp,%edi
  call   <tcflush@plt>
  mov    %rbx,%rdx
  mov    D37(%rip),%rax
  mov    (%rax),%esi
  mov    %ebp,%edi
  call   <tcsetattr@plt>
  mov    0x28(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L7
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L7:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int set_port_attr(int fd, int baudrate, int databit, const char *stopbit, char parity, int vtime, int vmin) {
  struct termios opt;
  tcgetattr(fd, &opt);
  set_baudrate(&opt, baudrate);
  opt.c_cflag &= ~CRTSCTS;
  set_data_bit(&opt, databit);
  set_parity(&opt, parity);
  set_stopbit(&opt, stopbit);
  opt.c_oflag = 0;
  opt.c_lflag |= 0;
  opt.c_oflag &= ~OPOST;
  opt.c_cc[VTIME] = vtime;
  opt.c_cc[VMIN] = vmin;
  tcflush(fd, TCIFLUSH);
  return (tcsetattr(fd, TCSANOW, &opt));
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<set_port_attr>:
  endbr64
  push   %r15
  mov    %edx,%r15d
  push   %r14
  mov    %rcx,%r14
  push   %r13
  mov    %r9d,%r13d
  push   %r12
  push   %rbp
  mov    %edi,%ebp
  push   %rbx
  mov    %r8d,%ebx
  sub    $0x38,%rsp
  mov    %esi,0xc(%rsp)
  lea    0x10(%rsp),%r12
  mov    %r12,%rsi
  mov    %fs:0x28,%rax
  mov    %rax,0x28(%rsp)
  xor    %eax,%eax
  call   <tcgetattr@plt>
  mov    0xc(%rsp),%esi
  mov    %r12,%rdi
  call   <set_baudrate@plt>
  mov    D25(%rip),%rax
  mov    %r15d,%esi
  mov    %r12,%rdi
  mov    (%rax),%eax
  not    %eax
  and    %eax,0x20(%rsp)
  call   <set_data_bit@plt>
  movsbl %bl,%esi
  mov    %r12,%rdi
  call   <set_parity@plt>
  mov    %r14,%rsi
  mov    %r12,%rdi
  call   <set_stopbit@plt>
  mov    0x10(%rsp),%rax
  mov    0x70(%rsp),%ecx
  mov    %ebp,%edi
  mov    D37(%rip),%rdx
  movl   $0x0,0x18(%rsp)
  mov    (%rdx),%rdx
  mov    %r13d,(%rax,%rdx,4)
  mov    D18(%rip),%rdx
  mov    (%rdx),%rdx
  mov    %ecx,(%rax,%rdx,4)
  mov    D20(%rip),%rax
  mov    (%rax),%esi
  call   <tcflush@plt>
  mov    D2(%rip),%rax
  mov    %r12,%rdx
  mov    %ebp,%edi
  mov    (%rax),%esi
  call   <tcsetattr@plt>
  mov    0x28(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L7
  add    $0x38,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L7:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int set_port_attr(int fd, int baudrate, int databit, const char *stopbit, char parity, int vtime, int vmin) {
  struct termios opt;
  tcgetattr(fd, &opt);
  set_baudrate(&opt, baudrate);
  opt.c_cflag &= ~CRTSCTS;
  set_data_bit(&opt, databit);
  set_parity(&opt, parity);
  set_stopbit(&opt, stopbit);
  opt.c_oflag = 0;
  opt.c_lflag |= 0;
  opt.c_oflag &= ~OPOST;
  opt.c_cc[VTIME] = vtime;
  opt.c_cc[VMIN] = vmin;
  tcflush(fd, TCIFLUSH);
  return (tcsetattr(fd, TCSANOW, &opt));
}
```