ylfeng/ReF-Decompile-dataset huggingface dataset:
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<xyz_conf_load>:
  endbr64
  push   %r12
  push   %rbp
  sub    $0x8,%rsp
  test   %rdi,%rdi
  je     L17
  call   <xyz_conf_open@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L17
  mov    %rax,%rdi
  call   <xyz_conf_read@plt>
  mov    %rbp,%rdi
  mov    %rax,%r12
  call   <fclose@plt>
  add    $0x8,%rsp
  mov    %r12,%rax
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax,%rax,1)
L17:
  xor    %r12d,%r12d
  add    $0x8,%rsp
  mov    %r12,%rax
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
struct xyz_conf_t *xyz_conf_load(char *file) {
  FILE *fp;
  if (file == NULL) {
    return NULL;
  }
  fp = xyz_conf_open(file);
  if (fp == NULL) {
    return NULL;
  }
  struct xyz_conf_t *tmp = xyz_conf_read(fp);
  fclose(fp);
  return tmp;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<tlg_fgetgrent>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %rdi,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L2
  mov    D17(%rip),%rax
  mov    (%rax),%edx
  mov    D10(%rip),%rax
  mov    %edx,(%rax)
  mov    $0x0,%eax
  jmp    L4
L2:
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <fileno@plt>
  mov    %eax,%edi
  call   <__tlg_getgrent@plt>
L4:
  leave
  ret
```

assistant: ```c
struct group *tlg_fgetgrent(FILE *file) {
  if (file == NULL) {
    errno = EINTR;
    return NULL;
  }
  return __tlg_getgrent(fileno(file));
}
```
user: What is the c source code of the assembly code below?

```asm
<tlg_fgetgrent>:
  endbr64
  test   %rdi,%rdi
  je     L4
  sub    $0x8,%rsp
  call   <fileno@plt>
  mov    %eax,%edi
  call   <__tlg_getgrent@plt>
  add    $0x8,%rsp
  ret
L4:
  mov    D9(%rip),%rax
  mov    (%rax),%edx
  mov    D5(%rip),%rax
  mov    %edx,(%rax)
  mov    %rdi,%rax
  ret
```

assistant: ```c
struct group *tlg_fgetgrent(FILE *file) {
  if (file == NULL) {
    errno = EINTR;
    return NULL;
  }
  return __tlg_getgrent(fileno(file));
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<tlg_fgetgrent>:
  endbr64
  test   %rdi,%rdi
  je     L8
  sub    $0x8,%rsp
  call   <fileno@plt>
  add    $0x8,%rsp
  mov    %eax,%edi
  jmp    1070 <__tlg_getgrent@plt>
  nopl   (%rax)
L8:
  mov    D3(%rip),%rax
  mov    (%rax),%edx
  mov    D14(%rip),%rax
  mov    %edx,(%rax)
  xor    %eax,%eax
  ret
```

assistant: ```c
struct group *tlg_fgetgrent(FILE *file) {
  if (file == NULL) {
    errno = EINTR;
    return NULL;
  }
  return __tlg_getgrent(fileno(file));
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<tlg_fgetgrent>:
  endbr64
  test   %rdi,%rdi
  je     L4
  sub    $0x8,%rsp
  call   <fileno@plt>
  add    $0x8,%rsp
  mov    %eax,%edi
  jmp    1070 <__tlg_getgrent@plt>
  nopl   (%rax)
L4:
  mov    D17(%rip),%rax
  mov    (%rax),%edx
  mov    D13(%rip),%rax
  mov    %edx,(%rax)
  xor    %eax,%eax
  ret
```

assistant: ```c
struct group *tlg_fgetgrent(FILE *file) {
  if (file == NULL) {
    errno = EINTR;
    return NULL;
  }
  return __tlg_getgrent(fileno(file));
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<strcspn>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  movq   $0x0,-0x8(%rbp)
  jmp    L31
L0:
  mov    -0x18(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movzbl (%rax),%eax
  movsbl %al,%edx
  mov    -0x20(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  jne    L39
  addq   $0x1,-0x8(%rbp)
  jmp    L31
L39:
  mov    -0x8(%rbp),%rax
  jmp    L22
L31:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L0
  mov    -0x8(%rbp),%rax
L22:
  leave
  ret
```

assistant: ```c
size_t strcspn(const char *s, const char *reject) {
  size_t count = 0;
  while (*s != '\0') {
    if (strchr(reject, *s++) == NULL) {
      ++count;
    } else {
      return count;
    }
  }
  return count;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<strcspn>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rsi,%r12
  movzbl (%rdi),%esi
  test   %sil,%sil
  je     L37
  mov    %rdi,%rbp
  mov    $0x0,%ebx
L15:
  movsbl %sil,%esi
  mov    %r12,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  jne    L13
  add    $0x1,%rbx
  movzbl 0x0(%rbp,%rbx,1),%esi
  test   %sil,%sil
  jne    L15
L13:
  mov    %rbx,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L37:
  mov    $0x0,%ebx
  jmp    L13
```

assistant: ```c
size_t strcspn(const char *s, const char *reject) {
  size_t count = 0;
  while (*s != '\0') {
    if (strchr(reject, *s++) == NULL) {
      ++count;
    } else {
      return count;
    }
  }
  return count;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<strcspn>:
  endbr64
  push   %r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  movsbl (%rdi),%esi
  test   %sil,%sil
  je     L11
  mov    %rdi,%rbx
  xor    %r12d,%r12d
  jmp    L1
  nopl   0x0(%rax,%rax,1)
L34:
  add    $0x1,%r12
  movsbl (%rbx,%r12,1),%esi
  test   %sil,%sil
  je     L36
L1:
  mov    %rbp,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  je     L34
L36:
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L11:
  xor    %r12d,%r12d
  jmp    L36
```

assistant: ```c
size_t strcspn(const char *s, const char *reject) {
  size_t count = 0;
  while (*s != '\0') {
    if (strchr(reject, *s++) == NULL) {
      ++count;
    } else {
      return count;
    }
  }
  return count;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<strcspn>:
  endbr64
  push   %r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  movsbl (%rdi),%esi
  test   %sil,%sil
  je     L17
  mov    %rdi,%rbx
  xor    %r12d,%r12d
  jmp    L46
  nopl   0x0(%rax,%rax,1)
L9:
  add    $0x1,%r12
  movsbl (%rbx,%r12,1),%esi
  test   %sil,%sil
  je     L38
L46:
  mov    %rbp,%rdi
  call   <strchr@plt>
  test   %rax,%rax
  je     L9
L38:
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L17:
  xor    %r12d,%r12d
  jmp    L38
```

assistant: ```c
size_t strcspn(const char *s, const char *reject) {
  size_t count = 0;
  while (*s != '\0') {
    if (strchr(reject, *s++) == NULL) {
      ++count;
    } else {
      return count;
    }
  }
  return count;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<openconnect_SSL_gets>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %rdx,-0x28(%rbp)
  movl   $0x0,-0x8(%rbp)
  cmpq   $0x1,-0x28(%rbp)
  ja     L32
  mov    D8(%rip),%rax
  mov    (%rax),%eax
  neg    %eax
  jmp    L75
L66:
  mov    -0x8(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0xa,%al
  jne    L53
  mov    -0x8(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  cmpl   $0x0,-0x8(%rbp)
  je     L76
  mov    -0x8(%rbp),%eax
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  cmp    $0xd,%al
  jne    L76
  mov    -0x8(%rbp),%eax
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  subl   $0x1,-0x8(%rbp)
L76:
  mov    -0x8(%rbp),%eax
  jmp    L75
L53:
  addl   $0x1,-0x8(%rbp)
  mov    -0x8(%rbp),%eax
  cltq
  mov    -0x28(%rbp),%rdx
  sub    $0x1,%rdx
  cmp    %rdx,%rax
  jb     L32
  mov    -0x8(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x8(%rbp),%eax
  jmp    L75
L32:
  mov    -0x8(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x18(%rbp),%rax
  mov    $0x1,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <SSL_read@plt>
  mov    %eax,-0x4(%rbp)
  cmpl   $0x1,-0x4(%rbp)
  je     L66
  cmpl   $0x0,-0x4(%rbp)
  jne    L99
  mov    -0x4(%rbp),%edx
  mov    -0x18(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <SSL_get_error@plt>
  neg    %eax
  mov    %eax,-0x4(%rbp)
L99:
  mov    -0x8(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x8(%rbp),%eax
  test   %eax,%eax
  jne    L75
  mov    -0x4(%rbp),%eax
L75:
  leave
  ret
```

assistant: ```c
int openconnect_SSL_gets(SSL *ssl, char *buf, size_t len) {
  int i = 0;
  int ret;
  if (len < 2)
    return -EINVAL;
  while ((ret = SSL_read(ssl, buf + i, 1)) == 1) {
    if (buf[i] == '\n') {
      buf[i] = 0;
      if (i && buf[i - 1] == '\r') {
        buf[i - 1] = 0;
        i--;
      }
      return i;
    }
    i++;
    if (i >= len - 1) {
      buf[i] = 0;
      return i;
    }
  }
  if (ret == 0) {
    ret = -SSL_get_error(ssl, ret);
  }
  buf[i] = 0;
  return i ?: ret;
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<openconnect_SSL_gets>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%r15
  mov    %rsi,%rbp
  lea    -0x1(%rdx),%rax
  mov    %rax,0x8(%rsp)
  mov    $0x0,%ebx
  cmp    $0x1,%rdx
  jbe    L18
L24:
  mov    %ebx,%r14d
  mov    %ebx,%r12d
  lea    0x0(%rbp,%rbx,1),%r13
  mov    $0x1,%edx
  mov    %r13,%rsi
  mov    %r15,%rdi
  call   <SSL_read@plt>
  cmp    $0x1,%eax
  jne    L106
  cmpb   $0xa,0x0(%rbp,%rbx,1)
  je     L92
  lea    0x1(%r14),%r12d
  add    $0x1,%rbx
  cmp    0x8(%rsp),%rbx
  jne    L24
  movb   $0x0,0x0(%rbp,%rbx,1)
  jmp    L89
L18:
  mov    D3(%rip),%rax
  mov    (%rax),%r12d
  neg    %r12d
L89:
  mov    %r12d,%eax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L92:
  movb   $0x0,0x0(%r13)
  test   %r12d,%r12d
  je     L89
  lea    -0x1(%rbp,%rbx,1),%rax
  cmpb   $0xd,(%rax)
  jne    L89
  movb   $0x0,(%rax)
  sub    $0x1,%r12d
  jmp    L89
L106:
  test   %eax,%eax
  je     L22
L64:
  movb   $0x0,0x0(%r13)
  test   %r12d,%r12d
  cmove  %eax,%r12d
  jmp    L89
L22:
  mov    $0x0,%esi
  mov    %r15,%rdi
  call   <SSL_get_error@plt>
  neg    %eax
  jmp    L64
```

assistant: ```c
int openconnect_SSL_gets(SSL *ssl, char *buf, size_t len) {
  int i = 0;
  int ret;
  if (len < 2)
    return -EINVAL;
  while ((ret = SSL_read(ssl, buf + i, 1)) == 1) {
    if (buf[i] == '\n') {
      buf[i] = 0;
      if (i && buf[i - 1] == '\r') {
        buf[i - 1] = 0;
        i--;
      }
      return i;
    }
    i++;
    if (i >= len - 1) {
      buf[i] = 0;
      return i;
    }
  }
  if (ret == 0) {
    ret = -SSL_get_error(ssl, ret);
  }
  buf[i] = 0;
  return i ?: ret;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<openconnect_SSL_gets>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  cmp    $0x1,%rdx
  jbe    L22
  mov    %rdi,%r15
  mov    %rsi,%rbp
  lea    -0x1(%rdx),%r13
  xor    %ebx,%ebx
  jmp    L50
  cs nopw 0x0(%rax,%rax,1)
L12:
  cmpb   $0xa,0x0(%rbp,%rbx,1)
  je     L106
  add    $0x1,%rbx
  add    $0x1,%r12d
  cmp    %r13,%rbx
  je     L49
L50:
  lea    0x0(%rbp,%rbx,1),%r14
  mov    $0x1,%edx
  mov    %r15,%rdi
  mov    %ebx,%r12d
  mov    %r14,%rsi
  call   <SSL_read@plt>
  cmp    $0x1,%eax
  je     L12
  test   %eax,%eax
  je     L114
L93:
  test   %r12d,%r12d
  movb   $0x0,(%r14)
  cmove  %eax,%r12d
L68:
  add    $0x8,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L22:
  mov    D9(%rip),%rax
  mov    (%rax),%r12d
  neg    %r12d
  jmp    L68
  nopw   0x0(%rax,%rax,1)
L106:
  movb   $0x0,(%r14)
  test   %r12d,%r12d
  je     L68
  lea    -0x1(%rbp,%rbx,1),%rax
  cmpb   $0xd,(%rax)
  jne    L68
  movb   $0x0,(%rax)
  sub    $0x1,%r12d
  jmp    L68
  nopl   0x0(%rax)
L49:
  movb   $0x0,0x0(%rbp,%rbx,1)
  jmp    L68
  nopw   0x0(%rax,%rax,1)
L114:
  xor    %esi,%esi
  mov    %r15,%rdi
  call   <SSL_get_error@plt>
  neg    %eax
  jmp    L93
```

assistant: ```c
int openconnect_SSL_gets(SSL *ssl, char *buf, size_t len) {
  int i = 0;
  int ret;
  if (len < 2)
    return -EINVAL;
  while ((ret = SSL_read(ssl, buf + i, 1)) == 1) {
    if (buf[i] == '\n') {
      buf[i] = 0;
      if (i && buf[i - 1] == '\r') {
        buf[i - 1] = 0;
        i--;
      }
      return i;
    }
    i++;
    if (i >= len - 1) {
      buf[i] = 0;
      return i;
    }
  }
  if (ret == 0) {
    ret = -SSL_get_error(ssl, ret);
  }
  buf[i] = 0;
  return i ?: ret;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<openconnect_SSL_gets>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  cmp    $0x1,%rdx
  jbe    L77
  mov    %rdi,%r15
  mov    %rsi,%rbp
  lea    -0x1(%rdx),%r13
  xor    %ebx,%ebx
  jmp    L112
  cs nopw 0x0(%rax,%rax,1)
L34:
  cmpb   $0xa,0x0(%rbp,%rbx,1)
  je     L87
  add    $0x1,%rbx
  add    $0x1,%r12d
  cmp    %r13,%rbx
  je     L63
L112:
  lea    0x0(%rbp,%rbx,1),%r14
  mov    $0x1,%edx
  mov    %r15,%rdi
  mov    %ebx,%r12d
  mov    %r14,%rsi
  call   <SSL_read@plt>
  cmp    $0x1,%eax
  je     L34
  test   %eax,%eax
  je     L52
L57:
  test   %r12d,%r12d
  movb   $0x0,(%r14)
  cmove  %eax,%r12d
L84:
  add    $0x8,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L77:
  mov    D8(%rip),%rax
  mov    (%rax),%r12d
  neg    %r12d
  jmp    L84
  nopw   0x0(%rax,%rax,1)
L87:
  movb   $0x0,(%r14)
  test   %r12d,%r12d
  je     L84
  lea    -0x1(%rbp,%rbx,1),%rax
  cmpb   $0xd,(%rax)
  jne    L84
  movb   $0x0,(%rax)
  sub    $0x1,%r12d
  jmp    L84
  nopl   0x0(%rax)
L63:
  movb   $0x0,0x0(%rbp,%rbx,1)
  jmp    L84
  nopw   0x0(%rax,%rax,1)
L52:
  xor    %esi,%esi
  mov    %r15,%rdi
  call   <SSL_get_error@plt>
  neg    %eax
  jmp    L57
```

assistant: ```c
int openconnect_SSL_gets(SSL *ssl, char *buf, size_t len) {
  int i = 0;
  int ret;
  if (len < 2)
    return -EINVAL;
  while ((ret = SSL_read(ssl, buf + i, 1)) == 1) {
    if (buf[i] == '\n') {
      buf[i] = 0;
      if (i && buf[i - 1] == '\r') {
        buf[i - 1] = 0;
        i--;
      }
      return i;
    }
    i++;
    if (i >= len - 1) {
      buf[i] = 0;
      return i;
    }
  }
  if (ret == 0) {
    ret = -SSL_get_error(ssl, ret);
  }
  buf[i] = 0;
  return i ?: ret;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<simple_strtoul>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %edx,-0x24(%rbp)
  movq   $0x0,-0x10(%rbp)
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x30,%al
  jne    L83
  addq   $0x1,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x78,%al
  jne    L32
  mov    -0x18(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <isxdigit@plt>
  test   %rax,%rax
  je     L32
  movl   $0x10,-0x24(%rbp)
  addq   $0x1,-0x18(%rbp)
L32:
  cmpl   $0x0,-0x24(%rbp)
  jne    L83
  movl   $0x8,-0x24(%rbp)
L83:
  cmpl   $0x0,-0x24(%rbp)
  jne    L14
  movl   $0xa,-0x24(%rbp)
  jmp    L14
L38:
  mov    -0x24(%rbp),%eax
  imul   -0x10(%rbp),%rax
  mov    %rax,%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  mov    %rax,-0x10(%rbp)
  addq   $0x1,-0x18(%rbp)
L14:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <isxdigit@plt>
  test   %rax,%rax
  je     L30
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <isdigit@plt>
  test   %rax,%rax
  je     L110
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  sub    $0x30,%eax
  cltq
  jmp    L129
L110:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <islower@plt>
  test   %rax,%rax
  je     L113
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <toupper@plt>
  movsbl %al,%eax
  sub    $0x37,%eax
  cltq
  jmp    L129
L113:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  movsbl %al,%eax
  sub    $0x37,%eax
  cltq
L129:
  mov    %rax,-0x8(%rbp)
  mov    -0x24(%rbp),%eax
  cmp    %rax,-0x8(%rbp)
  jb     L38
L30:
  cmpq   $0x0,-0x20(%rbp)
  je     L106
  mov    -0x20(%rbp),%rax
  mov    -0x18(%rbp),%rdx
  mov    %rdx,(%rax)
L106:
  mov    -0x10(%rbp),%rax
  leave
  ret
```

assistant: ```c
unsigned long simple_strtoul(const char *cp, char **endp, unsigned int base) {
  unsigned long result = 0, value;
  if (*cp == '0') {
    cp++;
    if ((*cp == 'x') && isxdigit(cp[1])) {
      base = 16;
      cp++;
    }
    if (!base)
      base = 8;
  }
  if (!base)
    base = 10;
  while (isxdigit(*cp) && (value = isdigit(*cp) ? *cp - '0' : (islower(*cp) ? toupper(*cp) : *cp) - 'A' + 10) < base) {
    result = result * base + value;
    cp++;
  }
  if (endp)
    *endp = (char *)cp;
  return result;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<simple_strtoul>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%rbx
  mov    %rsi,%r13
  mov    %edx,%r12d
  cmpb   $0x30,(%rdi)
  je     L144
  test   %edx,%edx
  mov    $0xa,%eax
  cmove  %eax,%r12d
L40:
  mov    $0x0,%ebp
  mov    %r12d,%r12d
  jmp    L123
L144:
  lea    0x1(%rdi),%rbp
  cmpb   $0x78,0x1(%rdi)
  je     L139
L122:
  test   %r12d,%r12d
  je     L39
L55:
  mov    %rbp,%rbx
  jmp    L40
L139:
  movsbl 0x2(%rdi),%edi
  call   <isxdigit@plt>
  test   %rax,%rax
  je     L122
  lea    0x2(%rbx),%rbp
  mov    $0x10,%r12d
  jmp    L55
L39:
  mov    %rbp,%rbx
  mov    $0x8,%r12d
  jmp    L40
L110:
  movsbl (%rbx),%edi
  call   <islower@plt>
  test   %rax,%rax
  jne    L138
  movsbl (%rbx),%eax
  sub    $0x37,%eax
  cltq
L42:
  cmp    %rax,%r12
  jbe    L23
  imul   %r12,%rbp
  add    %rax,%rbp
  add    $0x1,%rbx
L123:
  movsbl (%rbx),%edi
  call   <isxdigit@plt>
  test   %rax,%rax
  je     L23
  movsbl (%rbx),%edi
  call   <isdigit@plt>
  test   %rax,%rax
  je     L110
  movsbl (%rbx),%eax
  sub    $0x30,%eax
  cltq
  jmp    L42
L138:
  movsbl (%rbx),%edi
  call   <toupper@plt>
  movsbl %al,%eax
  sub    $0x37,%eax
  cltq
  jmp    L42
L23:
  test   %r13,%r13
  je     L103
  mov    %rbx,0x0(%r13)
L103:
  mov    %rbp,%rax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

assistant: ```c
unsigned long simple_strtoul(const char *cp, char **endp, unsigned int base) {
  unsigned long result = 0, value;
  if (*cp == '0') {
    cp++;
    if ((*cp == 'x') && isxdigit(cp[1])) {
      base = 16;
      cp++;
    }
    if (!base)
      base = 8;
  }
  if (!base)
    base = 10;
  while (isxdigit(*cp) && (value = isdigit(*cp) ? *cp - '0' : (islower(*cp) ? toupper(*cp) : *cp) - 'A' + 10) < base) {
    result = result * base + value;
    cp++;
  }
  if (endp)
    *endp = (char *)cp;
  return result;
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<simple_strtoul>:
  endbr64
  push   %r13
  mov    %rdi,%r13
  push   %r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  sub    $0x18,%rsp
  movsbl (%rdi),%edi
  cmp    $0x30,%dil
  je     L41
  test   %edx,%edx
  mov    $0xa,%eax
  cmove  %eax,%edx
L87:
  xor    %r12d,%r12d
  mov    %edx,%ebx
  jmp    L96
  nopw   0x0(%rax,%rax,1)
L99:
  movsbl 0x0(%r13),%eax
  sub    $0x30,%eax
  cltq
L83:
  cmp    %rax,%rbx
  jbe    L104
L127:
  imul   %rbx,%r12
  movsbl 0x1(%r13),%edi
  add    $0x1,%r13
  add    %rax,%r12
L96:
  call   <isxdigit@plt>
  test   %rax,%rax
  je     L104
  movsbl 0x0(%r13),%edi
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L99
  movsbl 0x0(%r13),%edi
  call   <islower@plt>
  test   %rax,%rax
  jne    L90
  movsbl 0x0(%r13),%eax
  sub    $0x37,%eax
  cltq
  cmp    %rax,%rbx
  ja     L127
  xchg   %ax,%ax
L104:
  test   %rbp,%rbp
  je     L136
  mov    %r13,0x0(%rbp)
L136:
  add    $0x18,%rsp
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopw   0x0(%rax,%rax,1)
L90:
  movsbl 0x0(%r13),%edi
  call   <toupper@plt>
  movsbl %al,%eax
  sub    $0x37,%eax
  cltq
  jmp    L83
  nopw   0x0(%rax,%rax,1)
L41:
  cmpb   $0x78,0x1(%r13)
  lea    0x1(%r13),%r12
  je     L73
L67:
  movsbl 0x1(%r13),%edi
  mov    %r12,%r13
  test   %edx,%edx
  jne    L87
  mov    $0x8,%edx
  jmp    L87
L73:
  movsbl 0x2(%r13),%edi
  mov    %edx,0xc(%rsp)
  call   <isxdigit@plt>
  mov    0xc(%rsp),%edx
  test   %rax,%rax
  je     L67
  movsbl 0x2(%r13),%edi
  mov    $0x10,%edx
  add    $0x2,%r13
  jmp    L87
```

assistant: ```c
unsigned long simple_strtoul(const char *cp, char **endp, unsigned int base) {
  unsigned long result = 0, value;
  if (*cp == '0') {
    cp++;
    if ((*cp == 'x') && isxdigit(cp[1])) {
      base = 16;
      cp++;
    }
    if (!base)
      base = 8;
  }
  if (!base)
    base = 10;
  while (isxdigit(*cp) && (value = isdigit(*cp) ? *cp - '0' : (islower(*cp) ? toupper(*cp) : *cp) - 'A' + 10) < base) {
    result = result * base + value;
    cp++;
  }
  if (endp)
    *endp = (char *)cp;
  return result;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<simple_strtoul>:
  endbr64
  push   %r13
  mov    %rdi,%r13
  push   %r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  sub    $0x18,%rsp
  cmpb   $0x30,(%rdi)
  je     L103
  test   %edx,%edx
  mov    $0xa,%eax
  cmove  %eax,%edx
L18:
  xor    %r12d,%r12d
  mov    %edx,%ebx
  jmp    L62
  xchg   %ax,%ax
L65:
  movsbl 0x0(%r13),%eax
  sub    $0x30,%eax
  cltq
L77:
  cmp    %rax,%rbx
  jbe    L79
L102:
  imul   %rbx,%r12
  add    $0x1,%r13
  add    %rax,%r12
L62:
  movsbl 0x0(%r13),%edi
  call   <isxdigit@plt>
  test   %rax,%rax
  je     L79
  movsbl 0x0(%r13),%edi
  call   <isdigit@plt>
  test   %rax,%rax
  jne    L65
  movsbl 0x0(%r13),%edi
  call   <islower@plt>
  test   %rax,%rax
  jne    L106
  movsbl 0x0(%r13),%eax
  sub    $0x37,%eax
  cltq
  cmp    %rax,%rbx
  ja     L102
  cs nopw 0x0(%rax,%rax,1)
L79:
  test   %rbp,%rbp
  je     L104
  mov    %r13,0x0(%rbp)
L104:
  add    $0x18,%rsp
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopw   0x0(%rax,%rax,1)
L106:
  movsbl 0x0(%r13),%edi
  call   <toupper@plt>
  movsbl %al,%eax
  sub    $0x37,%eax
  cltq
  jmp    L77
  nopw   0x0(%rax,%rax,1)
L103:
  cmpb   $0x78,0x1(%rdi)
  lea    0x1(%rdi),%r12
  je     L90
L124:
  test   %edx,%edx
  mov    $0x8,%eax
  mov    %r12,%r13
  cmove  %eax,%edx
  jmp    L18
L90:
  movsbl 0x2(%rdi),%edi
  mov    %edx,0xc(%rsp)
  call   <isxdigit@plt>
  mov    0xc(%rsp),%edx
  test   %rax,%rax
  je     L124
  add    $0x2,%r13
  mov    $0x10,%edx
  jmp    L18
```

assistant: ```c
unsigned long simple_strtoul(const char *cp, char **endp, unsigned int base) {
  unsigned long result = 0, value;
  if (*cp == '0') {
    cp++;
    if ((*cp == 'x') && isxdigit(cp[1])) {
      base = 16;
      cp++;
    }
    if (!base)
      base = 8;
  }
  if (!base)
    base = 10;
  while (isxdigit(*cp) && (value = isdigit(*cp) ? *cp - '0' : (islower(*cp) ? toupper(*cp) : *cp) - 'A' + 10) < base) {
    result = result * base + value;
    cp++;
  }
  if (endp)
    *endp = (char *)cp;
  return result;
}
```
user: 这段汇编代码用C语言表示是什么样的?

```asm
<find_max>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  movl   $0x0,-0x4(%rbp)
  movl   $0x0,-0x8(%rbp)
  jmp    L37
L36:
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm1
  mov    -0x8(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  comisd %xmm1,%xmm0
  jbe    L15
  mov    -0x8(%rbp),%eax
  jmp    L5
L15:
  mov    -0x4(%rbp),%eax
L5:
  mov    %eax,-0x4(%rbp)
  addl   $0x1,-0x8(%rbp)
L37:
  mov    -0x8(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jl     L36
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movsd  (%rax),%xmm0
  movq   %xmm0,%rax
  movq   %rax,%xmm0
  pop    %rbp
  ret
```

assistant: ```c
double find_max(double *array, int n) {
  int i;
  int j = 0;
  for (i = 0; i < n; i++) {
    j = (array[j] < array[i]) ? i : j;
  }
  return array[j];
}
```