ylfeng/ReF-Decompile-dataset huggingface dataset:
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<HTTP_OK2>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%r12
  mov    %rsi,%rbx
  mov    %edx,%r13d
  mov    (%rsi),%eax
  test   %eax,%eax
  je     L112
  mov    $0x0,%eax
L47:
  add    $0x1,%eax
  mov    %eax,%edx
  cmpl   $0x0,(%rbx,%rdx,4)
  jne    L47
L112:
  lea    0x5(%rax),%edi
  cmp    $0x9,%r13d
  jbe    L36
  lea    0x6(%rax),%edi
  cmp    $0x63,%r13d
  jbe    L36
  lea    0x7(%rax),%edi
L36:
  cmp    $0x3e7,%r13d
  jbe    L108
  add    $0x1,%edi
  mov    $0x0,%eax
  call   <put_socket@plt>
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <socket_put_string@plt>
  mov    %r13d,%edi
  mov    $0x0,%eax
  call   <socket_put_decimal@plt>
  lea    D11(%rip),%rdi
  mov    $0x0,%eax
  call   <socket_put_string@plt>
  mov    $0x0,%eax
  call   <socket_flush@plt>
  mov    $0x20b,%ebp
  cmp    $0x415,%r13d
  jbe    L99
L115:
  lea    -0x20b(%rbp),%ebx
  sub    $0x416,%r13d
  mov    $0x416,%edi
  mov    $0x0,%eax
  call   <put_socket@plt>
L91:
  mov    %ebx,%eax
  mov    (%r12,%rax,4),%edi
  mov    $0x0,%eax
  call   <put_socket@plt>
  add    $0x1,%ebx
  cmp    %ebx,%ebp
  jne    L91
  add    $0x20b,%ebp
  cmp    $0x415,%r13d
  ja     L115
L70:
  mov    %r13d,%edi
  mov    $0x0,%eax
  call   <put_socket@plt>
  shr    %r13d
  je     L8
L24:
  mov    $0x0,%ebp
L28:
  lea    (%rbx,%rbp,1),%eax
  mov    (%r12,%rax,4),%edi
  mov    $0x0,%eax
  call   <put_socket@plt>
  add    $0x1,%ebp
  cmp    %r13d,%ebp
  jb     L28
L8:
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L108:
  mov    $0x0,%eax
  call   <put_socket@plt>
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <socket_put_string@plt>
  mov    %r13d,%edi
  mov    $0x0,%eax
  call   <socket_put_decimal@plt>
  lea    D11(%rip),%rdi
  mov    $0x0,%eax
  call   <socket_put_string@plt>
  mov    $0x0,%eax
  call   <socket_flush@plt>
  mov    $0x0,%ebx
  jmp    L70
L99:
  mov    %r13d,%edi
  mov    $0x0,%eax
  call   <put_socket@plt>
  shr    %r13d
  mov    $0x0,%ebx
  jmp    L24
