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

```asm
<fc8180_spib_longread>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,%eax
  mov    %rdx,-0x28(%rbp)
  mov    %ax,-0x1c(%rbp)
  movb   $0xc0,-0x5(%rbp)
  mov    $0x0,%eax
  call   <OAL_OBTAIN_SEMAPHORE@plt>
  movzbl -0x5(%rbp),%edx
  movzwl -0x1c(%rbp),%esi
  mov    -0x28(%rbp),%rcx
  mov    -0x18(%rbp),%rax
  mov    $0x4,%r8d
  mov    %rax,%rdi
  call   <spi_bulkread@plt>
  mov    %eax,-0x4(%rbp)
  mov    $0x0,%eax
  call   <OAL_RELEASE_SEMAPHORE@plt>
  mov    -0x4(%rbp),%eax
  leave
  ret
```

assistant: ```c
signed int fc8180_spib_longread(void *handle, unsigned short addr, unsigned int *data) {
  signed int res;
  unsigned char command = 0x40 | 0x80;
  OAL_OBTAIN_SEMAPHORE();
  res = spi_bulkread(handle, addr, command, (unsigned char *)data, 4);
  OAL_RELEASE_SEMAPHORE();
  return res;
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<fc8180_spib_longread>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbp
  mov    %esi,%ebx
  mov    %rdx,%r12
  mov    $0x0,%eax
  call   <OAL_OBTAIN_SEMAPHORE@plt>
  movzwl %bx,%esi
  mov    $0x4,%r8d
  mov    %r12,%rcx
  mov    $0xc0,%edx
  mov    %rbp,%rdi
  call   <spi_bulkread@plt>
  mov    %eax,%ebx
  mov    $0x0,%eax
  call   <OAL_RELEASE_SEMAPHORE@plt>
  mov    %ebx,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
signed int fc8180_spib_longread(void *handle, unsigned short addr, unsigned int *data) {
  signed int res;
  unsigned char command = 0x40 | 0x80;
  OAL_OBTAIN_SEMAPHORE();
  res = spi_bulkread(handle, addr, command, (unsigned char *)data, 4);
  OAL_RELEASE_SEMAPHORE();
  return res;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<fc8180_spib_longread>:
  endbr64
  push   %r13
  xor    %eax,%eax
  mov    %rdx,%r13
  push   %r12
  mov    %rdi,%r12
  push   %rbx
  mov    %esi,%ebx
  call   <OAL_OBTAIN_SEMAPHORE@plt>
  movzwl %bx,%esi
  mov    %r13,%rcx
  mov    %r12,%rdi
  mov    $0x4,%r8d
  mov    $0xc0,%edx
  call   <spi_bulkread@plt>
  mov    %eax,%r12d
  xor    %eax,%eax
  call   <OAL_RELEASE_SEMAPHORE@plt>
  mov    %r12d,%eax
  pop    %rbx
  pop    %r12
  pop    %r13
  ret
```

assistant: ```c
signed int fc8180_spib_longread(void *handle, unsigned short addr, unsigned int *data) {
  signed int res;
  unsigned char command = 0x40 | 0x80;
  OAL_OBTAIN_SEMAPHORE();
  res = spi_bulkread(handle, addr, command, (unsigned char *)data, 4);
  OAL_RELEASE_SEMAPHORE();
  return res;
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<fc8180_spib_longread>:
  endbr64
  push   %r13
  xor    %eax,%eax
  mov    %rdx,%r13
  push   %r12
  mov    %rdi,%r12
  push   %rbx
  mov    %esi,%ebx
  call   <OAL_OBTAIN_SEMAPHORE@plt>
  movzwl %bx,%esi
  mov    %r13,%rcx
  mov    %r12,%rdi
  mov    $0x4,%r8d
  mov    $0xc0,%edx
  call   <spi_bulkread@plt>
  mov    %eax,%r12d
  xor    %eax,%eax
  call   <OAL_RELEASE_SEMAPHORE@plt>
  mov    %r12d,%eax
  pop    %rbx
  pop    %r12
  pop    %r13
  ret
```

