ylfeng/ReF-Decompile-dataset huggingface dataset:
user: 下面的汇编指令对应的C源代码是什么:

```asm
<chaz_ConfWriterPerl_quotify>:
  endbr64
  test   %rdi,%rdi
  je     L63
  push   %rbx
  movzbl (%rdi),%ecx
  mov    %rdi,%rbx
  mov    %rsi,%rax
  test   %cl,%cl
  je     L2
  mov    $0x3,%r8d
  jmp    L89
  nopw   0x0(%rax,%rax,1)
L97:
  movzbl 0x1(%rdi),%ecx
  add    $0x1,%rdi
  add    $0x1,%r8
  test   %cl,%cl
  je     L121
L89:
  cmp    $0x27,%cl
  je     L145
  cmp    $0x5c,%cl
  jne    L97
L145:
  movzbl 0x1(%rdi),%ecx
  add    $0x1,%rdi
  add    $0x2,%r8
  test   %cl,%cl
  jne    L89
L121:
  cmp    %r8,%rdx
  jb     L83
  movb   $0x27,(%rax)
  movzbl (%rbx),%edx
  test   %dl,%dl
  je     L132
L78:
  mov    $0x1,%edi
  jmp    L25
L31:
  movzbl (%rbx),%edx
  add    $0x1,%rbx
  lea    0x1(%rcx),%rdi
  mov    %dl,(%rax,%rcx,1)
  movzbl (%rbx),%edx
  test   %dl,%dl
  je     L155
L25:
  cmp    $0x27,%dl
  je     L66
  mov    %rdi,%rcx
  cmp    $0x5c,%dl
  jne    L31
L66:
  movb   $0x5c,(%rax,%rdi,1)
  lea    0x1(%rdi),%rcx
  jmp    L31
  nopl   0x0(%rax)
L155:
  add    $0x2,%rcx
  movb   $0x27,(%rax,%rdi,1)
  movb   $0x0,(%rax,%rcx,1)
  pop    %rbx
  ret
  xchg   %ax,%ax
L83:
  mov    %r8,%rdi
  call   <malloc@plt>
  movb   $0x27,(%rax)
  movzbl (%rbx),%edx
  test   %dl,%dl
  jne    L78
L132:
  mov    $0x2,%ecx
  mov    $0x1,%edi
  movb   $0x27,(%rax,%rdi,1)
  movb   $0x0,(%rax,%rcx,1)
  pop    %rbx
  ret
  cs nopw 0x0(%rax,%rax,1)
L2:
  mov    $0x3,%r8d
  jmp    L121
L63:
  xor    %eax,%eax
  ret
```

