ylfeng/ReF-Decompile-dataset huggingface dataset:
user: Translate the below assembly code into C programming language:

```asm
<is_dir>:
  endbr64
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    0x4(%rsp),%rsi
  call   <stat@plt>
  mov    0x4(%rsp),%edi
  call   <S_ISDIR@plt>
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L8
  add    $0x18,%rsp
  ret
L8:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int is_dir(char *path) {
  struct stat path_stat;
  stat(path, &path_stat);
  return S_ISDIR(path_stat.st_mode);
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<is_builtin_marker>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %rdi,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  lea    D15(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  je     L16
  mov    -0x8(%rbp),%rax
  lea    D10(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  je     L16
  mov    -0x8(%rbp),%rax
  lea    D0(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  jne    L1
L16:
  mov    $0x1,%eax
  jmp    L3
L1:
  mov    $0x0,%eax
L3:
  leave
  ret
```

tool_calls: name: parse_data
arguments: tag: D15
data_type: string
name: parse_data
arguments: tag: D10
data_type: string
name: parse_data
arguments: tag: D0
data_type: string

tool: D15: exp

tool: D10: addr

tool: D0: imm

assistant: ```c
int is_builtin_marker(char *s) {
  if (!strcmp(s, "exp") || !strcmp(s, "addr") || !strcmp(s, "imm"))
    return 1;
  else
    return 0;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<is_builtin_marker>:
  endbr64
  push   %rbx
  mov    %rdi,%rbx
  lea    D28(%rip),%rsi
  call   <strcmp@plt>
  mov    %eax,%edx
  mov    $0x1,%eax
  test   %edx,%edx
  je     L6
  lea    D3(%rip),%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  mov    %eax,%edx
  mov    $0x1,%eax
  test   %edx,%edx
  je     L6
  lea    D25(%rip),%rsi
  mov    %rbx,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  sete   %al
  movzbl %al,%eax
L6:
  pop    %rbx
  ret
```

tool_calls: name: read_data
arguments: data_tag: D28
datatype: string
name: read_data
arguments: data_tag: D3
datatype: string
name: read_data
arguments: data_tag: D25
datatype: string

tool: D28: exp

tool: D3: addr

tool: D25: imm

assistant: ```c
int is_builtin_marker(char *s) {
  if (!strcmp(s, "exp") || !strcmp(s, "addr") || !strcmp(s, "imm"))
    return 1;
  else
    return 0;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<is_builtin_marker>:
  endbr64
  push   %r12
  lea    D19(%rip),%rsi
  mov    $0x1,%r12d
  push   %rbp
  mov    %rdi,%rbp
  sub    $0x8,%rsp
  call   <strcmp@plt>
  test   %eax,%eax
  je     L8
  lea    D3(%rip),%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  je     L8
  lea    D2(%rip),%rsi
  mov    %rbp,%rdi
  xor    %r12d,%r12d
  call   <strcmp@plt>
  test   %eax,%eax
  sete   %r12b
L8:
  add    $0x8,%rsp
  mov    %r12d,%eax
  pop    %rbp
  pop    %r12
  ret
```

tool_calls: name: parse_data
arguments: tag: D19
type_guessed: string
name: parse_data
arguments: tag: D3
type_guessed: string
name: parse_data
arguments: tag: D2
type_guessed: string

tool: D19: exp

tool: D3: addr

tool: D2: imm

assistant: ```c
int is_builtin_marker(char *s) {
  if (!strcmp(s, "exp") || !strcmp(s, "addr") || !strcmp(s, "imm"))
    return 1;
  else
    return 0;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<is_builtin_marker>:
  endbr64
  push   %r12
  lea    D24(%rip),%rsi
  mov    $0x1,%r12d
  push   %rbp
  mov    %rdi,%rbp
  sub    $0x8,%rsp
  call   <strcmp@plt>
  test   %eax,%eax
  je     L9
  lea    D11(%rip),%rsi
  mov    %rbp,%rdi
  call   <strcmp@plt>
  test   %eax,%eax
  je     L9
  lea    D8(%rip),%rsi
  mov    %rbp,%rdi
  xor    %r12d,%r12d
  call   <strcmp@plt>
  test   %eax,%eax
  sete   %r12b
L9:
  add    $0x8,%rsp
  mov    %r12d,%eax
  pop    %rbp
  pop    %r12
  ret
```