assistant: ```c
signed int fc8180_spib_longread(void *handle, unsigned short addr, unsigned int *data) {
  signed int res;
  unsigned char command = 0x40 | 0x80;
  OAL_OBTAIN_SEMAPHORE();
  res = spi_bulkread(handle, addr, command, (unsigned char *)data, 4);
  OAL_RELEASE_SEMAPHORE();
  return res;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<genbrtrue>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %edi,-0x4(%rbp)
  mov    $0x0,%eax
  call   <gentext@plt>
  mov    -0x4(%rbp),%eax
  mov    %eax,%edi
  call   <cgbrtrue@plt>
  nop
  leave
  ret
```

assistant: ```c
void genbrtrue(int dest) {
  gentext();
  cgbrtrue(dest);
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<genbrtrue>:
  endbr64
  push   %rbx
  mov    %edi,%ebx
  mov    $0x0,%eax
  call   <gentext@plt>
  mov    %ebx,%edi
  call   <cgbrtrue@plt>
  pop    %rbx
  ret
```

assistant: ```c
void genbrtrue(int dest) {
  gentext();
  cgbrtrue(dest);
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<genbrtrue>:
  endbr64
  push   %rbp
  xor    %eax,%eax
  mov    %edi,%ebp
  call   <gentext@plt>
  mov    %ebp,%edi
  pop    %rbp
  jmp    1070 <cgbrtrue@plt>
```

assistant: ```c
void genbrtrue(int dest) {
  gentext();
  cgbrtrue(dest);
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<genbrtrue>:
  endbr64
  push   %rbp
  xor    %eax,%eax
  mov    %edi,%ebp
  call   <gentext@plt>
  mov    %ebp,%edi
  pop    %rbp
  jmp    1070 <cgbrtrue@plt>
```

assistant: ```c
void genbrtrue(int dest) {
  gentext();
  cgbrtrue(dest);
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<getLowerPowerOfTwo>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,-0x14(%rbp)
  movl   $0x1,-0x4(%rbp)
  jmp    L10
L8:
  shll   -0x4(%rbp)
L10:
  mov    -0x4(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jbe    L8
  mov    -0x4(%rbp),%eax
  shr    %eax
  pop    %rbp
  ret
```

assistant: ```c
unsigned int getLowerPowerOfTwo(const unsigned int x) {
  unsigned int i = 1;
  while (i <= x)
    i += i;
  return i >> 1;
}
```
user: 这段汇编代码用C语言表示是什么样的：

```asm
<getLowerPowerOfTwo>:
  endbr64
  test   %edi,%edi
  je     L28
  mov    $0x1,%eax
L18:
  add    %eax,%eax
  cmp    %eax,%edi
  jae    L18
L2:
  shr    %eax
  ret
L28:
  mov    $0x1,%eax
  jmp    L2
```

assistant: ```c
unsigned int getLowerPowerOfTwo(const unsigned int x) {
  unsigned int i = 1;
  while (i <= x)
    i += i;
  return i >> 1;
}
```
user: Translate the below assembly code into C programming language:

```asm
<getLowerPowerOfTwo>:
  endbr64
  test   %edi,%edi
  je     L0
  mov    $0x1,%eax
  nopl   (%rax)
L15:
  add    %eax,%eax
  cmp    %eax,%edi
  jae    L15
  shr    %eax
  ret
  nopl   0x0(%rax)
L0:
  xor    %eax,%eax
  ret
```

assistant: ```c
unsigned int getLowerPowerOfTwo(const unsigned int x) {
  unsigned int i = 1;
  while (i <= x)
    i += i;
  return i >> 1;
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<getLowerPowerOfTwo>:
  endbr64
  test   %edi,%edi
  je     L12
  mov    $0x1,%eax
  nopl   (%rax)
L13:
  add    %eax,%eax
  cmp    %eax,%edi
  jae    L13
  shr    %eax
  ret
  nopl   0x0(%rax)
L12:
  xor    %eax,%eax
  ret
```

assistant: ```c
unsigned int getLowerPowerOfTwo(const unsigned int x) {
  unsigned int i = 1;
  while (i <= x)
    i += i;
  return i >> 1;
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  movl   $0x0,-0x4(%rbp)
  nop
L0:
  mov    -0x4(%rbp),%eax
  test   %eax,%eax
  je     L0
  mov    $0x0,%eax
  pop    %rbp
  ret
```

assistant: ```c
int main() {
  volatile int cancel = 0;
  while (!cancel)
    ;
  return 0;
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<main>:
  endbr64
  movl   $0x0,-0x4(%rsp)
L9:
  mov    -0x4(%rsp),%eax
  test   %eax,%eax
  je     L9
  mov    $0x0,%eax
  ret
```

