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

```asm
<by_file_ctrl>:
  endbr64
  xor    %eax,%eax
  cmp    $0x80,%esi
  je     L58
  ret
  nop
L58:
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  sub    $0x8,%rsp
  mov    D19(%rip),%rax
  cmp    %rcx,(%rax)
  je     L74
  mov    D33(%rip),%rax
  mov    %rdx,%rsi
  cmp    %rcx,(%rax)
  je     L98
  mov    %ecx,%edx
  call   <X509_load_cert_file@plt>
  test   %eax,%eax
  setne  %al
  movzbl %al,%eax
L77:
  add    $0x8,%rsp
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax)
L98:
  mov    %rcx,%rdx
  call   <X509_load_cert_crl_file@plt>
  test   %eax,%eax
  setne  %al
  movzbl %al,%eax
  jmp    L77
  nopw   0x0(%rax,%rax,1)
L74:
  xor    %eax,%eax
  call   <issetugid@plt>
  test   %eax,%eax
  jne    L88
  call   <X509_get_default_cert_file_env@plt>
  mov    %eax,%edi
  call   <getenv@plt>
  mov    %rax,%rsi
  test   %rax,%rax
  je     L88
  mov    D33(%rip),%rax
  mov    %rbp,%rdi
  mov    (%rax),%rdx
  call   <X509_load_cert_crl_file@plt>
  test   %eax,%eax
  je     L82
L55:
  mov    $0x1,%eax
  jmp    L77
  nopl   0x0(%rax)
L88:
  mov    D33(%rip),%rax
  mov    (%rax),%r12
  xor    %eax,%eax
  call   <X509_get_default_cert_file@plt>
  mov    %rbp,%rdi
  mov    %rax,%rsi
  mov    %r12,%rdx
  call   <X509_load_cert_crl_file@plt>
  test   %eax,%eax
  jne    L55
L82:
  mov    D39(%rip),%rax
  mov    (%rax),%esi
  mov    D38(%rip),%rax
  mov    (%rax),%edi
  call   <X509err@plt>
  xor    %eax,%eax
  jmp    L77
```

assistant: ```c
int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl, char **ret) {
  int ok = 0;
  char *file = NULL;
  switch (cmd) {
  case X509_L_FILE_LOAD:
    if (argl == X509_FILETYPE_DEFAULT) {
      if (issetugid() == 0)
        file = getenv(X509_get_default_cert_file_env());
      if (file)
        ok = (X509_load_cert_crl_file(ctx, file, X509_FILETYPE_PEM) != 0);
      else
        ok = (X509_load_cert_crl_file(ctx, X509_get_default_cert_file(), X509_FILETYPE_PEM) != 0);
      if (!ok) {
        X509err(X509_F_BY_FILE_CTRL, X509_R_LOADING_DEFAULTS);
      }
    } else {
      if (argl == X509_FILETYPE_PEM)
        ok = (X509_load_cert_crl_file(ctx, argp, X509_FILETYPE_PEM) != 0);
      else
        ok = (X509_load_cert_file(ctx, argp, (int)argl) != 0);
    }
    break;
  }
  return (ok);
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<by_file_ctrl>:
  endbr64
  xor    %eax,%eax
  cmp    $0x80,%esi
  je     L42
  ret
  nop
L42:
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  sub    $0x8,%rsp
  mov    D23(%rip),%rax
  cmp    %rcx,(%rax)
  je     L20
  mov    D12(%rip),%rax
  mov    %rdx,%rsi
  cmp    %rcx,(%rax)
  je     L19
  mov    %ecx,%edx
  call   <X509_load_cert_file@plt>
  test   %eax,%eax
  setne  %al
  movzbl %al,%eax
L76:
  add    $0x8,%rsp
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax)
L19:
  mov    %rcx,%rdx
  call   <X509_load_cert_crl_file@plt>
  test   %eax,%eax
  setne  %al
  movzbl %al,%eax
  jmp    L76
  nopw   0x0(%rax,%rax,1)
L20:
  xor    %eax,%eax
  call   <issetugid@plt>
  test   %eax,%eax
  jne    L62
  call   <X509_get_default_cert_file_env@plt>
  mov    %eax,%edi
  call   <getenv@plt>
  mov    %rax,%rsi
  test   %rax,%rax
  je     L62
  mov    D12(%rip),%rax
  mov    %rbp,%rdi
  mov    (%rax),%rdx
  call   <X509_load_cert_crl_file@plt>
  test   %eax,%eax
  je     L30
L46:
  mov    $0x1,%eax
  jmp    L76
  nopl   0x0(%rax)
L62:
  mov    D12(%rip),%rax
  mov    (%rax),%r12
  xor    %eax,%eax
  call   <X509_get_default_cert_file@plt>
  mov    %rbp,%rdi
  mov    %rax,%rsi
  mov    %r12,%rdx
  call   <X509_load_cert_crl_file@plt>
  test   %eax,%eax
  jne    L46
L30:
  mov    D47(%rip),%rax
  mov    (%rax),%esi
  mov    D37(%rip),%rax
  mov    (%rax),%edi
  call   <X509err@plt>
  xor    %eax,%eax
  jmp    L76
```