assistant: ```c
char *chaz_ConfWriterPerl_quotify(const char *string, char *buf, size_t buf_size) {
  char *quoted = buf;
  if (!string) {
    return NULL;
  }
  {
    const char *ptr;
    size_t space = 3;
    for (ptr = string; *ptr; ptr++) {
      if (*ptr == '\'' || *ptr == '\\') {
        space += 2;
      } else {
        space += 1;
      }
    }
    if (space > buf_size) {
      quoted = (char *)malloc(space);
    }
  }
  {
    const char *ptr;
    size_t pos = 0;
    quoted[pos++] = '\'';
    for (ptr = string; *ptr; ptr++) {
      if (*ptr == '\'' || *ptr == '\\') {
        quoted[pos++] = '\\';
      }
      quoted[pos++] = *ptr;
    }
    quoted[pos++] = '\'';
    quoted[pos++] = '\0';
  }
  return quoted;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<chaz_ConfWriterPerl_quotify>:
  endbr64
  test   %rdi,%rdi
  je     L111
  push   %rbx
  movzbl (%rdi),%ecx
  mov    %rdi,%rbx
  mov    %rsi,%rax
  test   %cl,%cl
  je     L27
  mov    $0x3,%r8d
  jmp    L72
  nopw   0x0(%rax,%rax,1)
L52:
  movzbl 0x1(%rdi),%ecx
  add    $0x1,%rdi
  add    $0x1,%r8
  test   %cl,%cl
  je     L45
L72:
  cmp    $0x5c,%cl
  je     L40
  cmp    $0x27,%cl
  jne    L52
L40:
  movzbl 0x1(%rdi),%ecx
  add    $0x1,%rdi
  add    $0x2,%r8
  test   %cl,%cl
  jne    L72
L45:
  cmp    %r8,%rdx
  jb     L17
  movb   $0x27,(%rax)
  movzbl (%rbx),%edx
  test   %dl,%dl
  je     L148
L126:
  mov    $0x1,%ecx
  xchg   %ax,%ax
L10:
  cmp    $0x27,%dl
  je     L43
  cmp    $0x5c,%dl
  je     L43
  add    $0x1,%rbx
  mov    %dl,(%rax,%rcx,1)
  lea    0x1(%rcx),%rsi
  movzbl (%rbx),%edx
  mov    %rsi,%rcx
  test   %dl,%dl
  jne    L10
L42:
  lea    0x1(%rcx),%rdx
  movb   $0x27,(%rax,%rcx,1)
  movb   $0x0,(%rax,%rdx,1)
  pop    %rbx
  ret
  nopl   (%rax)
L43:
  movb   $0x5c,(%rax,%rcx,1)
  movzbl (%rbx),%esi
  lea    0x1(%rcx),%rdx
  add    $0x1,%rbx
  add    $0x2,%rcx
  mov    %sil,(%rax,%rdx,1)
  movzbl (%rbx),%edx
  test   %dl,%dl
  jne    L10
  jmp    L42
L17:
  mov    %r8,%rdi
  call   <malloc@plt>
  movb   $0x27,(%rax)
  movzbl (%rbx),%edx
  test   %dl,%dl
  jne    L126
L148:
  mov    $0x2,%edx
  mov    $0x1,%ecx
  movb   $0x27,(%rax,%rcx,1)
  movb   $0x0,(%rax,%rdx,1)
  pop    %rbx
  ret
  cs nopw 0x0(%rax,%rax,1)
L27:
  mov    $0x3,%r8d
  jmp    L45
L111:
  xor    %eax,%eax
  ret
```

assistant: ```c
char *chaz_ConfWriterPerl_quotify(const char *string, char *buf, size_t buf_size) {
  char *quoted = buf;
  if (!string) {
    return NULL;
  }
  {
    const char *ptr;
    size_t space = 3;
    for (ptr = string; *ptr; ptr++) {
      if (*ptr == '\'' || *ptr == '\\') {
        space += 2;
      } else {
        space += 1;
      }
    }
    if (space > buf_size) {
      quoted = (char *)malloc(space);
    }
  }
  {
    const char *ptr;
    size_t pos = 0;
    quoted[pos++] = '\'';
    for (ptr = string; *ptr; ptr++) {
      if (*ptr == '\'' || *ptr == '\\') {
        quoted[pos++] = '\\';
      }
      quoted[pos++] = *ptr;
    }
    quoted[pos++] = '\'';
    quoted[pos++] = '\0';
  }
  return quoted;
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<addbit>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,-0x4(%rbp)
  mov    %rsi,-0x10(%rbp)
  mov    %edx,-0x8(%rbp)
  shll   -0x4(%rbp)
  mov    -0x8(%rbp),%eax
  lea    0x7(%rax),%edx
  test   %eax,%eax
  cmovs  %edx,%eax
  sar    $0x3,%eax
  movslq %eax,%rdx
  mov    -0x10(%rbp),%rax
  add    %rdx,%rax
  movzbl (%rax),%eax
  movzbl %al,%edx
  mov    -0x8(%rbp),%eax
  mov    %eax,%ecx
  sar    $0x1f,%ecx
  shr    $0x1d,%ecx
  add    %ecx,%eax
  and    $0x7,%eax
  sub    %ecx,%eax
  mov    %eax,%ecx
  mov    $0x7,%eax
  sub    %ecx,%eax
  mov    %eax,%ecx
  sar    %cl,%edx
  mov    %edx,%eax
  and    $0x1,%eax
  add    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  pop    %rbp
  ret
```

