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

```asm
<gettime>:
  endbr64
  sub    $0x28,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  movl   $0x0,0x14(%rsp)
  movl   $0x0,0x10(%rsp)
  movl   $0x0,0xc(%rsp)
  lea    0x10(%rsp),%rcx
  lea    0xc(%rsp),%rdx
  lea    0x14(%rsp),%r8
  lea    D6(%rip),%rsi
  call   <sscanf@plt>
  sub    $0x1,%eax
  cmp    $0x2,%eax
  ja     L5
  mov    0xc(%rsp),%eax
  cmp    $0x18,%eax
  ja     L12
  mov    0x10(%rsp),%edx
  cmp    $0x3c,%edx
  ja     L68
  mov    0x14(%rsp),%ecx
  cmp    $0x3c,%ecx
  ja     L54
  imul   $0xe10,%eax,%eax
  imul   $0x3c,%edx,%edx
  add    %edx,%eax
  add    %ecx,%eax
L80:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L21
  add    $0x28,%rsp
  ret
L5:
  mov    $0xffffffff,%eax
  jmp    L80
L12:
  mov    $0xffffffff,%eax
  jmp    L80
L68:
  mov    $0xffffffff,%eax
  jmp    L80
L54:
  mov    $0xffffffff,%eax
  jmp    L80
L21:
  call   <__stack_chk_fail@plt>
```

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

tool: D6: %2d:%2d:%2d