assistant: ```c
int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl, char **ret) {
  int ok = 0;
  char *file = NULL;
  switch (cmd) {
  case X509_L_FILE_LOAD:
    if (argl == X509_FILETYPE_DEFAULT) {
      if (issetugid() == 0)
        file = getenv(X509_get_default_cert_file_env());
      if (file)
        ok = (X509_load_cert_crl_file(ctx, file, X509_FILETYPE_PEM) != 0);
      else
        ok = (X509_load_cert_crl_file(ctx, X509_get_default_cert_file(), X509_FILETYPE_PEM) != 0);
      if (!ok) {
        X509err(X509_F_BY_FILE_CTRL, X509_R_LOADING_DEFAULTS);
      }
    } else {
      if (argl == X509_FILETYPE_PEM)
        ok = (X509_load_cert_crl_file(ctx, argp, X509_FILETYPE_PEM) != 0);
      else
        ok = (X509_load_cert_file(ctx, argp, (int)argl) != 0);
    }
    break;
  }
  return (ok);
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<getCCCount>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x68,%rsp
  mov    %rdi,0x8(%rsp)
  mov    %rsi,0x18(%rsp)
  mov    %rdx,0x50(%rsp)
  mov    %rcx,0x58(%rsp)
  mov    %r8d,%ecx
  movsd  %xmm0,0x28(%rsp)
  mov    %r9d,%edx
  mov    %r9d,0x14(%rsp)
  mov    0xa0(%rsp),%r15
  mov    0xa8(%rsp),%r13
  imul   %r8d,%edx
  test   %edx,%edx
  jle    L76
  mov    %edx,%edx
  mov    $0x0,%eax
L29:
  movl   $0x0,(%r15,%rax,4)
  movl   $0x0,0x0(%r13,%rax,4)
  add    $0x1,%rax
  cmp    %rdx,%rax
  jne    L29
L76:
  test   %ecx,%ecx
  jle    L25
  mov    %ecx,%eax
  mov    %rax,0x48(%rsp)
  lea    -0x1(%rcx),%eax
  mov    0x8(%rsp),%rdi
  lea    0x8(%rdi,%rax,8),%rax
  mov    %rax,0x20(%rsp)
  movl   $0x0,0x44(%rsp)
  mov    $0x0,%r14d
  mov    0x14(%rsp),%eax
  sub    $0x1,%eax
  mov    %eax,0x40(%rsp)
L81:
  mov    0x18(%rsp),%rax
  mov    %rax,(%rsp)
  mov    0x50(%rsp),%rbp
  mov    0x58(%rsp),%rbx
  mov    0x8(%rsp),%r12
  movslq 0x44(%rsp),%rax
  mov    %rax,0x30(%rsp)
  add    $0x1,%rax
  mov    %rax,0x38(%rsp)
L70:
  mov    0x8(%rsp),%rax
  movsd  (%rax,%r14,8),%xmm0
  subsd  (%r12),%xmm0
  mov    0x18(%rsp),%rax
  movsd  (%rax,%r14,8),%xmm1
  mov    (%rsp),%rax
  subsd  (%rax),%xmm1
  mulsd  %xmm0,%xmm0
  mulsd  %xmm1,%xmm1
  addsd  %xmm1,%xmm0
  pxor   %xmm2,%xmm2
  ucomisd %xmm0,%xmm2
  ja     L72
  sqrtsd %xmm0,%xmm0
L16:
  divsd  0x28(%rsp),%xmm0
  call   <ceil@plt>
  test   %eax,%eax
  setg   %dl
  movzbl %dl,%edx
  sub    %edx,%eax
  cmp    %eax,0x14(%rsp)
  jle    L74
  movslq %eax,%rsi
  mov    0x30(%rsp),%rdi
  lea    (%rdi,%rsi,1),%rdx
  shl    $0x2,%rdx
  mov    0x40(%rsp),%ecx
  sub    %eax,%ecx
  add    0x38(%rsp),%rsi
  add    %rsi,%rcx
  shl    $0x2,%rcx
L54:
  mov    0x0(%rbp),%eax
  add    %eax,(%r15,%rdx,1)
  mov    (%rbx),%eax
  add    %eax,0x0(%r13,%rdx,1)
  add    $0x4,%rdx
  cmp    %rcx,%rdx
  jne    L54
L74:
  add    $0x8,%r12
  addq   $0x8,(%rsp)
  add    $0x4,%rbp
  add    $0x4,%rbx
  cmp    0x20(%rsp),%r12
  jne    L70
  add    $0x1,%r14
  mov    0x14(%rsp),%edi
  add    %edi,0x44(%rsp)
  cmp    0x48(%rsp),%r14
  jne    L81
L25:
  add    $0x68,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L72:
  call   <sqrt@plt>
  jmp    L16
```