assistant: ```c
int addbit(int value, unsigned char *word, int index) {
  value <<= 1;
  value += (word[index / 8] >> (7 - (index % 8))) & 1;
  return value;
}
```
user: Translate the below assembly code into C programming language:

```asm
<addbit>:
  endbr64
  lea    0x7(%rdx),%eax
  test   %edx,%edx
  cmovns %edx,%eax
  sar    $0x3,%eax
  cltq
  movzbl (%rsi,%rax,1),%esi
  mov    %edx,%eax
  sar    $0x1f,%eax
  shr    $0x1d,%eax
  add    %eax,%edx
  and    $0x7,%edx
  sub    %edx,%eax
  lea    0x7(%rax),%ecx
  sar    %cl,%esi
  and    $0x1,%esi
  lea    (%rsi,%rdi,2),%eax
  ret
```

assistant: ```c
int addbit(int value, unsigned char *word, int index) {
  value <<= 1;
  value += (word[index / 8] >> (7 - (index % 8))) & 1;
  return value;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<addbit>:
  endbr64
  test   %edx,%edx
  lea    0x7(%rdx),%eax
  cmovns %edx,%eax
  sar    $0x3,%eax
  cltq
  movzbl (%rsi,%rax,1),%esi
  mov    %edx,%eax
  sar    $0x1f,%eax
  shr    $0x1d,%eax
  add    %eax,%edx
  and    $0x7,%edx
  sub    %edx,%eax
  lea    0x7(%rax),%ecx
  sar    %cl,%esi
  and    $0x1,%esi
  lea    (%rsi,%rdi,2),%eax
  ret
```

assistant: ```c
int addbit(int value, unsigned char *word, int index) {
  value <<= 1;
  value += (word[index / 8] >> (7 - (index % 8))) & 1;
  return value;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<addbit>:
  endbr64
  test   %edx,%edx
  lea    0x7(%rdx),%eax
  cmovns %edx,%eax
  sar    $0x3,%eax
  cltq
  movzbl (%rsi,%rax,1),%esi
  mov    %edx,%eax
  sar    $0x1f,%eax
  shr    $0x1d,%eax
  add    %eax,%edx
  and    $0x7,%edx
  sub    %edx,%eax
  lea    0x7(%rax),%ecx
  sar    %cl,%esi
  and    $0x1,%esi
  lea    (%rsi,%rdi,2),%eax
  ret
```

assistant: ```c
int addbit(int value, unsigned char *word, int index) {
  value <<= 1;
  value += (word[index / 8] >> (7 - (index % 8))) & 1;
  return value;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<pattern_fill>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,(%rsp)
  mov    %esi,%r15d
  mov    %rdx,0x8(%rsp)
  mov    %ecx,%ebx
  mov    %r8d,%r12d
  test   %ecx,%ecx
  je     L79
  mov    %r8d,%eax
  cltd
  idiv   %ecx
  mov    %edx,%r12d
L79:
  sub    %r12d,%ebx
  cmp    %ebx,%r15d
  jl     L67
  movslq %ebx,%r13
  movslq %r12d,%r14
  mov    0x8(%rsp),%rax
  lea    (%rax,%r14,1),%rsi
  mov    %r13,%rdx
  mov    (%rsp),%rdi
  call   <memcpy@plt>
  mov    %r15d,%ebp
  sub    %ebx,%ebp
  add    (%rsp),%r13
  test   %r12d,%r12d
  jle    L35
  cmp    %ebp,%r12d
  jg     L30
  mov    %r14,%rdx
  mov    0x8(%rsp),%rsi
  mov    %r13,%rdi
  call   <memcpy@plt>
  sub    %r12d,%ebp
  add    %r14,%r13
L35:
  mov    %r13,%rax
  sub    (%rsp),%rax
  mov    %eax,%ebx
  cmp    %eax,%r15d
  jle    L5
L46:
  cmp    %ebp,%ebx
  mov    %ebp,%r12d
  cmovle %ebx,%r12d
  movslq %r12d,%r14
  mov    %r14,%rdx
  mov    (%rsp),%rsi
  mov    %r13,%rdi
  call   <memcpy@plt>
  add    %r14,%r13
  add    %r12d,%ebx
  sub    %r12d,%ebp
  cmp    %ebx,%r15d
  jg     L46
L5:
  mov    $0x0,%eax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L67:
  movslq %r15d,%rdx
  movslq %r12d,%rsi
  add    0x8(%rsp),%rsi
  mov    (%rsp),%rdi
  call   <memcpy@plt>
  jmp    L5
L30:
  movslq %ebp,%rdx
  mov    0x8(%rsp),%rsi
  mov    %r13,%rdi
  call   <memcpy@plt>
  jmp    L5
```