assistant: ```c
int main() {
  volatile int cancel = 0;
  while (!cancel)
    ;
  return 0;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<main>:
  endbr64
  movl   $0x0,-0x4(%rsp)
  nopl   0x0(%rax)
L6:
  mov    -0x4(%rsp),%eax
  test   %eax,%eax
  je     L6
  xor    %eax,%eax
  ret
```

assistant: ```c
int main() {
  volatile int cancel = 0;
  while (!cancel)
    ;
  return 0;
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<main>:
  endbr64
  movl   $0x0,-0x4(%rsp)
  nopl   0x0(%rax)
L4:
  mov    -0x4(%rsp),%eax
  test   %eax,%eax
  je     L4
  xor    %eax,%eax
  ret
```

assistant: ```c
int main() {
  volatile int cancel = 0;
  while (!cancel)
    ;
  return 0;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<rl_check_watched_keys>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  mov    %rdx,-0x28(%rbp)
  movl   $0x0,-0x4(%rbp)
  movl   $0x0,-0x8(%rbp)
  jmp    L24
L35:
  mov    -0x8(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x28(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rdx
  mov    -0x18(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <rl_key_sha_check_version@plt>
  mov    %eax,-0x4(%rbp)
  cmpl   $0x0,-0x4(%rbp)
  jne    L37
  addl   $0x1,-0x8(%rbp)
L24:
  mov    -0x8(%rbp),%eax
  cmp    -0x1c(%rbp),%eax
  jl     L35
  jmp    L3
L37:
  nop
L3:
  mov    -0x4(%rbp),%eax
  leave
  ret
```

assistant: ```c
int rl_check_watched_keys(struct rlite *db, int watched_count, struct watched_key **keys) {
  int i, retval = 0;
  for (i = 0; i < watched_count; i++) {
    retval = rl_key_sha_check_version(db, keys[i]);
    if (0 != retval)
      goto cleanup;
    ;
  }
cleanup:
  return retval;
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<rl_check_watched_keys>:
  endbr64
  test   %esi,%esi
  jle    L16
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbp
  mov    %rdx,%rbx
  lea    -0x1(%rsi),%eax
  lea    0x8(%rdx,%rax,8),%r12
L18:
  mov    (%rbx),%rsi
  mov    %rbp,%rdi
  call   <rl_key_sha_check_version@plt>
  test   %eax,%eax
  jne    L28
  add    $0x8,%rbx
  cmp    %r12,%rbx
  jne    L18
L28:
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L16:
  mov    $0x0,%eax
  ret
```

assistant: ```c
int rl_check_watched_keys(struct rlite *db, int watched_count, struct watched_key **keys) {
  int i, retval = 0;
  for (i = 0; i < watched_count; i++) {
    retval = rl_key_sha_check_version(db, keys[i]);
    if (0 != retval)
      goto cleanup;
    ;
  }
cleanup:
  return retval;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<rl_check_watched_keys>:
  endbr64
  test   %esi,%esi
  jle    L38
  lea    -0x1(%rsi),%eax
  push   %r12
  lea    0x8(%rdx,%rax,8),%r12
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  mov    %rdx,%rbx
  jmp    L30
  nopl   0x0(%rax)
L2:
  add    $0x8,%rbx
  cmp    %r12,%rbx
  je     L39
L30:
  mov    (%rbx),%rsi
  mov    %rbp,%rdi
  call   <rl_key_sha_check_version@plt>
  test   %eax,%eax
  je     L2
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopl   (%rax)
L39:
  pop    %rbx
  xor    %eax,%eax
  pop    %rbp
  pop    %r12
  ret
L38:
  xor    %eax,%eax
  ret
```

assistant: ```c
int rl_check_watched_keys(struct rlite *db, int watched_count, struct watched_key **keys) {
  int i, retval = 0;
  for (i = 0; i < watched_count; i++) {
    retval = rl_key_sha_check_version(db, keys[i]);
    if (0 != retval)
      goto cleanup;
    ;
  }
cleanup:
  return retval;
}
```
user: 这段汇编代码用C语言表示是什么样的?

