ylfeng/ReF-Decompile-dataset huggingface dataset:
user: 请将以下的汇编代码转换成C语言代码:

```asm
<http_parse_querystring>:
  endbr64
  test   %rdi,%rdi
  je     L131
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rsi,%r13
  call   <strdup@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L133
L53:
  movzbl 0x0(%rbp),%edx
  test   %dl,%dl
  je     L116
  mov    %rbp,%r14
  mov    %rbp,%rbx
  mov    $0x0,%r12d
  mov    $0x0,%r15d
  jmp    L124
L133:
  lea    D6(%rip),%rdi
  call   <printf@plt>
  mov    $0x1,%edi
  call   <exit@plt>
  jmp    L53
L1:
  movb   $0x0,(%rbx)
  lea    0x1(%rbx),%r12
  mov    %rbx,%rax
L97:
  lea    0x1(%rax),%rbx
  movzbl 0x1(%rax),%edx
  test   %dl,%dl
  je     L126
L124:
  cmp    $0x3d,%dl
  je     L1
  cmp    $0x2b,%dl
  je     L28
  cmp    $0x25,%dl
  je     L87
  mov    %rbx,%rax
  cmp    $0x26,%dl
  jne    L97
  movb   $0x0,(%rbx)
  mov    %r12,%rsi
  mov    %r14,%rdi
  call   *%r13
  lea    0x1(%rbx),%r14
  mov    %rbx,%rax
  mov    %r15,%r12
  jmp    L97
L28:
  movb   $0x20,(%rbx)
  mov    %rbx,%rax
  jmp    L97
L87:
  mov    %rbx,%rdi
  call   <convert_query_hexchar@plt>
  jmp    L97
L126:
  cmp    %rbx,%r14
  je     L116
  mov    %r12,%rsi
  mov    %r14,%rdi
  call   *%r13
L116:
  mov    %rbp,%rdi
  call   <free@plt>
  mov    $0x0,%eax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L131:
  mov    $0x0,%eax
  ret
```

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

tool: D6: Out of memory


assistant: ```c
int http_parse_querystring(const char *txt_, void (*fn)(const char *name, const char *value)) {
  char *o, *t, *txt, *value = NULL, c;
  if (!txt_)
    return 0;
  o = t = txt = strdup(txt_);
  if (t == NULL) {
    printf("Out of memory\n");
    exit(1);
  }
  while ((c = *t) != '\0') {
    if (c == '=') {
      *t = '\0';
      value = t + 1;
    } else if (c == '+') {
      *t = ' ';
    } else if (c == '%') {
      t = convert_query_hexchar(t);
    } else if (c == '&') {
      *t = '\0';
      (*fn)(txt, value);
      txt = t + 1;
      value = NULL;
    }
    t++;
  }
  if (t != txt)
    (*fn)(txt, value);
  free(o);
  return 0;
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<http_parse_querystring>:
  endbr64
  test   %rdi,%rdi
  je     L16
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rsi,%rbx
  sub    $0x8,%rsp
  call   <strdup@plt>
  mov    %rax,%r13
  test   %rax,%rax
  je     10e0 <http_parse_querystring.cold>
  movzbl (%rax),%eax
  mov    %r13,%r15
  mov    %r13,%rbp
  xor    %r12d,%r12d
  test   %al,%al
  jne    L33
  jmp    L112
  nopl   0x0(%rax)
L109:
  cmp    $0x2b,%al
  je     L71
  cmp    $0x25,%al
  je     L115
  lea    0x1(%rbp),%r14
  cmp    $0x26,%al
  je     L102
  mov    %rbp,%rax
  mov    %r14,%rbp
L118:
  movzbl 0x1(%rax),%eax
  test   %al,%al
  je     L66
L33:
  cmp    $0x3d,%al
  jne    L109
  mov    %rbp,%rax
  movb   $0x0,0x0(%rbp)
  lea    0x1(%rbp),%r12
  movzbl 0x1(%rax),%eax
  mov    %r12,%rbp
  test   %al,%al
  jne    L33
L66:
  cmp    %rbp,%r15
  je     L112
  mov    %r12,%rsi
  mov    %r15,%rdi
  call   *%rbx
L112:
  mov    %r13,%rdi
  call   <free@plt>
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L71:
  movb   $0x20,0x0(%rbp)
  mov    %rbp,%rax
  add    $0x1,%rbp
  jmp    L118
  nopl   (%rax)
L102:
  movb   $0x0,0x0(%rbp)
  mov    %r12,%rsi
  mov    %r15,%rdi
  xor    %r12d,%r12d
  call   *%rbx
  mov    %r14,%r15
  mov    %rbp,%rax
  mov    %r14,%rbp
  jmp    L118
  nopw   0x0(%rax,%rax,1)
L115:
  mov    %rbp,%rdi
  call   <convert_query_hexchar@plt>
  lea    0x1(%rax),%rbp
  jmp    L118
  nopl   0x0(%rax)
L16:
  xor    %eax,%eax
  ret
```

