ylfeng/ReF-Decompile-dataset huggingface dataset:
user: Translate the below assembly code into C programming language:

```asm
<read_n>:
  endbr64
  push   %r15
  mov    %rcx,%r15
  push   %r14
  push   %r13
  mov    %rsi,%r13
  push   %r12
  push   %rbp
  mov    %edi,%ebp
  push   %rbx
  mov    %rdx,%rbx
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  movq   $0x0,(%rsp)
  test   %rcx,%rcx
  je     L9
  movl   $0x0,(%rcx)
L9:
  xor    %r12d,%r12d
  test   %rbx,%rbx
  je     L38
  mov    %rsp,%r14
  jmp    L45
  nopl   (%rax)
L34:
  mov    (%rsp),%rax
  test   %rax,%rax
  je     L38
  add    %rax,%r12
  cmp    %r12,%rbx
  jbe    L38
L45:
  mov    %rbx,%rdx
  lea    0x0(%r13,%r12,1),%rsi
  mov    %r14,%rcx
  mov    %ebp,%edi
  sub    %r12,%rdx
  call   <receive@plt>
  test   %rax,%rax
  je     L34
  test   %r15,%r15
  je     L38
  movl   $0x1,(%r15)
L38:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L54
  add    $0x18,%rsp
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L54:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
size_t read_n(int fd, char *buf, size_t n, int *err) {
  size_t n_read = 0;
  size_t rx_amt = 0;
  if (err)
    *err = 0;
  while (n_read < n) {
    if (receive(fd, buf + n_read, n - n_read, &rx_amt) != 0) {
      if (err)
        *err = 1;
      break;
    }
    if (rx_amt == 0)
      break;
    n_read += rx_amt;
  }
  return n_read;
}
```
user: Translate the below assembly code into C programming language:

```asm
<read_n>:
  endbr64
  push   %r15
  mov    %rcx,%r15
  push   %r14
  push   %r13
  mov    %rsi,%r13
  push   %r12
  push   %rbp
  mov    %edi,%ebp
  push   %rbx
  mov    %rdx,%rbx
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  movq   $0x0,(%rsp)
  test   %rcx,%rcx
  je     L18
  movl   $0x0,(%rcx)
L18:
  xor    %r12d,%r12d
  test   %rbx,%rbx
  je     L32
  mov    %rsp,%r14
  jmp    L54
  nopl   (%rax)
L77:
  mov    (%rsp),%rax
  test   %rax,%rax
  je     L32
  add    %rax,%r12
  cmp    %r12,%rbx
  jbe    L32
L54:
  mov    %rbx,%rdx
  lea    0x0(%r13,%r12,1),%rsi
  mov    %r14,%rcx
  mov    %ebp,%edi
  sub    %r12,%rdx
  call   <receive@plt>
  test   %rax,%rax
  je     L77
  test   %r15,%r15
  je     L32
  movl   $0x1,(%r15)
L32:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L61
  add    $0x18,%rsp
  mov    %r12,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L61:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
size_t read_n(int fd, char *buf, size_t n, int *err) {
  size_t n_read = 0;
  size_t rx_amt = 0;
  if (err)
    *err = 0;
  while (n_read < n) {
    if (receive(fd, buf + n_read, n - n_read, &rx_amt) != 0) {
      if (err)
        *err = 1;
      break;
    }
    if (rx_amt == 0)
      break;
    n_read += rx_amt;
  }
  return n_read;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<talloc_strdup>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  cmpq   $0x0,-0x20(%rbp)
  jne    L31
  mov    $0x0,%eax
  jmp    L18
L31:
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
  mov    %rax,-0x10(%rbp)
  mov    -0x10(%rbp),%rax
  lea    0x1(%rax),%rcx
  mov    -0x18(%rbp),%rax
  lea    D4(%rip),%rdx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <talloc_named_const@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  jne    L17
  mov    $0x0,%eax
  jmp    L18
L17:
  mov    -0x10(%rbp),%rax
  lea    0x1(%rax),%rdx
  mov    -0x20(%rbp),%rcx
  mov    -0x8(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
  mov    -0x8(%rbp),%rax
L18:
  leave
  ret
```

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

tool: D4: /scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/osmocom/libosmocore/refs/heads/master/src/pseudotalloc/pseudotalloc.c:67