tool_calls: name: extract_symbolic_data
arguments: label: D24
type: string
name: extract_symbolic_data
arguments: label: D11
type: string
name: extract_symbolic_data
arguments: label: D8
type: string

tool: D24: exp

tool: D11: addr

tool: D8: imm

assistant: ```c
int is_builtin_marker(char *s) {
  if (!strcmp(s, "exp") || !strcmp(s, "addr") || !strcmp(s, "imm"))
    return 1;
  else
    return 0;
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<validatePort>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <atoi@plt>
  mov    %eax,-0x4(%rbp)
  cmpl   $0x0,-0x4(%rbp)
  jle    L10
  cmpl   $0xffff,-0x4(%rbp)
  jg     L10
  mov    $0x1,%eax
  jmp    L15
L10:
  mov    $0x0,%eax
L15:
  leave
  ret
```

assistant: ```c
int validatePort(char *p) {
  int port = atoi(p);
  if (port >= 1 && port <= 65535)
    return 1;
  else
    return 0;
}
```
user: 这段汇编代码用C语言表示是什么样的?

```asm
<validatePort>:
  endbr64
  sub    $0x8,%rsp
  call   <atoi@plt>
  sub    $0x1,%eax
  cmp    $0xfffe,%eax
  setbe  %al
  movzbl %al,%eax
  add    $0x8,%rsp
  ret
```

assistant: ```c
int validatePort(char *p) {
  int port = atoi(p);
  if (port >= 1 && port <= 65535)
    return 1;
  else
    return 0;
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<validatePort>:
  endbr64
  sub    $0x8,%rsp
  call   <atoi@plt>
  sub    $0x1,%eax
  cmp    $0xfffe,%eax
  setbe  %al
  add    $0x8,%rsp
  movzbl %al,%eax
  ret
```

assistant: ```c
int validatePort(char *p) {
  int port = atoi(p);
  if (port >= 1 && port <= 65535)
    return 1;
  else
    return 0;
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<validatePort>:
  endbr64
  sub    $0x8,%rsp
  call   <atoi@plt>
  sub    $0x1,%eax
  cmp    $0xfffe,%eax
  setbe  %al
  add    $0x8,%rsp
  movzbl %al,%eax
  ret
```

assistant: ```c
int validatePort(char *p) {
  int port = atoi(p);
  if (port >= 1 && port <= 65535)
    return 1;
  else
    return 0;
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<read_file>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  movl   $0x0,-0x14(%rbp)
  mov    D29(%rip),%rax
  mov    (%rax),%edx
  mov    -0x28(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <open@plt>
  mov    %eax,-0x10(%rbp)
  cmpl   $0x0,-0x10(%rbp)
  jns    L56
  mov    $0xffffffff,%eax
  jmp    L9
L56:
  mov    D4(%rip),%rax
  mov    (%rax),%rax
  add    $0x1,%rax
  mov    %rax,%rdi
  call   <malloc_or_die@plt>
  mov    %rax,-0x8(%rbp)
  jmp    L21
L4:
  mov    -0xc(%rbp),%eax
  add    %eax,-0x14(%rbp)
  mov    -0x14(%rbp),%eax
  movslq %eax,%rdx
  mov    D4(%rip),%rax
  mov    (%rax),%rax
  add    %rdx,%rax
  lea    0x1(%rax),%rdx
  mov    -0x8(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <realloc@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L21
  movl   $0xffffffff,-0x14(%rbp)
  jmp    L51
L21:
  mov    D4(%rip),%rax
  mov    (%rax),%rdx
  mov    -0x14(%rbp),%eax
  movslq %eax,%rcx
  mov    -0x8(%rbp),%rax
  add    %rax,%rcx
  mov    -0x10(%rbp),%eax
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <read@plt>
  mov    %eax,-0xc(%rbp)
  cmpl   $0x0,-0xc(%rbp)
  jg     L4
  mov    -0x30(%rbp),%rax
  mov    -0x8(%rbp),%rdx
  mov    %rdx,(%rax)
  mov    -0x14(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
L51:
  mov    -0x10(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  mov    -0x14(%rbp),%eax
L9:
  leave
  ret
```

