ylfeng/ReF-Decompile-dataset huggingface dataset:
user: Converte this assembly snippet into its equivalent C code:

```asm
<doname>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  lea    0x1(%rdi),%rbx
  jmp    L83
L61:
  movsbl %dil,%edi
  call   <putchar@plt>
L69:
  add    $0x1,%rbx
L83:
  lea    -0x1(%rbx),%rbp
  mov    %rbx,%rax
  movzbl -0x1(%rbx),%edi
  test   %dil,%dil
  je     L10
  cmp    $0x2e,%dil
  jne    L61
L10:
  test   %dil,%dil
  je     L38
  movzbl (%rax),%edx
  test   %dl,%dl
  je     L38
L15:
  cmp    $0x2e,%dl
  je     L58
  add    $0x1,%rax
  movzbl (%rax),%edx
  test   %dl,%dl
  jne    L15
L38:
  mov    $0x28,%edi
  call   <putchar@plt>
  cmpb   $0x0,0x0(%rbp)
  je     L19
  lea    0x1(%rbp),%rbx
  movzbl 0x1(%rbp),%edi
  test   %dil,%dil
  je     L19
L6:
  add    $0x1,%rbx
  movsbl %dil,%edi
  call   <putchar@plt>
  movzbl (%rbx),%edi
  test   %dil,%dil
  jne    L6
L19:
  mov    $0x29,%edi
  call   <putchar@plt>
  mov    $0x20,%edi
  call   <putchar@plt>
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
L58:
  movsbl %dil,%edi
  call   <putchar@plt>
  jmp    L69
```

assistant: ```c
void doname(char *name) {
  char *dp = name, *ep;
again:
  while (*dp && *dp != '.')
    (void)putchar(*dp++);
  if (*dp)
    for (ep = dp + 1; *ep; ep++)
      if (*ep == '.') {
        (void)putchar(*dp++);
        goto again;
      }
  (void)putchar('(');
  if (*dp)
    dp++;
  while (*dp)
    (void)putchar(*dp++);
  (void)putchar(')');
  (void)putchar(' ');
}
```
user: 这段汇编代码用C语言表示是什么样的:

```asm
<doname>:
  endbr64
  push   %rbp
  push   %rbx
  lea    0x1(%rdi),%rbx
  lea    -0x1(%rbx),%rbp
  mov    %rbx,%rdx
  sub    $0x8,%rsp
  movsbl -0x1(%rbx),%edi
  test   %dil,%dil
  je     L88
L37:
  cmp    $0x2e,%dil
  jne    L34
  test   %dil,%dil
  je     L88
  movzbl (%rbx),%eax
  test   %al,%al
  jne    L66
  jmp    L88
  cs nopw 0x0(%rax,%rax,1)
L53:
  movzbl 0x1(%rdx),%eax
  add    $0x1,%rdx
  test   %al,%al
  je     L88
L66:
  cmp    $0x2e,%al
  jne    L53
  mov    $0x2e,%edi
  call   <putchar@plt>
L58:
  movsbl (%rbx),%edi
  add    $0x1,%rbx
  lea    -0x1(%rbx),%rbp
  mov    %rbx,%rdx
  test   %dil,%dil
  jne    L37
L88:
  mov    $0x28,%edi
  call   <putchar@plt>
  cmpb   $0x0,0x0(%rbp)
  je     L6
  movsbl 0x1(%rbp),%edi
  lea    0x1(%rbp),%rbx
  test   %dil,%dil
  je     L6
  nopw   0x0(%rax,%rax,1)
L45:
  call   <putchar@plt>
  movsbl 0x1(%rbx),%edi
  add    $0x1,%rbx
  test   %dil,%dil
  jne    L45
L6:
  mov    $0x29,%edi
  call   <putchar@plt>
  add    $0x8,%rsp
  mov    $0x20,%edi
  pop    %rbx
  pop    %rbp
  jmp    1050 <putchar@plt>
  nopl   0x0(%rax)
L34:
  call   <putchar@plt>
  jmp    L58
```