assistant: ```c
int http_parse_querystring(const char *txt_, void (*fn)(const char *name, const char *value)) {
  char *o, *t, *txt, *value = NULL, c;
  if (!txt_)
    return 0;
  o = t = txt = strdup(txt_);
  if (t == NULL) {
    printf("Out of memory\n");
    exit(1);
  }
  while ((c = *t) != '\0') {
    if (c == '=') {
      *t = '\0';
      value = t + 1;
    } else if (c == '+') {
      *t = ' ';
    } else if (c == '%') {
      t = convert_query_hexchar(t);
    } else if (c == '&') {
      *t = '\0';
      (*fn)(txt, value);
      txt = t + 1;
      value = NULL;
    }
    t++;
  }
  if (t != txt)
    (*fn)(txt, value);
  free(o);
  return 0;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<http_parse_querystring>:
  endbr64
  test   %rdi,%rdi
  je     L27
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rsi,%rbx
  sub    $0x8,%rsp
  call   <strdup@plt>
  mov    %rax,%r13
  test   %rax,%rax
  je     10e0 <http_parse_querystring.cold>
  movzbl (%rax),%eax
  mov    %r13,%r15
  mov    %r13,%rbp
  xor    %r12d,%r12d
  test   %al,%al
  jne    L8
  jmp    L95
  nopl   0x0(%rax)
L41:
  cmp    $0x2b,%al
  je     L112
  cmp    $0x25,%al
  je     L91
  lea    0x1(%rbp),%r14
  cmp    $0x26,%al
  je     L47
  mov    %rbp,%rax
  mov    %r14,%rbp
L25:
  movzbl 0x1(%rax),%eax
  test   %al,%al
  je     L127
L8:
  cmp    $0x3d,%al
  jne    L41
  mov    %rbp,%rax
  movb   $0x0,0x0(%rbp)
  lea    0x1(%rbp),%r12
  movzbl 0x1(%rax),%eax
  mov    %r12,%rbp
  test   %al,%al
  jne    L8
L127:
  cmp    %rbp,%r15
  je     L95
  mov    %r12,%rsi
  mov    %r15,%rdi
  call   *%rbx
L95:
  mov    %r13,%rdi
  call   <free@plt>
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopw   0x0(%rax,%rax,1)
L112:
  movb   $0x20,0x0(%rbp)
  mov    %rbp,%rax
  add    $0x1,%rbp
  jmp    L25
  nopl   (%rax)
L47:
  movb   $0x0,0x0(%rbp)
  mov    %r12,%rsi
  mov    %r15,%rdi
  xor    %r12d,%r12d
  call   *%rbx
  mov    %r14,%r15
  mov    %rbp,%rax
  mov    %r14,%rbp
  jmp    L25
  nopw   0x0(%rax,%rax,1)
L91:
  mov    %rbp,%rdi
  call   <convert_query_hexchar@plt>
  lea    0x1(%rax),%rbp
  jmp    L25
  nopl   0x0(%rax)
L27:
  xor    %eax,%eax
  ret
```

