ylfeng/ReF-Decompile-dataset huggingface dataset:
user: Demonstrate the C code that generates the assembly output below:

```asm
<save_block>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x8(%rbp)
  mov    %rsi,-0x10(%rbp)
  mov    %edx,-0x14(%rbp)
  mov    %ecx,-0x18(%rbp)
  mov    -0x14(%rbp),%ecx
  mov    -0x8(%rbp),%rax
  mov    $0x0,%edx
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <save_word@plt>
  mov    -0x14(%rbp),%edx
  mov    -0x18(%rbp),%eax
  add    %edx,%eax
  lea    -0x1(%rax),%ecx
  mov    -0x8(%rbp),%rax
  mov    $0x0,%edx
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <save_word@plt>
  mov    -0x14(%rbp),%eax
  movslq %eax,%rdx
  mov    -0x10(%rbp),%rax
  lea    (%rdx,%rax,1),%rdi
  mov    -0x8(%rbp),%rdx
  mov    -0x18(%rbp),%eax
  mov    %rdx,%rcx
  mov    %eax,%edx
  mov    $0x1,%esi
  call   <fwrite@plt>
  mov    $0x1,%eax
  leave
  ret
```

assistant: ```c
int save_block(FILE *out, unsigned char *mem, int b, int sz) {
  save_word(out, b, 0);
  save_word(out, b + sz - 1, 0);
  fwrite(mem + b, 1, sz, out);
  return 1;
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<save_block>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%r12
  mov    %rsi,%rbp
  mov    %edx,%ebx
  mov    %ecx,%r13d
  mov    $0x0,%edx
  mov    %ebx,%esi
  call   <save_word@plt>
  lea    -0x1(%rbx,%r13,1),%esi
  mov    $0x0,%edx
  mov    %r12,%rdi
  call   <save_word@plt>
  movslq %ebx,%rbx
  lea    0x0(%rbp,%rbx,1),%rdi
  mov    %r12,%rcx
  mov    %r13d,%edx
  mov    $0x1,%esi
  call   <fwrite@plt>
  mov    $0x1,%eax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

assistant: ```c
int save_block(FILE *out, unsigned char *mem, int b, int sz) {
  save_word(out, b, 0);
  save_word(out, b + sz - 1, 0);
  fwrite(mem + b, 1, sz, out);
  return 1;
}
```
user: 这段汇编代码用C语言表示是什么样的：

```asm
<save_block>:
  endbr64
  push   %r13
  mov    %ecx,%r13d
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  movslq %edx,%rbx
  xor    %edx,%edx
  mov    %ebx,%esi
  sub    $0x8,%rsp
  call   <save_word@plt>
  lea    -0x1(%rbx,%r13,1),%esi
  mov    %r12,%rdi
  xor    %edx,%edx
  call   <save_word@plt>
  lea    0x0(%rbp,%rbx,1),%rdi
  mov    %r12,%rcx
  mov    %r13d,%edx
  mov    $0x1,%esi
  call   <fwrite@plt>
  add    $0x8,%rsp
  mov    $0x1,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