assistant: ```c
void doname(char *name) {
  char *dp = name, *ep;
again:
  while (*dp && *dp != '.')
    (void)putchar(*dp++);
  if (*dp)
    for (ep = dp + 1; *ep; ep++)
      if (*ep == '.') {
        (void)putchar(*dp++);
        goto again;
      }
  (void)putchar('(');
  if (*dp)
    dp++;
  while (*dp)
    (void)putchar(*dp++);
  (void)putchar(')');
  (void)putchar(' ');
}
```
user: 这段汇编代码用C语言表示是什么样的？

```asm
<doname>:
  endbr64
  push   %rbp
  push   %rbx
  lea    0x1(%rdi),%rbx
  lea    -0x1(%rbx),%rbp
  mov    %rbx,%rdx
  sub    $0x8,%rsp
  movsbl -0x1(%rbx),%edi
  test   %dil,%dil
  je     L91
L86:
  cmp    $0x2e,%dil
  jne    L90
  test   %dil,%dil
  je     L91
  movzbl (%rbx),%eax
  test   %al,%al
  jne    L65
  jmp    L91
  cs nopw 0x0(%rax,%rax,1)
L92:
  movzbl 0x1(%rdx),%eax
  add    $0x1,%rdx
  test   %al,%al
  je     L91
L65:
  cmp    $0x2e,%al
  jne    L92
  mov    $0x2e,%edi
  call   <putchar@plt>
L33:
  movsbl (%rbx),%edi
  add    $0x1,%rbx
  lea    -0x1(%rbx),%rbp
  mov    %rbx,%rdx
  test   %dil,%dil
  jne    L86
L91:
  mov    $0x28,%edi
  call   <putchar@plt>
  cmpb   $0x0,0x0(%rbp)
  je     L96
  movsbl 0x1(%rbp),%edi
  lea    0x1(%rbp),%rbx
  test   %dil,%dil
  je     L96
  nopw   0x0(%rax,%rax,1)
L84:
  call   <putchar@plt>
  movsbl 0x1(%rbx),%edi
  add    $0x1,%rbx
  test   %dil,%dil
  jne    L84
L96:
  mov    $0x29,%edi
  call   <putchar@plt>
  add    $0x8,%rsp
  mov    $0x20,%edi
  pop    %rbx
  pop    %rbp
  jmp    1050 <putchar@plt>
  nopl   0x0(%rax)
L90:
  call   <putchar@plt>
  jmp    L33
```

assistant: ```c
void doname(char *name) {
  char *dp = name, *ep;
again:
  while (*dp && *dp != '.')
    (void)putchar(*dp++);
  if (*dp)
    for (ep = dp + 1; *ep; ep++)
      if (*ep == '.') {
        (void)putchar(*dp++);
        goto again;
      }
  (void)putchar('(');
  if (*dp)
    dp++;
  while (*dp)
    (void)putchar(*dp++);
  (void)putchar(')');
  (void)putchar(' ');
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<sleep>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %edi,-0x14(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    -0xc(%rbp),%rdx
  mov    -0x14(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <os_sleep@plt>
  cmp    $0xffffffff,%eax
  jne    L14
  mov    $0x0,%eax
  call   <os_freakout@plt>
L14:
  mov    -0xc(%rbp),%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L18
  call   <__stack_chk_fail@plt>
L18:
  leave
  ret
```

assistant: ```c
unsigned int sleep(unsigned int seconds) {
  unsigned int rc;
  if (os_sleep(seconds, &rc) == -1)
    os_freakout();
  return rc;
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<sleep>:
  endbr64
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    0x4(%rsp),%rsi
  call   <os_sleep@plt>
  cmp    $0xffffffff,%eax
  je     L5
L1:
  mov    0x4(%rsp),%eax
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L18
  add    $0x18,%rsp
  ret
L5:
  mov    $0x0,%eax
  call   <os_freakout@plt>
  jmp    L1
L18:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
unsigned int sleep(unsigned int seconds) {
  unsigned int rc;
  if (os_sleep(seconds, &rc) == -1)
    os_freakout();
  return rc;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<sleep>:
  endbr64
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    0x4(%rsp),%rsi
  call   <os_sleep@plt>
  cmp    $0xffffffff,%eax
  je     L15
L23:
  mov    0x4(%rsp),%eax
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L10
  add    $0x18,%rsp
  ret
L15:
  xor    %eax,%eax
  call   <os_freakout@plt>
  jmp    L23
L10:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
unsigned int sleep(unsigned int seconds) {
  unsigned int rc;
  if (os_sleep(seconds, &rc) == -1)
    os_freakout();
  return rc;
}
```
user: Translate the below assembly code into C programming language:

```asm
<sleep>:
  endbr64
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    0x4(%rsp),%rsi
  call   <os_sleep@plt>
  cmp    $0xffffffff,%eax
  je     L1
L22:
  mov    0x4(%rsp),%eax
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L28
  add    $0x18,%rsp
  ret
L1:
  xor    %eax,%eax
  call   <os_freakout@plt>
  jmp    L22
L28:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
unsigned int sleep(unsigned int seconds) {
  unsigned int rc;
  if (os_sleep(seconds, &rc) == -1)
    os_freakout();
  return rc;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<DecUnitFloat>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,%eax
  mov    %al,-0x14(%rbp)
  movzbl -0x14(%rbp),%eax
  mov    %eax,-0xc(%rbp)
  pxor   %xmm0,%xmm0
  cvtsi2sdl -0xc(%rbp),%xmm0
  movsd  D6(%rip),%xmm1
  divsd  %xmm1,%xmm0
  movsd  D16(%rip),%xmm1
  subsd  %xmm1,%xmm0
  movsd  %xmm0,-0x8(%rbp)
  movsd  -0x8(%rbp),%xmm0
  movq   %xmm0,%rax
  movq   %rax,%xmm0
  pop    %rbp
  ret
```

tool_calls: name: retrieve_data
arguments: data_label: D6
type: f64
name: retrieve_data
arguments: data_label: D16
type: f64

tool: D6: 127.5

tool: D16: 1

assistant: ```c
double DecUnitFloat(c)
unsigned char c;
{
  double d;
  int i;
  i = 0xff & c;
  d = (((double)i) / 127.5) - 1.0;
  return d;
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<DecUnitFloat>:
  endbr64
  movzbl %dil,%edi
  pxor   %xmm0,%xmm0
  cvtsi2sd %edi,%xmm0
  divsd  D14(%rip),%xmm0
  subsd  D17(%rip),%xmm0
  ret
```

tool_calls: name: parse_data
arguments: data_label: D14
type: f64
name: parse_data
arguments: data_label: D17
type: f64

tool: D14: 127.5

tool: D17: 1

assistant: ```c
double DecUnitFloat(c)
unsigned char c;
{
  double d;
  int i;
  i = 0xff & c;
  d = (((double)i) / 127.5) - 1.0;
  return d;
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<DecUnitFloat>:
  endbr64
  movzbl %dil,%edi
  pxor   %xmm0,%xmm0
  cvtsi2sd %edi,%xmm0
  divsd  D7(%rip),%xmm0
  subsd  D1(%rip),%xmm0
  ret
```

tool_calls: name: unpack_data
arguments: label: D7
data_type: f64
name: unpack_data
arguments: label: D1
data_type: f64

tool: D7: 127.5

tool: D1: 1

assistant: ```c
double DecUnitFloat(c)
unsigned char c;
{
  double d;
  int i;
  i = 0xff & c;
  d = (((double)i) / 127.5) - 1.0;
  return d;
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<DecUnitFloat>:
  endbr64
  movzbl %dil,%edi
  pxor   %xmm0,%xmm0
  cvtsi2sd %edi,%xmm0
  divsd  D8(%rip),%xmm0
  subsd  D2(%rip),%xmm0
  ret
```

tool_calls: name: unpack_data
arguments: label: D8
data_type: f64
name: unpack_data
arguments: label: D2
data_type: f64

tool: D8: 127.5

tool: D2: 1

assistant: ```c
double DecUnitFloat(c)
unsigned char c;
{
  double d;
  int i;
  i = 0xff & c;
  d = (((double)i) / 127.5) - 1.0;
  return d;
}
```
user: What is the c source code of the assembly code below?

```asm
<messageHasData>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,-0x4(%rbp)
  mov    %esi,-0x8(%rbp)
  cmpl   $0x1,-0x4(%rbp)
  je     L10
  cmpl   $0x6,-0x4(%rbp)
  jne    L28
L10:
  mov    $0x0,%eax
  jmp    L13
L28:
  mov    $0xffffffff,%eax
L13:
  pop    %rbp
  ret
```