assistant: ```c
int http_parse_querystring(const char *txt_, void (*fn)(const char *name, const char *value)) {
  char *o, *t, *txt, *value = NULL, c;
  if (!txt_)
    return 0;
  o = t = txt = strdup(txt_);
  if (t == NULL) {
    printf("Out of memory\n");
    exit(1);
  }
  while ((c = *t) != '\0') {
    if (c == '=') {
      *t = '\0';
      value = t + 1;
    } else if (c == '+') {
      *t = ' ';
    } else if (c == '%') {
      t = convert_query_hexchar(t);
    } else if (c == '&') {
      *t = '\0';
      (*fn)(txt, value);
      txt = t + 1;
      value = NULL;
    }
    t++;
  }
  if (t != txt)
    (*fn)(txt, value);
  free(o);
  return 0;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<irc_info_create_string_with_pointer>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %rdi,-0x8(%rbp)
  mov    %rsi,-0x10(%rbp)
  mov    -0x8(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  je     L11
  mov    -0x8(%rbp),%rax
  mov    (%rax),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x8(%rbp),%rax
  movq   $0x0,(%rax)
L11:
  cmpq   $0x0,-0x10(%rbp)
  je     L26
  mov    $0x40,%edi
  call   <malloc@plt>
  mov    -0x8(%rbp),%rdx
  mov    %rax,(%rdx)
  mov    -0x8(%rbp),%rax
  mov    (%rax),%rax
  test   %rax,%rax
  je     L26
  mov    -0x10(%rbp),%rdx
  mov    -0x8(%rbp),%rax
  mov    (%rax),%rax
  mov    %rdx,%rcx
  lea    D2(%rip),%rdx
  mov    $0x40,%esi
  mov    %rax,%rdi
  call   <snprintf@plt>
L26:
  nop
  leave
  ret
```

tool_calls: name: retrieve_data
arguments: data_tag: D2
type_guessed: string

tool: D2: 0x%lx

assistant: ```c
void irc_info_create_string_with_pointer(char **string, void *pointer) {
  if (*string) {
    free(*string);
    *string = NULL;
  }
  if (pointer) {
    *string = malloc(64);
    if (*string) {
      snprintf(*string, 64, "0x%lx", (long unsigned int)pointer);
    }
  }
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<irc_info_create_string_with_pointer>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%rbx
  mov    %rsi,%rbp
  mov    (%rdi),%rdi
  test   %rdi,%rdi
  je     L23
  call   <free@plt>
  movq   $0x0,(%rbx)
L23:
  test   %rbp,%rbp
  je     L17
  mov    $0x40,%edi
  call   <malloc@plt>
  mov    %rax,(%rbx)
  test   %rax,%rax
  je     L17
  mov    %rbp,%rcx
  lea    D1(%rip),%rdx
  mov    $0x40,%esi
  mov    %rax,%rdi
  call   <snprintf@plt>
L17:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
```

tool_calls: name: read_data
arguments: tag: D1
type: string

tool: D1: 0x%lx

assistant: ```c
void irc_info_create_string_with_pointer(char **string, void *pointer) {
  if (*string) {
    free(*string);
    *string = NULL;
  }
  if (pointer) {
    *string = malloc(64);
    if (*string) {
      snprintf(*string, 64, "0x%lx", (long unsigned int)pointer);
    }
  }
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<irc_info_create_string_with_pointer>:
  endbr64
  push   %r12
  mov    %rsi,%r12
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x8,%rsp
  mov    (%rdi),%rdi
  test   %rdi,%rdi
  je     L10
  call   <free@plt>
  movq   $0x0,(%rbx)
L10:
  test   %r12,%r12
  je     L24
  mov    $0x40,%edi
  call   <malloc@plt>
  mov    %rax,(%rbx)
  mov    %rax,%rdi
  test   %rax,%rax
  je     L24
  add    $0x8,%rsp
  mov    %r12,%rcx
  mov    $0x40,%esi
  pop    %rbx
  lea    D9(%rip),%rdx
  pop    %r12
  jmp    1080 <snprintf@plt>
  nopw   0x0(%rax,%rax,1)
L24:
  add    $0x8,%rsp
  pop    %rbx
  pop    %r12
  ret
```

tool_calls: name: disassemble_data
arguments: data_label: D9
type_infered: string

tool: D9: 0x%lx

assistant: ```c
void irc_info_create_string_with_pointer(char **string, void *pointer) {
  if (*string) {
    free(*string);
    *string = NULL;
  }
  if (pointer) {
    *string = malloc(64);
    if (*string) {
      snprintf(*string, 64, "0x%lx", (long unsigned int)pointer);
    }
  }
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<irc_info_create_string_with_pointer>:
  endbr64
  push   %r12
  mov    %rsi,%r12
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x8,%rsp
  mov    (%rdi),%rdi
  test   %rdi,%rdi
  je     L29
  call   <free@plt>
  movq   $0x0,(%rbx)
L29:
  test   %r12,%r12
  je     L18
  mov    $0x40,%edi
  call   <malloc@plt>
  mov    %rax,(%rbx)
  mov    %rax,%rdi
  test   %rax,%rax
  je     L18
  add    $0x8,%rsp
  mov    %r12,%rcx
  mov    $0x40,%esi
  pop    %rbx
  lea    D7(%rip),%rdx
  pop    %r12
  jmp    1080 <snprintf@plt>
  nopw   0x0(%rax,%rax,1)
L18:
  add    $0x8,%rsp
  pop    %rbx
  pop    %r12
  ret
```