assistant: ```c
void getCCCount(double *x, double *y, int *nCass, int *nCons, int locCount, double wSize, int wCount, int *casInW, int *conInW) {
  double distance;
  int minWindow;
  for (int i = 0; i < locCount * wCount; i++) {
    casInW[i] = 0;
    conInW[i] = 0;
  }
#pragma omp parallel for private(distance, minWindow)
  for (int i = 0; i < locCount; i++) {
    for (int j = 0; j < locCount; j++) {
      distance = sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]));
      minWindow = (int)(ceil(distance / wSize));
      if (minWindow > 0)
        minWindow--;
      for (int k = minWindow; k < wCount; k++) {
        casInW[i * wCount + k] += nCass[j];
        conInW[i * wCount + k] += nCons[j];
      }
    }
  }
  return;
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<putGame>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %edi,-0x4(%rbp)
  mov    $0x47,%edi
  call   <putchar@plt>
  mov    $0x61,%edi
  call   <putchar@plt>
  mov    $0x6d,%edi
  call   <putchar@plt>
  mov    $0x65,%edi
  call   <putchar@plt>
  mov    $0x20,%edi
  call   <putchar@plt>
  mov    -0x4(%rbp),%eax
  mov    %eax,%edi
  call   <putint@plt>
  mov    $0x3a,%edi
  call   <putchar@plt>
  mov    $0x20,%edi
  call   <putchar@plt>
  mov    $0x0,%eax
  leave
  ret
```

assistant: ```c
int putGame(int T) {
  putchar(71);
  putchar(97);
  putchar(109);
  putchar(101);
  putchar(32);
  putint(T);
  putchar(58);
  putchar(32);
  return 0;
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<putGame>:
  endbr64
  push   %rbx
  mov    %edi,%ebx
  mov    $0x47,%edi
  call   <putchar@plt>
  mov    $0x61,%edi
  call   <putchar@plt>
  mov    $0x6d,%edi
  call   <putchar@plt>
  mov    $0x65,%edi
  call   <putchar@plt>
  mov    $0x20,%edi
  call   <putchar@plt>
  mov    %ebx,%edi
  call   <putint@plt>
  mov    $0x3a,%edi
  call   <putchar@plt>
  mov    $0x20,%edi
  call   <putchar@plt>
  mov    $0x0,%eax
  pop    %rbx
  ret
```