assistant: ```c
int messageHasData(unsigned int command, unsigned int arg) {
  switch (command) {
  case 1:
  case 6:
    return 0;
  case 0:
  case 8:
  default:
    return -1;
  }
  return -1;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<messageHasData>:
  endbr64
  mov    $0x0,%eax
  cmp    $0x1,%edi
  je     L3
  cmp    $0x6,%edi
  setne  %al
  movzbl %al,%eax
  neg    %eax
L3:
  ret
```

assistant: ```c
int messageHasData(unsigned int command, unsigned int arg) {
  switch (command) {
  case 1:
  case 6:
    return 0;
  case 0:
  case 8:
  default:
    return -1;
  }
  return -1;
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<messageHasData>:
  endbr64
  xor    %eax,%eax
  cmp    $0x1,%edi
  je     L5
  xor    %eax,%eax
  cmp    $0x6,%edi
  setne  %al
  neg    %eax
L5:
  ret
```

assistant: ```c
int messageHasData(unsigned int command, unsigned int arg) {
  switch (command) {
  case 1:
  case 6:
    return 0;
  case 0:
  case 8:
  default:
    return -1;
  }
  return -1;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<messageHasData>:
  endbr64
  xor    %eax,%eax
  cmp    $0x1,%edi
  je     L8
  xor    %eax,%eax
  cmp    $0x6,%edi
  setne  %al
  neg    %eax
L8:
  ret
```