assistant: ```c
int read_file(const char *file, char **buffer) {
  char *buf;
  int len = 0;
  int fd;
  int r;
  fd = open(file, O_RDONLY);
  if (fd < 0)
    return -1;
  buf = malloc_or_die(BUFSIZ + 1);
  while ((r = read(fd, buf + len, BUFSIZ)) > 0) {
    len += r;
    buf = realloc(buf, len + BUFSIZ + 1);
    if (!buf) {
      len = -1;
      goto out;
    }
  }
  *buffer = buf;
  buf[len] = 0;
out:
  close(fd);
  return len;
}
```
user: Translate the below assembly code into C programming language:

```asm
<read_file>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rsi,%r14
  mov    D35(%rip),%rax
  mov    (%rax),%esi
  call   <open@plt>
  test   %eax,%eax
  js     L21
  mov    %eax,%r12d
  mov    D33(%rip),%rax
  mov    (%rax),%rdi
  add    $0x1,%rdi
  call   <malloc_or_die@plt>
  mov    %rax,%rbx
  mov    $0x0,%ebp
  mov    D33(%rip),%r13
L22:
  movslq %ebp,%r15
  add    %rbx,%r15
  mov    0x0(%r13),%rdx
  mov    %r15,%rsi
  mov    %r12d,%edi
  call   <read@plt>
  test   %eax,%eax
  jle    L30
  add    %eax,%ebp
  movslq %ebp,%rsi
  mov    D33(%rip),%rax
  add    (%rax),%rsi
  add    $0x1,%rsi
  mov    %rbx,%rdi
  call   <realloc@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  jne    L22
  mov    $0xffffffff,%ebp
  jmp    L20
L30:
  mov    %rbx,(%r14)
  movb   $0x0,(%r15)
L20:
  mov    %r12d,%edi
  call   <close@plt>
L10:
  mov    %ebp,%eax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L21:
  mov    $0xffffffff,%ebp
  jmp    L10
```

assistant: ```c
int read_file(const char *file, char **buffer) {
  char *buf;
  int len = 0;
  int fd;
  int r;
  fd = open(file, O_RDONLY);
  if (fd < 0)
    return -1;
  buf = malloc_or_die(BUFSIZ + 1);
  while ((r = read(fd, buf + len, BUFSIZ)) > 0) {
    len += r;
    buf = realloc(buf, len + BUFSIZ + 1);
    if (!buf) {
      len = -1;
      goto out;
    }
  }
  *buffer = buf;
  buf[len] = 0;
out:
  close(fd);
  return len;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<read_file>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  mov    %rsi,%r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    D1(%rip),%rax
  mov    (%rax),%esi
  call   <open@plt>
  test   %eax,%eax
  js     L6
  mov    D7(%rip),%rbx
  mov    %eax,%r12d
  xor    %r14d,%r14d
  xor    %r15d,%r15d
  mov    (%rbx),%rax
  lea    0x1(%rax),%rdi
  call   <malloc_or_die@plt>
  mov    %rax,%rbp
  jmp    L17
  nopl   0x0(%rax)
L25:
  mov    (%rbx),%rsi
  add    %eax,%r14d
  mov    %rbp,%rdi
  movslq %r14d,%r15
  add    %r15,%rsi
  add    $0x1,%rsi
  call   <realloc@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L42
L17:
  add    %rbp,%r15
  mov    (%rbx),%rdx
  mov    %r12d,%edi
  mov    %r15,%rsi
  call   <read@plt>
  test   %eax,%eax
  jg     L25
  mov    %rbp,0x0(%r13)
  movb   $0x0,(%r15)
L54:
  mov    %r12d,%edi
  call   <close@plt>
L51:
  add    $0x8,%rsp
  mov    %r14d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L42:
  mov    $0xffffffff,%r14d
  jmp    L54
L6:
  mov    $0xffffffff,%r14d
  jmp    L51
```