assistant: ```c
int putGame(int T) {
  putchar(71);
  putchar(97);
  putchar(109);
  putchar(101);
  putchar(32);
  putint(T);
  putchar(58);
  putchar(32);
  return 0;
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<putGame>:
  endbr64
  push   %rbp
  mov    %edi,%ebp
  mov    $0x47,%edi
  call   <putchar@plt>
  mov    $0x61,%edi
  call   <putchar@plt>
  mov    $0x6d,%edi
  call   <putchar@plt>
  mov    $0x65,%edi
  call   <putchar@plt>
  mov    $0x20,%edi
  call   <putchar@plt>
  mov    %ebp,%edi
  call   <putint@plt>
  mov    $0x3a,%edi
  call   <putchar@plt>
  mov    $0x20,%edi
  call   <putchar@plt>
  xor    %eax,%eax
  pop    %rbp
  ret
```

assistant: ```c
int putGame(int T) {
  putchar(71);
  putchar(97);
  putchar(109);
  putchar(101);
  putchar(32);
  putint(T);
  putchar(58);
  putchar(32);
  return 0;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<putGame>:
  endbr64
  push   %rbp
  mov    %edi,%ebp
  mov    $0x47,%edi
  call   <putchar@plt>
  mov    $0x61,%edi
  call   <putchar@plt>
  mov    $0x6d,%edi
  call   <putchar@plt>
  mov    $0x65,%edi
  call   <putchar@plt>
  mov    $0x20,%edi
  call   <putchar@plt>
  mov    %ebp,%edi
  call   <putint@plt>
  mov    $0x3a,%edi
  call   <putchar@plt>
  mov    $0x20,%edi
  call   <putchar@plt>
  xor    %eax,%eax
  pop    %rbp
  ret
```

