ylfeng/ReF-Decompile-dataset huggingface dataset:
user: What is the c source code of the assembly code below?

```asm
<xrealloc>:
  endbr64
  push   %r12
  call   <realloc@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L19
L5:
  mov    %r12,%rax
  pop    %r12
  ret
L19:
  lea    D2(%rip),%rsi
  mov    $0x1,%edi
  call   <err@plt>
  jmp    L5
```

tool_calls: name: disassemble_data
arguments: label: D2
data_type: string

tool: D2: realloc() failed

assistant: ```c
void *xrealloc(void *p, size_t size) {
  void *ret = realloc(p, size);
  if (ret == NULL)
    err(1, "realloc() failed");
  return ret;
}
```
user: 这段汇编代码用C语言表示是什么样的?

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  lea    D4(%rip),%rax
  mov    %rax,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  mov    $0x1b6,%esi
  mov    %rax,%rdi
  call   <mkfifo@plt>
  mov    -0x8(%rbp),%rax
  mov    $0x1b6,%esi
  mov    %rax,%rdi
  call   <open@plt>
  mov    %eax,-0xc(%rbp)
  mov    -0xc(%rbp),%eax
  mov    $0x400,%edx
  lea    D5(%rip),%rcx
  mov    %rcx,%rsi
  mov    %eax,%edi
  call   <write@plt>
  mov    -0xc(%rbp),%eax
  mov    %eax,%edi
  call   <close@plt>
  mov    -0x8(%rbp),%rax
  mov    %rax,%rdi
  call   <unlink@plt>
  mov    $0x0,%eax
  leave
  ret