tool_calls: name: disassemble_data
arguments: label: D7
datatype: string

tool: D7: 0x%lx

assistant: ```c
void irc_info_create_string_with_pointer(char **string, void *pointer) {
  if (*string) {
    free(*string);
    *string = NULL;
  }
  if (pointer) {
    *string = malloc(64);
    if (*string) {
      snprintf(*string, 64, "0x%lx", (long unsigned int)pointer);
    }
  }
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<handleMoreRFC822LineBreak>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %edi,-0x14(%rbp)
  cmpl   $0x3b,-0x14(%rbp)
  jne    L26
  mov    $0x0,%eax
  call   <lexSkipLookahead@plt>
  mov    $0x0,%eax
  call   <lexLookahead@plt>
  mov    %eax,-0x4(%rbp)
  jmp    L64
L86:
  mov    $0x0,%eax
  call   <lexSkipLookahead@plt>
  mov    $0x0,%eax
  call   <lexLookahead@plt>
  mov    %eax,-0x4(%rbp)
L64:
  cmpl   $0x20,-0x4(%rbp)
  je     L86
  cmpl   $0x9,-0x4(%rbp)
  je     L86
  cmpl   $0xa,-0x4(%rbp)
  jne    L30
  mov    $0x0,%eax
  call   <lexSkipLookahead@plt>
  mov    $0x0,%eax
  call   <lexLookahead@plt>
  mov    %eax,-0x4(%rbp)
  cmpl   $0x20,-0x4(%rbp)
  je     L74
  cmpl   $0x9,-0x4(%rbp)
  jne    L25
L74:
  mov    $0x0,%eax
  call   <lexSkipWhite@plt>
  mov    $0x3b,%edi
  call   <lexPushLookaheadc@plt>
  jmp    L26
L25:
  mov    $0xa,%edi
  call   <lexPushLookaheadc@plt>
  mov    $0x3b,%edi
  call   <lexPushLookaheadc@plt>
  jmp    L26
L30:
  mov    $0x3b,%edi
  call   <lexPushLookaheadc@plt>
L26:
  nop
  leave
  ret
```

assistant: ```c
void handleMoreRFC822LineBreak(int c) {
  if (c == ';') {
    int a;
    lexSkipLookahead();
    a = lexLookahead();
    while (a == ' ' || a == '\t') {
      lexSkipLookahead();
      a = lexLookahead();
    }
    if (a == '\n') {
      lexSkipLookahead();
      a = lexLookahead();
      if (a == ' ' || a == '\t') {
        lexSkipWhite();
        lexPushLookaheadc(';');
      } else {
        lexPushLookaheadc('\n');
        lexPushLookaheadc(';');
      }
    } else {
      lexPushLookaheadc(';');
    }
  }
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<handleMoreRFC822LineBreak>:
  endbr64
  cmp    $0x3b,%edi
  je     L55
  ret
L55:
  sub    $0x8,%rsp
  mov    $0x0,%eax
  call   <lexSkipLookahead@plt>
  mov    $0x0,%eax
  call   <lexLookahead@plt>
  cmp    $0x20,%eax
  je     L53
  cmp    $0x9,%eax
  jne    L70
L53:
  mov    $0x0,%eax
  call   <lexSkipLookahead@plt>
  mov    $0x0,%eax
  call   <lexLookahead@plt>
  cmp    $0x20,%eax
  je     L53
  cmp    $0x9,%eax
  je     L53
L70:
  cmp    $0xa,%eax
  je     L74
  mov    $0x3b,%edi
  call   <lexPushLookaheadc@plt>
L62:
  add    $0x8,%rsp
  ret
L74:
  mov    $0x0,%eax
  call   <lexSkipLookahead@plt>
  mov    $0x0,%eax
  call   <lexLookahead@plt>
  cmp    $0x20,%eax
  je     L71
  cmp    $0x9,%eax
  je     L71
  mov    $0xa,%edi
  call   <lexPushLookaheadc@plt>
  mov    $0x3b,%edi
  call   <lexPushLookaheadc@plt>
  jmp    L62
L71:
  mov    $0x0,%eax
  call   <lexSkipWhite@plt>
  mov    $0x3b,%edi
  call   <lexPushLookaheadc@plt>
  jmp    L62
```