assistant: ```c
int putGame(int T) {
  putchar(71);
  putchar(97);
  putchar(109);
  putchar(101);
  putchar(32);
  putint(T);
  putchar(58);
  putchar(32);
  return 0;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<printmessage_1_svc>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %rdi,-0x8(%rbp)
  mov    %rsi,-0x10(%rbp)
  mov    -0x8(%rbp),%rax
  mov    %rax,%rsi
  lea    D3(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  lea    D0(%rip),%rax
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: data_tag: D3
datatype: string

tool: D3: %s


assistant: ```c
int *printmessage_1_svc(char *arg1, struct svc_req *rqstp) {
  static int result = 73;
  printf("%s\n", arg1);
  return &result;
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<printmessage_1_svc>:
  endbr64
  sub    $0x8,%rsp
  mov    %rdi,%rsi
  lea    D11(%rip),%rdi
  call   <printf@plt>
  lea    D17(%rip),%rax
  add    $0x8,%rsp
  ret
```

tool_calls: name: extract_symbolic_data
arguments: tag: D11
datatype: string

tool: D11: %s


assistant: ```c
int *printmessage_1_svc(char *arg1, struct svc_req *rqstp) {
  static int result = 73;
  printf("%s\n", arg1);
  return &result;
}
```
user: Translate the below assembly code into C programming language:

```asm
<printmessage_1_svc>:
  endbr64
  sub    $0x8,%rsp
  mov    %rdi,%rsi
  lea    D3(%rip),%rdi
  call   <printf@plt>
  lea    D15(%rip),%rax
  add    $0x8,%rsp
  ret
```

tool_calls: name: read_data
arguments: label: D3
type_guessed: string

tool: D3: %s


assistant: ```c
int *printmessage_1_svc(char *arg1, struct svc_req *rqstp) {
  static int result = 73;
  printf("%s\n", arg1);
  return &result;
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<printmessage_1_svc>:
  endbr64
  sub    $0x8,%rsp
  mov    %rdi,%rsi
  lea    D7(%rip),%rdi
  call   <printf@plt>
  lea    D13(%rip),%rax
  add    $0x8,%rsp
  ret
```

tool_calls: name: retrieve_data
arguments: data_tag: D7
type_infered: string

tool: D7: %s


assistant: ```c
int *printmessage_1_svc(char *arg1, struct svc_req *rqstp) {
  static int result = 73;
  printf("%s\n", arg1);
  return &result;
}
```
user: Translate the below assembly code into C programming language:

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  lea    D3(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    $0x0,%eax
  pop    %rbp
  ret
```

tool_calls: name: read_data
arguments: label: D3
type: string

tool: D3: Programming is fun!


assistant: ```c
int main(void) {
  printf("Programming is fun!\n");
  return 0;
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<main>:
  endbr64
  sub    $0x8,%rsp
  lea    D3(%rip),%rdi
  call   <printf@plt>
  mov    $0x0,%eax
  add    $0x8,%rsp
  ret
```

tool_calls: name: extract_symbolic_data
arguments: data_label: D3
type: string

tool: D3: Programming is fun!


assistant: ```c
int main(void) {
  printf("Programming is fun!\n");
  return 0;
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<main>:
  endbr64
  sub    $0x8,%rsp
  lea    D7(%rip),%rdi
  call   <printf@plt>
  xor    %eax,%eax
  add    $0x8,%rsp
  ret
```

tool_calls: name: parse_data
arguments: data_label: D7
data_type: string

tool: D7: Programming is fun!


assistant: ```c
int main(void) {
  printf("Programming is fun!\n");
  return 0;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<main>:
  endbr64
  sub    $0x8,%rsp
  lea    D6(%rip),%rdi
  call   <printf@plt>
  xor    %eax,%eax
  add    $0x8,%rsp
  ret
```

tool_calls: name: disassemble_data
arguments: label: D6
type: string

tool: D6: Programming is fun!


assistant: ```c
int main(void) {
  printf("Programming is fun!\n");
  return 0;
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<write_str>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %rdx,-0x28(%rbp)
  mov    -0x18(%rbp),%rax
  cmp    -0x20(%rbp),%rax
  setbe  %al
  movzbl %al,%eax
  mov    %eax,%edi
  call   <assert@plt>
  mov    -0x18(%rbp),%rax
  cmp    -0x20(%rbp),%rax
  jne    L15
  mov    -0x20(%rbp),%rax
  jmp    L30
L15:
  cmpq   $0x0,-0x28(%rbp)
  je     L10
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L47
L10:
  mov    -0x18(%rbp),%rax
  movb   $0x0,(%rax)
  mov    -0x18(%rbp),%rax
  add    $0x1,%rax
  jmp    L30
L47:
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  add    $0x1,%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x20(%rbp),%rax
  sub    -0x18(%rbp),%rax
  mov    %eax,%edx
  mov    -0x4(%rbp),%eax
  cmp    %edx,%eax
  cmova  %edx,%eax
  mov    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%edx
  mov    -0x28(%rbp),%rcx
  mov    -0x18(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  mov    -0x4(%rbp),%eax
  sub    $0x1,%eax
  mov    %eax,%edx
  mov    -0x18(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <rfind_utf8_leading_byte_index@plt>
  mov    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%edx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
  mov    -0x4(%rbp),%eax
  lea    0x1(%rax),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
L30:
  leave
  ret
```

assistant: ```c
char *write_str(char *buf, const char *buf_end, const char *str) {
  assert(buf <= buf_end);
  if (buf == buf_end)
    return (char *)buf_end;
  if (str == NULL || *str == '\0') {
    buf[0] = '\0';
    return buf + 1;
  } else {
    unsigned int n = strlen(str) + 1;
    n = ((n) < ((unsigned int)(buf_end - buf)) ? (n) : ((unsigned int)(buf_end - buf)));
    memcpy(buf, str, n);
    n = (unsigned int)rfind_utf8_leading_byte_index(buf, (int)(n - 1));
    buf[n] = '\0';
    return buf + n + 1;
  }
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<write_str>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbp
  mov    %rsi,%rbx
  mov    %rdx,%r12
  cmp    %rsi,%rdi
  setbe  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  cmp    %rbx,%rbp
  je     L39
  test   %r12,%r12
  je     L34
  cmpb   $0x0,(%r12)
  jne    L11
L34:
  movb   $0x0,0x0(%rbp)
  lea    0x1(%rbp),%rax
L1:
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L11:
  mov    %r12,%rdi
  call   <strlen@plt>
  lea    0x1(%rax),%esi
  sub    %rbp,%rbx
  cmp    %ebx,%esi
  cmovbe %esi,%ebx
  mov    %ebx,%edx
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <memcpy@plt>
  lea    -0x1(%rbx),%esi
  mov    %rbp,%rdi
  call   <rfind_utf8_leading_byte_index@plt>
  mov    %eax,%eax
  movb   $0x0,0x0(%rbp,%rax,1)
  lea    0x1(%rbp,%rax,1),%rax
  jmp    L1
L39:
  mov    %rbx,%rax
  jmp    L1
```

assistant: ```c
char *write_str(char *buf, const char *buf_end, const char *str) {
  assert(buf <= buf_end);
  if (buf == buf_end)
    return (char *)buf_end;
  if (str == NULL || *str == '\0') {
    buf[0] = '\0';
    return buf + 1;
  } else {
    unsigned int n = strlen(str) + 1;
    n = ((n) < ((unsigned int)(buf_end - buf)) ? (n) : ((unsigned int)(buf_end - buf)));
    memcpy(buf, str, n);
    n = (unsigned int)rfind_utf8_leading_byte_index(buf, (int)(n - 1));
    buf[n] = '\0';
    return buf + n + 1;
  }
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<write_str>:
  endbr64
  push   %r12
  cmp    %rsi,%rdi
  mov    %rdx,%r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  mov    %rdi,%rbx
  setbe  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  cmp    %rbp,%rbx
  je     L0
  test   %r12,%r12
  je     L24
  cmpb   $0x0,(%r12)
  jne    L19
L24:
  lea    0x1(%rbx),%rax
  movb   $0x0,(%rbx)
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  xchg   %ax,%ax
L19:
  mov    %r12,%rdi
  sub    %rbx,%rbp
  call   <strlen@plt>
  mov    %r12,%rsi
  mov    %rbx,%rdi
  add    $0x1,%eax
  cmp    %ebp,%eax
  cmovbe %eax,%ebp
  mov    %ebp,%edx
  call   <memcpy@plt>
  lea    -0x1(%rbp),%esi
  mov    %rbx,%rdi
  call   <rfind_utf8_leading_byte_index@plt>
  mov    %eax,%eax
  movb   $0x0,(%rbx,%rax,1)
  lea    0x1(%rbx,%rax,1),%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax,%rax,1)
L0:
  mov    %rbx,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
char *write_str(char *buf, const char *buf_end, const char *str) {
  assert(buf <= buf_end);
  if (buf == buf_end)
    return (char *)buf_end;
  if (str == NULL || *str == '\0') {
    buf[0] = '\0';
    return buf + 1;
  } else {
    unsigned int n = strlen(str) + 1;
    n = ((n) < ((unsigned int)(buf_end - buf)) ? (n) : ((unsigned int)(buf_end - buf)));
    memcpy(buf, str, n);
    n = (unsigned int)rfind_utf8_leading_byte_index(buf, (int)(n - 1));
    buf[n] = '\0';
    return buf + n + 1;
  }
}
```
user: 这段汇编代码用C语言表示是什么样的?

```asm
<write_str>:
  endbr64
  push   %r12
  cmp    %rsi,%rdi
  mov    %rdx,%r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  mov    %rdi,%rbx
  setbe  %dil
  movzbl %dil,%edi
  call   <assert@plt>
  cmp    %rbp,%rbx
  je     L27
  test   %r12,%r12
  je     L16
  cmpb   $0x0,(%r12)
  jne    L29
L16:
  lea    0x1(%rbx),%rax
  movb   $0x0,(%rbx)
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  xchg   %ax,%ax
L29:
  mov    %r12,%rdi
  sub    %rbx,%rbp
  call   <strlen@plt>
  mov    %r12,%rsi
  mov    %rbx,%rdi
  add    $0x1,%eax
  cmp    %ebp,%eax
  cmovbe %eax,%ebp
  mov    %ebp,%edx
  call   <memcpy@plt>
  lea    -0x1(%rbp),%esi
  mov    %rbx,%rdi
  call   <rfind_utf8_leading_byte_index@plt>
  mov    %eax,%eax
  movb   $0x0,(%rbx,%rax,1)
  lea    0x1(%rbx,%rax,1),%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax,%rax,1)
L27:
  mov    %rbx,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
char *write_str(char *buf, const char *buf_end, const char *str) {
  assert(buf <= buf_end);
  if (buf == buf_end)
    return (char *)buf_end;
  if (str == NULL || *str == '\0') {
    buf[0] = '\0';
    return buf + 1;
  } else {
    unsigned int n = strlen(str) + 1;
    n = ((n) < ((unsigned int)(buf_end - buf)) ? (n) : ((unsigned int)(buf_end - buf)));
    memcpy(buf, str, n);
    n = (unsigned int)rfind_utf8_leading_byte_index(buf, (int)(n - 1));
    buf[n] = '\0';
    return buf + n + 1;
  }
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<console_fontbank>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %edi,-0x24(%rbp)
  mov    %esi,-0x28(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movabs $0x3d3c3b3a39383736,%rax
  mov    %rax,-0x13(%rbp)
  movw   $0x3f3e,-0xb(%rbp)
  movb   $0x40,-0x9(%rbp)
  mov    $0x1b,%edi
  call   <putchar@plt>
  mov    $0x6a,%edi
  call   <putchar@plt>
  mov    $0x1b,%edi
  call   <putchar@plt>
  mov    $0x59,%edi
  call   <putchar@plt>
  mov    -0x24(%rbp),%eax
  add    $0x20,%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <putchar@plt>
  mov    $0x20,%edi
  call   <putchar@plt>
  mov    $0x1b,%edi
  call   <putchar@plt>
  mov    $0x5f,%edi
  call   <putchar@plt>
  cmpl   $0x0,-0x28(%rbp)
  jns    L3
  movl   $0x0,-0x28(%rbp)
L3:
  cmpl   $0xa,-0x28(%rbp)
  jle    L5
  movl   $0xa,-0x28(%rbp)
L5:
  mov    -0x28(%rbp),%eax
  cltq
  movzbl -0x13(%rbp,%rax,1),%eax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <putchar@plt>
  mov    $0x1b,%edi
  call   <putchar@plt>
  mov    $0x6b,%edi
  call   <putchar@plt>
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L20
  call   <__stack_chk_fail@plt>
L20:
  leave
  ret
```

assistant: ```c
void console_fontbank(int row, int bank) {
  char banks[] = {'6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@'};
  putchar(0x1b);
  putchar('j');
  putchar(0x1b);
  putchar('Y');
  putchar(' ' + row);
  putchar(' ' + 0);
  putchar(0x1b);
  putchar('_');
  if (bank < 0)
    bank = 0;
  if (bank > 10)
    bank = 10;
  putchar(banks[bank]);
  putchar(0x1b);
  putchar('k');
}
```
user: What is the c source code of the assembly code below:

```asm
<console_fontbank>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %edi,%ebp
  mov    %esi,%ebx
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  movabs $0x3d3c3b3a39383736,%rax
  mov    %rax,0xd(%rsp)
  movw   $0x3f3e,0x15(%rsp)
  movb   $0x40,0x17(%rsp)
  mov    $0x1b,%edi
  call   <putchar@plt>
  mov    $0x6a,%edi
  call   <putchar@plt>
  mov    $0x1b,%edi
  call   <putchar@plt>
  mov    $0x59,%edi
  call   <putchar@plt>
  lea    0x20(%rbp),%edi
  movsbl %dil,%edi
  call   <putchar@plt>
  mov    $0x20,%edi
  call   <putchar@plt>
  mov    $0x1b,%edi
  call   <putchar@plt>
  mov    $0x5f,%edi
  call   <putchar@plt>
  mov    $0xa,%eax
  cmp    %eax,%ebx
  cmovle %ebx,%eax
  mov    %eax,%esi
  test   %eax,%eax
  mov    $0x0,%eax
  cmovs  %eax,%esi
  movslq %esi,%rsi
  movsbl 0xd(%rsp,%rsi,1),%edi
  call   <putchar@plt>
  mov    $0x1b,%edi
  call   <putchar@plt>
  mov    $0x6b,%edi
  call   <putchar@plt>
  mov    0x18(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L5
  add    $0x28,%rsp
  pop    %rbx
  pop    %rbp
  ret
L5:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
void console_fontbank(int row, int bank) {
  char banks[] = {'6', '7', '8', '9', ':', ';', '<', '=', '>', '?', '@'};
  putchar(0x1b);
  putchar('j');
  putchar(0x1b);
  putchar('Y');
  putchar(' ' + row);
  putchar(' ' + 0);
  putchar(0x1b);
  putchar('_');
  if (bank < 0)
    bank = 0;
  if (bank > 10)
    bank = 10;
  putchar(banks[bank]);
  putchar(0x1b);
  putchar('k');
}
```