assistant: ```c
int read_file(const char *file, char **buffer) {
  char *buf;
  int len = 0;
  int fd;
  int r;
  fd = open(file, O_RDONLY);
  if (fd < 0)
    return -1;
  buf = malloc_or_die(BUFSIZ + 1);
  while ((r = read(fd, buf + len, BUFSIZ)) > 0) {
    len += r;
    buf = realloc(buf, len + BUFSIZ + 1);
    if (!buf) {
      len = -1;
      goto out;
    }
  }
  *buffer = buf;
  buf[len] = 0;
out:
  close(fd);
  return len;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<read_file>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  mov    %rsi,%r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    D11(%rip),%rax
  mov    (%rax),%esi
  call   <open@plt>
  test   %eax,%eax
  js     L21
  mov    D12(%rip),%rbx
  mov    %eax,%r12d
  xor    %r14d,%r14d
  xor    %r15d,%r15d
  mov    (%rbx),%rax
  lea    0x1(%rax),%rdi
  call   <malloc_or_die@plt>
  mov    %rax,%rbp
  jmp    L20
  nopl   0x0(%rax)
L7:
  mov    (%rbx),%rsi
  add    %eax,%r14d
  mov    %rbp,%rdi
  movslq %r14d,%r15
  add    %r15,%rsi
  add    $0x1,%rsi
  call   <realloc@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L36
L20:
  add    %rbp,%r15
  mov    (%rbx),%rdx
  mov    %r12d,%edi
  mov    %r15,%rsi
  call   <read@plt>
  test   %eax,%eax
  jg     L7
  mov    %rbp,0x0(%r13)
  movb   $0x0,(%r15)
L35:
  mov    %r12d,%edi
  call   <close@plt>
L37:
  add    $0x8,%rsp
  mov    %r14d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L36:
  mov    $0xffffffff,%r14d
  jmp    L35
L21:
  mov    $0xffffffff,%r14d
  jmp    L37
```

assistant: ```c
int read_file(const char *file, char **buffer) {
  char *buf;
  int len = 0;
  int fd;
  int r;
  fd = open(file, O_RDONLY);
  if (fd < 0)
    return -1;
  buf = malloc_or_die(BUFSIZ + 1);
  while ((r = read(fd, buf + len, BUFSIZ)) > 0) {
    len += r;
    buf = realloc(buf, len + BUFSIZ + 1);
    if (!buf) {
      len = -1;
      goto out;
    }
  }
  *buffer = buf;
  buf[len] = 0;
out:
  close(fd);
  return len;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<getop_ptr>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%r12
L200:
  mov    $0x0,%eax
  call   <getch@plt>
  mov    %eax,%ebx
  mov    %al,(%r12)
  cmp    $0x9,%eax
  je     L200
  cmp    $0x20,%al
  je     L200
  lea    0x1(%r12),%rbp
  movb   $0x0,0x1(%r12)
  movsbl %al,%r12d
  mov    %r12d,%edi
  call   <isalpha@plt>
  test   %rax,%rax
  jne    L41
  mov    %r12d,%edi
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L157
  lea    -0x2d(%rbx),%eax
  cmp    $0x1,%eax
  jbe    L157
  cmp    $0x3d,%ebx
  je     L152
  test   %ebx,%ebx
  mov    $0x32,%eax
  cmove  %eax,%ebx
  jmp    L2
L41:
  mov    $0x0,%eax
  call   <getch@plt>
  mov    %eax,%r12d
  add    $0x1,%rbp
  mov    %al,0x0(%rbp)
  movsbl %al,%edi
  call   <isalpha@plt>
  test   %rax,%rax
  jne    L41
  movb   $0x0,0x0(%rbp)
  mov    $0x31,%ebx
  mov    D7(%rip),%rax
  cmp    %r12d,(%rax)
  je     L2
  mov    %r12d,%edi
  call   <ungetch@plt>
  jmp    L2
L152:
  mov    $0x0,%eax
  call   <getch@plt>
  cmp    $0xa,%eax
  jne    L2
  mov    $0x0,%edi
  call   <ungetch@plt>
  jmp    L2
L157:
  cmp    $0x2d,%ebx
  je     L119
  mov    $0x0,%eax
  call   <getch@plt>
  mov    %eax,%r12d
  jmp    L210
L119:
  mov    $0x0,%eax
  call   <getch@plt>
  mov    %eax,%r12d
  movsbl %al,%edi
  call   <isdigit@plt>
  cmp    $0x2e,%r12d
  je     L210
  test   %rax,%rax
  jne    L210
  jmp    L2
L1:
  mov    $0x0,%eax
  call   <getch@plt>
  mov    %eax,%r12d
L210:
  add    $0x1,%rbp
  mov    %r12b,0x0(%rbp)
  movsbl %r12b,%edi
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L1
  cmp    $0x2e,%r12d
  je     L59
L24:
  movb   $0x0,0x0(%rbp)
  mov    $0x30,%ebx
  mov    D7(%rip),%rax
  cmp    %r12d,(%rax)
  jne    L4
L2:
  mov    %ebx,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L59:
  mov    $0x0,%eax
  call   <getch@plt>
  mov    %eax,%r12d
  add    $0x1,%rbp
  mov    %al,0x0(%rbp)
  movsbl %al,%edi
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L59
  jmp    L24
L4:
  mov    %r12d,%edi
  call   <ungetch@plt>
  jmp    L2
```