```asm
<rl_check_watched_keys>:
  endbr64
  test   %esi,%esi
  jle    L24
  lea    -0x1(%rsi),%eax
  push   %r12
  lea    0x8(%rdx,%rax,8),%r12
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  mov    %rdx,%rbx
  jmp    L7
  nopl   0x0(%rax)
L1:
  add    $0x8,%rbx
  cmp    %r12,%rbx
  je     L32
L7:
  mov    (%rbx),%rsi
  mov    %rbp,%rdi
  call   <rl_key_sha_check_version@plt>
  test   %eax,%eax
  je     L1
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopl   (%rax)
L32:
  pop    %rbx
  xor    %eax,%eax
  pop    %rbp
  pop    %r12
  ret
L24:
  xor    %eax,%eax
  ret
```

assistant: ```c
int rl_check_watched_keys(struct rlite *db, int watched_count, struct watched_key **keys) {
  int i, retval = 0;
  for (i = 0; i < watched_count; i++) {
    retval = rl_key_sha_check_version(db, keys[i]);
    if (0 != retval)
      goto cleanup;
    ;
  }
cleanup:
  return retval;
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<uart_wait_until_sent>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  nop
L1:
  mov    $0x3fd,%edi
  call   <inb@plt>
  and    $0x40,%eax
  test   %eax,%eax
  je     L1
  nop
  nop
  pop    %rbp
  ret
```

assistant: ```c
void uart_wait_until_sent(void) {
  while (!(inb(0x3f8 + 0x05) & 0x40))
    ;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<uart_wait_until_sent>:
  endbr64
  sub    $0x8,%rsp
L7:
  mov    $0x3fd,%edi
  call   <inb@plt>
  test   $0x40,%al
  je     L7
  add    $0x8,%rsp
  ret
```

assistant: ```c
void uart_wait_until_sent(void) {
  while (!(inb(0x3f8 + 0x05) & 0x40))
    ;
}
```
user: 这段汇编代码用C语言表示是什么样的：

```asm
<uart_wait_until_sent>:
  endbr64
  sub    $0x8,%rsp
  nopl   0x0(%rax,%rax,1)
L7:
  mov    $0x3fd,%edi
  call   <inb@plt>
  test   $0x40,%al
  je     L7
  add    $0x8,%rsp
  ret
```

assistant: ```c
void uart_wait_until_sent(void) {
  while (!(inb(0x3f8 + 0x05) & 0x40))
    ;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<uart_wait_until_sent>:
  endbr64
  sub    $0x8,%rsp
  nopl   0x0(%rax,%rax,1)
L1:
  mov    $0x3fd,%edi
  call   <inb@plt>
  test   $0x40,%al
  je     L1
  add    $0x8,%rsp
  ret
```

assistant: ```c
void uart_wait_until_sent(void) {
  while (!(inb(0x3f8 + 0x05) & 0x40))
    ;
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  movb   $0x18,-0xa(%rbp)
  movb   $0x1,-0x9(%rbp)
  movzbl -0xa(%rbp),%eax
  mov    %eax,%ecx
  sarq   %cl,-0x8(%rbp)
  movzbl -0x9(%rbp),%eax
  mov    %eax,%ecx
  sarq   %cl,-0x8(%rbp)
  mov    $0x0,%edi
  call   <assert@plt>
  mov    $0x0,%eax
  leave
  ret
```

assistant: ```c
int main() {
  long long accu;
  unsigned char x1 = 24, x2 = 1;
  accu >>= x1;
  accu >>= x2;
  assert(0);
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<main>:
  endbr64
  sub    $0x8,%rsp
  mov    $0x0,%edi
  call   <assert@plt>
  mov    $0x0,%eax
  add    $0x8,%rsp
  ret
```

assistant: ```c
int main() {
  long long accu;
  unsigned char x1 = 24, x2 = 1;
  accu >>= x1;
  accu >>= x2;
  assert(0);
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<main>:
  endbr64
  sub    $0x8,%rsp
  xor    %edi,%edi
  call   <assert@plt>
  xor    %eax,%eax
  add    $0x8,%rsp
  ret
```

assistant: ```c
int main() {
  long long accu;
  unsigned char x1 = 24, x2 = 1;
  accu >>= x1;
  accu >>= x2;
  assert(0);
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<main>:
  endbr64
  sub    $0x8,%rsp
  xor    %edi,%edi
  call   <assert@plt>
  xor    %eax,%eax
  add    $0x8,%rsp
  ret
```