assistant: ```c
int pattern_fill(buf, buflen, pat, patlen, patshift)
char *buf;
int buflen;
char *pat;
int patlen;
int patshift;
{
  int trans, ncopied, nleft;
  char *cp;
  if (patlen)
    patshift = patshift % patlen;
  cp = buf;
  nleft = buflen;
  trans = patlen - patshift;
  if (nleft < trans) {
    memcpy(cp, pat + patshift, nleft);
    return 0;
  } else {
    memcpy(cp, pat + patshift, trans);
    nleft -= trans;
    cp += trans;
  }
  if (patshift > 0) {
    trans = patshift;
    if (nleft < trans) {
      memcpy(cp, pat, nleft);
      return 0;
    } else {
      memcpy(cp, pat, trans);
      nleft -= trans;
      cp += trans;
    }
  }
  ncopied = cp - buf;
  while (ncopied < buflen) {
    trans = (ncopied < nleft) ? ncopied : nleft;
    memcpy(cp, buf, trans);
    cp += trans;
    ncopied += trans;
    nleft -= trans;
  }
  return (0);
}
```
user: Translate the below assembly code into C programming language:

```asm
<pattern_fill>:
  endbr64
  push   %r15
  mov    %rdi,%r15
  push   %r14
  mov    %rdx,%r14
  push   %r13
  mov    %esi,%r13d
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  test   %ecx,%ecx
  je     L29
  mov    %r8d,%eax
  cltd
  idiv   %ecx
  mov    %edx,%r8d
L29:
  sub    %r8d,%ecx
  mov    %ecx,%r12d
  movslq %r8d,%rcx
  lea    (%r14,%rcx,1),%rsi
  cmp    %r12d,%r13d
  jl     L41
  movslq %r12d,%rbx
  mov    %r15,%rdi
  mov    %r8d,(%rsp)
  mov    %r13d,%ebp
  mov    %rbx,%rdx
  mov    %rcx,0x8(%rsp)
  sub    %r12d,%ebp
  call   <memcpy@plt>
  mov    (%rsp),%r8d
  lea    (%r15,%rbx,1),%rdi
  test   %r8d,%r8d
  jle    L6
  cmp    %ebp,%r8d
  mov    0x8(%rsp),%rcx
  jg     L69
  mov    %rcx,%rdx
  mov    %r14,%rsi
  mov    %r8d,0x8(%rsp)
  mov    %rcx,(%rsp)
  call   <memcpy@plt>
  mov    0x8(%rsp),%r8d
  mov    (%rsp),%rcx
  mov    %rax,%rdi
  sub    %r8d,%ebp
  add    %rcx,%rdi
L6:
  mov    %rdi,%rax
  sub    %r15,%rax
  mov    %eax,%ebx
  cmp    %eax,%r13d
  jle    L64
  nopl   0x0(%rax)
L75:
  cmp    %ebp,%ebx
  mov    %ebp,%r12d
  mov    %r15,%rsi
  cmovle %ebx,%r12d
  movslq %r12d,%r14
  add    %r12d,%ebx
  sub    %r12d,%ebp
  mov    %r14,%rdx
  call   <memcpy@plt>
  mov    %rax,%rdi
  add    %r14,%rdi
  cmp    %ebx,%r13d
  jg     L75
L64:
  add    $0x18,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L41:
  movslq %r13d,%rdx
  mov    %r15,%rdi
  call   <memcpy@plt>
  jmp    L64
  nopl   (%rax)
L69:
  movslq %ebp,%rdx
  mov    %r14,%rsi
  call   <memcpy@plt>
  jmp    L64
```