assistant: ```c
void handleMoreRFC822LineBreak(int c) {
  if (c == ';') {
    int a;
    lexSkipLookahead();
    a = lexLookahead();
    while (a == ' ' || a == '\t') {
      lexSkipLookahead();
      a = lexLookahead();
    }
    if (a == '\n') {
      lexSkipLookahead();
      a = lexLookahead();
      if (a == ' ' || a == '\t') {
        lexSkipWhite();
        lexPushLookaheadc(';');
      } else {
        lexPushLookaheadc('\n');
        lexPushLookaheadc(';');
      }
    } else {
      lexPushLookaheadc(';');
    }
  }
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<handleMoreRFC822LineBreak>:
  endbr64
  cmp    $0x3b,%edi
  je     L40
  ret
  nopw   0x0(%rax,%rax,1)
L40:
  sub    $0x8,%rsp
  nopl   0x0(%rax)
L6:
  xor    %eax,%eax
  call   <lexSkipLookahead@plt>
  xor    %eax,%eax
  call   <lexLookahead@plt>
  cmp    $0x20,%eax
  je     L6
  cmp    $0x9,%eax
  je     L6
  cmp    $0xa,%eax
  je     L37
  mov    $0x3b,%edi
  add    $0x8,%rsp
  jmp    1090 <lexPushLookaheadc@plt>
  nopl   0x0(%rax,%rax,1)
L37:
  xor    %eax,%eax
  call   <lexSkipLookahead@plt>
  xor    %eax,%eax
  call   <lexLookahead@plt>
  cmp    $0x20,%eax
  je     L35
  cmp    $0x9,%eax
  je     L35
  mov    $0xa,%edi
  call   <lexPushLookaheadc@plt>
  mov    $0x3b,%edi
  add    $0x8,%rsp
  jmp    1090 <lexPushLookaheadc@plt>
  nopl   0x0(%rax,%rax,1)
L35:
  xor    %eax,%eax
  call   <lexSkipWhite@plt>
  mov    $0x3b,%edi
  add    $0x8,%rsp
  jmp    1090 <lexPushLookaheadc@plt>
```

assistant: ```c
void handleMoreRFC822LineBreak(int c) {
  if (c == ';') {
    int a;
    lexSkipLookahead();
    a = lexLookahead();
    while (a == ' ' || a == '\t') {
      lexSkipLookahead();
      a = lexLookahead();
    }
    if (a == '\n') {
      lexSkipLookahead();
      a = lexLookahead();
      if (a == ' ' || a == '\t') {
        lexSkipWhite();
        lexPushLookaheadc(';');
      } else {
        lexPushLookaheadc('\n');
        lexPushLookaheadc(';');
      }
    } else {
      lexPushLookaheadc(';');
    }
  }
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<handleMoreRFC822LineBreak>:
  endbr64
  cmp    $0x3b,%edi
  je     L8
  ret
  nopw   0x0(%rax,%rax,1)
L8:
  sub    $0x8,%rsp
  nopl   0x0(%rax)
L23:
  xor    %eax,%eax
  call   <lexSkipLookahead@plt>
  xor    %eax,%eax
  call   <lexLookahead@plt>
  cmp    $0x20,%eax
  je     L23
  cmp    $0x9,%eax
  je     L23
  cmp    $0xa,%eax
  je     L28
  mov    $0x3b,%edi
  add    $0x8,%rsp
  jmp    1090 <lexPushLookaheadc@plt>
  nopl   0x0(%rax,%rax,1)
L28:
  xor    %eax,%eax
  call   <lexSkipLookahead@plt>
  xor    %eax,%eax
  call   <lexLookahead@plt>
  cmp    $0x20,%eax
  je     L9
  cmp    $0x9,%eax
  je     L9
  mov    $0xa,%edi
  call   <lexPushLookaheadc@plt>
  mov    $0x3b,%edi
  add    $0x8,%rsp
  jmp    1090 <lexPushLookaheadc@plt>
  nopl   0x0(%rax,%rax,1)
L9:
  xor    %eax,%eax
  call   <lexSkipWhite@plt>
  mov    $0x3b,%edi
  add    $0x8,%rsp
  jmp    1090 <lexPushLookaheadc@plt>
```