```

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

tool: D11: 



assistant: ```c
void HTTP_OK2(unsigned body[], unsigned header[], unsigned body_length) {
  unsigned header_length;
  unsigned cnt;
  unsigned length, index, packet_count;
  header_length = 0;
  while (header[header_length])
    header_length++;
  length = header_length + 5;
  if (body_length > 9)
    length++;
  if (body_length > 99)
    length++;
  if (body_length > 999)
    length++;
  put_socket(length);
  socket_put_string(header);
  socket_put_decimal(body_length);
  socket_put_string("\r\n\r\n");
  socket_flush();
  length = body_length;
  index = 0;
  packet_count = 0;
  while (length >= 1046) {
    length -= 1046;
    put_socket(1046);
    for (packet_count = 0; packet_count < 523; packet_count++) {
      put_socket(body[index]);
      index++;
    }
  }
  put_socket(length);
  for (packet_count = 0; packet_count < (length >> 1); packet_count++) {
    put_socket(body[index]);
    index++;
  }
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<client_start>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  mov    -0x1c(%rbp),%edx
  mov    -0x18(%rbp),%rax
  mov    %edx,%esi
  mov    %rax,%rdi
  call   <socket_connect@plt>
  mov    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  mov    %eax,%edi
  call   <main_loop@plt>
  nop
  leave
  ret
```

assistant: ```c
void client_start(char *ip, int port) {
  int fd_socket = socket_connect(ip, port);
  main_loop(fd_socket);
}
```
user: What is the c source code of the assembly code below:

```asm
<client_start>:
  endbr64
  sub    $0x8,%rsp
  call   <socket_connect@plt>
  mov    %eax,%edi
  call   <main_loop@plt>
  add    $0x8,%rsp
  ret
```

assistant: ```c
void client_start(char *ip, int port) {
  int fd_socket = socket_connect(ip, port);
  main_loop(fd_socket);
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<client_start>:
  endbr64
  sub    $0x8,%rsp
  call   <socket_connect@plt>
  add    $0x8,%rsp
  mov    %eax,%edi
  jmp    1060 <main_loop@plt>
```

assistant: ```c
void client_start(char *ip, int port) {
  int fd_socket = socket_connect(ip, port);
  main_loop(fd_socket);
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<client_start>:
  endbr64
  sub    $0x8,%rsp
  call   <socket_connect@plt>
  add    $0x8,%rsp
  mov    %eax,%edi
  jmp    1060 <main_loop@plt>
```

assistant: ```c
void client_start(char *ip, int port) {
  int fd_socket = socket_connect(ip, port);
  main_loop(fd_socket);
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<f2>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  movsd  %xmm0,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  mov    $0x2,%edi
  movq   %rax,%xmm0
  call   <pow@plt>
  movq   %xmm0,%rax
  movsd  D1(%rip),%xmm1
  movq   %rax,%xmm0
  subsd  %xmm1,%xmm0
  movsd  %xmm0,-0x8(%rbp)
  movsd  -0x8(%rbp),%xmm0
  movq   %xmm0,%rax
  movq   %rax,%xmm0
  leave
  ret
```

tool_calls: name: extract_symbolic_data
arguments: data_tag: D1
type: f64

tool: D1: 2

assistant: ```c
double f2(double x) {
  double y = pow(x, 2) - 2.0;
  return y;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<f2>:
  endbr64
  sub    $0x8,%rsp
  mov    $0x2,%edi
  call   <pow@plt>
  subsd  D5(%rip),%xmm0
  add    $0x8,%rsp
  ret
```

tool_calls: name: unpack_data
arguments: label: D5
data_type: f64

tool: D5: 2

assistant: ```c
double f2(double x) {
  double y = pow(x, 2) - 2.0;
  return y;
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<f2>:
  endbr64
  sub    $0x8,%rsp
  mov    $0x2,%edi
  call   <pow@plt>
  subsd  D7(%rip),%xmm0
  add    $0x8,%rsp
  ret
```

tool_calls: name: parse_data
arguments: label: D7
type_guessed: f64

tool: D7: 2

assistant: ```c
double f2(double x) {
  double y = pow(x, 2) - 2.0;
  return y;
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<f2>:
  endbr64
  sub    $0x8,%rsp
  mov    $0x2,%edi
  call   <pow@plt>
  subsd  D4(%rip),%xmm0
  add    $0x8,%rsp
  ret
```

tool_calls: name: retrieve_data
arguments: data_tag: D4
type_infered: f64

tool: D4: 2

assistant: ```c
double f2(double x) {
  double y = pow(x, 2) - 2.0;
  return y;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<print_solution>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,-0x1c(%rbp)
  lea    D10(%rip),%rax
  mov    %rax,%rdi
  call   <puts@plt>
  movl   $0x0,-0x4(%rbp)
  jmp    L3
L12:
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,4),%rdx
  mov    -0x18(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%edx
  mov    -0x4(%rbp),%eax
  mov    %eax,%esi
  lea    D4(%rip),%rax
  mov    %rax,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  addl   $0x1,-0x4(%rbp)
L3:
  cmpl   $0x8,-0x4(%rbp)
  jle    L12
  nop
  nop
  leave
  ret
```

tool_calls: name: unpack_data
arguments: data_label: D10
type_guessed: string
name: unpack_data
arguments: data_label: D4
type_guessed: string

tool: D10: Vertex 		 Distance from initial node

tool: D4: %d 		 %d


assistant: ```c
void print_solution(int dist[], int n) {
  printf("Vertex \t\t Distance from initial node\n");
  for (int i = 0; i < 9; i++)
    printf("%d \t\t %d\n", i, dist[i]);
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<print_solution>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbp
  lea    D8(%rip),%rdi
  call   <puts@plt>
  mov    $0x0,%ebx
  lea    D6(%rip),%r12
L8:
  mov    0x0(%rbp,%rbx,4),%edx
  mov    %ebx,%esi
  mov    %r12,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  add    $0x1,%rbx
  cmp    $0x9,%rbx
  jne    L8
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

tool_calls: name: parse_data
arguments: data_label: D8
type_guessed: string
name: parse_data
arguments: data_label: D6
type_guessed: string

tool: D8: Vertex 		 Distance from initial node

tool: D6: %d 		 %d


assistant: ```c
void print_solution(int dist[], int n) {
  printf("Vertex \t\t Distance from initial node\n");
  for (int i = 0; i < 9; i++)
    printf("%d \t\t %d\n", i, dist[i]);
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<print_solution>:
  endbr64
  push   %r12
  lea    D5(%rip),%r12
  push   %rbp
  mov    %rdi,%rbp
  lea    D2(%rip),%rdi
  push   %rbx
  xor    %ebx,%ebx
  call   <puts@plt>
L6:
  mov    0x0(%rbp,%rbx,4),%edx
  mov    %ebx,%esi
  mov    %r12,%rdi
  xor    %eax,%eax
  add    $0x1,%rbx
  call   <printf@plt>
  cmp    $0x9,%rbx
  jne    L6
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

tool_calls: name: unpack_data
arguments: label: D5
datatype: string
name: unpack_data
arguments: label: D2
datatype: string

tool: D5: %d 		 %d


tool: D2: Vertex 		 Distance from initial node

assistant: ```c
void print_solution(int dist[], int n) {
  printf("Vertex \t\t Distance from initial node\n");
  for (int i = 0; i < 9; i++)
    printf("%d \t\t %d\n", i, dist[i]);
}
```
user: What is the c source code of the assembly code below?

```asm
<print_solution>:
  endbr64
  push   %r12
  lea    D4(%rip),%r12
  push   %rbp
  mov    %rdi,%rbp
  lea    D11(%rip),%rdi
  push   %rbx
  xor    %ebx,%ebx
  call   <puts@plt>
L0:
  mov    0x0(%rbp,%rbx,4),%edx
  mov    %ebx,%esi
  mov    %r12,%rdi
  xor    %eax,%eax
  add    $0x1,%rbx
  call   <printf@plt>
  cmp    $0x9,%rbx
  jne    L0
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

tool_calls: name: retrieve_data
arguments: data_label: D4
type: string
name: retrieve_data
arguments: data_label: D11
type: string

tool: D4: %d 		 %d


tool: D11: Vertex 		 Distance from initial node

assistant: ```c
void print_solution(int dist[], int n) {
  printf("Vertex \t\t Distance from initial node\n");
  for (int i = 0; i < 9; i++)
    printf("%d \t\t %d\n", i, dist[i]);
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<rop3_86_1_0>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  mov    %rdi,-0x18(%rbp)
  mov    %esi,%ecx
  mov    %edx,%eax
  mov    %ecx,%edx
  mov    %dl,-0x1c(%rbp)
  mov    %al,-0x20(%rbp)
  movzbl -0x20(%rbp),%eax
  or     -0x1c(%rbp),%al
  mov    %al,-0x2(%rbp)
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  xor    -0x2(%rbp),%al
  mov    %al,-0x1(%rbp)
  movzbl -0x1c(%rbp),%eax
  not    %eax
  mov    %eax,%edx
  movzbl -0x1(%rbp),%eax
  and    %eax,%edx
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  and    -0x1c(%rbp),%al
  or     %edx,%eax
  mov    %eax,%edx
  mov    -0x18(%rbp),%rax
  mov    %dl,(%rax)
  nop
  pop    %rbp
  ret
```

assistant: ```c
void rop3_86_1_0(unsigned char *D, unsigned char S, unsigned char T) {
  unsigned char stk1;
  unsigned char stk2;
  stk2 = T | S;
  stk1 = *D ^ stk2;
  *D = (stk1 & (~S)) | (*D & S);
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<rop3_86_1_0>:
  endbr64
  or     %esi,%edx
  xor    (%rdi),%dl
  mov    %esi,%eax
  not    %eax
  and    %eax,%edx
  mov    %esi,%eax
  and    (%rdi),%al
  or     %eax,%edx
  mov    %dl,(%rdi)
  ret
```

assistant: ```c
void rop3_86_1_0(unsigned char *D, unsigned char S, unsigned char T) {
  unsigned char stk1;
  unsigned char stk2;
  stk2 = T | S;
  stk1 = *D ^ stk2;
  *D = (stk1 & (~S)) | (*D & S);
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<rop3_86_1_0>:
  endbr64
  mov    %esi,%eax
  or     %esi,%edx
  xor    (%rdi),%dl
  not    %eax
  and    %eax,%edx
  movzbl (%rdi),%eax
  and    %esi,%eax
  or     %eax,%edx
  mov    %dl,(%rdi)
  ret
```

assistant: ```c
void rop3_86_1_0(unsigned char *D, unsigned char S, unsigned char T) {
  unsigned char stk1;
  unsigned char stk2;
  stk2 = T | S;
  stk1 = *D ^ stk2;
  *D = (stk1 & (~S)) | (*D & S);
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<rop3_86_1_0>:
  endbr64
  mov    %esi,%eax
  or     %esi,%edx
  xor    (%rdi),%dl
  not    %eax
  and    %eax,%edx
  movzbl (%rdi),%eax
  and    %esi,%eax
  or     %eax,%edx
  mov    %dl,(%rdi)
  ret
```

assistant: ```c
void rop3_86_1_0(unsigned char *D, unsigned char S, unsigned char T) {
  unsigned char stk1;
  unsigned char stk2;
  stk2 = T | S;
  stk1 = *D ^ stk2;
  *D = (stk1 & (~S)) | (*D & S);
}
```
user: Translate the below assembly code into C programming language:

```asm
<MPI_Pcontrol>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %edi,-0x4(%rbp)
  mov    -0x4(%rbp),%eax
  mov    %eax,%edi
  call   <PMPI_Pcontrol@plt>
  leave
  ret
```

assistant: ```c
int MPI_Pcontrol(int level) {
  ;
  return PMPI_Pcontrol(level);
}
```
user: What is the c source code of the assembly code below:

```asm
<MPI_Pcontrol>:
  endbr64
  sub    $0x8,%rsp
  call   <PMPI_Pcontrol@plt>
  add    $0x8,%rsp
  ret
```

assistant: ```c
int MPI_Pcontrol(int level) {
  ;
  return PMPI_Pcontrol(level);
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<MPI_Pcontrol>:
  endbr64
  jmp    1050 <PMPI_Pcontrol@plt>
```

assistant: ```c
int MPI_Pcontrol(int level) {
  ;
  return PMPI_Pcontrol(level);
}
```
user: What is the c source code of the assembly code below?

```asm
<MPI_Pcontrol>:
  endbr64
  jmp    1050 <PMPI_Pcontrol@plt>
```

assistant: ```c
int MPI_Pcontrol(int level) {
  ;
  return PMPI_Pcontrol(level);
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<partition>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %edi,-0x14(%rbp)
  mov    %esi,-0x18(%rbp)
  mov    -0x14(%rbp),%eax
  cmp    -0x18(%rbp),%eax
  jge    L4
  mov    -0x14(%rbp),%edx
  mov    -0x18(%rbp),%eax
  add    %edx,%eax
  mov    %eax,%edx
  shr    $0x1f,%edx
  add    %edx,%eax
  sar    %eax
  mov    %eax,-0x4(%rbp)
  mov    -0x4(%rbp),%edx
  mov    -0x14(%rbp),%eax
  mov    %edx,%esi
  mov    %eax,%edi
  call   <partition>
  mov    -0x4(%rbp),%eax
  lea    0x1(%rax),%edx
  mov    -0x18(%rbp),%eax
  mov    %eax,%esi
  mov    %edx,%edi
  call   <partition>
  mov    -0x18(%rbp),%edx
  mov    -0x4(%rbp),%ecx
  mov    -0x14(%rbp),%eax
  mov    %ecx,%esi
  mov    %eax,%edi
  call   <merge@plt>
  jmp    L15
L4:
  nop
L15:
  leave
  ret
```

assistant: ```c
void partition(int beg, int end) {
  int mid;
  if (beg < end) {
    mid = ((beg + end) / 2);
    partition(beg, mid);
    partition(mid + 1, end);
    merge(beg, mid, end);
  } else
    return;
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<partition>:
  endbr64
  cmp    %esi,%edi
  jl     L7
  ret
L7:
  push   %r12
  push   %rbp
  push   %rbx
  mov    %edi,%ebx
  mov    %esi,%ebp
  lea    (%rdi,%rsi,1),%eax
  mov    %eax,%r12d
  shr    $0x1f,%r12d
  add    %eax,%r12d
  sar    %r12d
  mov    %r12d,%esi
  call   <partition>
  lea    0x1(%r12),%edi
  mov    %ebp,%esi
  call   <partition>
  mov    %ebp,%edx
  mov    %r12d,%esi
  mov    %ebx,%edi
  call   <merge@plt>
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
void partition(int beg, int end) {
  int mid;
  if (beg < end) {
    mid = ((beg + end) / 2);
    partition(beg, mid);
    partition(mid + 1, end);
    merge(beg, mid, end);
  } else
    return;
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<mkdir_p>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r13
  push   %r12
  push   %rbx
  sub    $0x18,%rsp
  mov    %rdi,%rbx
  mov    %esi,%r13d
  mov    %fs:0x28,%rax
  mov    %rax,-0x28(%rbp)
  xor    %eax,%eax
  call   <strlen@plt>
  mov    D32(%rip),%rdx
  movslq (%rdx),%rcx
  lea    0xf(%rcx),%rdx
  mov    %rdx,%rdi
  and    $0xfffffffffffffff0,%rdi
  and    $0xfffffffffffff000,%rdx
  mov    %rsp,%rsi
  sub    %rdx,%rsi
L105:
  cmp    %rsi,%rsp
  je     L129
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  jmp    L105
L129:
  mov    %rdi,%rdx
  and    $0xfff,%edx
  sub    %rdx,%rsp
  test   %rdx,%rdx
  je     L26
  orq    $0x0,-0x8(%rsp,%rdx,1)
L26:
  mov    %rsp,%r12
  mov    D66(%rip),%rdx
  movq   $0x0,(%rdx)
  sub    $0x1,%rcx
  cmp    %rax,%rcx
  jb     L109
  mov    %rbx,%rsi
  mov    %r12,%rdi
  call   <strcpy@plt>
  lea    0x1(%r12),%rbx
  movzbl 0x1(%r12),%eax
  test   %al,%al
  jne    L49
L114:
  mov    %r13d,%esi
  mov    %r12,%rdi
  call   <mkdir@plt>
  mov    %rax,%rdx
  mov    $0x0,%eax
  test   %rdx,%rdx
  je     L117
  mov    D66(%rip),%rdx
  mov    D61(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,(%rdx)
  setne  %al
  movzbl %al,%eax
  neg    %eax
L117:
  mov    -0x28(%rbp),%rdx
  sub    %fs:0x28,%rdx
  jne    L83
  lea    -0x18(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %rbp
  ret
L109:
  mov    D72(%rip),%rax
  mov    (%rax),%rdx
  mov    D66(%rip),%rax
  mov    %rdx,(%rax)
  mov    $0xffffffff,%eax
  jmp    L117
L13:
  movb   $0x2f,(%rbx)
L58:
  add    $0x1,%rbx
  movzbl (%rbx),%eax
  test   %al,%al
  je     L114
L49:
  cmp    $0x2f,%al
  jne    L58
  movb   $0x0,(%rbx)
  mov    %r13d,%esi
  mov    %r12,%rdi
  call   <mkdir@plt>
  test   %rax,%rax
  je     L13
  mov    D66(%rip),%rdx
  mov    D61(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,(%rdx)
  je     L13
  mov    $0xffffffff,%eax
  jmp    L117
L83:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int mkdir_p(const char *path, mode_t mode) {
  const size_t len = strlen(path);
  char _path[PATH_MAX];
  char *p;
  errno = 0;
  if (len > sizeof(_path) - 1) {
    errno = ENAMETOOLONG;
    return -1;
  }
  strcpy(_path, path);
  for (p = _path + 1; *p; p++) {
    if (*p == '/') {
      *p = '\0';
      if (mkdir(_path, mode) != 0) {
        if (errno != EEXIST)
          return -1;
      }
      *p = '/';
    }
  }
  if (mkdir(_path, mode) != 0) {
    if (errno != EEXIST)
      return -1;
  }
  return 0;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<mkdir_p>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  mov    %rdi,%r14
  push   %r13
  push   %r12
  mov    %esi,%r12d
  push   %rbx
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  call   <strlen@plt>
  mov    D11(%rip),%rdx
  mov    %rsp,%rdi
  movslq (%rdx),%rcx
  lea    0xf(%rcx),%rdx
  mov    %rdx,%rsi
  and    $0xfffffffffffff000,%rdx
  sub    %rdx,%rdi
  and    $0xfffffffffffffff0,%rsi
  cmp    %rdi,%rsp
  je     L111
L63:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rdi,%rsp
  jne    L63
L111:
  and    $0xfff,%esi
  sub    %rsi,%rsp
  test   %rsi,%rsi
  jne    L66
L103:
  mov    D29(%rip),%r13
  sub    $0x1,%rcx
  mov    %rsp,%r15
  movq   $0x0,0x0(%r13)
  cmp    %rax,%rcx
  jb     L134
  mov    %r14,%rsi
  mov    %rsp,%rdi
  lea    0x1(%rsp),%rbx
  call   <strcpy@plt>
  movzbl 0x1(%rsp),%eax
  test   %al,%al
  jne    L43
  jmp    L118
  nopw   0x0(%rax,%rax,1)
L38:
  movzbl 0x1(%rbx),%eax
  add    $0x1,%rbx
  test   %al,%al
  je     L118
L43:
  cmp    $0x2f,%al
  jne    L38
  mov    %r12d,%esi
  mov    %r15,%rdi
  movb   $0x0,(%rbx)
  call   <mkdir@plt>
  test   %rax,%rax
  je     L112
  mov    D46(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,0x0(%r13)
  jne    L94
L112:
  movb   $0x2f,(%rbx)
  movzbl 0x1(%rbx),%eax
  add    $0x1,%rbx
  test   %al,%al
  jne    L43
  nopw   0x0(%rax,%rax,1)
L118:
  mov    %r12d,%esi
  mov    %r15,%rdi
  call   <mkdir@plt>
  mov    %rax,%r8
  xor    %eax,%eax
  test   %r8,%r8
  je     L24
  mov    D46(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,0x0(%r13)
  setne  %al
  movzbl %al,%eax
  neg    %eax
L24:
  mov    -0x38(%rbp),%rdx
  sub    %fs:0x28,%rdx
  jne    L152
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L66:
  orq    $0x0,-0x8(%rsp,%rsi,1)
  jmp    L103
L94:
  mov    $0xffffffff,%eax
  jmp    L24
L134:
  mov    D15(%rip),%rax
  mov    (%rax),%rax
  mov    %rax,0x0(%r13)
  mov    $0xffffffff,%eax
  jmp    L24
L152:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int mkdir_p(const char *path, mode_t mode) {
  const size_t len = strlen(path);
  char _path[PATH_MAX];
  char *p;
  errno = 0;
  if (len > sizeof(_path) - 1) {
    errno = ENAMETOOLONG;
    return -1;
  }
  strcpy(_path, path);
  for (p = _path + 1; *p; p++) {
    if (*p == '/') {
      *p = '\0';
      if (mkdir(_path, mode) != 0) {
        if (errno != EEXIST)
          return -1;
      }
      *p = '/';
    }
  }
  if (mkdir(_path, mode) != 0) {
    if (errno != EEXIST)
      return -1;
  }
  return 0;
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<mkdir_p>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %r15
  push   %r14
  mov    %rdi,%r14
  push   %r13
  push   %r12
  mov    %esi,%r12d
  push   %rbx
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x38(%rbp)
  xor    %eax,%eax
  call   <strlen@plt>
  mov    D5(%rip),%rdx
  mov    %rsp,%rdi
  movslq (%rdx),%rcx
  lea    0xf(%rcx),%rdx
  mov    %rdx,%rsi
  and    $0xfffffffffffff000,%rdx
  sub    %rdx,%rdi
  and    $0xfffffffffffffff0,%rsi
  cmp    %rdi,%rsp
  je     L24
L23:
  sub    $0x1000,%rsp
  orq    $0x0,0xff8(%rsp)
  cmp    %rdi,%rsp
  jne    L23
L24:
  and    $0xfff,%esi
  sub    %rsi,%rsp
  test   %rsi,%rsi
  jne    L159
L142:
  mov    D39(%rip),%r13
  sub    $0x1,%rcx
  mov    %rsp,%r15
  movq   $0x0,0x0(%r13)
  cmp    %rax,%rcx
  jb     L91
  mov    %r14,%rsi
  mov    %rsp,%rdi
  lea    0x1(%rsp),%rbx
  call   <strcpy@plt>
  movzbl 0x1(%rsp),%eax
  test   %al,%al
  jne    L40
  jmp    L96
  nopw   0x0(%rax,%rax,1)
L146:
  movzbl 0x1(%rbx),%eax
  add    $0x1,%rbx
  test   %al,%al
  je     L96
L40:
  cmp    $0x2f,%al
  jne    L146
  mov    %r12d,%esi
  mov    %r15,%rdi
  movb   $0x0,(%rbx)
  call   <mkdir@plt>
  test   %rax,%rax
  je     L107
  mov    D43(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,0x0(%r13)
  jne    L68
L107:
  movb   $0x2f,(%rbx)
  movzbl 0x1(%rbx),%eax
  add    $0x1,%rbx
  test   %al,%al
  jne    L40
  nopw   0x0(%rax,%rax,1)
L96:
  mov    %r12d,%esi
  mov    %r15,%rdi
  call   <mkdir@plt>
  mov    %rax,%r8
  xor    %eax,%eax
  test   %r8,%r8
  je     L97
  mov    D43(%rip),%rax
  mov    (%rax),%rax
  cmp    %rax,0x0(%r13)
  setne  %al
  movzbl %al,%eax
  neg    %eax
L97:
  mov    -0x38(%rbp),%rdx
  sub    %fs:0x28,%rdx
  jne    L85
  lea    -0x28(%rbp),%rsp
  pop    %rbx
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  pop    %rbp
  ret
L159:
  orq    $0x0,-0x8(%rsp,%rsi,1)
  jmp    L142
L68:
  mov    $0xffffffff,%eax
  jmp    L97
L91:
  mov    D13(%rip),%rax
  mov    (%rax),%rax
  mov    %rax,0x0(%r13)
  mov    $0xffffffff,%eax
  jmp    L97
L85:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int mkdir_p(const char *path, mode_t mode) {
  const size_t len = strlen(path);
  char _path[PATH_MAX];
  char *p;
  errno = 0;
  if (len > sizeof(_path) - 1) {
    errno = ENAMETOOLONG;
    return -1;
  }
  strcpy(_path, path);
  for (p = _path + 1; *p; p++) {
    if (*p == '/') {
      *p = '\0';
      if (mkdir(_path, mode) != 0) {
        if (errno != EEXIST)
          return -1;
      }
      *p = '/';
    }
  }
  if (mkdir(_path, mode) != 0) {
    if (errno != EEXIST)
      return -1;
  }
  return 0;
}
```