assistant: ```c
char *talloc_strdup(const void *context, const char *p) {
  char *ptr;
  size_t len;
  if (!p)
    return NULL;
  len = strlen(p);
  ptr = talloc_named_const(context, len + 1,
                           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/osmocom/libosmocore/refs/heads/master/src/pseudotalloc/pseudotalloc.c"
                           ":"
                           "67");
  if (!ptr)
    return NULL;
  memcpy(ptr, p, len + 1);
  return ptr;
}
```
user: 这段汇编代码用C语言表示是什么样的：

```asm
<talloc_strdup>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rsi,%rbx
  test   %rsi,%rsi
  je     L14
  mov    %rdi,%rbp
  mov    %rsi,%rdi
  call   <strlen@plt>
  lea    0x1(%rax),%r12
  lea    D0(%rip),%rdx
  mov    %r12,%rsi
  mov    %rbp,%rdi
  call   <talloc_named_const@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L27
  mov    %r12,%rdx
  mov    %rbx,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
L27:
  mov    %rbp,%rax
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L14:
  mov    %rsi,%rbp
  jmp    L27
```

tool_calls: name: read_data
arguments: label: D0
type_guessed: string

tool: D0: /scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/osmocom/libosmocore/refs/heads/master/src/pseudotalloc/pseudotalloc.c:67

assistant: ```c
char *talloc_strdup(const void *context, const char *p) {
  char *ptr;
  size_t len;
  if (!p)
    return NULL;
  len = strlen(p);
  ptr = talloc_named_const(context, len + 1,
                           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/osmocom/libosmocore/refs/heads/master/src/pseudotalloc/pseudotalloc.c"
                           ":"
                           "67");
  if (!ptr)
    return NULL;
  memcpy(ptr, p, len + 1);
  return ptr;
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<talloc_strdup>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  test   %rsi,%rsi
  je     L6
  mov    %rdi,%r12
  mov    %rsi,%rdi
  mov    %rsi,%rbp
  call   <strlen@plt>
  mov    %r12,%rdi
  lea    D4(%rip),%rdx
  lea    0x1(%rax),%r13
  mov    %r13,%rsi
  call   <talloc_named_const@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L5
  mov    %r13,%rdx
  mov    %rbp,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
L5:
  mov    %r12,%rax
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L6:
  xor    %r12d,%r12d
  pop    %rbp
  mov    %r12,%rax
  pop    %r12
  pop    %r13
  ret
```

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

tool: D4: /scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/osmocom/libosmocore/refs/heads/master/src/pseudotalloc/pseudotalloc.c:67

assistant: ```c
char *talloc_strdup(const void *context, const char *p) {
  char *ptr;
  size_t len;
  if (!p)
    return NULL;
  len = strlen(p);
  ptr = talloc_named_const(context, len + 1,
                           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/osmocom/libosmocore/refs/heads/master/src/pseudotalloc/pseudotalloc.c"
                           ":"
                           "67");
  if (!ptr)
    return NULL;
  memcpy(ptr, p, len + 1);
  return ptr;
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<talloc_strdup>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  test   %rsi,%rsi
  je     L7
  mov    %rdi,%r12
  mov    %rsi,%rdi
  mov    %rsi,%rbp
  call   <strlen@plt>
  mov    %r12,%rdi
  lea    D1(%rip),%rdx
  lea    0x1(%rax),%r13
  mov    %r13,%rsi
  call   <talloc_named_const@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L8
  mov    %r13,%rdx
  mov    %rbp,%rsi
  mov    %rax,%rdi
  call   <memcpy@plt>
L8:
  mov    %r12,%rax
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   0x0(%rax)
L7:
  xor    %r12d,%r12d
  pop    %rbp
  mov    %r12,%rax
  pop    %r12
  pop    %r13
  ret
```

tool_calls: name: disassemble_data
arguments: tag: D1
data_type: string

tool: D1: /scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/osmocom/libosmocore/refs/heads/master/src/pseudotalloc/pseudotalloc.c:67