assistant: ```c
int save_block(FILE *out, unsigned char *mem, int b, int sz) {
  save_word(out, b, 0);
  save_word(out, b + sz - 1, 0);
  fwrite(mem + b, 1, sz, out);
  return 1;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<save_block>:
  endbr64
  push   %r13
  mov    %ecx,%r13d
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  movslq %edx,%rbx
  xor    %edx,%edx
  mov    %ebx,%esi
  sub    $0x8,%rsp
  call   <save_word@plt>
  lea    -0x1(%rbx,%r13,1),%esi
  mov    %r12,%rdi
  xor    %edx,%edx
  call   <save_word@plt>
  lea    0x0(%rbp,%rbx,1),%rdi
  mov    %r12,%rcx
  mov    %r13d,%edx
  mov    $0x1,%esi
  call   <fwrite@plt>
  add    $0x8,%rsp
  mov    $0x1,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

assistant: ```c
int save_block(FILE *out, unsigned char *mem, int b, int sz) {
  save_word(out, b, 0);
  save_word(out, b + sz - 1, 0);
  fwrite(mem + b, 1, sz, out);
  return 1;
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<getMean1f>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  pxor   %xmm0,%xmm0
  movss  %xmm0,-0xc(%rbp)
  mov    -0x20(%rbp),%rax
  mov    %rax,-0x8(%rbp)
  jmp    L15
L6:
  mov    -0x18(%rbp),%rax
  lea    0x4(%rax),%rdx
  mov    %rdx,-0x18(%rbp)
  movss  (%rax),%xmm0
  movss  -0xc(%rbp),%xmm1
  addss  %xmm1,%xmm0
  movss  %xmm0,-0xc(%rbp)
L15:
  mov    -0x8(%rbp),%rax
  lea    -0x1(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  test   %rax,%rax
  jne    L6
  pxor   %xmm1,%xmm1
  cvtsi2ssq -0x20(%rbp),%xmm1
  movss  -0xc(%rbp),%xmm0
  divss  %xmm1,%xmm0
  pop    %rbp
  ret
```

assistant: ```c
float getMean1f(float *samples, long numberOfSamples) {
  long n;
  float mean = 0;
  n = numberOfSamples;
  while (n--)
    mean += *samples++;
  return (mean / numberOfSamples);
}
```
user: 这段汇编代码用C语言表示是什么样的：

```asm
<getMean1f>:
  endbr64
  test   %rsi,%rsi
  je     L29
  mov    $0x0,%eax
  pxor   %xmm0,%xmm0
L11:
  addss  (%rdi,%rax,4),%xmm0
  add    $0x1,%rax
  cmp    %rsi,%rax
  jne    L11
L2:
  pxor   %xmm1,%xmm1
  cvtsi2ss %rsi,%xmm1
  divss  %xmm1,%xmm0
  ret
L29:
  pxor   %xmm0,%xmm0
  jmp    L2
```

assistant: ```c
float getMean1f(float *samples, long numberOfSamples) {
  long n;
  float mean = 0;
  n = numberOfSamples;
  while (n--)
    mean += *samples++;
  return (mean / numberOfSamples);
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<getMean1f>:
  endbr64
  test   %rsi,%rsi
  je     L8
  xor    %eax,%eax
  pxor   %xmm0,%xmm0
  nop
L6:
  addss  (%rdi,%rax,4),%xmm0
  add    $0x1,%rax
  cmp    %rax,%rsi
  jne    L6
  pxor   %xmm1,%xmm1
  cvtsi2ss %rsi,%xmm1
  divss  %xmm1,%xmm0
  ret
  nopl   0x0(%rax)
L8:
  pxor   %xmm1,%xmm1
  pxor   %xmm0,%xmm0
  cvtsi2ss %rsi,%xmm1
  divss  %xmm1,%xmm0
  ret
```

assistant: ```c
float getMean1f(float *samples, long numberOfSamples) {
  long n;
  float mean = 0;
  n = numberOfSamples;
  while (n--)
    mean += *samples++;
  return (mean / numberOfSamples);
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<getMean1f>:
  endbr64
  lea    -0x1(%rsi),%r8
  test   %rsi,%rsi
  je     L11
  cmp    $0x2,%r8
  jbe    L7
  mov    %rsi,%rcx
  xor    %eax,%eax
  pxor   %xmm0,%xmm0
  shr    $0x2,%rcx
  nopl   0x0(%rax,%rax,1)
L65:
  mov    %rax,%rdx
  add    $0x1,%rax
  shl    $0x4,%rdx
  movups (%rdi,%rdx,1),%xmm1
  addss  %xmm1,%xmm0
  movaps %xmm1,%xmm2
  shufps $0x55,%xmm1,%xmm2
  addss  %xmm2,%xmm0
  movaps %xmm1,%xmm2
  unpckhps %xmm1,%xmm2
  shufps $0xff,%xmm1,%xmm1
  addss  %xmm2,%xmm0
  addss  %xmm1,%xmm0
  cmp    %rax,%rcx
  jne    L65
  mov    %rsi,%rax
  and    $0xfffffffffffffffc,%rax
  lea    (%rdi,%rax,4),%rdi
  sub    %rax,%r8
  cmp    %rax,%rsi
  je     L56
L3:
  addss  (%rdi),%xmm0
  test   %r8,%r8
  je     L56
  addss  0x4(%rdi),%xmm0
  cmp    $0x1,%r8
  je     L56
  addss  0x8(%rdi),%xmm0
L56:
  pxor   %xmm1,%xmm1
  cvtsi2ss %rsi,%xmm1
  divss  %xmm1,%xmm0
  ret
  nop
L11:
  pxor   %xmm1,%xmm1
  pxor   %xmm0,%xmm0
  cvtsi2ss %rsi,%xmm1
  divss  %xmm1,%xmm0
  ret
L7:
  pxor   %xmm0,%xmm0
  jmp    L3
```

assistant: ```c
float getMean1f(float *samples, long numberOfSamples) {
  long n;
  float mean = 0;
  n = numberOfSamples;
  while (n--)
    mean += *samples++;
  return (mean / numberOfSamples);
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<syscon_quaddobl_size_limit>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %edi,-0x14(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    -0x8(%rbp),%rcx
  mov    -0x20(%rbp),%rdx
  lea    -0x14(%rbp),%rax
  mov    $0x0,%r8d
  mov    %rax,%rsi
  mov    $0x25a,%edi
  call   <_ada_use_c2phc4c@plt>
  mov    %eax,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  leave
  ret
```

assistant: ```c
int syscon_quaddobl_size_limit(int k, int *szl) {
  int fail;
  double *c;
  fail = _ada_use_c2phc4c(602, &k, szl, c, 0);
  return fail;
}
```
user: 这段汇编代码用C语言表示是什么样的?

```asm
<syscon_quaddobl_size_limit>:
  endbr64
  sub    $0x18,%rsp
  mov    %edi,0xc(%rsp)
  mov    %rsi,%rdx
  lea    0xc(%rsp),%rsi
  mov    $0x0,%r8d
  mov    $0x0,%ecx
  mov    $0x25a,%edi
  call   <_ada_use_c2phc4c@plt>
  add    $0x18,%rsp
  ret
```

assistant: ```c
int syscon_quaddobl_size_limit(int k, int *szl) {
  int fail;
  double *c;
  fail = _ada_use_c2phc4c(602, &k, szl, c, 0);
  return fail;
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<syscon_quaddobl_size_limit>:
  endbr64
  sub    $0x18,%rsp
  mov    %rsi,%rdx
  xor    %r8d,%r8d
  xor    %ecx,%ecx
  mov    %edi,0xc(%rsp)
  lea    0xc(%rsp),%rsi
  mov    $0x25a,%edi
  call   <_ada_use_c2phc4c@plt>
  add    $0x18,%rsp
  ret
```

assistant: ```c
int syscon_quaddobl_size_limit(int k, int *szl) {
  int fail;
  double *c;
  fail = _ada_use_c2phc4c(602, &k, szl, c, 0);
  return fail;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<syscon_quaddobl_size_limit>:
  endbr64
  sub    $0x18,%rsp
  mov    %rsi,%rdx
  xor    %r8d,%r8d
  xor    %ecx,%ecx
  mov    %edi,0xc(%rsp)
  lea    0xc(%rsp),%rsi
  mov    $0x25a,%edi
  call   <_ada_use_c2phc4c@plt>
  add    $0x18,%rsp
  ret
```

assistant: ```c
int syscon_quaddobl_size_limit(int k, int *szl) {
  int fail;
  double *c;
  fail = _ada_use_c2phc4c(602, &k, szl, c, 0);
  return fail;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<index>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,%rax
  mov    %esi,%edx
  mov    %edx,%ecx
L8:
  movzbl (%rax),%edx
  cmp    %dl,%cl
  jne    L21
  jmp    L18
L21:
  mov    %rax,%rdx
  lea    0x1(%rdx),%rax
  movzbl (%rdx),%edx
  test   %dl,%dl
  jne    L8
  mov    $0x0,%eax
L18:
  pop    %rbp
  ret
```

assistant: ```c
char *index(s, c)
register char *s, c;
{
  do {
    if (*s == c)
      return (s);
  } while (*s++ != 0);
  return (0);
}
```
user: What is the c source code of the assembly code below?

```asm
<index>:
  endbr64
  mov    %rdi,%rax
L11:
  movzbl (%rax),%edx
  cmp    %sil,%dl
  je     L10
  add    $0x1,%rax
  test   %dl,%dl
  jne    L11
  mov    $0x0,%eax
L10:
  ret
```

assistant: ```c
char *index(s, c)
register char *s, c;
{
  do {
    if (*s == c)
      return (s);
  } while (*s++ != 0);
  return (0);
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<index>:
  endbr64
  mov    %rdi,%rax
  jmp    L25
  nopl   0x0(%rax)
L28:
  add    $0x1,%rax
  test   %dl,%dl
  je     L23
L25:
  movzbl (%rax),%edx
  cmp    %sil,%dl
  jne    L28
  ret
  nopl   0x0(%rax)
L23:
  xor    %eax,%eax
  ret
```

assistant: ```c
char *index(s, c)
register char *s, c;
{
  do {
    if (*s == c)
      return (s);
  } while (*s++ != 0);
  return (0);
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<index>:
  endbr64
  mov    %rdi,%rax
  jmp    L9
  nopl   0x0(%rax)
L19:
  add    $0x1,%rax
  test   %dl,%dl
  je     L1
L9:
  movzbl (%rax),%edx
  cmp    %sil,%dl
  jne    L19
  ret
  nopl   0x0(%rax)
L1:
  xor    %eax,%eax
  ret
```

assistant: ```c
char *index(s, c)
register char *s, c;
{
  do {
    if (*s == c)
      return (s);
  } while (*s++ != 0);
  return (0);
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<get_value>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x8(%rbp)
  mov    %rsi,-0x10(%rbp)
  mov    %rdx,-0x18(%rbp)
  mov    -0x18(%rbp),%rdx
  mov    -0x10(%rbp),%rcx
  mov    -0x8(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  jne    L26
  mov    -0x18(%rbp),%rax
  add    %rax,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x3a,%al
  jne    L26
  addq   $0x1,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <bytesize@plt>
  jmp    L11
L26:
  mov    $0xffffffffffffffff,%rax
L11:
  leave
  ret
```

assistant: ```c
long long get_value(char *ptr, const char *str, size_t str_len) {
  if (strncmp(ptr, str, str_len) == 0) {
    ptr += str_len;
    if (*ptr == ':') {
      ptr += 1;
      return (bytesize(ptr));
    }
  }
  return (-1L);
}
```
user: Translate the below assembly code into C programming language:

```asm
<get_value>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%rbx
  mov    %rdx,%rbp
  call   <strncmp@plt>
  test   %rax,%rax
  jne    L17
  add    %rbp,%rbx
  cmpb   $0x3a,(%rbx)
  jne    L36
  lea    0x1(%rbx),%rdi
  call   <bytesize@plt>
L11:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
L17:
  mov    $0xffffffffffffffff,%rax
  jmp    L11
L36:
  mov    $0xffffffffffffffff,%rax
  jmp    L11
```

assistant: ```c
long long get_value(char *ptr, const char *str, size_t str_len) {
  if (strncmp(ptr, str, str_len) == 0) {
    ptr += str_len;
    if (*ptr == ':') {
      ptr += 1;
      return (bytesize(ptr));
    }
  }
  return (-1L);
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<get_value>:
  endbr64
  push   %rbp
  mov    %rdx,%rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x8,%rsp
  call   <strncmp@plt>
  test   %rax,%rax
  jne    L5
  add    %rbp,%rbx
  cmpb   $0x3a,(%rbx)
  jne    L5
  add    $0x8,%rsp
  lea    0x1(%rbx),%rdi
  pop    %rbx
  pop    %rbp
  jmp    1070 <bytesize@plt>
  nopl   0x0(%rax)
L5:
  add    $0x8,%rsp
  mov    $0xffffffffffffffff,%rax
  pop    %rbx
  pop    %rbp
  ret
```

assistant: ```c
long long get_value(char *ptr, const char *str, size_t str_len) {
  if (strncmp(ptr, str, str_len) == 0) {
    ptr += str_len;
    if (*ptr == ':') {
      ptr += 1;
      return (bytesize(ptr));
    }
  }
  return (-1L);
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<get_value>:
  endbr64
  push   %rbp
  mov    %rdx,%rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x8,%rsp
  call   <strncmp@plt>
  test   %rax,%rax
  jne    L10
  add    %rbp,%rbx
  cmpb   $0x3a,(%rbx)
  jne    L10
  add    $0x8,%rsp
  lea    0x1(%rbx),%rdi
  pop    %rbx
  pop    %rbp
  jmp    1070 <bytesize@plt>
  nopl   0x0(%rax)
L10:
  add    $0x8,%rsp
  mov    $0xffffffffffffffff,%rax
  pop    %rbx
  pop    %rbp
  ret
```

assistant: ```c
long long get_value(char *ptr, const char *str, size_t str_len) {
  if (strncmp(ptr, str, str_len) == 0) {
    ptr += str_len;
    if (*ptr == ':') {
      ptr += 1;
      return (bytesize(ptr));
    }
  }
  return (-1L);
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<flsnz>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,-0x14(%rbp)
  bsr    -0x14(%rbp),%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  add    $0x1,%eax
  pop    %rbp
  ret
```

assistant: ```c
int flsnz(int x) {
  int r;
  __asm__("bsrl %1,%0\n" : "=r"(r) : "rm"(x));
  return r + 1;
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<flsnz>:
  endbr64
  bsr    %edi,%eax
  add    $0x1,%eax
  ret
```

assistant: ```c
int flsnz(int x) {
  int r;
  __asm__("bsrl %1,%0\n" : "=r"(r) : "rm"(x));
  return r + 1;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<flsnz>:
  endbr64
  bsr    %edi,%eax
  add    $0x1,%eax
  ret
```

assistant: ```c
int flsnz(int x) {
  int r;
  __asm__("bsrl %1,%0\n" : "=r"(r) : "rm"(x));
  return r + 1;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<flsnz>:
  endbr64
  bsr    %edi,%eax
  add    $0x1,%eax
  ret
```

assistant: ```c
int flsnz(int x) {
  int r;
  __asm__("bsrl %1,%0\n" : "=r"(r) : "rm"(x));
  return r + 1;
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<CPSWClkEnable>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    $0x44e00014,%eax
  movl   $0x2,(%rax)
  nop
L13:
  mov    $0x44e00014,%eax
  mov    (%rax),%eax
  and    $0x30000,%eax
  test   %eax,%eax
  jne    L13
  mov    $0x44e00144,%eax
  movl   $0x2,(%rax)
  nop
L6:
  mov    $0x44e00144,%eax
  mov    (%rax),%eax
  and    $0x10,%eax
  test   %eax,%eax
  je     L6
  nop
  nop
  pop    %rbp
  ret
```

assistant: ```c
void CPSWClkEnable(void) {
  (*((volatile unsigned int *)((0x44E00000) + (0x14)))) = (0x2u);
  while (0 != ((*((volatile unsigned int *)((0x44E00000) + (0x14)))) & (0x00030000u)))
    ;
  (*((volatile unsigned int *)((0x44E00000) + (0x144)))) = (0x2u);
  while (0 == ((*((volatile unsigned int *)((0x44E00000) + (0x144)))) & (0x00000010u)))
    ;
}
```
user: Translate the below assembly code into C programming language:

```asm
<CPSWClkEnable>:
  endbr64
  movl   $0x2,0x44e00014
L10:
  mov    0x44e00014,%eax
  test   $0x30000,%eax
  jne    L10
  movl   $0x2,0x44e00144
L6:
  mov    0x44e00144,%eax
  test   $0x10,%al
  je     L6
  ret
```

assistant: ```c
void CPSWClkEnable(void) {
  (*((volatile unsigned int *)((0x44E00000) + (0x14)))) = (0x2u);
  while (0 != ((*((volatile unsigned int *)((0x44E00000) + (0x14)))) & (0x00030000u)))
    ;
  (*((volatile unsigned int *)((0x44E00000) + (0x144)))) = (0x2u);
  while (0 == ((*((volatile unsigned int *)((0x44E00000) + (0x144)))) & (0x00000010u)))
    ;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<CPSWClkEnable>:
  endbr64
  movl   $0x2,0x44e00014
  nop
L18:
  mov    0x44e00014,%eax
  test   $0x30000,%eax
  jne    L18
  movl   $0x2,0x44e00144
  nopl   0x0(%rax)
L9:
  mov    0x44e00144,%eax
  test   $0x10,%al
  je     L9
  ret
```

assistant: ```c
void CPSWClkEnable(void) {
  (*((volatile unsigned int *)((0x44E00000) + (0x14)))) = (0x2u);
  while (0 != ((*((volatile unsigned int *)((0x44E00000) + (0x14)))) & (0x00030000u)))
    ;
  (*((volatile unsigned int *)((0x44E00000) + (0x144)))) = (0x2u);
  while (0 == ((*((volatile unsigned int *)((0x44E00000) + (0x144)))) & (0x00000010u)))
    ;
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<CPSWClkEnable>:
  endbr64
  movl   $0x2,0x44e00014
  nop
L5:
  mov    0x44e00014,%eax
  test   $0x30000,%eax
  jne    L5
  movl   $0x2,0x44e00144
  nopl   0x0(%rax)
L9:
  mov    0x44e00144,%eax
  test   $0x10,%al
  je     L9
  ret
```

assistant: ```c
void CPSWClkEnable(void) {
  (*((volatile unsigned int *)((0x44E00000) + (0x14)))) = (0x2u);
  while (0 != ((*((volatile unsigned int *)((0x44E00000) + (0x14)))) & (0x00030000u)))
    ;
  (*((volatile unsigned int *)((0x44E00000) + (0x144)))) = (0x2u);
  while (0 == ((*((volatile unsigned int *)((0x44E00000) + (0x144)))) & (0x00000010u)))
    ;
}
```
user: 这段汇编代码用C语言表示是什么样的?

```asm
<pagetable_alloc>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  mov    %edx,-0x20(%rbp)
  mov    %ecx,-0x24(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x20(%rbp),%eax
  shr    $0xc,%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x20(%rbp),%eax
  and    $0xfff,%eax
  test   %eax,%eax
  je     L47
  addl   $0x1,-0xc(%rbp)
L47:
  andl   $0xfffff000,-0x1c(%rbp)
  jmp    L29
L49:
  lea    -0x10(%rbp),%rdx
  mov    -0x1c(%rbp),%esi
  mov    -0x18(%rbp),%rax
  mov    $0x0,%ecx
  mov    %rax,%rdi
  call   <pagetable_getmap@plt>
  test   %eax,%eax
  jne    L24
  mov    -0x24(%rbp),%eax
  or     $0x2,%eax
  mov    %eax,%edx
  mov    -0x1c(%rbp),%esi
  mov    -0x18(%rbp),%rax
  mov    %edx,%ecx
  mov    $0x0,%edx
  mov    %rax,%rdi
  call   <pagetable_map@plt>
L24:
  addl   $0x1000,-0x1c(%rbp)
  subl   $0x1,-0xc(%rbp)
L29:
  cmpl   $0x0,-0xc(%rbp)
  jne    L49
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L6
  call   <__stack_chk_fail@plt>
L6:
  leave
  ret
```

assistant: ```c
void pagetable_alloc(struct pagetable *p, unsigned vaddr, unsigned length, int flags) {
  unsigned npages = length / 4096;
  if (length % 4096)
    npages++;
  vaddr &= 0xfffff000;
  while (npages > 0) {
    unsigned paddr;
    if (!pagetable_getmap(p, vaddr, &paddr, 0)) {
      pagetable_map(p, vaddr, 0, flags | 2);
    }
    vaddr += 4096;
    npages--;
  }
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<pagetable_alloc>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x10,%rsp
  mov    %rdi,%r12
  mov    %esi,%ebx
  mov    %ecx,%r14d
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  mov    %edx,%ebp
  shr    $0xc,%ebp
  test   $0xfff,%edx
  je     L52
  add    $0x1,%ebp
  and    $0xfffff000,%ebx
L27:
  lea    0x4(%rsp),%r13
  jmp    L8
L52:
  and    $0xfffff000,%ebx
  cmp    $0xfff,%edx
  ja     L27
L62:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L48
  add    $0x10,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L25:
  add    $0x1000,%ebx
  sub    $0x1,%ebp
  je     L62
L8:
  mov    $0x0,%ecx
  mov    %r13,%rdx
  mov    %ebx,%esi
  mov    %r12,%rdi
  call   <pagetable_getmap@plt>
  test   %eax,%eax
  jne    L25
  mov    %r14d,%ecx
  or     $0x2,%ecx
  mov    $0x0,%edx
  mov    %ebx,%esi
  mov    %r12,%rdi
  call   <pagetable_map@plt>
  jmp    L25
L48:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void pagetable_alloc(struct pagetable *p, unsigned vaddr, unsigned length, int flags) {
  unsigned npages = length / 4096;
  if (length % 4096)
    npages++;
  vaddr &= 0xfffff000;
  while (npages > 0) {
    unsigned paddr;
    if (!pagetable_getmap(p, vaddr, &paddr, 0)) {
      pagetable_map(p, vaddr, 0, flags | 2);
    }
    vaddr += 4096;
    npages--;
  }
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<pagetable_alloc>:
  endbr64
  push   %r14
  and    $0xfffff000,%esi
  push   %r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  mov    %edx,%ebp
  push   %rbx
  shr    $0xc,%ebp
  mov    %esi,%ebx
  sub    $0x10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  and    $0xfff,%edx
  je     L70
  add    $0x1,%ebp
L22:
  or     $0x2,%ecx
  lea    0x4(%rsp),%r13
  mov    %ecx,%r14d
  jmp    L52
  nopl   0x0(%rax,%rax,1)
L19:
  add    $0x1000,%ebx
  sub    $0x1,%ebp
  je     L45
L52:
  xor    %ecx,%ecx
  mov    %r13,%rdx
  mov    %ebx,%esi
  mov    %r12,%rdi
  call   <pagetable_getmap@plt>
  test   %eax,%eax
  jne    L19
  mov    %ebx,%esi
  mov    %r14d,%ecx
  xor    %edx,%edx
  mov    %r12,%rdi
  call   <pagetable_map@plt>
  add    $0x1000,%ebx
  sub    $0x1,%ebp
  jne    L52
L45:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L28
  add    $0x10,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopl   (%rax)
L70:
  test   %ebp,%ebp
  jne    L22
  jmp    L45
L28:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void pagetable_alloc(struct pagetable *p, unsigned vaddr, unsigned length, int flags) {
  unsigned npages = length / 4096;
  if (length % 4096)
    npages++;
  vaddr &= 0xfffff000;
  while (npages > 0) {
    unsigned paddr;
    if (!pagetable_getmap(p, vaddr, &paddr, 0)) {
      pagetable_map(p, vaddr, 0, flags | 2);
    }
    vaddr += 4096;
    npages--;
  }
}
```
user: 这段汇编代码用C语言表示是什么样的:

```asm
<pagetable_alloc>:
  endbr64
  push   %r14
  and    $0xfffff000,%esi
  push   %r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  mov    %edx,%ebp
  push   %rbx
  shr    $0xc,%ebp
  mov    %esi,%ebx
  sub    $0x10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  and    $0xfff,%edx
  je     L54
  add    $0x1,%ebp
L64:
  or     $0x2,%ecx
  lea    0x4(%rsp),%r13
  mov    %ecx,%r14d
  cs nopw 0x0(%rax,%rax,1)
L78:
  xor    %ecx,%ecx
  mov    %r13,%rdx
  mov    %ebx,%esi
  mov    %r12,%rdi
  call   <pagetable_getmap@plt>
  test   %eax,%eax
  je     L15
  add    $0x1000,%ebx
  sub    $0x1,%ebp
  jne    L78
L20:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L70
  add    $0x10,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
  nopl   0x0(%rax,%rax,1)
L15:
  mov    %ebx,%esi
  mov    %r14d,%ecx
  xor    %edx,%edx
  mov    %r12,%rdi
  call   <pagetable_map@plt>
  add    $0x1000,%ebx
  sub    $0x1,%ebp
  jne    L78
  jmp    L20
  nopl   0x0(%rax)
L54:
  test   %ebp,%ebp
  jne    L64
  jmp    L20
L70:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void pagetable_alloc(struct pagetable *p, unsigned vaddr, unsigned length, int flags) {
  unsigned npages = length / 4096;
  if (length % 4096)
    npages++;
  vaddr &= 0xfffff000;
  while (npages > 0) {
    unsigned paddr;
    if (!pagetable_getmap(p, vaddr, &paddr, 0)) {
      pagetable_map(p, vaddr, 0, flags | 2);
    }
    vaddr += 4096;
    npages--;
  }
}
```