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

```asm
<hex_dec>:
  endbr64
  push   %rbx
  sub    $0x10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  mov    %rsp,%rbx
  mov    %rbx,%rsi
  lea    D37(%rip),%rdi
  call   <scanf@plt>
  mov    %rbx,%rdx
  lea    0x7(%rsp),%rcx
  mov    %rbx,%rax
L88:
  movzbl 0x1(%rax),%esi
  mov    %sil,(%rax)
  add    $0x1,%rax
  cmp    %rcx,%rax
  jne    L88
  lea    D26(%rip),%rsi
  jmp    L84
  movb   $0xa,(%rdx)
L28:
  add    $0x1,%rdx
  cmp    %rcx,%rdx
  je     L37
L84:
  movzbl (%rdx),%eax
  sub    $0x61,%eax
  cmp    $0x5,%al
  ja     L28
  movzbl %al,%eax
  movslq (%rsi,%rax,4),%rax
  add    %rsi,%rax
  notrack jmp *%rax
  movb   $0xb,(%rdx)
  jmp    L28
  movb   $0xc,(%rdx)
  jmp    L28
  movb   $0xd,(%rdx)
  jmp    L28
  movb   $0xe,(%rdx)
  jmp    L28
  movb   $0xf,(%rdx)
  jmp    L28
L37:
  lea    D45(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  movsbl (%rsp),%esi
  shl    $0x4,%esi
  movsbl 0x1(%rsp),%eax
  or     %eax,%esi
  lea    D49(%rip),%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  movsbl 0x2(%rsp),%esi
  shl    $0x4,%esi
  movsbl 0x3(%rsp),%eax
  or     %eax,%esi
  lea    D16(%rip),%rbx
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  movsbl 0x4(%rsp),%esi
  shl    $0x4,%esi
  movsbl 0x5(%rsp),%eax
  or     %eax,%esi
  mov    %rbx,%rdi
  mov    $0x0,%eax
  call   <printf@plt>
  mov    $0x29,%edi
  call   <putchar@plt>
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L2
  mov    $0x0,%eax
  add    $0x10,%rsp
  pop    %rbx
  ret
L2:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: read_data
arguments: tag: D37
data_type: string
name: read_data
arguments: tag: D45
data_type: string
name: read_data
arguments: tag: D49
data_type: string
name: read_data
arguments: tag: D16
data_type: string

tool: D37: %8s

tool: D45: rbg(

tool: D49: %d

tool: D16: , %d

assistant: ```c
int hex_dec() {
  char a[8];
  scanf("%8s", a);
  for (int i = 0; i < 7; ++i) {
    a[i] = a[i + 1];
  }
  for (int i = 0; i < 7; ++i) {
    switch (a[i]) {
    case 'a':
      a[i] = 10;
      break;
    case 'b':
      a[i] = 11;
      break;
    case 'c':
      a[i] = 12;
      break;
    case 'd':
      a[i] = 13;
      break;
    case 'e':
      a[i] = 14;
      break;
    case 'f':
      a[i] = 15;
      break;
    }
  }
  printf("rbg(");
  printf("%d", (a[0] << 4) | a[0 + 1]);
  for (int i = 2; i < 6; i = i + 2) {
    printf(", %d", (a[i] << 4) | a[i + 1]);
  }
  printf(")");
  return 0;
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<getFrom>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x30,%rsp
  mov    %edi,-0x14(%rbp)
  mov    %rsi,-0x20(%rbp)
  mov    %rdx,-0x28(%rbp)
  movl   $0x0,-0x8(%rbp)
  jmp    L53
L24:
  movl   $0x0,-0x4(%rbp)
  jmp    L59
L13:
  mov    -0x8(%rbp),%eax
  movslq %eax,%rdx
  mov    %rdx,%rax
  shl    $0x2,%rax
  add    %rdx,%rax
  add    %rax,%rax
  mov    %rax,%rdx
  mov    -0x28(%rbp),%rax
  lea    (%rdx,%rax,1),%rcx
  mov    -0x4(%rbp),%eax
  cltq
  lea    0x0(,%rax,8),%rdx
  mov    -0x20(%rbp),%rax
  add    %rdx,%rax
  mov    (%rax),%rax
  mov    $0x3,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncmp@plt>
  test   %eax,%eax
  jne    L4
  mov    -0x4(%rbp),%eax
  jmp    L54
L4:
  addl   $0x1,-0x4(%rbp)
L59:
  mov    -0x4(%rbp),%eax
  cmp    -0x14(%rbp),%eax
  jl     L13
  addl   $0x1,-0x8(%rbp)
L53:
  cmpl   $0x2,-0x8(%rbp)
  jle    L24
  mov    $0xffffffff,%eax
L54:
  leave
  ret
```

assistant: ```c
int getFrom(int size, char **str, char source[][10]) {
  int i, n;
  for (i = 0; i < 3; i++) {
    for (n = 0; n < size; n++)
      if (!strncmp(str[n], source[i], 3))
        return n;
  }
  return -1;
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<getFrom>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %edi,0x4(%rsp)
  mov    %rsi,%rbp
  mov    %rdx,%r15
  lea    0x1e(%rdx),%rax
  mov    %rax,0x8(%rsp)
  mov    %edi,%r14d
L38:
  mov    %r15,%r12
  mov    $0x0,%ebx
  cmpl   $0x0,0x4(%rsp)
  jle    L13
L8:
  mov    %ebx,%r13d
  mov    0x0(%rbp,%rbx,8),%rdi
  mov    $0x3,%edx
  mov    %r12,%rsi
  call   <strncmp@plt>
  test   %eax,%eax
  je     L34
  add    $0x1,%rbx
  cmp    %r14,%rbx
  jne    L8
L13:
  add    $0xa,%r15
  cmp    0x8(%rsp),%r15
  jne    L38
  mov    $0xffffffff,%r13d
L34:
  mov    %r13d,%eax
  add    $0x18,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
```

assistant: ```c
int getFrom(int size, char **str, char source[][10]) {
  int i, n;
  for (i = 0; i < 3; i++) {
    for (n = 0; n < size; n++)
      if (!strncmp(str[n], source[i], 3))
        return n;
  }
  return -1;
}
```
user: 提供的汇编代码用C语言表示会是什么样子:

```asm
<getFrom>:
  endbr64
  push   %r15
  lea    0x1e(%rdx),%rax
  mov    %rsi,%r15
  push   %r14
  push   %r13
  movslq %edi,%r13
  push   %r12
  mov    %r13,%r14
  push   %rbp
  mov    %rdx,%rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rax,0x8(%rsp)
L47:
  xor    %ebx,%ebx
  test   %r14d,%r14d
  jg     L9
  jmp    L10
L15:
  add    $0x1,%rbx
  cmp    %r13,%rbx
  je     L10
L9:
  mov    (%r15,%rbx,8),%rdi
  mov    $0x3,%edx
  mov    %rbp,%rsi
  mov    %ebx,%r12d
  call   <strncmp@plt>
  test   %eax,%eax
  jne    L15
L41:
  add    $0x18,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L10:
  add    $0xa,%rbp
  cmp    0x8(%rsp),%rbp
  jne    L47
  mov    $0xffffffff,%r12d
  jmp    L41
```

assistant: ```c
int getFrom(int size, char **str, char source[][10]) {
  int i, n;
  for (i = 0; i < 3; i++) {
    for (n = 0; n < size; n++)
      if (!strncmp(str[n], source[i], 3))
        return n;
  }
  return -1;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<getFrom>:
  endbr64
  push   %r15
  lea    0x1e(%rdx),%rax
  mov    %rsi,%r15
  push   %r14
  push   %r13
  movslq %edi,%r13
  push   %r12
  mov    %r13,%r14
  push   %rbp
  mov    %rdx,%rbp
  push   %rbx
  sub    $0x18,%rsp
  mov    %rax,0x8(%rsp)
L2:
  xor    %ebx,%ebx
  test   %r14d,%r14d
  jg     L16
  jmp    L54
L5:
  add    $0x1,%rbx
  cmp    %r13,%rbx
  je     L54
L16:
  mov    (%r15,%rbx,8),%rdi
  mov    $0x3,%edx
  mov    %rbp,%rsi
  mov    %ebx,%r12d
  call   <strncmp@plt>
  test   %eax,%eax
  jne    L5
L49:
  add    $0x18,%rsp
  mov    %r12d,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nopl   0x0(%rax,%rax,1)
L54:
  add    $0xa,%rbp
  cmp    0x8(%rsp),%rbp
  jne    L2
  mov    $0xffffffff,%r12d
  jmp    L49
```

assistant: ```c
int getFrom(int size, char **str, char source[][10]) {
  int i, n;
  for (i = 0; i < 3; i++) {
    for (n = 0; n < size; n++)
      if (!strncmp(str[n], source[i], 3))
        return n;
  }
  return -1;
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<ons_get_hw_table_size>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  lea    -0xc(%rbp),%rax
  mov    %rax,%rsi
  mov    $0x4b000010,%edi
  call   <rdReg@plt>
  mov    -0xc(%rbp),%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L8
  call   <__stack_chk_fail@plt>
L8:
  leave
  ret
```

assistant: ```c
uint32_t ons_get_hw_table_size() {
  uint32_t val;
  rdReg(0x4b000010, &val);
  return val;
}
```
user: What is the c source code of the assembly code below:

```asm
<ons_get_hw_table_size>:
  endbr64
  sub    $0x18,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    0x4(%rsp),%rsi
  mov    $0x4b000010,%edi
  call   <rdReg@plt>
  mov    0x4(%rsp),%eax
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L7
  add    $0x18,%rsp
  ret
L7:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
uint32_t ons_get_hw_table_size() {
  uint32_t val;
  rdReg(0x4b000010, &val);
  return val;
}
```
user: 提供的汇编代码用C语言表示会是什么样子：

```asm
<ons_get_hw_table_size>:
  endbr64
  sub    $0x18,%rsp
  mov    $0x4b000010,%edi
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    0x4(%rsp),%rsi
  call   <rdReg@plt>
  mov    0x4(%rsp),%eax
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L0
  add    $0x18,%rsp
  ret
L0:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
uint32_t ons_get_hw_table_size() {
  uint32_t val;
  rdReg(0x4b000010, &val);
  return val;
}
```
user: 下面的汇编指令对应的C源代码是什么：

```asm
<ons_get_hw_table_size>:
  endbr64
  sub    $0x18,%rsp
  mov    $0x4b000010,%edi
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    0x4(%rsp),%rsi
  call   <rdReg@plt>
  mov    0x4(%rsp),%eax
  mov    0x8(%rsp),%rdx
  sub    %fs:0x28,%rdx
  jne    L7
  add    $0x18,%rsp
  ret
L7:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
uint32_t ons_get_hw_table_size() {
  uint32_t val;
  rdReg(0x4b000010, &val);
  return val;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<UI_GetBotNameByNumber>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x20,%rsp
  mov    %edi,-0x14(%rbp)
  mov    -0x14(%rbp),%eax
  mov    %eax,%edi
  call   <UI_GetBotInfoByNumber@plt>
  mov    %rax,-0x8(%rbp)
  cmpq   $0x0,-0x8(%rbp)
  je     L15
  mov    -0x8(%rbp),%rax
  lea    D13(%rip),%rdx
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <Info_ValueForKey@plt>
  jmp    L9
L15:
  lea    D5(%rip),%rax
L9:
  leave
  ret
```

tool_calls: name: unpack_data
arguments: data_tag: D13
type: string
name: unpack_data
arguments: data_tag: D5
type: string

tool: D13: name

tool: 

assistant: ```c
char *UI_GetBotNameByNumber(int num) {
  char *info = UI_GetBotInfoByNumber(num);
  if (info)
    return Info_ValueForKey(info, "name");
  return "";
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<UI_GetBotNameByNumber>:
  endbr64
  sub    $0x8,%rsp
  call   <UI_GetBotInfoByNumber@plt>
  mov    %rax,%rdi
  lea    D13(%rip),%rax
  test   %rdi,%rdi
  jne    L10
L6:
  add    $0x8,%rsp
  ret
L10:
  lea    D12(%rip),%rsi
  call   <Info_ValueForKey@plt>
  jmp    L6
```

tool_calls: name: unpack_data
arguments: data_tag: D13
type: string
name: unpack_data
arguments: data_tag: D12
type: string

tool: 

tool: D12: name

assistant: ```c
char *UI_GetBotNameByNumber(int num) {
  char *info = UI_GetBotInfoByNumber(num);
  if (info)
    return Info_ValueForKey(info, "name");
  return "";
}
```
user: What is the c source code of the assembly code below?

```asm
<UI_GetBotNameByNumber>:
  endbr64
  sub    $0x8,%rsp
  call   <UI_GetBotInfoByNumber@plt>
  test   %rax,%rax
  jne    L8
  lea    D11(%rip),%rax
  add    $0x8,%rsp
  ret
  xchg   %ax,%ax
L8:
  lea    D5(%rip),%rsi
  mov    %rax,%rdi
  add    $0x8,%rsp
  jmp    1070 <Info_ValueForKey@plt>
```

tool_calls: name: parse_data
arguments: label: D11
type_guessed: string
name: parse_data
arguments: label: D5
type_guessed: string

tool: 

tool: D5: name

assistant: ```c
char *UI_GetBotNameByNumber(int num) {
  char *info = UI_GetBotInfoByNumber(num);
  if (info)
    return Info_ValueForKey(info, "name");
  return "";
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<UI_GetBotNameByNumber>:
  endbr64
  sub    $0x8,%rsp
  call   <UI_GetBotInfoByNumber@plt>
  test   %rax,%rax
  jne    L9
  lea    D13(%rip),%rax
  add    $0x8,%rsp
  ret
  xchg   %ax,%ax
L9:
  lea    D14(%rip),%rsi
  mov    %rax,%rdi
  add    $0x8,%rsp
  jmp    1070 <Info_ValueForKey@plt>
```

tool_calls: name: retrieve_data
arguments: tag: D13
type_guessed: string
name: retrieve_data
arguments: tag: D14
type_guessed: string

tool: 

tool: D14: name

assistant: ```c
char *UI_GetBotNameByNumber(int num) {
  char *info = UI_GetBotInfoByNumber(num);
  if (info)
    return Info_ValueForKey(info, "name");
  return "";
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<has_cachedir_tag>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x48,%rsp
  mov    %rdi,%rbx
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  xor    %eax,%eax
  call   <strlen@plt>
  add    $0xf,%eax
  mov    D77(%rip),%edx
  cmp    %eax,%edx
  jl     L7
  cmpq   $0x0,D101(%rip)
  jne    L45
L7:
  add    %edx,%edx
  cmp    %eax,%edx
  cmovl  %eax,%edx
  mov    %edx,D114(%rip)
  mov    D101(%rip),%rdi
  call   <free@plt>
  mov    D114(%rip),%edi
  call   <malloc@plt>
  mov    %rax,D114(%rip)
L45:
  lea    D114(%rip),%r8
  mov    %rbx,%rcx
  lea    D127(%rip),%rdx
  mov    D114(%rip),%esi
  mov    D114(%rip),%rdi
  call   <snprintf@plt>
  lea    D11(%rip),%rsi
  mov    D114(%rip),%rdi
  call   <fopen@plt>
  mov    %rax,%rbx
  mov    $0x0,%ebp
  test   %rax,%rax
  je     L51
  mov    %rsp,%rdi
  mov    %rax,%rcx
  mov    $0x2b,%edx
  mov    $0x1,%esi
  call   <fread@plt>
  cmp    $0x2b,%rax
  je     L16
L9:
  mov    %rbx,%rdi
  call   <fclose@plt>
L51:
  mov    0x38(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L8
  mov    %ebp,%eax
  add    $0x48,%rsp
  pop    %rbx
  pop    %rbp
  ret
L16:
  mov    %rsp,%rdi
  mov    $0x2b,%edx
  lea    D73(%rip),%rsi
  call   <memcmp@plt>
  test   %eax,%eax
  sete   %bpl
  movzbl %bpl,%ebp
  jmp    L9
L8:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: disassemble_data
arguments: tag: D114
datatype: string
name: disassemble_data
arguments: tag: D127
datatype: string
name: disassemble_data
arguments: tag: D11
datatype: string
name: disassemble_data
arguments: tag: D73
datatype: string

tool: D114: CACHEDIR.TAG

tool: D127: %s/%s

tool: D11: rb

tool: D73: Signature: 8a477f597d28d172789f06886806bc55

assistant: ```c
int has_cachedir_tag(const char *name) {
  static int path_l = 1024;
  static char *path = NULL;
  int l;
  const size_t signature_l = sizeof "Signature: 8a477f597d28d172789f06886806bc55" - 1;
  char buf[signature_l];
  FILE *f;
  int match = 0;
  l = strlen(name) + sizeof "CACHEDIR.TAG" + 2;
  if (l > path_l || path == NULL) {
    path_l = path_l * 2;
    if (path_l < l)
      path_l = l;
    free(path);
    path = malloc(path_l);
  }
  snprintf(path, path_l, "%s/%s", name, "CACHEDIR.TAG");
  f = fopen(path, "rb");
  if (f != NULL) {
    match = ((fread(buf, 1, signature_l, f) == signature_l) && !memcmp(buf, "Signature: 8a477f597d28d172789f06886806bc55", signature_l));
    fclose(f);
  }
  return match;
}
```
user: 请从给定的汇编指令推导出C源代码:

```asm
<has_cachedir_tag>:
  endbr64
  push   %r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  sub    $0x40,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  xor    %eax,%eax
  call   <strlen@plt>
  mov    D35(%rip),%esi
  mov    D21(%rip),%rdi
  add    $0xf,%eax
  cmp    %eax,%esi
  jl     L41
  test   %rdi,%rdi
  je     L41
L23:
  mov    %r12,%rcx
  lea    D69(%rip),%r8
  xor    %r12d,%r12d
  lea    D85(%rip),%rdx
  call   <snprintf@plt>
  mov    D21(%rip),%rdi
  lea    D4(%rip),%rsi
  call   <fopen@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L58
  mov    %rsp,%r13
  mov    %rax,%rcx
  mov    $0x2b,%edx
  mov    $0x1,%esi
  mov    %r13,%rdi
  call   <fread@plt>
  cmp    $0x2b,%rax
  je     L39
L62:
  mov    %rbp,%rdi
  call   <fclose@plt>
L58:
  mov    0x38(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L40
  add    $0x40,%rsp
  mov    %r12d,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   (%rax)
L41:
  add    %esi,%esi
  cmp    %eax,%esi
  cmovl  %eax,%esi
  mov    %esi,D82(%rip)
  call   <free@plt>
  mov    D82(%rip),%edi
  call   <malloc@plt>
  mov    D82(%rip),%esi
  mov    %rax,D82(%rip)
  mov    %rax,%rdi
  jmp    L23
  nopw   0x0(%rax,%rax,1)
L39:
  mov    $0x2b,%edx
  lea    D82(%rip),%rsi
  mov    %r13,%rdi
  xor    %r12d,%r12d
  call   <memcmp@plt>
  test   %eax,%eax
  sete   %r12b
  jmp    L62
L40:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: label: D69
type: string
name: extract_symbolic_data
arguments: label: D85
type: string
name: extract_symbolic_data
arguments: label: D4
type: string
name: extract_symbolic_data
arguments: label: D82
type: string

tool: D69: CACHEDIR.TAG

tool: D85: %s/%s

tool: D4: rb

tool: D82: Signature: 8a477f597d28d172789f06886806bc55

assistant: ```c
int has_cachedir_tag(const char *name) {
  static int path_l = 1024;
  static char *path = NULL;
  int l;
  const size_t signature_l = sizeof "Signature: 8a477f597d28d172789f06886806bc55" - 1;
  char buf[signature_l];
  FILE *f;
  int match = 0;
  l = strlen(name) + sizeof "CACHEDIR.TAG" + 2;
  if (l > path_l || path == NULL) {
    path_l = path_l * 2;
    if (path_l < l)
      path_l = l;
    free(path);
    path = malloc(path_l);
  }
  snprintf(path, path_l, "%s/%s", name, "CACHEDIR.TAG");
  f = fopen(path, "rb");
  if (f != NULL) {
    match = ((fread(buf, 1, signature_l, f) == signature_l) && !memcmp(buf, "Signature: 8a477f597d28d172789f06886806bc55", signature_l));
    fclose(f);
  }
  return match;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<has_cachedir_tag>:
  endbr64
  push   %r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  sub    $0x40,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x38(%rsp)
  xor    %eax,%eax
  call   <strlen@plt>
  mov    D102(%rip),%esi
  mov    D30(%rip),%rdi
  add    $0xf,%eax
  cmp    %eax,%esi
  jl     L14
  test   %rdi,%rdi
  je     L14
L69:
  mov    %r12,%rcx
  lea    D106(%rip),%r8
  xor    %r12d,%r12d
  lea    D77(%rip),%rdx
  call   <snprintf@plt>
  mov    D30(%rip),%rdi
  lea    D60(%rip),%rsi
  call   <fopen@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L47
  mov    %rsp,%r13
  mov    %rax,%rcx
  mov    $0x2b,%edx
  mov    $0x1,%esi
  mov    %r13,%rdi
  call   <fread@plt>
  cmp    $0x2b,%rax
  je     L22
L52:
  mov    %rbp,%rdi
  call   <fclose@plt>
L47:
  mov    0x38(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L62
  add    $0x40,%rsp
  mov    %r12d,%eax
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
  nopl   (%rax)
L14:
  add    %esi,%esi
  cmp    %eax,%esi
  cmovl  %eax,%esi
  mov    %esi,D74(%rip)
  call   <free@plt>
  mov    D74(%rip),%edi
  call   <malloc@plt>
  mov    D74(%rip),%esi
  mov    %rax,D74(%rip)
  mov    %rax,%rdi
  jmp    L69
  nopw   0x0(%rax,%rax,1)
L22:
  mov    $0x2b,%edx
  lea    D74(%rip),%rsi
  mov    %r13,%rdi
  xor    %r12d,%r12d
  call   <memcmp@plt>
  test   %eax,%eax
  sete   %r12b
  jmp    L52
L62:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: parse_data
arguments: tag: D106
type: string
name: parse_data
arguments: tag: D77
type: string
name: parse_data
arguments: tag: D60
type: string
name: parse_data
arguments: tag: D74
type: string

tool: D106: CACHEDIR.TAG

tool: D77: %s/%s

tool: D60: rb

tool: D74: Signature: 8a477f597d28d172789f06886806bc55

assistant: ```c
int has_cachedir_tag(const char *name) {
  static int path_l = 1024;
  static char *path = NULL;
  int l;
  const size_t signature_l = sizeof "Signature: 8a477f597d28d172789f06886806bc55" - 1;
  char buf[signature_l];
  FILE *f;
  int match = 0;
  l = strlen(name) + sizeof "CACHEDIR.TAG" + 2;
  if (l > path_l || path == NULL) {
    path_l = path_l * 2;
    if (path_l < l)
      path_l = l;
    free(path);
    path = malloc(path_l);
  }
  snprintf(path, path_l, "%s/%s", name, "CACHEDIR.TAG");
  f = fopen(path, "rb");
  if (f != NULL) {
    match = ((fread(buf, 1, signature_l, f) == signature_l) && !memcmp(buf, "Signature: 8a477f597d28d172789f06886806bc55", signature_l));
    fclose(f);
  }
  return match;
}
```
user: 请将这段汇编代码片段转换成等效的C代码：

```asm
<mg_get_ip_address_of_nameserver>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x330,%rsp
  mov    %rdi,-0x328(%rbp)
  mov    %rsi,-0x330(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0xffffffff,-0x31c(%rbp)
  lea    D35(%rip),%rax
  mov    %rax,%rsi
  lea    D30(%rip),%rax
  mov    %rax,%rdi
  call   <fopen@plt>
  mov    %rax,-0x318(%rbp)
  cmpq   $0x0,-0x318(%rbp)
  jne    L53
  movl   $0xffffffff,-0x31c(%rbp)
  jmp    L36
L53:
  movl   $0xffffffff,-0x31c(%rbp)
  jmp    L55
L4:
  lea    -0x310(%rbp),%rdx
  lea    -0x210(%rbp),%rax
  lea    D33(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <sscanf@plt>
  cmp    $0x1,%eax
  jne    L55
  lea    -0x310(%rbp),%rdx
  mov    -0x330(%rbp),%rsi
  mov    -0x328(%rbp),%rax
  mov    %rdx,%rcx
  lea    D28(%rip),%rdx
  mov    %rax,%rdi
  call   <snprintf@plt>
  movl   $0x0,-0x31c(%rbp)
  jmp    L54
L55:
  mov    -0x318(%rbp),%rdx
  lea    -0x210(%rbp),%rax
  mov    $0x200,%esi
  mov    %rax,%rdi
  call   <fgets@plt>
  test   %rax,%rax
  jne    L4
L54:
  mov    -0x318(%rbp),%rax
  mov    %rax,%rdi
  call   <fclose@plt>
L36:
  mov    -0x31c(%rbp),%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L12
  call   <__stack_chk_fail@plt>
L12:
  leave
  ret
```

tool_calls: name: disassemble_data
arguments: data_label: D35
datatype: string
name: disassemble_data
arguments: data_label: D30
datatype: string
name: disassemble_data
arguments: data_label: D33
datatype: string
name: disassemble_data
arguments: data_label: D28
datatype: string

tool: D35: r

tool: D30: /etc/resolv.conf

tool: D33: nameserver %255[^
	 #]s

tool: D28: udp://%s:53

assistant: ```c
int mg_get_ip_address_of_nameserver(char *name, size_t name_len) {
  int ret = -1;
  FILE *fp;
  char line[512];
  if ((fp = fopen("/etc/resolv.conf", "r")) == NULL) {
    ret = -1;
  } else {
    for (ret = -1; fgets(line, sizeof(line), fp) != NULL;) {
      char buf[256];
      if (sscanf(line, "nameserver %255[^\n\t #]s", buf) == 1) {
        snprintf(name, name_len, "udp://%s:53", buf);
        ret = 0;
        break;
      }
    }
    (void)fclose(fp);
  }
  return ret;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<mg_get_ip_address_of_nameserver>:
  endbr64
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x318,%rsp
  mov    %rdi,%r12
  mov    %rsi,%r13
  mov    %fs:0x28,%rax
  mov    %rax,0x308(%rsp)
  xor    %eax,%eax
  lea    D19(%rip),%rsi
  lea    D30(%rip),%rdi
  call   <fopen@plt>
  test   %rax,%rax
  je     L3
  mov    %rax,%rbx
  lea    D38(%rip),%rbp
L17:
  lea    0x100(%rsp),%rdi
  mov    %rbx,%rdx
  mov    $0x200,%esi
  call   <fgets@plt>
  test   %rax,%rax
  je     L49
  mov    %rsp,%rdx
  lea    0x100(%rsp),%rdi
  mov    %rbp,%rsi
  call   <sscanf@plt>
  cmp    $0x1,%eax
  jne    L17
  mov    %rsp,%rcx
  lea    D5(%rip),%rdx
  mov    %r13,%rsi
  mov    %r12,%rdi
  call   <snprintf@plt>
  mov    $0x0,%ebp
  jmp    L26
L49:
  mov    $0xffffffff,%ebp
L26:
  mov    %rbx,%rdi
  call   <fclose@plt>
L20:
  mov    0x308(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L54
  mov    %ebp,%eax
  add    $0x318,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  ret
L3:
  mov    $0xffffffff,%ebp
  jmp    L20
L54:
  call   <__stack_chk_fail@plt>
```

tool_calls: name: extract_symbolic_data
arguments: label: D19
datatype: string
name: extract_symbolic_data
arguments: label: D30
datatype: string
name: extract_symbolic_data
arguments: label: D38
datatype: string
name: extract_symbolic_data
arguments: label: D5
datatype: string

tool: D19: r

tool: D30: /etc/resolv.conf

tool: D38: nameserver %255[^
	 #]s

tool: D5: udp://%s:53

assistant: ```c
int mg_get_ip_address_of_nameserver(char *name, size_t name_len) {
  int ret = -1;
  FILE *fp;
  char line[512];
  if ((fp = fopen("/etc/resolv.conf", "r")) == NULL) {
    ret = -1;
  } else {
    for (ret = -1; fgets(line, sizeof(line), fp) != NULL;) {
      char buf[256];
      if (sscanf(line, "nameserver %255[^\n\t #]s", buf) == 1) {
        snprintf(name, name_len, "udp://%s:53", buf);
        ret = 0;
        break;
      }
    }
    (void)fclose(fp);
  }
  return ret;
}
```