assistant: ```c
void handleMoreRFC822LineBreak(int c) {
  if (c == ';') {
    int a;
    lexSkipLookahead();
    a = lexLookahead();
    while (a == ' ' || a == '\t') {
      lexSkipLookahead();
      a = lexLookahead();
    }
    if (a == '\n') {
      lexSkipLookahead();
      a = lexLookahead();
      if (a == ' ' || a == '\t') {
        lexSkipWhite();
        lexPushLookaheadc(';');
      } else {
        lexPushLookaheadc('\n');
        lexPushLookaheadc(';');
      }
    } else {
      lexPushLookaheadc(';');
    }
  }
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<rotate>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  mov    %edx,-0x20(%rbp)
  mov    -0x1c(%rbp),%eax
  sub    -0x20(%rbp),%eax
  mov    %eax,-0x8(%rbp)
  mov    -0x20(%rbp),%eax
  sub    -0x8(%rbp),%eax
  mov    %eax,-0x4(%rbp)
  jmp    L29
L22:
  cmpl   $0x0,-0x4(%rbp)
  jns    L24
  cmpl   $0x1,-0x20(%rbp)
  jne    L98
  mov    -0x1c(%rbp),%edx
  mov    -0x18(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <rotate1_left@plt>
  movl   $0x0,-0x20(%rbp)
  jmp    L34
L98:
  mov    -0x8(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x20(%rbp),%edx
  mov    -0x18(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <exchange@plt>
  mov    -0x8(%rbp),%eax
  mov    %eax,-0x1c(%rbp)
  jmp    L34
L24:
  cmpl   $0x1,-0x8(%rbp)
  jne    L49
  mov    -0x1c(%rbp),%edx
  mov    -0x18(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <rotate1_right@plt>
  movl   $0x0,-0x20(%rbp)
  jmp    L34
L49:
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x8(%rbp),%edx
  mov    -0x18(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <exchange@plt>
  mov    -0x8(%rbp),%eax
  cltq
  shl    $0x2,%rax
  add    %rax,-0x18(%rbp)
  mov    -0x20(%rbp),%eax
  mov    %eax,-0x1c(%rbp)
  mov    -0x8(%rbp),%eax
  sub    %eax,-0x20(%rbp)
L34:
  mov    -0x1c(%rbp),%eax
  sub    -0x20(%rbp),%eax
  mov    %eax,-0x8(%rbp)
  mov    -0x20(%rbp),%eax
  sub    -0x8(%rbp),%eax
  mov    %eax,-0x4(%rbp)
L29:
  cmpl   $0x0,-0x4(%rbp)
  je     L31
  cmpl   $0x0,-0x20(%rbp)
  jne    L22
L31:
  cmpl   $0x0,-0x20(%rbp)
  jle    L58
  mov    -0x20(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x20(%rbp),%edx
  mov    -0x18(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <exchange@plt>
L58:
  nop
  leave
  ret
```

assistant: ```c
void rotate(int *a, int len, int idx) {
  int xdi = len - idx;
  int delta = idx - xdi;
  while (0 != delta && 0 != idx) {
    if (delta < 0) {
      if (1 == idx) {
        rotate1_left(a, len);
        idx = 0;
      } else {
        exchange(a, a + xdi, idx);
        len = xdi;
      }
    } else {
      if (1 == xdi) {
        rotate1_right(a, len);
        idx = 0;
      } else {
        exchange(a, a + idx, xdi);
        a += xdi;
        len = idx;
        idx -= xdi;
      }
    }
    xdi = len - idx;
    delta = idx - xdi;
  }
  if (0 < idx)
    exchange(a, a + idx, idx);
}
```
user: 这段汇编代码用C语言表示是什么样的?