assistant: ```c
char *talloc_strdup(const void *context, const char *p) {
  char *ptr;
  size_t len;
  if (!p)
    return NULL;
  len = strlen(p);
  ptr = talloc_named_const(context, len + 1,
                           "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/osmocom/libosmocore/refs/heads/master/src/pseudotalloc/pseudotalloc.c"
                           ":"
                           "67");
  if (!ptr)
    return NULL;
  memcpy(ptr, p, len + 1);
  return ptr;
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<stringToBlock>:
  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
  movl   $0x0,-0xc(%rbp)
  jmp    L19
L3:
  mov    -0xc(%rbp),%eax
  add    %eax,%eax
  movslq %eax,%rdx
  mov    -0x18(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  lea    -0x10(%rbp),%rax
  mov    %rax,%rdx
  lea    D5(%rip),%rax
  mov    %rax,%rsi
  mov    %rcx,%rdi
  call   <sscanf@plt>
  mov    -0x10(%rbp),%edx
  mov    -0xc(%rbp),%eax
  movslq %eax,%rcx
  mov    -0x20(%rbp),%rax
  add    %rcx,%rax
  mov    %dl,(%rax)
  addl   $0x1,-0xc(%rbp)
L19:
  cmpl   $0xf,-0xc(%rbp)
  jle    L3
  nop
  mov    -0x8(%rbp),%rax
  sub    %fs:0x28,%rax
  je     L17
  call   <__stack_chk_fail@plt>
L17:
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: tag: D5
data_type: string

tool: D5: %02X

assistant: ```c
void stringToBlock(char *str, unsigned char block[16]) {
  int i;
  for (i = 0; i < 16; i++) {
    int temp;
    sscanf(&str[2 * i], "%02X", &temp);
    block[i] = (unsigned char)temp;
  }
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<stringToBlock>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  mov    %rdi,%rbx
  mov    %rsi,%rbp
  lea    0x20(%rdi),%r12
  lea    D6(%rip),%r13
L3:
  lea    0x4(%rsp),%rdx
  mov    %r13,%rsi
  mov    %rbx,%rdi
  call   <sscanf@plt>
  mov    0x4(%rsp),%eax
  mov    %al,0x0(%rbp)
  add    $0x2,%rbx
  add    $0x1,%rbp
  cmp    %r12,%rbx
  jne    L3
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L7
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L7:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: label: D6
type_guessed: string

tool: D6: %02X

assistant: ```c
void stringToBlock(char *str, unsigned char block[16]) {
  int i;
  for (i = 0; i < 16; i++) {
    int temp;
    sscanf(&str[2 * i], "%02X", &temp);
    block[i] = (unsigned char)temp;
  }
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<stringToBlock>:
  endbr64
  push   %r14
  lea    0x20(%rdi),%r14
  push   %r13
  push   %r12
  lea    D6(%rip),%r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    0x4(%rsp),%r13
  cs nopw 0x0(%rax,%rax,1)
L1:
  mov    %rbx,%rdi
  mov    %r13,%rdx
  mov    %r12,%rsi
  add    $0x2,%rbx
  call   <sscanf@plt>
  mov    0x4(%rsp),%eax
  add    $0x1,%rbp
  mov    %al,-0x1(%rbp)
  cmp    %r14,%rbx
  jne    L1
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L6
  add    $0x10,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L6:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: data_tag: D6
data_type: string

tool: D6: %02X

assistant: ```c
void stringToBlock(char *str, unsigned char block[16]) {
  int i;
  for (i = 0; i < 16; i++) {
    int temp;
    sscanf(&str[2 * i], "%02X", &temp);
    block[i] = (unsigned char)temp;
  }
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<stringToBlock>:
  endbr64
  push   %r14
  lea    0x20(%rdi),%r14
  push   %r13
  push   %r12
  lea    D0(%rip),%r12
  push   %rbp
  mov    %rsi,%rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    0x4(%rsp),%r13
  cs nopw 0x0(%rax,%rax,1)
L17:
  mov    %rbx,%rdi
  mov    %r13,%rdx
  mov    %r12,%rsi
  add    $0x2,%rbx
  call   <sscanf@plt>
  mov    0x4(%rsp),%eax
  add    $0x1,%rbp
  mov    %al,-0x1(%rbp)
  cmp    %r14,%rbx
  jne    L17
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L4
  add    $0x10,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
L4:
  call   <__stack_chk_fail@plt>
```

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

tool: D0: %02X

assistant: ```c
void stringToBlock(char *str, unsigned char block[16]) {
  int i;
  for (i = 0; i < 16; i++) {
    int temp;
    sscanf(&str[2 * i], "%02X", &temp);
    block[i] = (unsigned char)temp;
  }
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<fio_cli_get_i>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  mov    -0x28(%rbp),%rax
  mov    %rax,%rdi
  call   <fio_cli_get@plt>
  mov    %rax,-0x10(%rbp)
  mov    -0x10(%rbp),%rax
  test   %rax,%rax
  jne    L18
  mov    $0x0,%eax
  jmp    L23
L18:
  lea    -0x10(%rbp),%rax
  mov    %rax,%rdi
  call   <fio_atol@plt>
  mov    %eax,-0x14(%rbp)
  mov    -0x14(%rbp),%eax
L23:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L11
  call   <__stack_chk_fail@plt>
L11:
  leave
  ret
```

assistant: ```c
int fio_cli_get_i(char const *name) {
  char const *val = fio_cli_get(name);
  if (!val)
    return 0;
  int i = (int)fio_atol((char **)&val);
  return i;
}
```
user: Translate the below assembly code into C programming language:

```asm
<fio_cli_get_i>:
  endbr64
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  call   <fio_cli_get@plt>
  mov    %rax,(%rsp)
  mov    $0x0,%edx
  test   %rax,%rax
  je     L4
  mov    %rsp,%rdi
  call   <fio_atol@plt>
  mov    %eax,%edx
L4:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L1
  mov    %edx,%eax
  add    $0x18,%rsp
  ret
L1:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int fio_cli_get_i(char const *name) {
  char const *val = fio_cli_get(name);
  if (!val)
    return 0;
  int i = (int)fio_atol((char **)&val);
  return i;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现:

```asm
<fio_cli_get_i>:
  endbr64
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  call   <fio_cli_get@plt>
  xor    %r8d,%r8d
  mov    %rax,(%rsp)
  test   %rax,%rax
  je     L17
  mov    %rsp,%rdi
  call   <fio_atol@plt>
  mov    %eax,%r8d
L17:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L6
  mov    %r8d,%eax
  add    $0x18,%rsp
  ret
L6:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int fio_cli_get_i(char const *name) {
  char const *val = fio_cli_get(name);
  if (!val)
    return 0;
  int i = (int)fio_atol((char **)&val);
  return i;
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<fio_cli_get_i>:
  endbr64
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  call   <fio_cli_get@plt>
  xor    %r8d,%r8d
  mov    %rax,(%rsp)
  test   %rax,%rax
  je     L1
  mov    %rsp,%rdi
  call   <fio_atol@plt>
  mov    %eax,%r8d
L1:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L18
  mov    %r8d,%eax
  add    $0x18,%rsp
  ret
L18:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
int fio_cli_get_i(char const *name) {
  char const *val = fio_cli_get(name);
  if (!val)
    return 0;
  int i = (int)fio_atol((char **)&val);
  return i;
}
```
user: 请将以下的汇编代码转换成C语言代码:

```asm
<path_curr>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %rdi,-0x18(%rbp)
  mov    %rsi,-0x20(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  jne    L16
  mov    -0x20(%rbp),%rax
  movb   $0x0,(%rax)
  jmp    L12
L16:
  mov    -0x18(%rbp),%rax
  mov    $0x2e,%esi
  mov    %rax,%rdi
  call   <strchr@plt>
  mov    %rax,-0x10(%rbp)
  cmpq   $0x0,-0x10(%rbp)
  je     L35
  mov    -0x10(%rbp),%rax
  sub    -0x18(%rbp),%rax
  jmp    L29
L35:
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <strlen@plt>
L29:
  mov    %rax,-0x8(%rbp)
  mov    -0x18(%rbp),%rdx
  mov    -0x20(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcpy@plt>
  mov    -0x20(%rbp),%rdx
  mov    -0x8(%rbp),%rax
  add    %rdx,%rax
  movb   $0x0,(%rax)
L12:
  leave
  ret
```

assistant: ```c
void path_curr(char *path, char *dest) {
  if (!path) {
    dest[0] = '\0';
    return;
  }
  char *delpos = strchr(path, ('.'));
  uint32_t intpos;
  intpos = delpos ? (uint32_t)(delpos - path) : strlen(path);
  strcpy(dest, path);
  dest[intpos] = '\0';
}
```
user: What is the c source code of the assembly code below?

```asm
<path_curr>:
  endbr64
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rsi,%r12
  test   %rdi,%rdi
  je     L25
  mov    %rdi,%rbx
  mov    $0x2e,%esi
  call   <strchr@plt>
  test   %rax,%rax
  je     L14
  sub    %rbx,%rax
  mov    %rax,%rbp
L21:
  mov    %rbx,%rsi
  mov    %r12,%rdi
  call   <strcpy@plt>
  movb   $0x0,(%r12,%rbp,1)
L5:
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
L25:
  movb   $0x0,(%rsi)
  jmp    L5
L14:
  mov    %rbx,%rdi
  call   <strlen@plt>
  mov    %rax,%rbp
  jmp    L21
```

assistant: ```c
void path_curr(char *path, char *dest) {
  if (!path) {
    dest[0] = '\0';
    return;
  }
  char *delpos = strchr(path, ('.'));
  uint32_t intpos;
  intpos = delpos ? (uint32_t)(delpos - path) : strlen(path);
  strcpy(dest, path);
  dest[intpos] = '\0';
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<path_curr>:
  endbr64
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  push   %rbx
  test   %rdi,%rdi
  je     L28
  mov    $0x2e,%esi
  mov    %rdi,%rbp
  call   <strchr@plt>
  test   %rax,%rax
  je     L5
  sub    %rbp,%rax
  mov    %rax,%rbx
L23:
  mov    %rbp,%rsi
  mov    %r12,%rdi
  call   <strcpy@plt>
  movb   $0x0,(%r12,%rbx,1)
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopl   (%rax)
L5:
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %rax,%rbx
  jmp    L23
  nopl   (%rax)
L28:
  movb   $0x0,(%rsi)
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
void path_curr(char *path, char *dest) {
  if (!path) {
    dest[0] = '\0';
    return;
  }
  char *delpos = strchr(path, ('.'));
  uint32_t intpos;
  intpos = delpos ? (uint32_t)(delpos - path) : strlen(path);
  strcpy(dest, path);
  dest[intpos] = '\0';
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<path_curr>:
  endbr64
  push   %r12
  mov    %rsi,%r12
  push   %rbp
  push   %rbx
  test   %rdi,%rdi
  je     L9
  mov    $0x2e,%esi
  mov    %rdi,%rbp
  call   <strchr@plt>
  test   %rax,%rax
  je     L11
  sub    %rbp,%rax
  mov    %rax,%rbx
L0:
  mov    %rbp,%rsi
  mov    %r12,%rdi
  call   <strcpy@plt>
  movb   $0x0,(%r12,%rbx,1)
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
  nopl   (%rax)
L11:
  mov    %rbp,%rdi
  call   <strlen@plt>
  mov    %rax,%rbx
  jmp    L0
  nopl   (%rax)
L9:
  movb   $0x0,(%rsi)
  pop    %rbx
  pop    %rbp
  pop    %r12
  ret
```

assistant: ```c
void path_curr(char *path, char *dest) {
  if (!path) {
    dest[0] = '\0';
    return;
  }
  char *delpos = strchr(path, ('.'));
  uint32_t intpos;
  intpos = delpos ? (uint32_t)(delpos - path) : strlen(path);
  strcpy(dest, path);
  dest[intpos] = '\0';
}
```
user: What is the c source code of the assembly code below?

```asm
<search_cmd_in_hist>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  push   %rbx
  sub    $0x38,%rsp
  mov    %rdi,-0x38(%rbp)
  movq   $0x0,-0x20(%rbp)
  mov    $0x0,%eax
  call   <reset_actual_ptr@plt>
  mov    $0x0,%eax
  call   <is_empty_hist@plt>
  test   %eax,%eax
  jne    L53
  jmp    L68
L89:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L45
  mov    -0x38(%rbp),%rdx
  mov    -0x18(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strstr@plt>
  test   %rax,%rax
  je     L68
  addl   $0x1,-0x24(%rbp)
L68:
  mov    $0x0,%eax
  call   <get_prev_cmd@plt>
  mov    %rax,-0x18(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  jne    L89
  jmp    L13
L45:
  nop
L13:
  mov    -0x24(%rbp),%eax
  add    $0x1,%eax
  cltq
  shl    $0x3,%eax
  mov    %eax,%edi
  call   <malloc@plt>
  mov    %rax,-0x20(%rbp)
  movl   $0x0,-0x24(%rbp)
  mov    $0x0,%eax
  call   <reset_actual_ptr@plt>
  jmp    L107
L4:
  mov    -0x18(%rbp),%rax
  movzbl (%rax),%eax
  test   %al,%al
  je     L32
  mov    -0x38(%rbp),%rdx
  mov    -0x18(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strstr@plt>
  test   %rax,%rax
  je     L39
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x20(%rbp),%rax
  lea    (%rdx,%rax,1),%rbx
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <strdup@plt>
  mov    %rax,(%rbx)
L39:
  addl   $0x1,-0x24(%rbp)
L107:
  mov    $0x0,%eax
  call   <get_prev_cmd@plt>
  mov    %rax,-0x18(%rbp)
  cmpq   $0x0,-0x18(%rbp)
  jne    L4
  jmp    L37
L32:
  nop
L37:
  mov    -0x24(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  movq   $0x0,(%rax)
L53:
  mov    $0x0,%eax
  call   <reset_actual_ptr@plt>
  mov    $0x0,%eax
  mov    -0x8(%rbp),%rbx
  leave
  ret
```

assistant: ```c
char **search_cmd_in_hist(char *cmd_in) {
  int nb_cmd;
  char *my_cmd;
  char **tab_cmd = NULL;
  reset_actual_ptr();
  if (!is_empty_hist()) {
    while ((my_cmd = get_prev_cmd())) {
      if (my_cmd[0] != '\0') {
        if (strstr(my_cmd, cmd_in) != NULL)
          nb_cmd++;
      } else
        break;
    }
    tab_cmd = malloc((nb_cmd + 1) * sizeof(char *));
    nb_cmd = 0;
    reset_actual_ptr();
    while ((my_cmd = get_prev_cmd())) {
      if (my_cmd[0] != '\0') {
        if (strstr(my_cmd, cmd_in) != NULL)
          tab_cmd[nb_cmd] = strdup(my_cmd);
        nb_cmd++;
      } else
        break;
    }
    tab_cmd[nb_cmd] = NULL;
  }
  reset_actual_ptr();
  return NULL;
}
```
user: Translate the below assembly code into C programming language:

```asm
<search_cmd_in_hist>:
  endbr64
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%r12
  mov    $0x0,%eax
  call   <reset_actual_ptr@plt>
  mov    $0x0,%eax
  call   <is_empty_hist@plt>
  test   %eax,%eax
  jne    L32
L17:
  mov    $0x0,%eax
  call   <get_prev_cmd@plt>
  mov    %rax,%rdi
  test   %rax,%rax
  je     L22
  cmpb   $0x0,(%rdi)
  je     L22
  mov    %r12,%rsi
  call   <strstr@plt>
  cmp    $0x1,%rax
  sbb    $0xffffffff,%ebx
  jmp    L17
L22:
  lea    0x8(,%rbx,8),%edi
  call   <malloc@plt>
  mov    %rax,%r13
  mov    $0x0,%eax
  call   <reset_actual_ptr@plt>
  mov    $0x0,%ebp
  jmp    L43
L21:
  add    $0x1,%rbp
L43:
  mov    %ebp,%r14d
  mov    $0x0,%eax
  call   <get_prev_cmd@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L28
  cmpb   $0x0,(%rbx)
  je     L28
  mov    %r12,%rsi
  mov    %rbx,%rdi
  call   <strstr@plt>
  test   %rax,%rax
  je     L21
  mov    %rbx,%rdi
  call   <strdup@plt>
  mov    %rax,0x0(%r13,%rbp,8)
  jmp    L21
L28:
  movslq %r14d,%r14
  movq   $0x0,0x0(%r13,%r14,8)
L32:
  mov    $0x0,%eax
  call   <reset_actual_ptr@plt>
  mov    $0x0,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  ret
```

assistant: ```c
char **search_cmd_in_hist(char *cmd_in) {
  int nb_cmd;
  char *my_cmd;
  char **tab_cmd = NULL;
  reset_actual_ptr();
  if (!is_empty_hist()) {
    while ((my_cmd = get_prev_cmd())) {
      if (my_cmd[0] != '\0') {
        if (strstr(my_cmd, cmd_in) != NULL)
          nb_cmd++;
      } else
        break;
    }
    tab_cmd = malloc((nb_cmd + 1) * sizeof(char *));
    nb_cmd = 0;
    reset_actual_ptr();
    while ((my_cmd = get_prev_cmd())) {
      if (my_cmd[0] != '\0') {
        if (strstr(my_cmd, cmd_in) != NULL)
          tab_cmd[nb_cmd] = strdup(my_cmd);
        nb_cmd++;
      } else
        break;
    }
    tab_cmd[nb_cmd] = NULL;
  }
  reset_actual_ptr();
  return NULL;
}
```