assistant: ```c
int getop_ptr(char *s) {
  int c, next_ch;
  while ((*s = c = getch()) == ' ' || c == '\t')
    ;
  *++s = '\0';
  if (isalpha(c)) {
    while (isalpha(*++s = c = getch()))
      ;
    *s = '\0';
    if (c != EOF)
      ungetch(c);
    return '1';
  }
  if (!isdigit(c) && c != '.' && c != '-') {
    if (c == '=' && (next_ch = getch()) == '\n') {
      ungetch('\0');
      return c;
    }
    if (c == '\0')
      return '2';
    return c;
  }
  if (c == '-') {
    next_ch = getch();
    if (!isdigit(next_ch) && next_ch != '.')
      return c;
    c = next_ch;
  } else
    c = getch();
  while (isdigit(*++s = c))
    c = getch();
  if (c == '.')
    while (isdigit(*++s = c = getch()))
      ;
  *s = '\0';
  if (c != EOF)
    ungetch(c);
  return '0';
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<getop_ptr>:
  endbr64
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  sub    $0x10,%rsp
  nop
L172:
  xor    %eax,%eax
  call   <getch@plt>
  mov    %al,0x0(%rbp)
  mov    %eax,%r12d
  cmp    $0x9,%eax
  je     L172
  cmp    $0x20,%al
  je     L172
  movb   $0x0,0x1(%rbp)
  lea    0x1(%rbp),%rbx
  movsbl %al,%ebp
  mov    %ebp,%edi
  call   <isalpha@plt>
  test   %rax,%rax
  jne    L113
  mov    %ebp,%edi
  call   <isdigit@plt>
  test   %rax,%rax
  je     L186
L17:
  xor    %eax,%eax
  cmp    $0x2d,%r12d
  jne    L69
  jmp    L162
  nopw   0x0(%rax,%rax,1)
L196:
  xor    %eax,%eax
L69:
  call   <getch@plt>
  mov    %eax,%ebp
  movsbl %al,%edi
L19:
  mov    %bpl,0x1(%rbx)
  add    $0x1,%rbx
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L196
  cmp    $0x2e,%ebp
  je     L63
L62:
  mov    D6(%rip),%rax
  movb   $0x0,(%rbx)
  mov    $0x30,%r12d
  cmp    %ebp,(%rax)
  je     L150
L31:
  mov    %ebp,%edi
  call   <ungetch@plt>
L150:
  add    $0x10,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopw   0x0(%rax,%rax,1)
L113:
  xor    %eax,%eax
  add    $0x1,%rbx
  call   <getch@plt>
  mov    %al,(%rbx)
  movsbl %al,%edi
  mov    %eax,%ebp
  call   <isalpha@plt>
  test   %rax,%rax
  jne    L113
  mov    D6(%rip),%rax
  movb   $0x0,(%rbx)
  mov    $0x31,%r12d
  cmp    %ebp,(%rax)
  jne    L31
  add    $0x10,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax)
L63:
  xor    %eax,%eax
  add    $0x1,%rbx
  call   <getch@plt>
  mov    %al,(%rbx)
  movsbl %al,%edi
  mov    %eax,%ebp
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L63
  jmp    L62
  nopl   0x0(%rax)
L186:
  lea    -0x2d(%r12),%eax
  cmp    $0x1,%eax
  jbe    L17
  cmp    $0x3d,%r12d
  je     L118
  test   %r12d,%r12d
  mov    $0x32,%eax
  cmove  %eax,%r12d
  add    $0x10,%rsp
  pop    %rbx
  pop    %rbp
  mov    %r12d,%eax
  pop    %r12
  ret
  nopl   0x0(%rax)
L162:
  call   <getch@plt>
  movsbl %al,%edi
  mov    %eax,%ebp
  mov    %edi,0xc(%rsp)
  call   <isdigit@plt>
  mov    0xc(%rsp),%edi
  test   %rax,%rax
  jne    L19
  cmp    $0x2e,%ebp
  je     L19
  jmp    L150
L118:
  xor    %eax,%eax
  call   <getch@plt>
  cmp    $0xa,%eax
  jne    L150
  xor    %edi,%edi
  call   <ungetch@plt>
  jmp    L150
```

