ylfeng/ReF-Decompile-dataset huggingface dataset:
user: What would the C source look like for the assembly code provided here?

```asm
<tlv_encode_next>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %edx,-0x24(%rbp)
  mov    %ecx,-0x28(%rbp)
  mov    %r8,-0x30(%rbp)
  mov    -0x18(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x28(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    -0x20(%rbp),%rax
  mov    (%rax),%eax
  cmp    %eax,%edx
  jl     L27
  mov    $0x0,%eax
  jmp    L20
L8:
  mov    -0x8(%rbp),%rax
  lea    0x4(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  mov    -0x24(%rbp),%edx
  mov    %edx,(%rax)
  mov    -0x28(%rbp),%eax
  mov    $0xff,%edx
  cmp    %edx,%eax
  cmovg  %edx,%eax
  mov    %eax,-0xc(%rbp)
  mov    -0x8(%rbp),%rax
  lea    0x4(%rax),%rdx
  mov    %rdx,-0x8(%rbp)
  mov    -0xc(%rbp),%edx
  mov    %edx,(%rax)
  mov    -0xc(%rbp),%edx
  mov    -0x30(%rbp),%rcx
  mov    -0x8(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  mov    -0xc(%rbp),%eax
  cltq
  shl    $0x2,%rax
  add    %rax,-0x30(%rbp)
  mov    -0xc(%rbp),%eax
  cltq
  shl    $0x2,%rax
  add    %rax,-0x8(%rbp)
  mov    -0xc(%rbp),%eax
  sub    %eax,-0x28(%rbp)
  mov    -0x20(%rbp),%rax
  mov    (%rax),%eax
  mov    -0xc(%rbp),%edx
  lea    0x2(%rdx),%ecx
  sub    %ecx,%eax
  mov    %eax,%edx
  mov    -0x20(%rbp),%rax
  mov    %edx,(%rax)
L27:
  cmpl   $0x0,-0x28(%rbp)
  jg     L8
  mov    -0x18(%rbp),%rax
  mov    -0x8(%rbp),%rdx
  mov    %rdx,(%rax)
  mov    $0x1,%eax
L20:
  leave
  ret
```

assistant: ```c
uint8_t tlv_encode_next(uint8_t **data, uint16_t *dlength, uint8_t type, uint16_t length, const uint8_t *value) {
  uint8_t *iptr = *data;
  if (length + 2 > *dlength) {
    return 0;
  }
  while (length > 0) {
    *iptr++ = type;
    uint8_t piece = length > 255 ? 255 : length;
    *iptr++ = piece;
    memcpy(iptr, value, piece);
    value += piece;
    iptr += piece;
    length -= piece;
    *dlength -= piece + 2;
  }
  *data = iptr;
  return 1;
}
```
user: Translate the below assembly code into C programming language:

```asm
<tlv_encode_next>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,0x8(%rsp)
  mov    %edx,%r15d
  lea    0x1(%rcx),%edx
  mov    $0x0,%eax
  cmp    (%rsi),%edx
  jge    L12
  mov    %rsi,%r14
  mov    %ecx,%ebp
  mov    %r8,%r12
  mov    (%rdi),%rax
  test   %ecx,%ecx
  jle    L20
L9:
  mov    %r15d,(%rax)
  mov    $0xff,%ebx
  cmp    %ebx,%ebp
  cmovle %ebp,%ebx
  lea    0x8(%rax),%r13
  mov    %ebx,0x4(%rax)
  mov    %ebx,%edx
  mov    %r12,%rsi
  mov    %r13,%rdi
  call   <memcpy@plt>
  movslq %ebx,%rax
  shl    $0x2,%rax
  add    %rax,%r12
  add    %r13,%rax
  sub    %ebx,%ebp
  add    $0x2,%ebx
  sub    %ebx,(%r14)
  test   %ebp,%ebp
  jg     L9
L20:
  mov    0x8(%rsp),%rcx
  mov    %rax,(%rcx)
  mov    $0x1,%eax
L12:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
uint8_t tlv_encode_next(uint8_t **data, uint16_t *dlength, uint8_t type, uint16_t length, const uint8_t *value) {
  uint8_t *iptr = *data;
  if (length + 2 > *dlength) {
    return 0;
  }
  while (length > 0) {
    *iptr++ = type;
    uint8_t piece = length > 255 ? 255 : length;
    *iptr++ = piece;
    memcpy(iptr, value, piece);
    value += piece;
    iptr += piece;
    length -= piece;
    *dlength -= piece + 2;
  }
  *data = iptr;
  return 1;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<tlv_encode_next>:
  endbr64
  push   %r15
  xor    %eax,%eax
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  mov    %edx,%ebp
  lea    0x1(%rcx),%edx
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,0x8(%rsp)
  cmp    (%rsi),%edx
  jge    L12
  mov    (%rdi),%rax
  mov    %rsi,%r13
  mov    %ecx,%r14d
  mov    %r8,%r15
  test   %ecx,%ecx
  jle    L22
  nopw   0x0(%rax,%rax,1)
L29:
  mov    $0xff,%ebx
  mov    %ebp,(%rax)
  lea    0x8(%rax),%r12
  mov    %r15,%rsi
  cmp    %ebx,%r14d
  mov    %r12,%rdi
  cmovle %r14d,%ebx
  mov    %ebx,0x4(%rax)
  mov    %ebx,%edx
  sub    %ebx,%r14d
  call   <memcpy@plt>
  movslq %ebx,%rax
  add    $0x2,%ebx
  sub    %ebx,0x0(%r13)
  shl    $0x2,%rax
  add    %rax,%r15
  add    %r12,%rax
  test   %r14d,%r14d
  jg     L29
L22:
  mov    0x8(%rsp),%rcx
  mov    %rax,(%rcx)
  mov    $0x1,%eax
L12:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
uint8_t tlv_encode_next(uint8_t **data, uint16_t *dlength, uint8_t type, uint16_t length, const uint8_t *value) {
  uint8_t *iptr = *data;
  if (length + 2 > *dlength) {
    return 0;
  }
  while (length > 0) {
    *iptr++ = type;
    uint8_t piece = length > 255 ? 255 : length;
    *iptr++ = piece;
    memcpy(iptr, value, piece);
    value += piece;
    iptr += piece;
    length -= piece;
    *dlength -= piece + 2;
  }
  *data = iptr;
  return 1;
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<tlv_encode_next>:
  endbr64
  push   %r15
  xor    %eax,%eax
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %edx,0xc(%rsp)
  lea    0x1(%rcx),%edx
  cmp    (%rsi),%edx
  jge    L22
  mov    (%rdi),%rax
  mov    %rdi,%r12
  mov    %rsi,%r13
  mov    %ecx,%r14d
  mov    %r8,%r15
  test   %ecx,%ecx
  jle    L18
  nopw   0x0(%rax,%rax,1)
L24:
  mov    $0xff,%ebx
  movd   0xc(%rsp),%xmm0
  lea    0x8(%rax),%rbp
  mov    %r15,%rsi
  cmp    %ebx,%r14d
  mov    %rbp,%rdi
  cmovle %r14d,%ebx
  movd   %ebx,%xmm1
  mov    %ebx,%edx
  sub    %ebx,%r14d
  punpckldq %xmm1,%xmm0
  movq   %xmm0,(%rax)
  call   <memcpy@plt>
  movslq %ebx,%rax
  add    $0x2,%ebx
  sub    %ebx,0x0(%r13)
  shl    $0x2,%rax
  add    %rax,%r15
  add    %rbp,%rax
  test   %r14d,%r14d
  jg     L24
L18:
  mov    %rax,(%r12)
  mov    $0x1,%eax
L22:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
uint8_t tlv_encode_next(uint8_t **data, uint16_t *dlength, uint8_t type, uint16_t length, const uint8_t *value) {
  uint8_t *iptr = *data;
  if (length + 2 > *dlength) {
    return 0;
  }
  while (length > 0) {
    *iptr++ = type;
    uint8_t piece = length > 255 ? 255 : length;
    *iptr++ = piece;
    memcpy(iptr, value, piece);
    value += piece;
    iptr += piece;
    length -= piece;
    *dlength -= piece + 2;
  }
  *data = iptr;
  return 1;
}
```
user: What is the c source code of the assembly code below?