assistant: ```c
int main() {
  long long accu;
  unsigned char x1 = 24, x2 = 1;
  accu >>= x1;
  accu >>= x2;
  assert(0);
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<readln>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  movl   $0x0,-0x4(%rbp)
  jmp    L29
L33:
  mov    -0x1c(%rbp),%eax
  sub    $0x1,%eax
  cmp    %eax,-0x4(%rbp)
  jge    L53
  mov    -0x4(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    %edx,-0x4(%rbp)
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  add    %rax,%rdx
  movzbl -0x5(%rbp),%eax
  mov    %al,(%rdx)
  cmpb   $0xa,-0x5(%rbp)
  je     L58
L29:
  mov    $0x0,%eax
  call   <getchar@plt>
  mov    %al,-0x5(%rbp)
  mov    D6(%rip),%rax
  movzbl (%rax),%eax
  cmp    %al,-0x5(%rbp)
  jne    L33
  jmp    L30
L53:
  nop
  jmp    L30
L58:
  nop
L30:
  mov    -0x4(%rbp),%eax
  cltq
  lea    -0x1(%rax),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x4(%rbp),%eax
  leave
  ret
```

assistant: ```c
int readln(char *s, int max_len) {
  char c;
  int len = 0;
  while ((c = getchar()) != EOF) {
    if (len >= max_len - 1)
      break;
    s[len++] = c;
    if (c == '\n')
      break;
  }
  s[len - 1] = 0;
  return len;
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<readln>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%r13
  mov    %rdi,%rbp
  mov    $0x0,%ebx
  lea    -0x1(%rsi),%r12d
L21:
  mov    $0x0,%eax
  call   <getchar@plt>
  mov    D4(%rip),%rdx
  cmp    %al,(%rdx)
  je     L27
  cmp    %ebx,%r12d
  jle    L27
  add    $0x1,%ebx
  mov    %al,0x0(%rbp)
  add    $0x1,%rbp
  cmp    $0xa,%al
  jne    L21
L27:
  movslq %ebx,%rax
  movb   $0x0,-0x1(%r13,%rax,1)
  mov    %ebx,%eax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
```

assistant: ```c
int readln(char *s, int max_len) {
  char c;
  int len = 0;
  while ((c = getchar()) != EOF) {
    if (len >= max_len - 1)
      break;
    s[len++] = c;
    if (c == '\n')
      break;
  }
  s[len - 1] = 0;
  return len;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<readln>:
  endbr64
  push   %r14
  mov    %rdi,%r14
  push   %r13
  mov    %rdi,%r13
  push   %r12
  xor    %r12d,%r12d
  push   %rbp
  mov    D2(%rip),%rbp
  push   %rbx
  lea    -0x1(%rsi),%ebx
  jmp    L33
  nopl   0x0(%rax)
L17:
  cmp    %r12d,%ebx
  jle    L39
  mov    %al,(%r14)
  add    $0x1,%r12d
  add    $0x1,%r14
  cmp    $0xa,%al
  je     L39
L33:
  xor    %eax,%eax
  call   <getchar@plt>
  cmp    %al,0x0(%rbp)
  jne    L17
L39:
  movslq %r12d,%rax
  movb   $0x0,-0x1(%r13,%rax,1)
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
```

assistant: ```c
int readln(char *s, int max_len) {
  char c;
  int len = 0;
  while ((c = getchar()) != EOF) {
    if (len >= max_len - 1)
      break;
    s[len++] = c;
    if (c == '\n')
      break;
  }
  s[len - 1] = 0;
  return len;
}
```
user: What is the c source code of the assembly code below?

```asm
<readln>:
  endbr64
  push   %r14
  mov    %rdi,%r14
  push   %r13
  mov    %rdi,%r13
  push   %r12
  xor    %r12d,%r12d
  push   %rbp
  mov    D8(%rip),%rbp
  push   %rbx
  lea    -0x1(%rsi),%ebx
  jmp    L20
  nopl   0x0(%rax)
L15:
  cmp    %r12d,%ebx
  jle    L3
  mov    %al,(%r14)
  add    $0x1,%r12d
  add    $0x1,%r14
  cmp    $0xa,%al
  je     L3
L20:
  xor    %eax,%eax
  call   <getchar@plt>
  cmp    %al,0x0(%rbp)
  jne    L15
L3:
  movslq %r12d,%rax
  movb   $0x0,-0x1(%r13,%rax,1)
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
```