assistant: ```c
int getop_ptr(char *s) {
  int c, next_ch;
  while ((*s = c = getch()) == ' ' || c == '\t')
    ;
  *++s = '\0';
  if (isalpha(c)) {
    while (isalpha(*++s = c = getch()))
      ;
    *s = '\0';
    if (c != EOF)
      ungetch(c);
    return '1';
  }
  if (!isdigit(c) && c != '.' && c != '-') {
    if (c == '=' && (next_ch = getch()) == '\n') {
      ungetch('\0');
      return c;
    }
    if (c == '\0')
      return '2';
    return c;
  }
  if (c == '-') {
    next_ch = getch();
    if (!isdigit(next_ch) && next_ch != '.')
      return c;
    c = next_ch;
  } else
    c = getch();
  while (isdigit(*++s = c))
    c = getch();
  if (c == '.')
    while (isdigit(*++s = c = getch()))
      ;
  *s = '\0';
  if (c != EOF)
    ungetch(c);
  return '0';
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<getop_ptr>:
  endbr64
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  sub    $0x10,%rsp
  nop
L26:
  xor    %eax,%eax
  call   <getch@plt>
  mov    %al,0x0(%rbp)
  mov    %eax,%r12d
  cmp    $0x9,%eax
  je     L26
  cmp    $0x20,%al
  je     L26
  movb   $0x0,0x1(%rbp)
  lea    0x1(%rbp),%rbx
  movsbl %al,%ebp
  mov    %ebp,%edi
  call   <isalpha@plt>
  test   %rax,%rax
  jne    L186
  mov    %ebp,%edi
  call   <isdigit@plt>
  test   %rax,%rax
  je     L47
L109:
  xor    %eax,%eax
  cmp    $0x2d,%r12d
  jne    L141
  jmp    L56
  nopw   0x0(%rax,%rax,1)
L103:
  xor    %eax,%eax
L141:
  call   <getch@plt>
  mov    %eax,%ebp
  movsbl %al,%edi
L110:
  mov    %bpl,0x1(%rbx)
  add    $0x1,%rbx
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L103
  cmp    $0x2e,%ebp
  je     L12
L113:
  mov    D18(%rip),%rax
  movb   $0x0,(%rbx)
  mov    $0x30,%r12d
  cmp    %ebp,(%rax)
  je     L57
L34:
  mov    %ebp,%edi
  call   <ungetch@plt>
L57:
  add    $0x10,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopw   0x0(%rax,%rax,1)
L186:
  xor    %eax,%eax
  add    $0x1,%rbx
  call   <getch@plt>
  mov    %al,(%rbx)
  movsbl %al,%edi
  mov    %eax,%ebp
  call   <isalpha@plt>
  test   %rax,%rax
  jne    L186
  mov    D18(%rip),%rax
  movb   $0x0,(%rbx)
  mov    $0x31,%r12d
  cmp    %ebp,(%rax)
  jne    L34
  add    $0x10,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax)
L12:
  xor    %eax,%eax
  add    $0x1,%rbx
  call   <getch@plt>
  mov    %al,(%rbx)
  movsbl %al,%edi
  mov    %eax,%ebp
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L12
  jmp    L113
  nopl   0x0(%rax)
L47:
  lea    -0x2d(%r12),%eax
  cmp    $0x1,%eax
  jbe    L109
  cmp    $0x3d,%r12d
  je     L169
  test   %r12d,%r12d
  mov    $0x32,%eax
  cmove  %eax,%r12d
  add    $0x10,%rsp
  pop    %rbx
  pop    %rbp
  mov    %r12d,%eax
  pop    %r12
  ret
  nopl   0x0(%rax)
L56:
  call   <getch@plt>
  movsbl %al,%edi
  mov    %eax,%ebp
  mov    %edi,0xc(%rsp)
  call   <isdigit@plt>
  mov    0xc(%rsp),%edi
  test   %rax,%rax
  jne    L110
  cmp    $0x2e,%ebp
  je     L110
  jmp    L57
L169:
  xor    %eax,%eax
  call   <getch@plt>
  cmp    $0xa,%eax
  jne    L57
  xor    %edi,%edi
  call   <ungetch@plt>
  jmp    L57
```