assistant: ```c
int pattern_fill(buf, buflen, pat, patlen, patshift)
char *buf;
int buflen;
char *pat;
int patlen;
int patshift;
{
  int trans, ncopied, nleft;
  char *cp;
  if (patlen)
    patshift = patshift % patlen;
  cp = buf;
  nleft = buflen;
  trans = patlen - patshift;
  if (nleft < trans) {
    memcpy(cp, pat + patshift, nleft);
    return 0;
  } else {
    memcpy(cp, pat + patshift, trans);
    nleft -= trans;
    cp += trans;
  }
  if (patshift > 0) {
    trans = patshift;
    if (nleft < trans) {
      memcpy(cp, pat, nleft);
      return 0;
    } else {
      memcpy(cp, pat, trans);
      nleft -= trans;
      cp += trans;
    }
  }
  ncopied = cp - buf;
  while (ncopied < buflen) {
    trans = (ncopied < nleft) ? ncopied : nleft;
    memcpy(cp, buf, trans);
    cp += trans;
    ncopied += trans;
    nleft -= trans;
  }
  return (0);
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<pattern_fill>:
  endbr64
  push   %r15
  mov    %rdi,%r15
  push   %r14
  mov    %rdx,%r14
  push   %r13
  mov    %esi,%r13d
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  test   %ecx,%ecx
  je     L42
  mov    %r8d,%eax
  cltd
  idiv   %ecx
  mov    %edx,%r8d
L42:
  sub    %r8d,%ecx
  mov    %ecx,%r12d
  movslq %r8d,%rcx
  lea    (%r14,%rcx,1),%rsi
  cmp    %r12d,%r13d
  jl     L19
  movslq %r12d,%rbx
  mov    %r15,%rdi
  mov    %r8d,(%rsp)
  mov    %r13d,%ebp
  mov    %rbx,%rdx
  mov    %rcx,0x8(%rsp)
  sub    %r12d,%ebp
  call   <memcpy@plt>
  mov    (%rsp),%r8d
  lea    (%r15,%rbx,1),%rdi
  test   %r8d,%r8d
  jle    L5
  cmp    %ebp,%r8d
  mov    0x8(%rsp),%rcx
  jg     L10
  mov    %rcx,%rdx
  mov    %r14,%rsi
  mov    %r8d,0x8(%rsp)
  mov    %rcx,(%rsp)
  call   <memcpy@plt>
  mov    0x8(%rsp),%r8d
  mov    (%rsp),%rcx
  mov    %rax,%rdi
  sub    %r8d,%ebp
  add    %rcx,%rdi
L5:
  mov    %rdi,%rax
  sub    %r15,%rax
  mov    %eax,%ebx
  cmp    %eax,%r13d
  jle    L72
  nopl   0x0(%rax)
L69:
  cmp    %ebp,%ebx
  mov    %ebp,%r12d
  mov    %r15,%rsi
  cmovle %ebx,%r12d
  movslq %r12d,%r14
  add    %r12d,%ebx
  sub    %r12d,%ebp
  mov    %r14,%rdx
  call   <memcpy@plt>
  mov    %rax,%rdi
  add    %r14,%rdi
  cmp    %ebx,%r13d
  jg     L69
L72:
  add    $0x18,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L19:
  movslq %r13d,%rdx
  mov    %r15,%rdi
  call   <memcpy@plt>
  jmp    L72
  nopl   (%rax)
L10:
  movslq %ebp,%rdx
  mov    %r14,%rsi
  call   <memcpy@plt>
  jmp    L72
```