```

tool_calls: name: extract_symbolic_data
arguments: label: D4
type: string
name: extract_symbolic_data
arguments: label: D5
type: string

tool: D4: myfifo

tool: D5: Testing 123 !

assistant: ```c
int main() {
  int fd;
  char *fifo = "myfifo";
  mkfifo(fifo, 0666);
  fd = open(fifo, 0666);
  write(fd, "Testing 123 !", 1024);
  close(fd);
  unlink(fifo);
  return 0;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<main>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    $0x1b6,%esi
  lea    D5(%rip),%rbp
  mov    %rbp,%rdi
  call   <mkfifo@plt>
  mov    $0x1b6,%esi
  mov    %rbp,%rdi
  call   <open@plt>
  mov    %eax,%ebx
  mov    $0x400,%edx
  lea    D19(%rip),%rsi
  mov    %eax,%edi
  call   <write@plt>
  mov    %ebx,%edi
  call   <close@plt>
  mov    %rbp,%rdi
  call   <unlink@plt>
  mov    $0x0,%eax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
```

tool_calls: name: unpack_data
arguments: data_tag: D5
datatype: string
name: unpack_data
arguments: data_tag: D19
datatype: string

tool: D5: myfifo

tool: D19: Testing 123 !

assistant: ```c
int main() {
  int fd;
  char *fifo = "myfifo";
  mkfifo(fifo, 0666);
  fd = open(fifo, 0666);
  write(fd, "Testing 123 !", 1024);
  close(fd);
  unlink(fifo);
  return 0;
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<main>:
  endbr64
  push   %r12
  lea    D4(%rip),%r12
  mov    $0x1b6,%esi
  push   %rbp
  mov    %r12,%rdi
  sub    $0x8,%rsp
  call   <mkfifo@plt>
  mov    %r12,%rdi
  mov    $0x1b6,%esi
  call   <open@plt>
  mov    $0x400,%edx
  lea    D10(%rip),%rsi
  mov    %eax,%ebp
  mov    %eax,%edi
  call   <write@plt>
  mov    %ebp,%edi
  call   <close@plt>
  mov    %r12,%rdi
  call   <unlink@plt>
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbp
  pop    %r12
  ret
```

tool_calls: name: disassemble_data
arguments: data_label: D4
type: string
name: disassemble_data
arguments: data_label: D10
type: string

tool: D4: myfifo

tool: D10: Testing 123 !

assistant: ```c
int main() {
  int fd;
  char *fifo = "myfifo";
  mkfifo(fifo, 0666);
  fd = open(fifo, 0666);
  write(fd, "Testing 123 !", 1024);
  close(fd);
  unlink(fifo);
  return 0;
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<main>:
  endbr64
  push   %r12
  lea    D6(%rip),%r12
  mov    $0x1b6,%esi
  push   %rbp
  mov    %r12,%rdi
  sub    $0x8,%rsp
  call   <mkfifo@plt>
  mov    %r12,%rdi
  mov    $0x1b6,%esi
  call   <open@plt>
  mov    $0x400,%edx
  lea    D2(%rip),%rsi
  mov    %eax,%ebp
  mov    %eax,%edi
  call   <write@plt>
  mov    %ebp,%edi
  call   <close@plt>
  mov    %r12,%rdi
  call   <unlink@plt>
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbp
  pop    %r12
  ret
```

tool_calls: name: retrieve_data
arguments: tag: D6
type_guessed: string
name: retrieve_data
arguments: tag: D2
type_guessed: string

tool: D6: myfifo

tool: D2: Testing 123 !

assistant: ```c
int main() {
  int fd;
  char *fifo = "myfifo";
  mkfifo(fifo, 0666);
  fd = open(fifo, 0666);
  write(fd, "Testing 123 !", 1024);
  close(fd);
  unlink(fifo);
  return 0;
}
```
user: What is the c source code of the assembly code below?

```asm
<ic_parse_decl_func>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  movq   $0x0,-0x8(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  jne    L17
  lea    D4(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    $0x0,%eax
  jmp    L16
L17:
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <ic_parse_decl_func_header@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L20
  lea    D19(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    $0x0,%eax
  jmp    L16
L20:
  mov    -0x8(%rbp),%rdx
  mov    -0x18(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <ic_parse_decl_func_body@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L13
  lea    D15(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  mov    $0x0,%eax
  jmp    L16
L13:
  mov    -0x8(%rbp),%rax
L16:
  leave
  ret
```

tool_calls: name: unpack_data
arguments: data_label: D4
type_infered: string
name: unpack_data
arguments: data_label: D19
type_infered: string
name: unpack_data
arguments: data_label: D15
type_infered: string

tool: D4: ic_parse_decl_func: token_list was null

tool: D19: ic_parse_decl_func: call to ic_parse_decl_func_header failed

tool: D15: ic_parse_decl_func: call to ic_parse_decl_func_body failed

assistant: ```c
struct ic_decl *ic_parse_decl_func(struct ic_token_list *token_list) {
  struct ic_decl *decl = 0;
  if (!token_list) {
    puts("ic_parse_decl_func: token_list was null");
    return 0;
  }
  decl = ic_parse_decl_func_header(token_list);
  if (!decl) {
    puts("ic_parse_decl_func: call to ic_parse_decl_func_header failed");
    return 0;
  }
  decl = ic_parse_decl_func_body(token_list, decl);
  if (!decl) {
    puts("ic_parse_decl_func: call to ic_parse_decl_func_body failed");
    return 0;
  }
  return decl;
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<ic_parse_decl_func>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%rbp
  test   %rdi,%rdi
  je     L24
  call   <ic_parse_decl_func_header@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L47
  mov    %rax,%rsi
  mov    %rbp,%rdi
  call   <ic_parse_decl_func_body@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L25
L2:
  mov    %rbx,%rax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
L24:
  lea    D16(%rip),%rdi
  call   <puts@plt>
  mov    %rbp,%rbx
  jmp    L2
L47:
  lea    D12(%rip),%rdi
  call   <puts@plt>
  jmp    L2
L25:
  lea    D26(%rip),%rdi
  call   <puts@plt>
  jmp    L2
```

tool_calls: name: disassemble_data
arguments: label: D16
datatype: string
name: disassemble_data
arguments: label: D12
datatype: string
name: disassemble_data
arguments: label: D26
datatype: string

tool: D16: ic_parse_decl_func: token_list was null

tool: D12: ic_parse_decl_func: call to ic_parse_decl_func_header failed

tool: D26: ic_parse_decl_func: call to ic_parse_decl_func_body failed

assistant: ```c
struct ic_decl *ic_parse_decl_func(struct ic_token_list *token_list) {
  struct ic_decl *decl = 0;
  if (!token_list) {
    puts("ic_parse_decl_func: token_list was null");
    return 0;
  }
  decl = ic_parse_decl_func_header(token_list);
  if (!decl) {
    puts("ic_parse_decl_func: call to ic_parse_decl_func_header failed");
    return 0;
  }
  decl = ic_parse_decl_func_body(token_list, decl);
  if (!decl) {
    puts("ic_parse_decl_func: call to ic_parse_decl_func_body failed");
    return 0;
  }
  return decl;
}
```
user: Translate the below assembly code into C programming language:

```asm
<ic_parse_decl_func>:
  endbr64
  push   %r12
  push   %rbp
  sub    $0x8,%rsp
  test   %rdi,%rdi
  je     L4
  mov    %rdi,%rbp
  call   <ic_parse_decl_func_header@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L14
  mov    %rax,%rsi
  mov    %rbp,%rdi
  call   <ic_parse_decl_func_body@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L44
L11:
  add    $0x8,%rsp
  mov    %r12,%rax
  pop    %rbp
  pop    %r12
  ret
  xchg   %ax,%ax
L4:
  lea    D3(%rip),%rdi
  xor    %r12d,%r12d
  call   <puts@plt>
  jmp    L11
  nopl   0x0(%rax)
L14:
  lea    D12(%rip),%rdi
  call   <puts@plt>
  jmp    L11
  cs nopw 0x0(%rax,%rax,1)
L44:
  lea    D16(%rip),%rdi
  call   <puts@plt>
  jmp    L11
```

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

tool: D3: ic_parse_decl_func: token_list was null

tool: D12: ic_parse_decl_func: call to ic_parse_decl_func_header failed

tool: D16: ic_parse_decl_func: call to ic_parse_decl_func_body failed

assistant: ```c
struct ic_decl *ic_parse_decl_func(struct ic_token_list *token_list) {
  struct ic_decl *decl = 0;
  if (!token_list) {
    puts("ic_parse_decl_func: token_list was null");
    return 0;
  }
  decl = ic_parse_decl_func_header(token_list);
  if (!decl) {
    puts("ic_parse_decl_func: call to ic_parse_decl_func_header failed");
    return 0;
  }
  decl = ic_parse_decl_func_body(token_list, decl);
  if (!decl) {
    puts("ic_parse_decl_func: call to ic_parse_decl_func_body failed");
    return 0;
  }
  return decl;
}
```
user: 这段汇编代码用C语言表示是什么样的?

```asm
<ic_parse_decl_func>:
  endbr64
  push   %r12
  push   %rbp
  sub    $0x8,%rsp
  test   %rdi,%rdi
  je     L56
  mov    %rdi,%rbp
  call   <ic_parse_decl_func_header@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L25
  mov    %rax,%rsi
  mov    %rbp,%rdi
  call   <ic_parse_decl_func_body@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L9
L41:
  add    $0x8,%rsp
  mov    %r12,%rax
  pop    %rbp
  pop    %r12
  ret
  xchg   %ax,%ax
L56:
  lea    D5(%rip),%rdi
  xor    %r12d,%r12d
  call   <puts@plt>
  jmp    L41
  nopl   0x0(%rax)
L25:
  lea    D22(%rip),%rdi
  call   <puts@plt>
  jmp    L41
  cs nopw 0x0(%rax,%rax,1)
L9:
  lea    D0(%rip),%rdi
  call   <puts@plt>
  jmp    L41
```

tool_calls: name: read_data
arguments: label: D5
data_type: string
name: read_data
arguments: label: D22
data_type: string
name: read_data
arguments: label: D0
data_type: string

tool: D5: ic_parse_decl_func: token_list was null

tool: D22: ic_parse_decl_func: call to ic_parse_decl_func_header failed

tool: D0: ic_parse_decl_func: call to ic_parse_decl_func_body failed

assistant: ```c
struct ic_decl *ic_parse_decl_func(struct ic_token_list *token_list) {
  struct ic_decl *decl = 0;
  if (!token_list) {
    puts("ic_parse_decl_func: token_list was null");
    return 0;
  }
  decl = ic_parse_decl_func_header(token_list);
  if (!decl) {
    puts("ic_parse_decl_func: call to ic_parse_decl_func_header failed");
    return 0;
  }
  decl = ic_parse_decl_func_body(token_list, decl);
  if (!decl) {
    puts("ic_parse_decl_func: call to ic_parse_decl_func_body failed");
    return 0;
  }
  return decl;
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<test_two>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %edi,-0x14(%rbp)
  mov    %esi,-0x18(%rbp)
  movl   $0x0,-0x8(%rbp)
  jmp    L16
L24:
  movl   $0x0,-0x4(%rbp)
  jmp    L0
L8:
  addl   $0x1,-0x4(%rbp)
L0:
  mov    -0x4(%rbp),%eax
  cmp    -0x18(%rbp),%eax
  jl     L8
  addl   $0x1,-0x8(%rbp)
L16:
  mov    -0x8(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jl     L24
  nop
  nop
  pop    %rbp
  ret
```

assistant: ```c
void test_two(int x, int y) {
#pragma omp target parallel for simd
  for (int i = 0; i < x; i++)
    for (int i = 0; i < y; i++)
      ;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<test_two>:
  endbr64
  mov    $0x0,%edx
  test   %edi,%edi
  jg     L25
  ret
L11:
  add    $0x1,%eax
  cmp    %eax,%esi
  jne    L11
L6:
  add    $0x1,%edx
  cmp    %edx,%edi
  je     L29
L25:
  mov    $0x0,%eax
  test   %esi,%esi
  jg     L11
  jmp    L6
L29:
  ret
```

assistant: ```c
void test_two(int x, int y) {
#pragma omp target parallel for simd
  for (int i = 0; i < x; i++)
    for (int i = 0; i < y; i++)
      ;
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<test_two>:
  endbr64
  ret
```

assistant: ```c
void test_two(int x, int y) {
#pragma omp target parallel for simd
  for (int i = 0; i < x; i++)
    for (int i = 0; i < y; i++)
      ;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<test_two>:
  endbr64
  ret
```

assistant: ```c
void test_two(int x, int y) {
#pragma omp target parallel for simd
  for (int i = 0; i < x; i++)
    for (int i = 0; i < y; i++)
      ;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<mp2vstart_init>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x8(%rbp)
  mov    %esi,-0xc(%rbp)
  mov    -0x8(%rbp),%rax
  movl   $0x0,(%rax)
  mov    -0x8(%rbp),%rax
  add    $0x4,%rax
  movl   $0x0,(%rax)
  mov    -0x8(%rbp),%rax
  add    $0x8,%rax
  movl   $0x1,(%rax)
  mov    -0x8(%rbp),%rax
  lea    0xc(%rax),%rdx
  mov    -0xc(%rbp),%eax
  mov    %eax,(%rdx)
  nop
  pop    %rbp
  ret
```

assistant: ```c
void mp2vstart_init(uint8_t *p_mp2vstart, uint8_t startcode) {
  p_mp2vstart[0] = 0x0;
  p_mp2vstart[1] = 0x0;
  p_mp2vstart[2] = 0x1;
  p_mp2vstart[3] = startcode;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<mp2vstart_init>:
  endbr64
  movl   $0x0,(%rdi)
  movl   $0x0,0x4(%rdi)
  movl   $0x1,0x8(%rdi)
  mov    %esi,0xc(%rdi)
  ret
```

assistant: ```c
void mp2vstart_init(uint8_t *p_mp2vstart, uint8_t startcode) {
  p_mp2vstart[0] = 0x0;
  p_mp2vstart[1] = 0x0;
  p_mp2vstart[2] = 0x1;
  p_mp2vstart[3] = startcode;
}
```
user: 这段汇编代码用C语言表示是什么样的:

```asm
<mp2vstart_init>:
  endbr64
  movq   $0x0,(%rdi)
  movl   $0x1,0x8(%rdi)
  mov    %esi,0xc(%rdi)
  ret
```

assistant: ```c
void mp2vstart_init(uint8_t *p_mp2vstart, uint8_t startcode) {
  p_mp2vstart[0] = 0x0;
  p_mp2vstart[1] = 0x0;
  p_mp2vstart[2] = 0x1;
  p_mp2vstart[3] = startcode;
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<mp2vstart_init>:
  endbr64
  movq   $0x0,(%rdi)
  movl   $0x1,0x8(%rdi)
  mov    %esi,0xc(%rdi)
  ret
```

assistant: ```c
void mp2vstart_init(uint8_t *p_mp2vstart, uint8_t startcode) {
  p_mp2vstart[0] = 0x0;
  p_mp2vstart[1] = 0x0;
  p_mp2vstart[2] = 0x1;
  p_mp2vstart[3] = startcode;
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<os_file_rename>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  cmpq   $0x0,-0x18(%rbp)
  je     L73
  cmpq   $0x0,-0x20(%rbp)
  jne    L34
L73:
  mov    D98(%rip),%rax
  mov    (%rax),%eax
  neg    %eax
  jmp    L127
L34:
  lea    -0x10(%rbp),%rdx
  mov    -0x18(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <stat@plt>
  test   %rax,%rax
  je     L1
  mov    D4(%rip),%rax
  mov    (%rax),%eax
  neg    %eax
  jmp    L127
L1:
  mov    -0x10(%rbp),%eax
  mov    %eax,%edi
  call   <S_ISDIR@plt>
  test   %rax,%rax
  je     L64
  mov    D58(%rip),%rax
  mov    (%rax),%eax
  neg    %eax
  jmp    L127
L64:
  lea    -0xc(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <stat@plt>
  test   %rax,%rax
  je     L151
  mov    D4(%rip),%rax
  mov    (%rax),%edx
  mov    D53(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,%edx
  je     L151
  mov    D4(%rip),%rax
  mov    (%rax),%eax
  neg    %eax
  jmp    L127
L151:
  mov    D4(%rip),%rax
  mov    (%rax),%edx
  mov    D53(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,%edx
  je     L49
  mov    -0xc(%rbp),%eax
  mov    %eax,%edi
  call   <S_ISDIR@plt>
  test   %rax,%rax
  je     L49
  mov    D58(%rip),%rax
  mov    (%rax),%eax
  neg    %eax
  jmp    L127
L49:
  mov    -0x20(%rbp),%rdx
  mov    -0x18(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <rename@plt>
  test   %rax,%rax
  je     L18
  mov    D4(%rip),%rax
  mov    (%rax),%eax
  neg    %eax
  jmp    L127
L18:
  mov    $0x0,%eax
L127:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L21
  call   <__stack_chk_fail@plt>
L21:
  leave
  ret
```

assistant: ```c
int os_file_rename(const char *src, const char *dest) {
  struct stat src_stat, dest_stat;
  if (src == NULL || dest == NULL)
    return -EINVAL;
  if (stat(src, &src_stat) != 0)
    return -errno;
  if (S_ISDIR(src_stat.st_mode))
    return -EISDIR;
  if (stat(dest, &dest_stat) != 0 && errno != ENOENT)
    return -errno;
  if (errno != ENOENT && S_ISDIR(dest_stat.st_mode))
    return -EISDIR;
  if (rename(src, dest) != 0)
    return -errno;
  return 0;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<os_file_rename>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  test   %rdi,%rdi
  je     L26
  mov    %rdi,%rbx
  mov    %rsi,%rbp
  test   %rsi,%rsi
  je     L26
  mov    %rsp,%rsi
  call   <stat@plt>
  test   %rax,%rax
  je     L65
  mov    D79(%rip),%rax
  mov    (%rax),%eax
  neg    %eax
  jmp    L34
L26:
  mov    D3(%rip),%rax
  mov    (%rax),%eax
  neg    %eax
L34:
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L62
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  ret
L65:
  mov    (%rsp),%edi
  call   <S_ISDIR@plt>
  test   %rax,%rax
  je     L57
  mov    D55(%rip),%rax
  mov    (%rax),%eax
  neg    %eax
  jmp    L34
L57:
  lea    0x4(%rsp),%rsi
  mov    %rbp,%rdi
  call   <stat@plt>
  test   %rax,%rax
  je     L116
  mov    D79(%rip),%rax
  mov    (%rax),%eax
  mov    D83(%rip),%rdx
  cmp    (%rdx),%eax
  je     L29
  neg    %eax
  jmp    L34
L116:
  mov    D79(%rip),%rdx
  mov    D83(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,(%rdx)
  je     L29
  mov    0x4(%rsp),%edi
  call   <S_ISDIR@plt>
  test   %rax,%rax
  jne    L101
L29:
  mov    %rbp,%rsi
  mov    %rbx,%rdi
  call   <rename@plt>
  mov    %rax,%rdx
  mov    $0x0,%eax
  test   %rdx,%rdx
  je     L34
  mov    D79(%rip),%rax
  mov    (%rax),%eax
  neg    %eax
  jmp    L34
L101:
  mov    D55(%rip),%rax
  mov    (%rax),%eax
  neg    %eax
  jmp    L34
L62:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int os_file_rename(const char *src, const char *dest) {
  struct stat src_stat, dest_stat;
  if (src == NULL || dest == NULL)
    return -EINVAL;
  if (stat(src, &src_stat) != 0)
    return -errno;
  if (S_ISDIR(src_stat.st_mode))
    return -EISDIR;
  if (stat(dest, &dest_stat) != 0 && errno != ENOENT)
    return -errno;
  if (errno != ENOENT && S_ISDIR(dest_stat.st_mode))
    return -EISDIR;
  if (rename(src, dest) != 0)
    return -errno;
  return 0;
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<os_file_rename>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  test   %rdi,%rdi
  je     L76
  mov    %rsi,%r12
  test   %rsi,%rsi
  je     L76
  mov    %rsp,%rsi
  mov    %rdi,%rbp
  call   <stat@plt>
  test   %rax,%rax
  je     L62
  mov    D20(%rip),%rax
  mov    (%rax),%eax
  neg    %eax
  jmp    L83
  cs nopw 0x0(%rax,%rax,1)
L76:
  mov    D43(%rip),%rax
  mov    (%rax),%eax
  neg    %eax
L83:
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L78
  add    $0x10,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax,%rax,1)
L62:
  mov    (%rsp),%edi
  call   <S_ISDIR@plt>
  test   %rax,%rax
  je     L73
L33:
  mov    D28(%rip),%rax
  mov    (%rax),%eax
  neg    %eax
  jmp    L83
  nopw   0x0(%rax,%rax,1)
L73:
  lea    0x4(%rsp),%rsi
  mov    %r12,%rdi
  call   <stat@plt>
  mov    D20(%rip),%rbx
  test   %rax,%rax
  je     L131
  mov    D15(%rip),%rdx
  mov    (%rbx),%eax
  cmp    (%rdx),%eax
  je     L112
  neg    %eax
  jmp    L83
  nopw   0x0(%rax,%rax,1)
L131:
  mov    D15(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,(%rbx)
  je     L112
  mov    0x4(%rsp),%edi
  call   <S_ISDIR@plt>
  test   %rax,%rax
  jne    L33
L112:
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <rename@plt>
  mov    %rax,%r8
  xor    %eax,%eax
  test   %r8,%r8
  je     L83
  mov    (%rbx),%eax
  neg    %eax
  jmp    L83
L78:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int os_file_rename(const char *src, const char *dest) {
  struct stat src_stat, dest_stat;
  if (src == NULL || dest == NULL)
    return -EINVAL;
  if (stat(src, &src_stat) != 0)
    return -errno;
  if (S_ISDIR(src_stat.st_mode))
    return -EISDIR;
  if (stat(dest, &dest_stat) != 0 && errno != ENOENT)
    return -errno;
  if (errno != ENOENT && S_ISDIR(dest_stat.st_mode))
    return -EISDIR;
  if (rename(src, dest) != 0)
    return -errno;
  return 0;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<os_file_rename>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  test   %rdi,%rdi
  je     L95
  mov    %rsi,%r12
  test   %rsi,%rsi
  je     L95
  mov    %rsp,%rsi
  mov    %rdi,%rbp
  call   <stat@plt>
  test   %rax,%rax
  je     L79
  mov    D22(%rip),%rax
  mov    (%rax),%eax
  neg    %eax
  jmp    L60
  cs nopw 0x0(%rax,%rax,1)
L95:
  mov    D39(%rip),%rax
  mov    (%rax),%eax
  neg    %eax
L60:
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L57
  add    $0x10,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopl   0x0(%rax,%rax,1)
L79:
  mov    (%rsp),%edi
  call   <S_ISDIR@plt>
  test   %rax,%rax
  je     L93
L124:
  mov    D15(%rip),%rax
  mov    (%rax),%eax
  neg    %eax
  jmp    L60
  nopw   0x0(%rax,%rax,1)
L93:
  lea    0x4(%rsp),%rsi
  mov    %r12,%rdi
  call   <stat@plt>
  mov    D22(%rip),%rbx
  test   %rax,%rax
  je     L15
  mov    D24(%rip),%rdx
  mov    (%rbx),%eax
  cmp    (%rdx),%eax
  je     L101
  neg    %eax
  jmp    L60
  nopw   0x0(%rax,%rax,1)
L15:
  mov    D24(%rip),%rax
  mov    (%rax),%eax
  cmp    %eax,(%rbx)
  je     L101
  mov    0x4(%rsp),%edi
  call   <S_ISDIR@plt>
  test   %rax,%rax
  jne    L124
L101:
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <rename@plt>
  mov    %rax,%r8
  xor    %eax,%eax
  test   %r8,%r8
  je     L60
  mov    (%rbx),%eax
  neg    %eax
  jmp    L60
L57:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int os_file_rename(const char *src, const char *dest) {
  struct stat src_stat, dest_stat;
  if (src == NULL || dest == NULL)
    return -EINVAL;
  if (stat(src, &src_stat) != 0)
    return -errno;
  if (S_ISDIR(src_stat.st_mode))
    return -EISDIR;
  if (stat(dest, &dest_stat) != 0 && errno != ENOENT)
    return -errno;
  if (errno != ENOENT && S_ISDIR(dest_stat.st_mode))
    return -EISDIR;
  if (rename(src, dest) != 0)
    return -errno;
  return 0;
}
```