assistant: ```c
int getop_ptr(char *s) {
  int c, next_ch;
  while ((*s = c = getch()) == ' ' || c == '\t')
    ;
  *++s = '\0';
  if (isalpha(c)) {
    while (isalpha(*++s = c = getch()))
      ;
    *s = '\0';
    if (c != EOF)
      ungetch(c);
    return '1';
  }
  if (!isdigit(c) && c != '.' && c != '-') {
    if (c == '=' && (next_ch = getch()) == '\n') {
      ungetch('\0');
      return c;
    }
    if (c == '\0')
      return '2';
    return c;
  }
  if (c == '-') {
    next_ch = getch();
    if (!isdigit(next_ch) && next_ch != '.')
      return c;
    c = next_ch;
  } else
    c = getch();
  while (isdigit(*++s = c))
    c = getch();
  if (c == '.')
    while (isdigit(*++s = c = getch()))
      ;
  *s = '\0';
  if (c != EOF)
    ungetch(c);
  return '0';
}
```
user: What is the c source code of the assembly code below?

```asm
<encrypt>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %esi,-0x2c(%rbp)
  mov    %rdx,-0x38(%rbp)
  mov    %rcx,-0x40(%rbp)
  mov    %r8,-0x48(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    $0x0,%eax
  call   <EVP_CIPHER_CTX_new@plt>
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  jne    L2
  mov    $0x0,%eax
  call   <handleErrors@plt>
L2:
  mov    $0x0,%eax
  call   <EVP_aes_256_ctr@plt>
  mov    %eax,%esi
  mov    -0x40(%rbp),%rcx
  mov    -0x38(%rbp),%rdx
  mov    -0x10(%rbp),%rax
  mov    %rcx,%r8
  mov    %rdx,%rcx
  mov    $0x0,%edx
  mov    %rax,%rdi
  call   <EVP_EncryptInit_ex@plt>
  cmp    $0x1,%eax
  je     L39
  mov    $0x0,%eax
  call   <handleErrors@plt>
L39:
  mov    -0x2c(%rbp),%edi
  mov    -0x28(%rbp),%rcx
  lea    -0x18(%rbp),%rdx
  mov    -0x48(%rbp),%rsi
  mov    -0x10(%rbp),%rax
  mov    %edi,%r8d
  mov    %rax,%rdi
  call   <EVP_EncryptUpdate@plt>
  cmp    $0x1,%eax
  je     L49
  mov    $0x0,%eax
  call   <handleErrors@plt>
L49:
  mov    -0x18(%rbp),%eax
  mov    %eax,-0x14(%rbp)
  mov    -0x18(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x48(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  lea    -0x18(%rbp),%rdx
  mov    -0x10(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <EVP_EncryptFinal_ex@plt>
  cmp    $0x1,%eax
  je     L46
  mov    $0x0,%eax
  call   <handleErrors@plt>
L46:
  mov    -0x18(%rbp),%eax
  add    %eax,-0x14(%rbp)
  mov    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <EVP_CIPHER_CTX_free@plt>
  mov    -0x14(%rbp),%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L11
  call   <__stack_chk_fail@plt>
L11:
  leave
  ret
```

assistant: ```c
int encrypt(unsigned char *plaintext, int plaintext_len, unsigned char *key, unsigned char *iv, unsigned char *ciphertext) {
  EVP_CIPHER_CTX *ctx;
  int len;
  int ciphertext_len;
  if (!(ctx = EVP_CIPHER_CTX_new())) {
    handleErrors();
  }
  if (EVP_EncryptInit_ex(ctx, EVP_aes_256_ctr(), NULL, key, iv) != 1) {
    handleErrors();
  }
  if (EVP_EncryptUpdate(ctx, ciphertext, &len, plaintext, plaintext_len) != 1) {
    handleErrors();
  }
  ciphertext_len = len;
  if (EVP_EncryptFinal_ex(ctx, ciphertext + len, &len) != 1) {
    handleErrors();
  }
  ciphertext_len += len;
  EVP_CIPHER_CTX_free(ctx);
  return ciphertext_len;
}
```