assistant: ```c
int messageHasData(unsigned int command, unsigned int arg) {
  switch (command) {
  case 1:
  case 6:
    return 0;
  case 0:
  case 8:
  default:
    return -1;
  }
  return -1;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<read_perms>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %edi,-0x4(%rbp)
  cmpl   $0x0,-0x4(%rbp)
  jne    L42
  mov    $0x0,%eax
  call   <get_permissoins@plt>
  mov    %eax,-0x4(%rbp)
L42:
  lea    D18(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    -0x4(%rbp),%eax
  and    $0x2,%eax
  test   %eax,%eax
  je     L17
  lea    D43(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
L17:
  mov    -0x4(%rbp),%eax
  and    $0x1,%eax
  test   %eax,%eax
  je     L8
  lea    D45(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
L8:
  mov    -0x4(%rbp),%eax
  and    $0x4,%eax
  test   %eax,%eax
  je     L37
  lea    D48(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
L37:
  mov    -0x4(%rbp),%eax
  and    $0x8,%eax
  test   %eax,%eax
  je     L38
  lea    D28(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
L38:
  nop
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: label: D18
type_infered: string
name: disassemble_data
arguments: label: D43
type_infered: string
name: disassemble_data
arguments: label: D45
type_infered: string
name: disassemble_data
arguments: label: D48
type_infered: string
name: disassemble_data
arguments: label: D28
type_infered: string

tool: D18: Set permissions: 


tool: D43: 	 BLOCK_ALL


tool: D45: 	 ALLOW_ALL


tool: D48: 	 BLOCK_USBHID


tool: D28: 	 BLOCK_USB_INTERFACE


assistant: ```c
void read_perms(int perms) {
  if (perms == 0)
    perms = get_permissoins();
  printf("Set permissions: \n");
  if (perms & 1 << 1)
    printf("\t BLOCK_ALL\n");
  if (perms & 1 << 0)
    printf("\t ALLOW_ALL\n");
  if (perms & 1 << 2)
    printf("\t BLOCK_USBHID\n");
  if (perms & 1 << 3)
    printf("\t BLOCK_USB_INTERFACE\n");
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<read_perms>:
  endbr64
  push   %rbx
  mov    %edi,%ebx
  test   %edi,%edi
  je     L43
L86:
  lea    D16(%rip),%rdi
  call   <printf@plt>
  test   $0x2,%bl
  jne    L5
L3:
  test   $0x1,%bl
  jne    L55
L38:
  test   $0x4,%bl
  jne    L2
L4:
  test   $0x8,%bl
  jne    L51
L94:
  pop    %rbx
  ret
L43:
  mov    $0x0,%eax
  call   <get_permissoins@plt>
  mov    %eax,%ebx
  jmp    L86
L5:
  lea    D7(%rip),%rdi
  call   <printf@plt>
  jmp    L3
L55:
  lea    D13(%rip),%rdi
  call   <printf@plt>
  jmp    L38
L2:
  lea    D41(%rip),%rdi
  call   <printf@plt>
  jmp    L4
L51:
  lea    D15(%rip),%rdi
  call   <printf@plt>
  jmp    L94
```

tool_calls: name: disassemble_data
arguments: label: D16
datatype: string
name: disassemble_data
arguments: label: D7
datatype: string
name: disassemble_data
arguments: label: D13
datatype: string
name: disassemble_data
arguments: label: D41
datatype: string
name: disassemble_data
arguments: label: D15
datatype: string

tool: D16: Set permissions: 


tool: D7: 	 BLOCK_ALL


tool: D13: 	 ALLOW_ALL


tool: D41: 	 BLOCK_USBHID


tool: D15: 	 BLOCK_USB_INTERFACE


assistant: ```c
void read_perms(int perms) {
  if (perms == 0)
    perms = get_permissoins();
  printf("Set permissions: \n");
  if (perms & 1 << 1)
    printf("\t BLOCK_ALL\n");
  if (perms & 1 << 0)
    printf("\t ALLOW_ALL\n");
  if (perms & 1 << 2)
    printf("\t BLOCK_USBHID\n");
  if (perms & 1 << 3)
    printf("\t BLOCK_USB_INTERFACE\n");
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<read_perms>:
  endbr64
  push   %rbx
  mov    %edi,%ebx
  test   %edi,%edi
  je     L71
L48:
  lea    D17(%rip),%rdi
  call   <printf@plt>
  test   $0x2,%bl
  jne    L30
L31:
  test   $0x1,%bl
  jne    L53
L84:
  test   $0x4,%bl
  jne    L41
L43:
  and    $0x8,%ebx
  jne    L60
  pop    %rbx
  ret
  nopl   (%rax)
L71:
  xor    %eax,%eax
  call   <get_permissoins@plt>
  mov    %eax,%ebx
  jmp    L48
  nopl   0x0(%rax,%rax,1)
L60:
  lea    D48(%rip),%rdi
  pop    %rbx
  jmp    1060 <printf@plt>
  nopl   (%rax)
L41:
  lea    D12(%rip),%rdi
  call   <printf@plt>
  jmp    L43
  xchg   %ax,%ax
L53:
  lea    D2(%rip),%rdi
  call   <printf@plt>
  jmp    L84
  xchg   %ax,%ax
L30:
  lea    D27(%rip),%rdi
  call   <printf@plt>
  jmp    L31
```

tool_calls: name: parse_data
arguments: tag: D17
type_infered: string
name: parse_data
arguments: tag: D48
type_infered: string
name: parse_data
arguments: tag: D12
type_infered: string
name: parse_data
arguments: tag: D2
type_infered: string
name: parse_data
arguments: tag: D27
type_infered: string

tool: D17: Set permissions: 


tool: D48: 	 BLOCK_USB_INTERFACE


tool: D12: 	 BLOCK_USBHID


tool: D2: 	 ALLOW_ALL


tool: D27: 	 BLOCK_ALL


assistant: ```c
void read_perms(int perms) {
  if (perms == 0)
    perms = get_permissoins();
  printf("Set permissions: \n");
  if (perms & 1 << 1)
    printf("\t BLOCK_ALL\n");
  if (perms & 1 << 0)
    printf("\t ALLOW_ALL\n");
  if (perms & 1 << 2)
    printf("\t BLOCK_USBHID\n");
  if (perms & 1 << 3)
    printf("\t BLOCK_USB_INTERFACE\n");
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<read_perms>:
  endbr64
  push   %rbx
  mov    %edi,%ebx
  test   %edi,%edi
  je     L23
L13:
  lea    D12(%rip),%rdi
  call   <printf@plt>
  test   $0x2,%bl
  jne    L61
L62:
  test   $0x1,%bl
  jne    L10
L31:
  test   $0x4,%bl
  jne    L73
L75:
  and    $0x8,%ebx
  jne    L82
  pop    %rbx
  ret
  nopl   (%rax)
L23:
  xor    %eax,%eax
  call   <get_permissoins@plt>
  mov    %eax,%ebx
  jmp    L13
  nopl   0x0(%rax,%rax,1)
L82:
  lea    D35(%rip),%rdi
  pop    %rbx
  jmp    1060 <printf@plt>
  nopl   (%rax)
L73:
  lea    D7(%rip),%rdi
  call   <printf@plt>
  jmp    L75
  xchg   %ax,%ax
L10:
  lea    D19(%rip),%rdi
  call   <printf@plt>
  jmp    L31
  xchg   %ax,%ax
L61:
  lea    D44(%rip),%rdi
  call   <printf@plt>
  jmp    L62
```

tool_calls: name: parse_data
arguments: data_tag: D12
type: string
name: parse_data
arguments: data_tag: D35
type: string
name: parse_data
arguments: data_tag: D7
type: string
name: parse_data
arguments: data_tag: D19
type: string
name: parse_data
arguments: data_tag: D44
type: string

tool: D12: Set permissions: 


tool: D35: 	 BLOCK_USB_INTERFACE


tool: D7: 	 BLOCK_USBHID


tool: D19: 	 ALLOW_ALL


tool: D44: 	 BLOCK_ALL


assistant: ```c
void read_perms(int perms) {
  if (perms == 0)
    perms = get_permissoins();
  printf("Set permissions: \n");
  if (perms & 1 << 1)
    printf("\t BLOCK_ALL\n");
  if (perms & 1 << 0)
    printf("\t ALLOW_ALL\n");
  if (perms & 1 << 2)
    printf("\t BLOCK_USBHID\n");
  if (perms & 1 << 3)
    printf("\t BLOCK_USB_INTERFACE\n");
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<grepline>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %rdx,-0x38(%rbp)
  movq   $0x0,-0x18(%rbp)
  mov    -0x38(%rbp),%rax
  mov    %rax,%rdi
  call   <ftell@plt>
  mov    %rax,-0x10(%rbp)
  movb   $0x0,-0x19(%rbp)
  movq   $0x0,-0x8(%rbp)
  movb   $0x0,-0x1a(%rbp)
  cmpq   $0x0,-0x28(%rbp)
  je     L64
  mov    -0x28(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <free@plt>
L64:
  mov    -0x38(%rbp),%rax
  mov    %rax,%rdi
  call   <fgetc@plt>
  mov    %al,-0x19(%rbp)
  addq   $0x1,-0x18(%rbp)
  mov    -0x38(%rbp),%rax
  mov    %rax,%rdi
  call   <feof@plt>
  test   %eax,%eax
  jne    L40
  cmpb   $0xa,-0x19(%rbp)
  je     L40
  cmpb   $0xd,-0x19(%rbp)
  jne    L64
L40:
  cmpb   $0xd,-0x19(%rbp)
  jne    L6
  mov    -0x38(%rbp),%rax
  mov    %rax,%rdi
  call   <fgetc@plt>
  mov    %al,-0x19(%rbp)
  cmpb   $0xa,-0x19(%rbp)
  jne    L6
  movzbl -0x1a(%rbp),%eax
  add    $0x1,%eax
  mov    %al,-0x1a(%rbp)
L6:
  mov    D4(%rip),%rax
  mov    (%rax),%edx
  mov    -0x10(%rbp),%rcx
  mov    -0x38(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <fseek@plt>
  mov    -0x18(%rbp),%rax
  add    $0x1,%rax
  mov    %rax,%rdi
  call   <malloc@plt>
  mov    %rax,-0x8(%rbp)
  mov    -0x38(%rbp),%rdx
  mov    -0x18(%rbp),%rsi
  mov    -0x8(%rbp),%rax
  mov    %rdx,%rcx
  mov    $0x1,%edx
  mov    %rax,%rdi
  call   <fread@plt>
  cmpb   $0x0,-0x1a(%rbp)
  je     L51
  mov    -0x38(%rbp),%rax
  mov    %rax,%rdi
  call   <fgetc@plt>
  mov    %al,-0x19(%rbp)
L51:
  mov    -0x18(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movb   $0xa,(%rax)
  mov    -0x8(%rbp),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x30(%rbp),%rax
  mov    -0x18(%rbp),%rdx
  mov    %rdx,(%rax)
  mov    -0x28(%rbp),%rax
  mov    -0x8(%rbp),%rdx
  mov    %rdx,(%rax)
  mov    -0x18(%rbp),%rax
  leave
  ret
```

assistant: ```c
size_t grepline(char **lineptr, size_t *n, FILE *stream) {
  size_t len = 0;
  size_t offset = ftell(stream);
  char trash = 0;
  char *buf = NULL;
  char sizeofnewline = 0;
  if (lineptr != NULL) {
    free(*lineptr);
  }
  do {
    trash = fgetc(stream);
    ++len;
  } while (!feof(stream) && trash != '\n' && trash != '\r');
  if (trash == '\r') {
    trash = fgetc(stream);
    if (trash == '\n') {
      ++sizeofnewline;
    }
  }
  fseek(stream, offset, SEEK_SET);
  buf = (char *)malloc(len + 1);
  fread(buf, len, 1, stream);
  if (sizeofnewline) {
    trash = fgetc(stream);
  }
  buf[len - 1] = '\n';
  buf[len] = '\0';
  *n = len;
  *lineptr = buf;
  return len;
}
```
user: Translate the below assembly code into C programming language:

```asm
<grepline>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%r14
  mov    %rsi,%r15
  mov    %rdx,%r12
  mov    %rdx,%rdi
  call   <ftell@plt>
  mov    %rax,(%rsp)
  test   %r14,%r14
  je     L19
  mov    (%r14),%rdi
  call   <free@plt>
L19:
  mov    $0x0,%ebp
L6:
  mov    %r12,%rdi
  call   <fgetc@plt>
  mov    %eax,%ebx
  mov    %rbp,%r13
  add    $0x1,%rbp
  mov    %r12,%rdi
  call   <feof@plt>
  test   %eax,%eax
  jne    L50
  cmp    $0xa,%bl
  je     L50
  cmp    $0xd,%bl
  jne    L6
L50:
  cmp    $0xd,%bl
  je     L65
  mov    D1(%rip),%rax
  mov    (%rax),%edx
  mov    (%rsp),%rsi
  mov    %r12,%rdi
  call   <fseek@plt>
  lea    0x2(%r13),%rdi
  call   <malloc@plt>
  mov    %rax,%rbx
  mov    %r12,%rcx
  mov    $0x1,%edx
  mov    %rbp,%rsi
  mov    %rax,%rdi
  call   <fread@plt>
L57:
  movb   $0xa,(%rbx,%r13,1)
  movb   $0x0,(%rbx,%rbp,1)
  mov    %rbp,(%r15)
  mov    %rbx,(%r14)
  mov    %rbp,%rax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L65:
  mov    %r12,%rdi
  call   <fgetc@plt>
  mov    %al,0xf(%rsp)
  mov    D1(%rip),%rax
  mov    (%rax),%edx
  mov    (%rsp),%rsi
  mov    %r12,%rdi
  call   <fseek@plt>
  lea    0x2(%r13),%rdi
  call   <malloc@plt>
  mov    %rax,%rbx
  mov    %r12,%rcx
  mov    $0x1,%edx
  mov    %rbp,%rsi
  mov    %rax,%rdi
  call   <fread@plt>
  cmpb   $0xa,0xf(%rsp)
  jne    L57
  mov    %r12,%rdi
  call   <fgetc@plt>
  jmp    L57
```

assistant: ```c
size_t grepline(char **lineptr, size_t *n, FILE *stream) {
  size_t len = 0;
  size_t offset = ftell(stream);
  char trash = 0;
  char *buf = NULL;
  char sizeofnewline = 0;
  if (lineptr != NULL) {
    free(*lineptr);
  }
  do {
    trash = fgetc(stream);
    ++len;
  } while (!feof(stream) && trash != '\n' && trash != '\r');
  if (trash == '\r') {
    trash = fgetc(stream);
    if (trash == '\n') {
      ++sizeofnewline;
    }
  }
  fseek(stream, offset, SEEK_SET);
  buf = (char *)malloc(len + 1);
  fread(buf, len, 1, stream);
  if (sizeofnewline) {
    trash = fgetc(stream);
  }
  buf[len - 1] = '\n';
  buf[len] = '\0';
  *n = len;
  *lineptr = buf;
  return len;
}
```