```asm
<rangematch>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x28,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %esi,%eax
  mov    %edx,-0x30(%rbp)
  mov    %al,-0x2c(%rbp)
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x21,%al
  sete   %al
  movzbl %al,%eax
  mov    %eax,-0x14(%rbp)
  cmpl   $0x0,-0x14(%rbp)
  je     L142
  addq   $0x1,-0x28(%rbp)
L142:
  movl   $0x0,-0x18(%rbp)
  jmp    L68
L94:
  cmpb   $0x0,-0x1a(%rbp)
  jne    L28
  mov    $0x0,%eax
  jmp    L90
L28:
  mov    -0x28(%rbp),%rax
  movzbl (%rax),%eax
  cmp    $0x2d,%al
  jne    L129
  mov    -0x28(%rbp),%rax
  add    $0x1,%rax
  movzbl (%rax),%eax
  mov    %al,-0x19(%rbp)
  cmpb   $0x0,-0x19(%rbp)
  je     L129
  cmpb   $0x5d,-0x19(%rbp)
  je     L129
  movzbl -0x1a(%rbp),%eax
  cmp    -0x2c(%rbp),%al
  jg     L164
  movzbl -0x2c(%rbp),%eax
  cmp    -0x19(%rbp),%al
  jg     L164
  movl   $0x1,-0x18(%rbp)
L164:
  cmpl   $0x0,-0x30(%rbp)
  je     L96
  movsbl -0x1a(%rbp),%eax
  mov    %eax,%edi
  call   <toupper@plt>
  mov    %rax,%rbx
  movsbl -0x2c(%rbp),%eax
  mov    %eax,%edi
  call   <toupper@plt>
  cmp    %rax,%rbx
  jg     L96
  movsbl -0x2c(%rbp),%eax
  mov    %eax,%edi
  call   <toupper@plt>
  mov    %rax,%rbx
  movsbl -0x19(%rbp),%eax
  mov    %eax,%edi
  call   <toupper@plt>
  cmp    %rax,%rbx
  jg     L96
  movl   $0x1,-0x18(%rbp)
L96:
  addq   $0x2,-0x28(%rbp)
  jmp    L68
L129:
  movzbl -0x1a(%rbp),%eax
  cmp    -0x2c(%rbp),%al
  jne    L104
  movl   $0x1,-0x18(%rbp)
  jmp    L68
L104:
  cmpl   $0x0,-0x30(%rbp)
  je     L68
  movsbl -0x1a(%rbp),%eax
  mov    %eax,%edi
  call   <toupper@plt>
  mov    %rax,%rbx
  movsbl -0x2c(%rbp),%eax
  mov    %eax,%edi
  call   <toupper@plt>
  cmp    %rax,%rbx
  jne    L68
  movl   $0x1,-0x18(%rbp)
L68:
  mov    -0x28(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x28(%rbp)
  movzbl (%rax),%eax
  mov    %al,-0x1a(%rbp)
  cmpb   $0x5d,-0x1a(%rbp)
  jne    L94
  mov    -0x18(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  je     L59
  mov    -0x28(%rbp),%rax
  jmp    L90
L59:
  mov    $0x0,%eax
L90:
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

assistant: ```c
const char *rangematch(const char *pattern, char test, int nocase) {
  char c, c2;
  int negate, ok;
  if ((negate = (*pattern == '!')))
    ++pattern;
  for (ok = 0; (c = *pattern++) != ']';) {
    if (c == 0)
      return 0;
    if (*pattern == '-' && (c2 = pattern[1]) != 0 && c2 != ']') {
      if (c <= test && test <= c2)
        ok = 1;
      if (nocase && toupper(c) <= toupper(test) && toupper(test) <= toupper(c2))
        ok = 1;
      pattern += 2;
    } else if (c == test)
      ok = 1;
    else if (nocase && (toupper(c) == toupper(test)))
      ok = 1;
  }
  return ok == negate ? NULL : pattern;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<rangematch>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%rbx
  mov    %edx,%r13d
  mov    %esi,%r12d
  movzbl (%rdi),%eax
  mov    %al,0xf(%rsp)
  cmp    $0x21,%al
  je     L13
  lea    0x1(%rdi),%rbp
  movzbl 0xf(%rsp),%eax
  mov    %eax,%edi
  cmp    $0x5d,%al
  je     L87
L127:
  mov    $0x0,%r14d
  movsbl %r12b,%eax
  mov    %eax,0x8(%rsp)
  jmp    L180
L13:
  lea    0x1(%rdi),%rax
  lea    0x2(%rdi),%rbp
  movzbl 0x1(%rdi),%edi
  cmp    $0x5d,%dil
  je     L135
  mov    %rax,%rbx
  jmp    L127
L143:
  movzbl 0x2(%rbx),%r15d
  cmp    $0x5d,%r15b
  je     L96
  test   %r15b,%r15b
  je     L96
  cmp    %dil,%r12b
  jl     L130
  cmp    %r12b,%r15b
  mov    $0x1,%eax
  cmovge %eax,%r14d
L130:
  test   %r13d,%r13d
  jne    L126
L69:
  add    $0x3,%rbx
  jmp    L40
L126:
  movsbl %dil,%edi
  call   <toupper@plt>
  mov    %rax,%rbp
  mov    0x8(%rsp),%edi
  call   <toupper@plt>
  cmp    %rax,%rbp
  jg     L69
  mov    0x8(%rsp),%edi
  call   <toupper@plt>
  mov    %rax,%rbp
  movsbl %r15b,%edi
  call   <toupper@plt>
  cmp    %rax,%rbp
  mov    $0x1,%eax
  cmovle %eax,%r14d
  jmp    L69
L193:
  mov    %rbp,%rbx
  mov    $0x1,%r14d
L40:
  lea    0x1(%rbx),%rbp
  movzbl (%rbx),%edi
  cmp    $0x5d,%dil
  je     L51
L180:
  test   %dil,%dil
  je     L105
  cmpb   $0x2d,0x1(%rbx)
  je     L143
L96:
  cmp    %dil,%r12b
  je     L193
  mov    %rbp,%rbx
  test   %r13d,%r13d
  je     L40
  movsbl %dil,%edi
  call   <toupper@plt>
  mov    %rax,%r15
  mov    0x8(%rsp),%edi
  call   <toupper@plt>
  cmp    %rax,%r15
  mov    $0x1,%eax
  cmove  %eax,%r14d
  jmp    L40
L51:
  cmpb   $0x21,0xf(%rsp)
  sete   %al
  movzbl %al,%eax
  cmp    %eax,%r14d
  mov    $0x0,%eax
  cmove  %rax,%rbp
  jmp    L135
L105:
  mov    $0x0,%ebp
L135:
  mov    %rbp,%rax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L87:
  mov    $0x0,%ebp
  jmp    L135
```

assistant: ```c
const char *rangematch(const char *pattern, char test, int nocase) {
  char c, c2;
  int negate, ok;
  if ((negate = (*pattern == '!')))
    ++pattern;
  for (ok = 0; (c = *pattern++) != ']';) {
    if (c == 0)
      return 0;
    if (*pattern == '-' && (c2 = pattern[1]) != 0 && c2 != ']') {
      if (c <= test && test <= c2)
        ok = 1;
      if (nocase && toupper(c) <= toupper(test) && toupper(test) <= toupper(c2))
        ok = 1;
      pattern += 2;
    } else if (c == test)
      ok = 1;
    else if (nocase && (toupper(c) == toupper(test)))
      ok = 1;
  }
  return ok == negate ? NULL : pattern;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<rangematch>:
  endbr64
  push   %r15
  push   %r14
  mov    %edx,%r14d
  push   %r13
  mov    %esi,%r13d
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x18,%rsp
  movzbl (%rdi),%eax
  mov    %eax,%ecx
  mov    %al,0x7(%rsp)
  lea    0x1(%rdi),%rax
  cmp    $0x21,%cl
  je     L55
  movzbl 0x7(%rsp),%esi
  movsbl %sil,%edi
  cmp    $0x5d,%sil
  je     L59
L107:
  xor    %ebp,%ebp
  movsbl %r13b,%r12d
  jmp    L45
  nopl   0x0(%rax)
L96:
  mov    %rax,%rbx
  cmp    %dil,%r13b
  je     L185
  test   %r14d,%r14d
  jne    L57
L42:
  movsbl (%rbx),%edi
  lea    0x1(%rbx),%rax
  cmp    $0x5d,%dil
  je     L187
L45:
  test   %dil,%dil
  je     L59
  cmpb   $0x2d,0x1(%rbx)
  jne    L96
  movzbl 0x2(%rbx),%r15d
  cmp    $0x5d,%r15b
  je     L96
  test   %r15b,%r15b
  je     L96
  cmp    %dil,%r13b
  jl     L118
  cmp    %r13b,%r15b
  mov    $0x1,%eax
  cmovge %eax,%ebp
L118:
  test   %r14d,%r14d
  jne    L115
L191:
  movsbl 0x3(%rbx),%edi
  add    $0x3,%rbx
  lea    0x1(%rbx),%rax
  cmp    $0x5d,%dil
  jne    L45
  nopl   0x0(%rax,%rax,1)
L187:
  xor    %ecx,%ecx
  cmpb   $0x21,0x7(%rsp)
  sete   %cl
  cmp    %ecx,%ebp
  jne    L151
  xchg   %ax,%ax
L59:
  xor    %eax,%eax
L151:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L185:
  mov    $0x1,%ebp
  jmp    L42
  nopw   0x0(%rax,%rax,1)
L57:
  call   <toupper@plt>
  mov    %r12d,%edi
  mov    %rax,%r15
  call   <toupper@plt>
  cmp    %rax,%r15
  mov    $0x1,%eax
  cmove  %eax,%ebp
  jmp    L42
  nopl   0x0(%rax,%rax,1)
L55:
  lea    0x2(%rdi),%rdx
  movsbl 0x1(%rdi),%edi
  cmp    $0x5d,%dil
  je     L93
  mov    %rax,%rbx
  mov    %rdx,%rax
  jmp    L107
  nopl   0x0(%rax)
L115:
  call   <toupper@plt>
  mov    %r12d,%edi
  mov    %rax,0x8(%rsp)
  call   <toupper@plt>
  cmp    %rax,0x8(%rsp)
  jg     L191
  mov    %r12d,%edi
  call   <toupper@plt>
  movsbl %r15b,%edi
  mov    %rax,0x8(%rsp)
  call   <toupper@plt>
  cmp    %rax,0x8(%rsp)
  mov    $0x1,%eax
  cmovle %eax,%ebp
  jmp    L191
L93:
  mov    %rdx,%rax
  jmp    L151
```

assistant: ```c
const char *rangematch(const char *pattern, char test, int nocase) {
  char c, c2;
  int negate, ok;
  if ((negate = (*pattern == '!')))
    ++pattern;
  for (ok = 0; (c = *pattern++) != ']';) {
    if (c == 0)
      return 0;
    if (*pattern == '-' && (c2 = pattern[1]) != 0 && c2 != ']') {
      if (c <= test && test <= c2)
        ok = 1;
      if (nocase && toupper(c) <= toupper(test) && toupper(test) <= toupper(c2))
        ok = 1;
      pattern += 2;
    } else if (c == test)
      ok = 1;
    else if (nocase && (toupper(c) == toupper(test)))
      ok = 1;
  }
  return ok == negate ? NULL : pattern;
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<rangematch>:
  endbr64
  push   %r15
  push   %r14
  mov    %edx,%r14d
  push   %r13
  mov    %esi,%r13d
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x18,%rsp
  movzbl (%rdi),%eax
  mov    %eax,%ecx
  mov    %al,0x7(%rsp)
  lea    0x1(%rdi),%rax
  cmp    $0x21,%cl
  je     L188
  movsbl %cl,%edi
  cmp    $0x5d,%cl
  je     L77
L1:
  xor    %ebp,%ebp
  movsbl %r13b,%r12d
  jmp    L127
  nopl   (%rax)
L121:
  mov    %rax,%rbx
  cmp    %dil,%r13b
  je     L94
  test   %r14d,%r14d
  jne    L102
L154:
  movsbl (%rbx),%edi
  lea    0x1(%rbx),%rax
  cmp    $0x5d,%dil
  je     L38
L127:
  test   %dil,%dil
  je     L77
  cmpb   $0x2d,0x1(%rbx)
  jne    L121
  movzbl 0x2(%rbx),%r15d
  cmp    $0x5d,%r15b
  je     L121
  test   %r15b,%r15b
  je     L121
  cmp    %dil,%r13b
  jl     L32
  cmp    %r13b,%r15b
  mov    $0x1,%eax
  cmovge %eax,%ebp
L32:
  test   %r14d,%r14d
  jne    L161
L145:
  movsbl 0x3(%rbx),%edi
  add    $0x3,%rbx
  lea    0x1(%rbx),%rax
  cmp    $0x5d,%dil
  jne    L127
L38:
  xor    %ecx,%ecx
  cmpb   $0x21,0x7(%rsp)
  sete   %cl
  cmp    %ecx,%ebp
  jne    L12
  xchg   %ax,%ax
L77:
  xor    %eax,%eax
L12:
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax)
L94:
  mov    $0x1,%ebp
  jmp    L154
  nopw   0x0(%rax,%rax,1)
L102:
  call   <toupper@plt>
  mov    %r12d,%edi
  mov    %rax,%r15
  call   <toupper@plt>
  cmp    %rax,%r15
  mov    $0x1,%eax
  cmove  %eax,%ebp
  jmp    L154
  nopl   0x0(%rax,%rax,1)
L188:
  lea    0x2(%rdi),%rdx
  movsbl 0x1(%rdi),%edi
  cmp    $0x5d,%dil
  je     L34
  mov    %rax,%rbx
  mov    %rdx,%rax
  jmp    L1
  nopl   0x0(%rax)
L161:
  call   <toupper@plt>
  mov    %r12d,%edi
  mov    %rax,0x8(%rsp)
  call   <toupper@plt>
  cmp    %rax,0x8(%rsp)
  jg     L145
  mov    %r12d,%edi
  call   <toupper@plt>
  movsbl %r15b,%edi
  mov    %rax,0x8(%rsp)
  call   <toupper@plt>
  cmp    %rax,0x8(%rsp)
  mov    $0x1,%eax
  cmovle %eax,%ebp
  jmp    L145
L34:
  mov    %rdx,%rax
  jmp    L12
```

assistant: ```c
const char *rangematch(const char *pattern, char test, int nocase) {
  char c, c2;
  int negate, ok;
  if ((negate = (*pattern == '!')))
    ++pattern;
  for (ok = 0; (c = *pattern++) != ']';) {
    if (c == 0)
      return 0;
    if (*pattern == '-' && (c2 = pattern[1]) != 0 && c2 != ']') {
      if (c <= test && test <= c2)
        ok = 1;
      if (nocase && toupper(c) <= toupper(test) && toupper(test) <= toupper(c2))
        ok = 1;
      pattern += 2;
    } else if (c == test)
      ok = 1;
    else if (nocase && (toupper(c) == toupper(test)))
      ok = 1;
  }
  return ok == negate ? NULL : pattern;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<xstrdup>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  je     L20
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <strdup@plt>
  jmp    L16
L20:
  lea    D1(%rip),%rax
  mov    %rax,%rdi
  call   <strdup@plt>
L16:
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L17
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %rax,%rsi
  lea    D14(%rip),%rax
  mov    %rax,%rdi
  call   <fatal@plt>
L17:
  mov    -0x8(%rbp),%rax
  leave
  ret
```

tool_calls: name: unpack_data
arguments: data_tag: D1
type_infered: string
name: unpack_data
arguments: data_tag: D14
type_infered: string

tool: 

tool: D14: gpsbabel: Unable to allocate %ld bytes of memory.


assistant: ```c
char *xstrdup(const char *s) {
  char *o = s ? strdup(s) : strdup("");
  if (!o) {
    fatal("gpsbabel: Unable to allocate %ld bytes of memory.\n", (unsigned long)strlen(s));
  }
  return o;
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<xstrdup>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%rbp
  test   %rdi,%rdi
  je     L27
  call   <strdup@plt>
  mov    %rax,%rbx
L26:
  test   %rbx,%rbx
  je     L29
L24:
  mov    %rbx,%rax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
L27:
  lea    D14(%rip),%rdi
  call   <strdup@plt>
  mov    %rax,%rbx
  jmp    L26
L29:
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %rax,%rsi
  lea    D15(%rip),%rdi
  call   <fatal@plt>
  jmp    L24
```

tool_calls: name: unpack_data
arguments: data_tag: D14
type_guessed: string
name: unpack_data
arguments: data_tag: D15
type_guessed: string

tool: 

tool: D15: gpsbabel: Unable to allocate %ld bytes of memory.


assistant: ```c
char *xstrdup(const char *s) {
  char *o = s ? strdup(s) : strdup("");
  if (!o) {
    fatal("gpsbabel: Unable to allocate %ld bytes of memory.\n", (unsigned long)strlen(s));
  }
  return o;
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<xstrdup>:
  endbr64
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  sub    $0x8,%rsp
  test   %rdi,%rdi
  je     L7
  call   <strdup@plt>
  mov    %rax,%r12
L29:
  test   %r12,%r12
  je     L10
L36:
  add    $0x8,%rsp
  mov    %r12,%rax
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax,%rax,1)
L7:
  lea    D11(%rip),%rdi
  call   <strdup@plt>
  mov    %rax,%r12
  jmp    L29
L10:
  mov    %rbp,%rdi
  call   <strlen@plt>
  lea    D15(%rip),%rdi
  mov    %rax,%rsi
  call   <fatal@plt>
  jmp    L36
```

tool_calls: name: parse_data
arguments: data_label: D11
type: string
name: parse_data
arguments: data_label: D15
type: string

tool: 

tool: D15: gpsbabel: Unable to allocate %ld bytes of memory.


assistant: ```c
char *xstrdup(const char *s) {
  char *o = s ? strdup(s) : strdup("");
  if (!o) {
    fatal("gpsbabel: Unable to allocate %ld bytes of memory.\n", (unsigned long)strlen(s));
  }
  return o;
}
```
user: What is the c source code of the assembly code below:

```asm
<xstrdup>:
  endbr64
  push   %r12
  push   %rbp
  mov    %rdi,%rbp
  sub    $0x8,%rsp
  test   %rdi,%rdi
  je     L26
  call   <strdup@plt>
  mov    %rax,%r12
L1:
  test   %r12,%r12
  je     L7
L2:
  add    $0x8,%rsp
  mov    %r12,%rax
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax,%rax,1)
L26:
  lea    D7(%rip),%rdi
  call   <strdup@plt>
  mov    %rax,%r12
  jmp    L1
L7:
  mov    %rbp,%rdi
  call   <strlen@plt>
  lea    D11(%rip),%rdi
  mov    %rax,%rsi
  call   <fatal@plt>
  jmp    L2
```

tool_calls: name: extract_symbolic_data
arguments: label: D7
data_type: string
name: extract_symbolic_data
arguments: label: D11
data_type: string

tool: 

tool: D11: gpsbabel: Unable to allocate %ld bytes of memory.


assistant: ```c
char *xstrdup(const char *s) {
  char *o = s ? strdup(s) : strdup("");
  if (!o) {
    fatal("gpsbabel: Unable to allocate %ld bytes of memory.\n", (unsigned long)strlen(s));
  }
  return o;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<rotate>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x8(%rbp)
  mov    %esi,-0xc(%rbp)
  mov    %edx,-0x10(%rbp)
  mov    %ecx,-0x14(%rbp)
  mov    %r8d,-0x18(%rbp)
  mov    %r9,-0x20(%rbp)
  cvtsd2ss %xmm0,%xmm0
  movss  %xmm0,-0x28(%rbp)
  pxor   %xmm0,%xmm0
  cvtsd2ss %xmm1,%xmm0
  movss  %xmm0,-0x30(%rbp)
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x8(%rbp),%rax
  add    %rax,%rdx
  mov    -0x10(%rbp),%eax
  cltq
  movss  (%rdx,%rax,4),%xmm0
  mov    0x10(%rbp),%rax
  movss  %xmm0,(%rax)
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x8(%rbp),%rax
  add    %rax,%rdx
  mov    -0x18(%rbp),%eax
  cltq
  movss  (%rdx,%rax,4),%xmm0
  mov    -0x20(%rbp),%rax
  movss  %xmm0,(%rax)
  mov    0x10(%rbp),%rax
  movss  (%rax),%xmm0
  mov    -0x20(%rbp),%rax
  movss  (%rax),%xmm2
  mov    0x10(%rbp),%rax
  movss  (%rax),%xmm1
  mulss  -0x30(%rbp),%xmm1
  addss  %xmm2,%xmm1
  mulss  -0x28(%rbp),%xmm1
  mov    -0xc(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x8(%rbp),%rax
  add    %rax,%rdx
  subss  %xmm1,%xmm0
  mov    -0x10(%rbp),%eax
  cltq
  movss  %xmm0,(%rdx,%rax,4)
  mov    -0x20(%rbp),%rax
  movss  (%rax),%xmm2
  mov    0x10(%rbp),%rax
  movss  (%rax),%xmm0
  mov    -0x20(%rbp),%rax
  movss  (%rax),%xmm1
  mulss  -0x30(%rbp),%xmm1
  subss  %xmm1,%xmm0
  mulss  -0x28(%rbp),%xmm0
  mov    -0x14(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x8(%rbp),%rax
  add    %rax,%rdx
  addss  %xmm2,%xmm0
  mov    -0x18(%rbp),%eax
  cltq
  movss  %xmm0,(%rdx,%rax,4)
  nop
  pop    %rbp
  ret
```

assistant: ```c
rotate(a, i, j, k, l, h, g, s, tau) float a[2][2], s, tau;
int i, j, k, l;
float *h, *g;
{
  (*g) = a[i][j];
  (*h) = a[k][l];
  a[i][j] = (*g) - s * ((*h) + (*g) * tau);
  a[k][l] = (*h) + s * ((*g) - (*h) * tau);
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<rotate>:
  endbr64
  mov    %rdi,%rax
  mov    0x8(%rsp),%rdi
  pxor   %xmm3,%xmm3
  cvtsd2ss %xmm0,%xmm3
  cvtsd2ss %xmm1,%xmm1
  movslq %esi,%rsi
  lea    (%rax,%rsi,8),%rsi
  movslq %edx,%rdx
  movss  (%rsi,%rdx,4),%xmm0
  movss  %xmm0,(%rdi)
  movslq %ecx,%rcx
  lea    (%rax,%rcx,8),%rax
  movslq %r8d,%r8
  movss  (%rax,%r8,4),%xmm4
  movss  %xmm4,(%r9)
  movss  (%rdi),%xmm0
  movaps %xmm0,%xmm2
  mulss  %xmm1,%xmm2
  addss  %xmm4,%xmm2
  mulss  %xmm3,%xmm2
  subss  %xmm2,%xmm0
  movss  %xmm0,(%rsi,%rdx,4)
  movss  (%r9),%xmm2
  mulss  %xmm2,%xmm1
  movss  (%rdi),%xmm0
  subss  %xmm1,%xmm0
  mulss  %xmm3,%xmm0
  addss  %xmm2,%xmm0
  movss  %xmm0,(%rax,%r8,4)
  ret
```

assistant: ```c
rotate(a, i, j, k, l, h, g, s, tau) float a[2][2], s, tau;
int i, j, k, l;
float *h, *g;
{
  (*g) = a[i][j];
  (*h) = a[k][l];
  a[i][j] = (*g) - s * ((*h) + (*g) * tau);
  a[k][l] = (*h) + s * ((*g) - (*h) * tau);
}
```