assistant: ```c
int readln(char *s, int max_len) {
  char c;
  int len = 0;
  while ((c = getchar()) != EOF) {
    if (len >= max_len - 1)
      break;
    s[len++] = c;
    if (c == '\n')
      break;
  }
  s[len - 1] = 0;
  return len;
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<printf>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbx
  sub    $0xe8,%rsp
  mov    %rdi,-0x108(%rbp)
  mov    %rsi,-0xd8(%rbp)
  mov    %rdx,-0xd0(%rbp)
  mov    %rcx,-0xc8(%rbp)
  mov    %r8,-0xc0(%rbp)
  mov    %r9,-0xb8(%rbp)
  test   %al,%al
  je     L23
  movaps %xmm0,-0xb0(%rbp)
  movaps %xmm1,-0xa0(%rbp)
  movaps %xmm2,-0x90(%rbp)
  movaps %xmm3,-0x80(%rbp)
  movaps %xmm4,-0x70(%rbp)
  movaps %xmm5,-0x60(%rbp)
  movaps %xmm6,-0x50(%rbp)
  movaps %xmm7,-0x40(%rbp)
L23:
  mov    %fs:0x28,%rax
  mov    %rax,-0xe8(%rbp)
  xor    %eax,%eax
  movl   $0x0,-0x100(%rbp)
  mov    -0x108(%rbp),%rdx
  mov    -0xfc(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <va_start@plt>
  mov    -0xfc(%rbp),%edx
  mov    -0x108(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <ts_formatlength@plt>
  mov    %eax,-0x100(%rbp)
  mov    -0xfc(%rbp),%eax
  mov    %eax,%edi
  call   <va_end@plt>
  mov    %rsp,%rax
  mov    %rax,%rbx
  mov    -0x100(%rbp),%eax
  movslq %eax,%rdx
  sub    $0x1,%rdx
  mov    %rdx,-0xf8(%rbp)
  movslq %eax,%rdx
  mov    %rdx,%r14
  mov    $0x0,%r15d
  movslq %eax,%rdx
  mov    %rdx,%r12
  mov    $0x0,%r13d
  cltq
  mov    $0x10,%edx
  sub    $0x1,%rdx
  add    %rdx,%rax
  mov    $0x10,%esi
  mov    $0x0,%edx
  div    %rsi
  imul   $0x10,%rax,%rax
  mov    %rax,%rcx
  and    $0xfffffffffffff000,%rcx
  mov    %rsp,%rdx
  sub    %rcx,%rdx
L47:
  cmp    %rdx,%rsp
  je     L13
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L47
L13:
  mov    %rax,%rdx
  and    $0xfff,%edx
  sub    %rdx,%rsp
  mov    %rax,%rdx
  and    $0xfff,%edx
  test   %rdx,%rdx
  je     L21
  and    $0xfff,%eax
  sub    $0x8,%rax
  add    %rsp,%rax
  orq    $0x0,(%rax)
L21:
  mov    %rsp,%rax
  add    $0x0,%rax
  mov    %rax,-0xf0(%rbp)
  mov    -0x108(%rbp),%rdx
  mov    -0xfc(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <va_start@plt>
  mov    -0xfc(%rbp),%edx
  mov    -0x108(%rbp),%rcx
  mov    -0xf0(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <ts_formatstring@plt>
  mov    %eax,-0x100(%rbp)
  mov    -0x100(%rbp),%edx
  mov    -0xf0(%rbp),%rax
  mov    %rax,%rsi
  mov    $0x1,%edi
  call   <_write@plt>
  mov    %eax,-0x100(%rbp)
  mov    -0xfc(%rbp),%eax
  mov    %eax,%edi
  call   <va_end@plt>
  mov    %rbx,%rsp
  mov    -0x100(%rbp),%eax
  mov    -0xe8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L11
  call   <__stack_chk_fail@plt>
L11:
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
```