assistant: ```c
int gettime(const char *digit) {
  int hour, min, sec;
  hour = min = sec = 0;
  switch (sscanf(digit, "%2d:%2d:%2d", &hour, &min, &sec)) {
  case 1:
  case 2:
  case 3:
    if (hour < 0 || hour > 24 || min < 0 || min > 60 || sec < 0 || sec > 60)
      return -1;
    return hour * 3600 + min * 60 + sec;
  default:
    break;
  }
  return -1;
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<gettime>:
  endbr64
  sub    $0x28,%rsp
  lea    D2(%rip),%rsi
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  lea    0x10(%rsp),%rcx
  lea    0xc(%rsp),%rdx
  movl   $0x0,0x14(%rsp)
  lea    0x14(%rsp),%r8
  movl   $0x0,0x10(%rsp)
  movl   $0x0,0xc(%rsp)
  call   <sscanf@plt>
  sub    $0x1,%eax
  cmp    $0x2,%eax
  ja     L20
  mov    0xc(%rsp),%eax
  cmp    $0x18,%eax
  ja     L20
  mov    0x10(%rsp),%edx
  cmp    $0x3c,%edx
  ja     L20
  mov    0x14(%rsp),%ecx
  cmp    $0x3c,%ecx
  ja     L20
  imul   $0xe10,%eax,%eax
  imul   $0x3c,%edx,%edx
  add    %edx,%eax
  add    %ecx,%eax
L58:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L39
  add    $0x28,%rsp
  ret
L20:
  mov    $0xffffffff,%eax
  jmp    L58
L39:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: label: D2
datatype: string

tool: D2: %2d:%2d:%2d

assistant: ```c
int gettime(const char *digit) {
  int hour, min, sec;
  hour = min = sec = 0;
  switch (sscanf(digit, "%2d:%2d:%2d", &hour, &min, &sec)) {
  case 1:
  case 2:
  case 3:
    if (hour < 0 || hour > 24 || min < 0 || min > 60 || sec < 0 || sec > 60)
      return -1;
    return hour * 3600 + min * 60 + sec;
  default:
    break;
  }
  return -1;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<gettime>:
  endbr64
  sub    $0x28,%rsp
  lea    D5(%rip),%rsi
  mov    %fs:0x28,%rax
  mov    %rax,0x18(%rsp)
  xor    %eax,%eax
  lea    0x10(%rsp),%rcx
  lea    0xc(%rsp),%rdx
  movl   $0x0,0x14(%rsp)
  lea    0x14(%rsp),%r8
  movl   $0x0,0x10(%rsp)
  movl   $0x0,0xc(%rsp)
  call   <sscanf@plt>
  sub    $0x1,%eax
  cmp    $0x2,%eax
  ja     L35
  mov    0xc(%rsp),%eax
  cmp    $0x18,%eax
  ja     L35
  mov    0x10(%rsp),%edx
  cmp    $0x3c,%edx
  ja     L35
  mov    0x14(%rsp),%ecx
  cmp    $0x3c,%ecx
  ja     L35
  imul   $0xe10,%eax,%eax
  imul   $0x3c,%edx,%edx
  add    %edx,%eax
  add    %ecx,%eax
L12:
  mov    0x18(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L23
  add    $0x28,%rsp
  ret
L35:
  mov    $0xffffffff,%eax
  jmp    L12
L23:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: retrieve_data
arguments: tag: D5
type: string

tool: D5: %2d:%2d:%2d

assistant: ```c
int gettime(const char *digit) {
  int hour, min, sec;
  hour = min = sec = 0;
  switch (sscanf(digit, "%2d:%2d:%2d", &hour, &min, &sec)) {
  case 1:
  case 2:
  case 3:
    if (hour < 0 || hour > 24 || min < 0 || min > 60 || sec < 0 || sec > 60)
      return -1;
    return hour * 3600 + min * 60 + sec;
  default:
    break;
  }
  return -1;
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %edi,-0x4(%rbp)
  mov    %rsi,-0x10(%rbp)
  mov    $0x0,%eax
  call   <test_default_mpool@plt>
  mov    $0x0,%eax
  call   <test_grow_mpool@plt>
  mov    $0x0,%eax
  leave
  ret
```

assistant: ```c
int main(int argc, char **argv) {
  test_default_mpool();
  test_grow_mpool();
  return 0;
}
```
user: Demonstrate the C code that generates the assembly output below:

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

assistant: ```c
int main(int argc, char **argv) {
  test_default_mpool();
  test_grow_mpool();
  return 0;
}
```
user: What is the c source code of the assembly code below:

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

assistant: ```c
int main(int argc, char **argv) {
  test_default_mpool();
  test_grow_mpool();
  return 0;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

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

assistant: ```c
int main(int argc, char **argv) {
  test_default_mpool();
  test_grow_mpool();
  return 0;
}
```
user: Translate the below assembly code into C programming language:

```asm
<getpid>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  lea    D9(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
  mov    $0x0,%edx
  mov    $0x0,%esi
  mov    $0x0,%edi
  call   <syscall@plt>
  pop    %rbp
  ret
```

tool_calls: name: parse_data
arguments: label: D9
type: string

tool: D9: Entering kernal to get pid...


assistant: ```c
int getpid() {
  printf("Entering kernal to get pid...\n");
  return syscall(0, 0, 0);
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<getpid>:
  endbr64
  sub    $0x8,%rsp
  lea    D4(%rip),%rdi
  call   <printf@plt>
  mov    $0x0,%edx
  mov    $0x0,%esi
  mov    $0x0,%edi
  call   <syscall@plt>
  add    $0x8,%rsp
  ret
```

tool_calls: name: unpack_data
arguments: tag: D4
datatype: string

tool: D4: Entering kernal to get pid...


assistant: ```c
int getpid() {
  printf("Entering kernal to get pid...\n");
  return syscall(0, 0, 0);
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<getpid>:
  endbr64
  sub    $0x8,%rsp
  lea    D8(%rip),%rdi
  call   <printf@plt>
  xor    %edx,%edx
  xor    %esi,%esi
  xor    %edi,%edi
  add    $0x8,%rsp
  jmp    1070 <syscall@plt>
```

tool_calls: name: disassemble_data
arguments: tag: D8
type_guessed: string

tool: D8: Entering kernal to get pid...


assistant: ```c
int getpid() {
  printf("Entering kernal to get pid...\n");
  return syscall(0, 0, 0);
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<getpid>:
  endbr64
  sub    $0x8,%rsp
  lea    D7(%rip),%rdi
  call   <printf@plt>
  xor    %edx,%edx
  xor    %esi,%esi
  xor    %edi,%edi
  add    $0x8,%rsp
  jmp    1070 <syscall@plt>
```

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

tool: D7: Entering kernal to get pid...


assistant: ```c
int getpid() {
  printf("Entering kernal to get pid...\n");
  return syscall(0, 0, 0);
}
```
user: What is the c source code of the assembly code below?

```asm
<close_device>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %edi,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  cmp    $0xffffffff,%eax
  jne    L1
  lea    D1(%rip),%rax
  mov    %rax,%rdi
  call   <errno_exit@plt>
L1:
  nop
  leave
  ret
```

tool_calls: name: read_data
arguments: data_label: D1
type_guessed: string

tool: D1: close

assistant: ```c
void close_device(int fd) {
  if (-1 == close(fd))
    errno_exit("close");
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<close_device>:
  endbr64
  sub    $0x8,%rsp
  call   <close@plt>
  cmp    $0xffffffff,%eax
  je     L11
L3:
  add    $0x8,%rsp
  ret
L11:
  lea    D4(%rip),%rdi
  call   <errno_exit@plt>
  jmp    L3
```

tool_calls: name: retrieve_data
arguments: data_label: D4
type_guessed: string

tool: D4: close

assistant: ```c
void close_device(int fd) {
  if (-1 == close(fd))
    errno_exit("close");
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<close_device>:
  endbr64
  sub    $0x8,%rsp
  call   <close@plt>
  cmp    $0xffffffff,%eax
  je     L0
  add    $0x8,%rsp
  ret
  nopw   0x0(%rax,%rax,1)
L0:
  lea    D1(%rip),%rdi
  add    $0x8,%rsp
  jmp    1060 <errno_exit@plt>
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D1
type_infered: string

tool: D1: close

assistant: ```c
void close_device(int fd) {
  if (-1 == close(fd))
    errno_exit("close");
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<close_device>:
  endbr64
  sub    $0x8,%rsp
  call   <close@plt>
  cmp    $0xffffffff,%eax
  je     L0
  add    $0x8,%rsp
  ret
  nopw   0x0(%rax,%rax,1)
L0:
  lea    D4(%rip),%rdi
  add    $0x8,%rsp
  jmp    1060 <errno_exit@plt>
```

tool_calls: name: disassemble_data
arguments: data_tag: D4
type: string

tool: D4: close

assistant: ```c
void close_device(int fd) {
  if (-1 == close(fd))
    errno_exit("close");
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<stat>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    -0x18(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <open@plt>
  mov    %eax,-0x8(%rbp)
  cmpl   $0x0,-0x8(%rbp)
  jns    L6
  mov    $0xffffffff,%eax
  jmp    L15
L6:
  mov    -0x20(%rbp),%rdx
  mov    -0x8(%rbp),%eax
  mov    %rdx,%rsi
  mov    %eax,%edi
  call   <fstat@plt>
  mov    %eax,-0x4(%rbp)
  mov    -0x8(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  mov    -0x4(%rbp),%eax
L15:
  leave
  ret
```

assistant: ```c
int stat(char *n, struct stat *st) {
  int fd;
  int r;
  fd = open(n, 0x000);
  if (fd < 0)
    return -1;
  r = fstat(fd, st);
  close(fd);
  return r;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<stat>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rsi,%rbp
  mov    $0x0,%esi
  call   <open@plt>
  test   %eax,%eax
  js     L2
  mov    %eax,%ebx
  mov    %rbp,%rsi
  mov    %eax,%edi
  call   <fstat@plt>
  mov    %eax,%ebp
  mov    %ebx,%edi
  call   <close@plt>
L11:
  mov    %ebp,%eax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
L2:
  mov    $0xffffffff,%ebp
  jmp    L11
```

assistant: ```c
int stat(char *n, struct stat *st) {
  int fd;
  int r;
  fd = open(n, 0x000);
  if (fd < 0)
    return -1;
  r = fstat(fd, st);
  close(fd);
  return r;
}
```
user: 这段汇编代码用C语言表示是什么样的:

```asm
<stat>:
  endbr64
  push   %r12
  mov    %rsi,%r12
  xor    %esi,%esi
  push   %rbp
  sub    $0x8,%rsp
  call   <open@plt>
  test   %eax,%eax
  js     L10
  mov    %eax,%ebp
  mov    %r12,%rsi
  mov    %eax,%edi
  call   <fstat@plt>
  mov    %ebp,%edi
  mov    %eax,%r12d
  call   <close@plt>
L17:
  add    $0x8,%rsp
  mov    %r12d,%eax
  pop    %rbp
  pop    %r12
  ret
  nopw   0x0(%rax,%rax,1)
L10:
  mov    $0xffffffff,%r12d
  jmp    L17
```

assistant: ```c
int stat(char *n, struct stat *st) {
  int fd;
  int r;
  fd = open(n, 0x000);
  if (fd < 0)
    return -1;
  r = fstat(fd, st);
  close(fd);
  return r;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<stat>:
  endbr64
  push   %r12
  mov    %rsi,%r12
  xor    %esi,%esi
  push   %rbp
  sub    $0x8,%rsp
  call   <open@plt>
  test   %eax,%eax
  js     L5
  mov    %eax,%ebp
  mov    %r12,%rsi
  mov    %eax,%edi
  call   <fstat@plt>
  mov    %ebp,%edi
  mov    %eax,%r12d
  call   <close@plt>
L9:
  add    $0x8,%rsp
  mov    %r12d,%eax
  pop    %rbp
  pop    %r12
  ret
  nopw   0x0(%rax,%rax,1)
L5:
  mov    $0xffffffff,%r12d
  jmp    L9
```

assistant: ```c
int stat(char *n, struct stat *st) {
  int fd;
  int r;
  fd = open(n, 0x000);
  if (fd < 0)
    return -1;
  r = fstat(fd, st);
  close(fd);
  return r;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<gen_hash>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  movq   $0x1505,-0x10(%rbp)
  mov    -0x18(%rbp),%rax
  mov    %rax,-0x8(%rbp)
  jmp    L19
L13:
  mov    -0x10(%rbp),%rax
  shl    $0x5,%rax
  xor    -0x10(%rbp),%rax
  mov    %rax,%rdx
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  movsbq %al,%rax
  add    %rdx,%rax
  mov    %rax,-0x10(%rbp)
L19:
  addq   $0x1,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  jne    L13
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <free@plt>
  mov    -0x10(%rbp),%rax
  leave
  ret
```

assistant: ```c
unsigned long gen_hash(char *key) {
  unsigned long hash = 5381;
  char *iter = key;
  while (*++iter) {
    hash = ((hash << 5) ^ hash) + *iter;
  }
  free(key);
  return hash;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<gen_hash>:
  endbr64
  push   %rbx
  movzbl 0x1(%rdi),%eax
  test   %al,%al
  je     L12
  lea    0x1(%rdi),%rdx
  mov    $0x1505,%ebx
L22:
  mov    %rbx,%rcx
  shl    $0x5,%rcx
  xor    %rcx,%rbx
  movsbq %al,%rax
  add    %rax,%rbx
  add    $0x1,%rdx
  movzbl (%rdx),%eax
  test   %al,%al
  jne    L22
L0:
  call   <free@plt>
  mov    %rbx,%rax
  pop    %rbx
  ret
L12:
  mov    $0x1505,%ebx
  jmp    L0
```

assistant: ```c
unsigned long gen_hash(char *key) {
  unsigned long hash = 5381;
  char *iter = key;
  while (*++iter) {
    hash = ((hash << 5) ^ hash) + *iter;
  }
  free(key);
  return hash;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<gen_hash>:
  endbr64
  movsbq 0x1(%rdi),%rax
  push   %r12
  test   %al,%al
  je     L14
  lea    0x1(%rdi),%rdx
  mov    $0x1505,%r12d
  nopl   0x0(%rax)
L2:
  mov    %r12,%rcx
  add    $0x1,%rdx
  shl    $0x5,%rcx
  xor    %rcx,%r12
  add    %rax,%r12
  movsbq (%rdx),%rax
  test   %al,%al
  jne    L2
  call   <free@plt>
  mov    %r12,%rax
  pop    %r12
  ret
  nopl   0x0(%rax)
L14:
  call   <free@plt>
  mov    $0x1505,%r12d
  mov    %r12,%rax
  pop    %r12
  ret
```

assistant: ```c
unsigned long gen_hash(char *key) {
  unsigned long hash = 5381;
  char *iter = key;
  while (*++iter) {
    hash = ((hash << 5) ^ hash) + *iter;
  }
  free(key);
  return hash;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<gen_hash>:
  endbr64
  movsbq 0x1(%rdi),%rax
  push   %r12
  test   %al,%al
  je     L12
  lea    0x1(%rdi),%rdx
  mov    $0x1505,%r12d
  nopl   0x0(%rax)
L5:
  mov    %r12,%rcx
  add    $0x1,%rdx
  shl    $0x5,%rcx
  xor    %rcx,%r12
  add    %rax,%r12
  movsbq (%rdx),%rax
  test   %al,%al
  jne    L5
  call   <free@plt>
  mov    %r12,%rax
  pop    %r12
  ret
  nopl   0x0(%rax)
L12:
  call   <free@plt>
  mov    $0x1505,%r12d
  mov    %r12,%rax
  pop    %r12
  ret
```

assistant: ```c
unsigned long gen_hash(char *key) {
  unsigned long hash = 5381;
  char *iter = key;
  while (*++iter) {
    hash = ((hash << 5) ^ hash) + *iter;
  }
  free(key);
  return hash;
}
```
user: Translate the below assembly code into C programming language:

```asm
<menu_load_start>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    $0x1,%esi
  mov    $0x0,%edi
  call   <menu_load@plt>
  test   %rax,%rax
  je     L5
  mov    $0x0,%edi
  call   <reset_all_save@plt>
L5:
  nop
  pop    %rbp
  ret
```

assistant: ```c
void menu_load_start(void) {
  if (menu_load(0, 1))
    reset_all_save(0);
}
```
user: Translate the below assembly code into C programming language:

```asm
<menu_load_start>:
  endbr64
  sub    $0x8,%rsp
  mov    $0x1,%esi
  mov    $0x0,%edi
  call   <menu_load@plt>
  test   %rax,%rax
  jne    L13
L11:
  add    $0x8,%rsp
  ret
L13:
  mov    $0x0,%edi
  call   <reset_all_save@plt>
  jmp    L11
```

assistant: ```c
void menu_load_start(void) {
  if (menu_load(0, 1))
    reset_all_save(0);
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<menu_load_start>:
  endbr64
  sub    $0x8,%rsp
  xor    %edi,%edi
  mov    $0x1,%esi
  call   <menu_load@plt>
  test   %rax,%rax
  jne    L1
  add    $0x8,%rsp
  ret
  xchg   %ax,%ax
L1:
  xor    %edi,%edi
  add    $0x8,%rsp
  jmp    1070 <reset_all_save@plt>
```

assistant: ```c
void menu_load_start(void) {
  if (menu_load(0, 1))
    reset_all_save(0);
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<menu_load_start>:
  endbr64
  sub    $0x8,%rsp
  xor    %edi,%edi
  mov    $0x1,%esi
  call   <menu_load@plt>
  test   %rax,%rax
  jne    L9
  add    $0x8,%rsp
  ret
  xchg   %ax,%ax
L9:
  xor    %edi,%edi
  add    $0x8,%rsp
  jmp    1070 <reset_all_save@plt>
```

assistant: ```c
void menu_load_start(void) {
  if (menu_load(0, 1))
    reset_all_save(0);
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<register_chdir>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x130,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    D15(%rip),%rax
  mov    %rax,%rdi
  call   <getenv@plt>
  mov    %rax,-0x128(%rbp)
  lea    -0x110(%rbp),%rax
  mov    $0x100,%esi
  mov    %rax,%rdi
  call   <getcwd@plt>
  test   %eax,%eax
  jne    L8
  lea    D4(%rip),%rax
  mov    %rax,%rdi
  call   <error@plt>
  jmp    L10
L8:
  lea    -0x110(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  add    $0x6,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x120(%rbp)
  lea    -0x110(%rbp),%rdx
  mov    -0x120(%rbp),%rax
  lea    D10(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  cmpq   $0x0,-0x128(%rbp)
  je     L0
  mov    -0x128(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  add    $0x9,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x118(%rbp)
  mov    -0x128(%rbp),%rdx
  mov    -0x118(%rbp),%rax
  lea    D13(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  mov    -0x118(%rbp),%rax
  mov    %rax,%rdi
  call   <putenv@plt>
L0:
  mov    -0x120(%rbp),%rax
  mov    %rax,%rdi
  call   <putenv@plt>
L10:
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L24
  call   <__stack_chk_fail@plt>
L24:
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: data_tag: D15
type_infered: string
name: disassemble_data
arguments: data_tag: D4
type_infered: string
name: disassemble_data
arguments: data_tag: D10
type_infered: string
name: disassemble_data
arguments: data_tag: D13
type_infered: string

tool: D15: PWD

tool: D4: esh: cd: cannot read current directory.

tool: D10: PWD=%s

tool: D13: OLDPWD=%s

assistant: ```c
void register_chdir(void) {
  char *buff1;
  char *buff2;
  char *foo = getenv("PWD");
  char bar[256];
  if (!getcwd(bar, 256)) {
    error("esh: cd: cannot read current directory.");
    return;
  }
  buff2 = (char *)malloc(sizeof(char) * (strlen(bar) + 6));
  sprintf(buff2, "PWD=%s", bar);
  if (foo) {
    buff1 = (char *)malloc(sizeof(char) * (strlen(foo) + 9));
    sprintf(buff1, "OLDPWD=%s", foo);
    putenv(buff1);
  }
  putenv(buff2);
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<register_chdir>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x110,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x108(%rsp)
  xor    %eax,%eax
  lea    D31(%rip),%rdi
  call   <getenv@plt>
  mov    %rax,%rbx
  mov    %rsp,%rdi
  mov    $0x100,%esi
  call   <getcwd@plt>
  test   %eax,%eax
  je     L23
  mov    %rsp,%r12
  mov    %r12,%rdi
  call   <strlen@plt>
  lea    0x6(%rax),%edi
  call   <malloc@plt>
  mov    %rax,%rbp
  mov    %r12,%rdx
  lea    D38(%rip),%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  test   %rbx,%rbx
  je     L20
  mov    %rbx,%rdi
  call   <strlen@plt>
  lea    0x9(%rax),%edi
  call   <malloc@plt>
  mov    %rax,%r12
  mov    %rbx,%rdx
  lea    D30(%rip),%rsi
  mov    %rax,%rdi
  call   <sprintf@plt>
  mov    %r12,%rdi
  call   <putenv@plt>
L20:
  mov    %rbp,%rdi
  call   <putenv@plt>
L7:
  mov    0x108(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L0
  add    $0x110,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L23:
  lea    D5(%rip),%rdi
  call   <error@plt>
  jmp    L7
L0:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: data_tag: D31
type_guessed: string
name: parse_data
arguments: data_tag: D38
type_guessed: string
name: parse_data
arguments: data_tag: D30
type_guessed: string
name: parse_data
arguments: data_tag: D5
type_guessed: string

tool: D31: PWD

tool: D38: PWD=%s

tool: D30: OLDPWD=%s

tool: D5: esh: cd: cannot read current directory.

assistant: ```c
void register_chdir(void) {
  char *buff1;
  char *buff2;
  char *foo = getenv("PWD");
  char bar[256];
  if (!getcwd(bar, 256)) {
    error("esh: cd: cannot read current directory.");
    return;
  }
  buff2 = (char *)malloc(sizeof(char) * (strlen(bar) + 6));
  sprintf(buff2, "PWD=%s", bar);
  if (foo) {
    buff1 = (char *)malloc(sizeof(char) * (strlen(foo) + 9));
    sprintf(buff1, "OLDPWD=%s", foo);
    putenv(buff1);
  }
  putenv(buff2);
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<register_chdir>:
  endbr64
  push   %r13
  lea    D18(%rip),%rdi
  push   %r12
  push   %rbp
  sub    $0x110,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x108(%rsp)
  xor    %eax,%eax
  mov    %rsp,%r13
  call   <getenv@plt>
  mov    $0x100,%esi
  mov    %r13,%rdi
  mov    %rax,%r12
  call   <getcwd@plt>
  test   %eax,%eax
  je     L4
  mov    %r13,%rdi
  call   <strlen@plt>
  lea    0x6(%rax),%edi
  call   <malloc@plt>
  mov    %r13,%rdx
  lea    D11(%rip),%rsi
  mov    %rax,%rdi
  mov    %rax,%rbp
  call   <sprintf@plt>
  test   %r12,%r12
  je     L25
  mov    %r12,%rdi
  call   <strlen@plt>
  lea    0x9(%rax),%edi
  call   <malloc@plt>
  mov    %r12,%rdx
  lea    D29(%rip),%rsi
  mov    %rax,%r13
  mov    %rax,%rdi
  call   <sprintf@plt>
  mov    %r13,%rdi
  call   <putenv@plt>
L25:
  mov    %rbp,%rdi
  call   <putenv@plt>
L36:
  mov    0x108(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L18
  add    $0x110,%rsp
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L4:
  lea    D20(%rip),%rdi
  call   <error@plt>
  jmp    L36
L18:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: data_label: D18
type: string
name: parse_data
arguments: data_label: D11
type: string
name: parse_data
arguments: data_label: D29
type: string
name: parse_data
arguments: data_label: D20
type: string

tool: D18: PWD

tool: D11: PWD=%s

tool: D29: OLDPWD=%s

tool: D20: esh: cd: cannot read current directory.

assistant: ```c
void register_chdir(void) {
  char *buff1;
  char *buff2;
  char *foo = getenv("PWD");
  char bar[256];
  if (!getcwd(bar, 256)) {
    error("esh: cd: cannot read current directory.");
    return;
  }
  buff2 = (char *)malloc(sizeof(char) * (strlen(bar) + 6));
  sprintf(buff2, "PWD=%s", bar);
  if (foo) {
    buff1 = (char *)malloc(sizeof(char) * (strlen(foo) + 9));
    sprintf(buff1, "OLDPWD=%s", foo);
    putenv(buff1);
  }
  putenv(buff2);
}
```