assistant: ```c
int pattern_fill(buf, buflen, pat, patlen, patshift)
char *buf;
int buflen;
char *pat;
int patlen;
int patshift;
{
  int trans, ncopied, nleft;
  char *cp;
  if (patlen)
    patshift = patshift % patlen;
  cp = buf;
  nleft = buflen;
  trans = patlen - patshift;
  if (nleft < trans) {
    memcpy(cp, pat + patshift, nleft);
    return 0;
  } else {
    memcpy(cp, pat + patshift, trans);
    nleft -= trans;
    cp += trans;
  }
  if (patshift > 0) {
    trans = patshift;
    if (nleft < trans) {
      memcpy(cp, pat, nleft);
      return 0;
    } else {
      memcpy(cp, pat, trans);
      nleft -= trans;
      cp += trans;
    }
  }
  ncopied = cp - buf;
  while (ncopied < buflen) {
    trans = (ncopied < nleft) ? ncopied : nleft;
    memcpy(cp, buf, trans);
    cp += trans;
    ncopied += trans;
    nleft -= trans;
  }
  return (0);
}
```
user: Translate the below assembly code into C programming language:

```asm
<encode_three_bytes>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  mov    %edx,-0x20(%rbp)
  mov    %ecx,-0x24(%rbp)
  mov    %r8d,-0x28(%rbp)
  mov    -0x1c(%rbp),%eax
  sar    $0x2,%eax
  mov    %eax,%edx
  mov    -0x28(%rbp),%eax
  mov    %eax,%esi
  mov    %edx,%edi
  call   <getsymbol@plt>
  mov    -0x18(%rbp),%rdx
  mov    %eax,(%rdx)
  mov    -0x1c(%rbp),%eax
  shl    $0x4,%eax
  and    $0x30,%eax
  mov    %eax,%edx
  mov    -0x20(%rbp),%eax
  sar    $0x4,%eax
  or     %eax,%edx
  mov    -0x18(%rbp),%rax
  lea    0x4(%rax),%rbx
  mov    -0x28(%rbp),%eax
  mov    %eax,%esi
  mov    %edx,%edi
  call   <getsymbol@plt>
  mov    %eax,(%rbx)
  mov    -0x20(%rbp),%eax
  shl    $0x2,%eax
  and    $0x3c,%eax
  mov    %eax,%edx
  mov    -0x24(%rbp),%eax
  sar    $0x6,%eax
  or     %eax,%edx
  mov    -0x18(%rbp),%rax
  lea    0x8(%rax),%rbx
  mov    -0x28(%rbp),%eax
  mov    %eax,%esi
  mov    %edx,%edi
  call   <getsymbol@plt>
  mov    %eax,(%rbx)
  mov    -0x24(%rbp),%eax
  and    $0x3f,%eax
  mov    %eax,%edx
  mov    -0x18(%rbp),%rax
  lea    0xc(%rax),%rbx
  mov    -0x28(%rbp),%eax
  mov    %eax,%esi
  mov    %edx,%edi
  call   <getsymbol@plt>
  mov    %eax,(%rbx)
  nop
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

assistant: ```c
void encode_three_bytes(uint8_t *dest, uint8_t b1, uint8_t b2, uint8_t b3, bool urlsafe) {
  dest[0] = getsymbol(b1 >> 2, urlsafe);
  dest[1] = getsymbol(((b1 & 0x03) << 4) | (b2 >> 4), urlsafe);
  dest[2] = getsymbol(((b2 & 0x0f) << 2) | (b3 >> 6), urlsafe);
  dest[3] = getsymbol(b3 & 0x3f, urlsafe);
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<encode_three_bytes>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%r12
  mov    %esi,%ebp
  mov    %edx,%ebx
  mov    %ecx,%r13d
  mov    %r8d,%r14d
  mov    %esi,%edi
  sar    $0x2,%edi
  mov    %r8d,%esi
  call   <getsymbol@plt>
  mov    %eax,(%r12)
  mov    %ebp,%edi
  shl    $0x4,%edi
  and    $0x30,%edi
  mov    %ebx,%eax
  sar    $0x4,%eax
  or     %eax,%edi
  mov    %r14d,%esi
  call   <getsymbol@plt>
  mov    %eax,0x4(%r12)
  lea    0x0(,%rbx,4),%edi
  and    $0x3c,%edi
  mov    %r13d,%eax
  sar    $0x6,%eax
  or     %eax,%edi
  mov    %r14d,%esi
  call   <getsymbol@plt>
  mov    %eax,0x8(%r12)
  mov    %r13d,%edi
  and    $0x3f,%edi
  mov    %r14d,%esi
  call   <getsymbol@plt>
  mov    %eax,0xc(%r12)
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
```

assistant: ```c
void encode_three_bytes(uint8_t *dest, uint8_t b1, uint8_t b2, uint8_t b3, bool urlsafe) {
  dest[0] = getsymbol(b1 >> 2, urlsafe);
  dest[1] = getsymbol(((b1 & 0x03) << 4) | (b2 >> 4), urlsafe);
  dest[2] = getsymbol(((b2 & 0x0f) << 2) | (b3 >> 6), urlsafe);
  dest[3] = getsymbol(b3 & 0x3f, urlsafe);
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<encode_three_bytes>:
  endbr64
  push   %r14
  mov    %r8d,%r14d
  push   %r13
  mov    %ecx,%r13d
  push   %r12
  mov    %rdi,%r12
  mov    %esi,%edi
  push   %rbp
  sar    $0x2,%edi
  mov    %esi,%ebp
  mov    %r8d,%esi
  push   %rbx
  mov    %edx,%ebx
  call   <getsymbol@plt>
  mov    %ebp,%edi
  mov    %r14d,%esi
  mov    %eax,(%r12)
  shl    $0x4,%edi
  mov    %ebx,%eax
  sar    $0x4,%eax
  and    $0x30,%edi
  or     %eax,%edi
  call   <getsymbol@plt>
  lea    0x0(,%rbx,4),%edi
  mov    %r14d,%esi
  mov    %eax,0x4(%r12)
  mov    %r13d,%eax
  and    $0x3c,%edi
  sar    $0x6,%eax
  or     %eax,%edi
  call   <getsymbol@plt>
  mov    %r13d,%edi
  mov    %r14d,%esi
  mov    %eax,0x8(%r12)
  and    $0x3f,%edi
  call   <getsymbol@plt>
  pop    %rbx
  pop    %rbp
  mov    %eax,0xc(%r12)
  pop    %r12
  pop    %r13
  pop    %r14
  ret
```

assistant: ```c
void encode_three_bytes(uint8_t *dest, uint8_t b1, uint8_t b2, uint8_t b3, bool urlsafe) {
  dest[0] = getsymbol(b1 >> 2, urlsafe);
  dest[1] = getsymbol(((b1 & 0x03) << 4) | (b2 >> 4), urlsafe);
  dest[2] = getsymbol(((b2 & 0x0f) << 2) | (b3 >> 6), urlsafe);
  dest[3] = getsymbol(b3 & 0x3f, urlsafe);
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<encode_three_bytes>:
  endbr64
  push   %r14
  mov    %r8d,%r14d
  push   %r13
  mov    %ecx,%r13d
  push   %r12
  mov    %rdi,%r12
  mov    %esi,%edi
  push   %rbp
  sar    $0x2,%edi
  mov    %esi,%ebp
  mov    %r8d,%esi
  push   %rbx
  mov    %edx,%ebx
  call   <getsymbol@plt>
  mov    %ebp,%edi
  mov    %r14d,%esi
  mov    %eax,(%r12)
  shl    $0x4,%edi
  mov    %ebx,%eax
  sar    $0x4,%eax
  and    $0x30,%edi
  or     %eax,%edi
  call   <getsymbol@plt>
  lea    0x0(,%rbx,4),%edi
  mov    %r14d,%esi
  mov    %eax,0x4(%r12)
  mov    %r13d,%eax
  and    $0x3c,%edi
  sar    $0x6,%eax
  or     %eax,%edi
  call   <getsymbol@plt>
  mov    %r13d,%edi
  mov    %r14d,%esi
  mov    %eax,0x8(%r12)
  and    $0x3f,%edi
  call   <getsymbol@plt>
  pop    %rbx
  pop    %rbp
  mov    %eax,0xc(%r12)
  pop    %r12
  pop    %r13
  pop    %r14
  ret
```

assistant: ```c
void encode_three_bytes(uint8_t *dest, uint8_t b1, uint8_t b2, uint8_t b3, bool urlsafe) {
  dest[0] = getsymbol(b1 >> 2, urlsafe);
  dest[1] = getsymbol(((b1 & 0x03) << 4) | (b2 >> 4), urlsafe);
  dest[2] = getsymbol(((b2 & 0x0f) << 2) | (b3 >> 6), urlsafe);
  dest[3] = getsymbol(b3 & 0x3f, urlsafe);
}
```
user: Translate the below assembly code into C programming language:

```asm
<__strings_distance>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %rdx,-0x28(%rbp)
  movl   $0xffffffff,-0x4(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  je     L76
  cmpq   $0x0,-0x28(%rbp)
  je     L76
  movl   $0x0,-0x8(%rbp)
L54:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  mov    %al,-0xa(%rbp)
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  mov    %al,-0x9(%rbp)
  cmpb   $0x0,-0xa(%rbp)
  je     L178
  mov    -0x18(%rbp),%rax
  cmp    -0x20(%rbp),%rax
  jne    L88
L178:
  cmpb   $0x0,-0x9(%rbp)
  jne    L88
  cmpl   $0x0,-0x8(%rbp)
  je     L82
  mov    $0x0,%eax
  jmp    L56
L82:
  mov    $0xffffffff,%eax
L56:
  mov    %eax,-0x4(%rbp)
  jmp    L76
L88:
  cmpb   $0x0,-0xa(%rbp)
  je     L105
  mov    -0x18(%rbp),%rax
  cmp    -0x20(%rbp),%rax
  je     L105
  cmpb   $0x0,-0x9(%rbp)
  jne    L79
L105:
  cmpl   $0x0,-0x8(%rbp)
  je     L155
  mov    -0x8(%rbp),%eax
  jmp    L206
L155:
  mov    $0xffffffff,%eax
L206:
  mov    %eax,-0x4(%rbp)
  jmp    L76
L79:
  cmpb   $0x40,-0xa(%rbp)
  jle    L133
  cmpb   $0x5a,-0xa(%rbp)
  jg     L133
  movzbl -0xa(%rbp),%eax
  add    $0x20,%eax
  mov    %al,-0xa(%rbp)
L133:
  cmpb   $0x40,-0x9(%rbp)
  jle    L150
  cmpb   $0x5a,-0x9(%rbp)
  jg     L150
  movzbl -0x9(%rbp),%eax
  add    $0x20,%eax
  mov    %al,-0x9(%rbp)
L150:
  movzbl -0xa(%rbp),%eax
  cmp    -0x9(%rbp),%al
  je     L219
  cmpl   $0x0,-0x8(%rbp)
  je     L94
  mov    -0x8(%rbp),%eax
  jmp    L217
L94:
  mov    $0xffffffff,%eax
L217:
  mov    %eax,-0x4(%rbp)
  jmp    L76
L219:
  addq   $0x1,-0x18(%rbp)
  addq   $0x1,-0x28(%rbp)
  addl   $0x1,-0x8(%rbp)
  jmp    L54
L76:
  mov    -0x4(%rbp),%eax
  pop    %rbp
  ret
```

assistant: ```c
int __strings_distance(char *s1, char *stop, char *s2) {
  char c1, c2;
  int i, distance = -1;
  if (s1 && s2) {
    for (i = 0;; s1++, s2++, i++) {
      c1 = *s1;
      c2 = *s2;
      if ((!c1 || s1 == stop) && !c2) {
        distance = i ? 0 : -1;
        break;
      }
      if ((!c1 || s1 == stop) || !c2) {
        distance = i ? i : -1;
        break;
      }
      if ('A' <= c1 && c1 <= 'Z')
        c1 += 'a' - 'A';
      if ('A' <= c2 && c2 <= 'Z')
        c2 += 'a' - 'A';
      if (c1 != c2) {
        distance = i ? i : -1;
        break;
      }
    }
  }
  return distance;
}
```