assistant: ```c
int printf(const char *fmt, ...) {
  int length = 0;
  va_list va;
  va_start(va, fmt);
  length = ts_formatlength(fmt, va);
  va_end(va);
  {
    char buf[length];
    va_start(va, fmt);
    length = ts_formatstring(buf, fmt, va);
    length = _write(1, buf, length);
    va_end(va);
  }
  return length;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<printf>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%r12
  mov    %fs:0x28,%rax
  mov    %rax,-0x28(%rbp)
  xor    %eax,%eax
  mov    %rdi,%rsi
  mov    $0x0,%r13d
  mov    %r13d,%edi
  call   <va_start@plt>
  mov    %r13d,%esi
  mov    %r12,%rdi
  call   <ts_formatlength@plt>
  mov    %eax,%ebx
  mov    %r13d,%edi
  call   <va_end@plt>
  movslq %ebx,%rax
  add    $0xf,%rax
  mov    %rax,%rcx
  and    $0xfffffffffffffff0,%rcx
  and    $0xfffffffffffff000,%rax
  mov    %rsp,%rdx
  sub    %rax,%rdx
L10:
  cmp    %rdx,%rsp
  je     L25
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L10
L25:
  mov    %rcx,%rax
  and    $0xfff,%eax
  sub    %rax,%rsp
  test   %rax,%rax
  je     L12
  orq    $0x0,-0x8(%rsp,%rax,1)
L12:
  mov    %r12,%rsi
  mov    $0x0,%r13d
  mov    %r13d,%edi
  call   <va_start@plt>
  mov    %r13d,%edx
  mov    %r12,%rsi
  mov    %rsp,%rdi
  call   <ts_formatstring@plt>
  mov    %eax,%edx
  mov    %rsp,%rsi
  mov    $0x1,%edi
  call   <_write@plt>
  mov    %eax,%ebx
  mov    %r13d,%edi
  call   <va_end@plt>
  mov    -0x28(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L39
  mov    %ebx,%eax
  lea    -0x18(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %rbp
  ret
L39:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int printf(const char *fmt, ...) {
  int length = 0;
  va_list va;
  va_start(va, fmt);
  length = ts_formatlength(fmt, va);
  va_end(va);
  {
    char buf[length];
    va_start(va, fmt);
    length = ts_formatstring(buf, fmt, va);
    length = _write(1, buf, length);
    va_end(va);
  }
  return length;
}
```
user: Translate the below assembly code into C programming language:

```asm
<printf>:
  endbr64
  push   %rbp
  mov    %rdi,%rsi
  mov    %rsp,%rbp
  push   %r13
  xor    %r13d,%r13d
  push   %r12
  mov    %rdi,%r12
  mov    %r13d,%edi
  push   %rbx
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x28(%rbp)
  xor    %eax,%eax
  call   <va_start@plt>
  mov    %r13d,%esi
  mov    %r12,%rdi
  call   <ts_formatlength@plt>
  mov    %r13d,%edi
  mov    %eax,%ebx
  call   <va_end@plt>
  movslq %ebx,%rax
  mov    %rsp,%rcx
  add    $0xf,%rax
  mov    %rax,%rdx
  and    $0xfffffffffffff000,%rax
  sub    %rax,%rcx
  and    $0xfffffffffffffff0,%rdx
  cmp    %rcx,%rsp
  je     L13
L19:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rcx,%rsp
  jne    L19
L13:
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  jne    L1
L15:
  xor    %r13d,%r13d
  mov    %r12,%rsi
  mov    %r13d,%edi
  call   <va_start@plt>
  mov    %r12,%rsi
  mov    %r13d,%edx
  mov    %rsp,%rdi
  call   <ts_formatstring@plt>
  mov    $0x1,%edi
  mov    %rsp,%rsi
  mov    %eax,%edx
  call   <_write@plt>
  mov    %r13d,%edi
  mov    %eax,%r12d
  call   <va_end@plt>
  mov    -0x28(%rbp),%rax
  sub    %fs:0x28,%rax
  jne    L5
  lea    -0x18(%rbp),%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %rbp
  ret
  nopl   0x0(%rax,%rax,1)
L1:
  orq    $0x0,-0x8(%rsp,%rdx,1)
  jmp    L15
L5:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int printf(const char *fmt, ...) {
  int length = 0;
  va_list va;
  va_start(va, fmt);
  length = ts_formatlength(fmt, va);
  va_end(va);
  {
    char buf[length];
    va_start(va, fmt);
    length = ts_formatstring(buf, fmt, va);
    length = _write(1, buf, length);
    va_end(va);
  }
  return length;
}
```