```asm
<rotate>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%r12
  mov    %edx,%ebx
  mov    %esi,%ebp
  sub    %edx,%ebp
  mov    %edx,%eax
  sub    %ebp,%eax
  je     L33
  test   %edx,%edx
  jne    L87
L33:
  test   %ebx,%ebx
  jle    L47
  movslq %ebx,%rax
  lea    (%r12,%rax,4),%rsi
  mov    %ebx,%edx
  mov    %r12,%rdi
  call   <exchange@plt>
  jmp    L47
L8:
  cmp    $0x1,%ebx
  je     L50
  movslq %ebp,%rax
  lea    (%r12,%rax,4),%rsi
  mov    %ebx,%edx
  mov    %r12,%rdi
  call   <exchange@plt>
  mov    %ebp,%esi
L5:
  mov    %esi,%ebp
  sub    %ebx,%ebp
  mov    %ebx,%eax
  sub    %ebp,%eax
  je     L33
  test   %ebx,%ebx
  je     L33
L87:
  test   %eax,%eax
  js     L8
  cmp    $0x1,%ebp
  je     L36
  movslq %ebx,%rax
  lea    (%r12,%rax,4),%rsi
  mov    %ebp,%edx
  mov    %r12,%rdi
  call   <exchange@plt>
  movslq %ebp,%rax
  lea    (%r12,%rax,4),%r12
  mov    %ebx,%esi
  sub    %ebp,%ebx
  jmp    L5
L50:
  mov    %r12,%rdi
  call   <rotate1_left@plt>
  jmp    L47
L36:
  mov    %r12,%rdi
  call   <rotate1_right@plt>
L47:
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
void rotate(int *a, int len, int idx) {
  int xdi = len - idx;
  int delta = idx - xdi;
  while (0 != delta && 0 != idx) {
    if (delta < 0) {
      if (1 == idx) {
        rotate1_left(a, len);
        idx = 0;
      } else {
        exchange(a, a + xdi, idx);
        len = xdi;
      }
    } else {
      if (1 == xdi) {
        rotate1_right(a, len);
        idx = 0;
      } else {
        exchange(a, a + idx, xdi);
        a += xdi;
        len = idx;
        idx -= xdi;
      }
    }
    xdi = len - idx;
    delta = idx - xdi;
  }
  if (0 < idx)
    exchange(a, a + idx, idx);
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<rotate>:
  endbr64
  push   %r12
  mov    %edx,%eax
  mov    %edx,%r12d
  push   %rbp
  mov    %rdi,%rbp
  push   %rbx
  mov    %esi,%ebx
  sub    %edx,%ebx
  sub    %ebx,%eax
  jne    L51
  jmp    L59
  nopw   0x0(%rax,%rax,1)
L65:
  cmp    $0x1,%ebx
  je     L76
  movslq %r12d,%rax
  mov    %rbp,%rdi
  mov    %ebx,%edx
  lea    0x0(%rbp,%rax,4),%rsi
  call   <exchange@plt>
  movslq %ebx,%rax
  mov    %r12d,%esi
  sub    %ebx,%r12d
  lea    0x0(%rbp,%rax,4),%rbp
L88:
  mov    %r12d,%eax
  sub    %ebx,%eax
  je     L59
L51:
  test   %r12d,%r12d
  je     L59
  test   %eax,%eax
  jns    L65
  cmp    $0x1,%r12d
  je     L28
  movslq %ebx,%rax
  mov    %r12d,%edx
  mov    %rbp,%rdi
  lea    0x0(%rbp,%rax,4),%rsi
  call   <exchange@plt>
  mov    %ebx,%esi
  sub    %r12d,%ebx
  jmp    L88
  nopl   (%rax)
L76:
  pop    %rbx
  mov    %rbp,%rdi
  pop    %rbp
  pop    %r12
  jmp    1080 <rotate1_right@plt>
  nopl   0x0(%rax)
L28:
  pop    %rbx
  mov    %rbp,%rdi
  pop    %rbp
  pop    %r12
  jmp    1070 <rotate1_left@plt>
  nopl   0x0(%rax)
L59:
  test   %r12d,%r12d
  jle    L32
  movslq %r12d,%rax
  pop    %rbx
  mov    %r12d,%edx
  mov    %rbp,%rdi
  lea    0x0(%rbp,%rax,4),%rsi
  pop    %rbp
  pop    %r12
  jmp    1090 <exchange@plt>
L32:
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
void rotate(int *a, int len, int idx) {
  int xdi = len - idx;
  int delta = idx - xdi;
  while (0 != delta && 0 != idx) {
    if (delta < 0) {
      if (1 == idx) {
        rotate1_left(a, len);
        idx = 0;
      } else {
        exchange(a, a + xdi, idx);
        len = xdi;
      }
    } else {
      if (1 == xdi) {
        rotate1_right(a, len);
        idx = 0;
      } else {
        exchange(a, a + idx, xdi);
        a += xdi;
        len = idx;
        idx -= xdi;
      }
    }
    xdi = len - idx;
    delta = idx - xdi;
  }
  if (0 < idx)
    exchange(a, a + idx, idx);
}
```