ylfeng/ReF-Decompile-dataset huggingface dataset:
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<trim>:
  endbr64
  push   %r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  call   <strlen@plt>
  movslq %eax,%rbx
  jmp    L55
  nopl   0x0(%rax,%rax,1)
L26:
  movb   $0x0,(%r12,%rbx,1)
L55:
  movsbl -0x1(%r12,%rbx,1),%edi
  mov    %ebx,%r13d
  sub    $0x1,%rbx
  call   <isspace@plt>
  test   %rax,%rax
  jne    L26
  movsbl (%r12),%edi
  mov    %r12,%rbp
  lea    0x0(%r13,%r12,1),%ebx
  test   %dil,%dil
  jne    L8
  jmp    L18
L47:
  movsbl 0x1(%rbp),%edi
  add    $0x1,%rbp
  test   %dil,%dil
  je     L46
L8:
  mov    %ebx,%r13d
  sub    %ebp,%r13d
  call   <isspace@plt>
  test   %rax,%rax
  jne    L47
L18:
  add    $0x1,%r13d
L46:
  add    $0x8,%rsp
  mov    %r13d,%edx
  mov    %rbp,%rsi
  mov    %r12,%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  jmp    1090 <memmove@plt>
```

assistant: ```c
void trim(char *s) {
  char *p = s;
  int l = strlen(p);
  while (isspace(p[l - 1]))
    p[--l] = 0;
  while (*p && isspace(*p))
    ++p, --l;
  memmove(s, p, l + 1);
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<trim>:
  endbr64
  push   %r13
  push   %r12
  mov    %rdi,%r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  call   <strlen@plt>
  movslq %eax,%rbx
  jmp    L41
  nopl   0x0(%rax,%rax,1)
L32:
  movb   $0x0,(%r12,%rbx,1)
L41:
  movsbl -0x1(%r12,%rbx,1),%edi
  mov    %ebx,%r13d
  sub    $0x1,%rbx
  call   <isspace@plt>
  test   %rax,%rax
  jne    L32
  movsbl (%r12),%edi
  mov    %r12,%rbp
  lea    0x0(%r13,%r12,1),%ebx
  test   %dil,%dil
  jne    L21
  jmp    L19
L16:
  movsbl 0x1(%rbp),%edi
  add    $0x1,%rbp
  test   %dil,%dil
  je     L24
L21:
  mov    %ebx,%r13d
  sub    %ebp,%r13d
  call   <isspace@plt>
  test   %rax,%rax
  jne    L16
L19:
  add    $0x1,%r13d
L24:
  add    $0x8,%rsp
  mov    %r13d,%edx
  mov    %rbp,%rsi
  mov    %r12,%rdi
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  jmp    1090 <memmove@plt>
```

assistant: ```c
void trim(char *s) {
  char *p = s;
  int l = strlen(p);
  while (isspace(p[l - 1]))
    p[--l] = 0;
  while (*p && isspace(*p))
    ++p, --l;
  memmove(s, p, l + 1);
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<GetMemory>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  mov    %rdi,-0x8(%rbp)
  mov    $0x64,%edi
  call   <malloc@plt>
  mov    %rax,-0x8(%rbp)
  mov    -0x8(%rbp),%rax
  leave
  ret
```

assistant: ```c
char *GetMemory(char *p) {
  p = (char *)malloc(100);
  return p;
}
```
user: 请将这段汇编代码片段转换成等效的C代码:

```asm
<GetMemory>:
  endbr64
  sub    $0x8,%rsp
  mov    $0x64,%edi
  call   <malloc@plt>
  add    $0x8,%rsp
  ret
```

assistant: ```c
char *GetMemory(char *p) {
  p = (char *)malloc(100);
  return p;
}
```
user: 这段汇编代码用C语言表示是什么样的？

```asm
<GetMemory>:
  endbr64
  mov    $0x64,%edi
  jmp    1050 <malloc@plt>
```

assistant: ```c
char *GetMemory(char *p) {
  p = (char *)malloc(100);
  return p;
}
```
user: 请从给定的汇编指令推导出C源代码：

```asm
<GetMemory>:
  endbr64
  mov    $0x64,%edi
  jmp    1050 <malloc@plt>
```

assistant: ```c
char *GetMemory(char *p) {
  p = (char *)malloc(100);
  return p;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<Handle_Backslash>:
  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
  lea    0x1(%rax),%rdx
  mov    %rdx,-0x28(%rbp)
  movzbl (%rax),%eax
  mov    %al,-0x11(%rbp)
  cmpb   $0x0,-0x11(%rbp)
  jne    L37
  mov    -0x28(%rbp),%rax
  jmp    L88
L37:
  movsbl -0x11(%rbp),%eax
  cmp    $0x74,%eax
  je     L65
  cmp    $0x74,%eax
  jg     L12
  cmp    $0x37,%eax
  jg     L108
  cmp    $0x30,%eax
  jge    L107
  jmp    L12
L108:
  cmp    $0x6e,%eax
  jne    L12
  mov    $0xa,%edi
  call   <putchar@plt>
  jmp    L112
L65:
  mov    $0x9,%edi
  call   <putchar@plt>
  jmp    L112
L107:
  lea    -0x10(%rbp),%rdx
  mov    -0x28(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <Scan_Octal@plt>
  mov    %rax,-0x28(%rbp)
  mov    -0x10(%rbp),%rax
  movsbl %al,%eax
  mov    %eax,%edi
  call   <putchar@plt>
  jmp    L112
L12:
  movsbl -0x11(%rbp),%eax
  mov    %eax,%edi
  call   <putchar@plt>
  nop
L112:
  mov    -0x28(%rbp),%rax
L88:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L0
  call   <__stack_chk_fail@plt>
L0:
  leave
  ret
```

assistant: ```c
const char *Handle_Backslash(const char *dformat) {
  char c;
  unsigned long i;
  if (!(c = *(dformat++)))
    return dformat;
  switch (c) {
  case 'n':
    putchar('\n');
    break;
  case 't':
    putchar('\t');
    break;
  case '0':
  case '1':
  case '2':
  case '3':
  case '4':
  case '5':
  case '6':
  case '7':
    dformat = Scan_Octal(dformat, &i);
    putchar((int)i);
    break;
  default:
    putchar(c);
    break;
  }
  return dformat;
}
```
user: 请显示与下面列出的汇编代码相匹配的C语言实现：

```asm
<Handle_Backslash>:
  endbr64
  push   %rbx
  sub    $0x10,%rsp
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  lea    0x1(%rdi),%rbx
  movzbl (%rdi),%edi
  test   %dil,%dil
  je     L69
  cmp    $0x6e,%dil
  je     L39
  jg     L45
  lea    -0x30(%rdi),%eax
  cmp    $0x7,%al
  ja     L16
  mov    %rsp,%rsi
  mov    %rbx,%rdi
  call   <Scan_Octal@plt>
  mov    %rax,%rbx
  movsbl (%rsp),%edi
  call   <putchar@plt>
  jmp    L69
L45:
  cmp    $0x74,%dil
  jne    L16
  mov    $0x9,%edi
  call   <putchar@plt>
  jmp    L69
L39:
  mov    $0xa,%edi
  call   <putchar@plt>
L69:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L5
  mov    %rbx,%rax
  add    $0x10,%rsp
  pop    %rbx
  ret
L16:
  movsbl %dil,%edi
  call   <putchar@plt>
  jmp    L69
L5:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
const char *Handle_Backslash(const char *dformat) {
  char c;
  unsigned long i;
  if (!(c = *(dformat++)))
    return dformat;
  switch (c) {
  case 'n':
    putchar('\n');
    break;
  case 't':
    putchar('\t');
    break;
  case '0':
  case '1':
  case '2':
  case '3':
  case '4':
  case '5':
  case '6':
  case '7':
    dformat = Scan_Octal(dformat, &i);
    putchar((int)i);
    break;
  default:
    putchar(c);
    break;
  }
  return dformat;
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<Handle_Backslash>:
  endbr64
  push   %r12
  lea    0x1(%rdi),%r12
  sub    $0x10,%rsp
  movsbl (%rdi),%edi
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  test   %dil,%dil
  je     L43
  cmp    $0x6e,%dil
  je     L69
  jg     L32
  lea    -0x30(%rdi),%eax
  cmp    $0x7,%al
  ja     L60
  mov    %r12,%rdi
  mov    %rsp,%rsi
  call   <Scan_Octal@plt>
  movsbl (%rsp),%edi
  mov    %rax,%r12
  call   <putchar@plt>
  nopl   0x0(%rax)
L43:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L46
  add    $0x10,%rsp
  mov    %r12,%rax
  pop    %r12
  ret
  nopw   0x0(%rax,%rax,1)
L32:
  cmp    $0x74,%dil
  jne    L60
  mov    $0x9,%edi
  call   <putchar@plt>
  jmp    L43
  nopw   0x0(%rax,%rax,1)
L60:
  call   <putchar@plt>
  jmp    L43
  nop
L69:
  mov    $0xa,%edi
  call   <putchar@plt>
  jmp    L43
L46:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
const char *Handle_Backslash(const char *dformat) {
  char c;
  unsigned long i;
  if (!(c = *(dformat++)))
    return dformat;
  switch (c) {
  case 'n':
    putchar('\n');
    break;
  case 't':
    putchar('\t');
    break;
  case '0':
  case '1':
  case '2':
  case '3':
  case '4':
  case '5':
  case '6':
  case '7':
    dformat = Scan_Octal(dformat, &i);
    putchar((int)i);
    break;
  default:
    putchar(c);
    break;
  }
  return dformat;
}
```
user: Please show me the C implementation that matches the assembly code listed below:

```asm
<Handle_Backslash>:
  endbr64
  push   %r12
  lea    0x1(%rdi),%r12
  sub    $0x10,%rsp
  movsbl (%rdi),%edi
  mov    %fs:0x28,%rax
  mov    %rax,0x8(%rsp)
  xor    %eax,%eax
  test   %dil,%dil
  je     L6
  cmp    $0x6e,%dil
  je     L83
  jg     L66
  lea    -0x30(%rdi),%eax
  cmp    $0x7,%al
  ja     L69
  mov    %r12,%rdi
  mov    %rsp,%rsi
  call   <Scan_Octal@plt>
  movsbl (%rsp),%edi
  mov    %rax,%r12
  call   <putchar@plt>
  nopl   0x0(%rax)
L6:
  mov    0x8(%rsp),%rax
  sub    %fs:0x28,%rax
  jne    L56
  add    $0x10,%rsp
  mov    %r12,%rax
  pop    %r12
  ret
  nopw   0x0(%rax,%rax,1)
L66:
  cmp    $0x74,%dil
  jne    L69
  mov    $0x9,%edi
  call   <putchar@plt>
  jmp    L6
  nopw   0x0(%rax,%rax,1)
L69:
  call   <putchar@plt>
  jmp    L6
  nop
L83:
  mov    $0xa,%edi
  call   <putchar@plt>
  jmp    L6
L56:
  call   <__stack_chk_fail@plt>
```

assistant: ```c
const char *Handle_Backslash(const char *dformat) {
  char c;
  unsigned long i;
  if (!(c = *(dformat++)))
    return dformat;
  switch (c) {
  case 'n':
    putchar('\n');
    break;
  case 't':
    putchar('\t');
    break;
  case '0':
  case '1':
  case '2':
  case '3':
  case '4':
  case '5':
  case '6':
  case '7':
    dformat = Scan_Octal(dformat, &i);
    putchar((int)i);
    break;
  default:
    putchar(c);
    break;
  }
  return dformat;
}
```
user: 这段汇编代码用C语言表示是什么样的?

```asm
<main>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x10,%rsp
  movl   $0x0,-0x4(%rbp)
L16:
  mov    -0x4(%rbp),%edx
  movslq %edx,%rax
  imul   $0x55555556,%rax,%rax
  shr    $0x20,%rax
  mov    %edx,%ecx
  sar    $0x1f,%ecx
  sub    %ecx,%eax
  mov    %eax,%ecx
  add    %ecx,%ecx
  add    %eax,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  test   %eax,%eax
  je     L9
  mov    -0x4(%rbp),%edx
  movslq %edx,%rax
  imul   $0xffffffff92492493,%rax,%rax
  shr    $0x20,%rax
  add    %edx,%eax
  sar    $0x2,%eax
  mov    %edx,%ecx
  sar    $0x1f,%ecx
  sub    %ecx,%eax
  mov    %eax,%ecx
  shl    $0x3,%ecx
  sub    %eax,%ecx
  mov    %edx,%eax
  sub    %ecx,%eax
  test   %eax,%eax
  je     L9
  mov    -0x4(%rbp),%eax
  mov    %eax,%esi
  lea    D5(%rip),%rax
  mov    %rax,%rdi
  call   <printf@plt>
L9:
  addl   $0x1,-0x4(%rbp)
  cmpl   $0x7530,-0x4(%rbp)
  jle    L16
  mov    $0x0,%eax
  leave
  ret
```

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

tool: D5: %d 


assistant: ```c
int main() {
  int i;
  i = 0;
  do {
    if (i % 3 && i % 7) {
      printf("%d \n", i);
    }
    i = i + 1;
  } while (i <= 30000);
  return (0);
}
```
user: What would the C source look like for the assembly code provided here:

```asm
<main>:
  endbr64
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    $0x0,%ebx
  lea    D7(%rip),%rbp
L36:
  add    $0x1,%ebx
  cmp    $0x7531,%ebx
  je     L2
  movslq %ebx,%rax
  imul   $0x55555556,%rax,%rax
  shr    $0x20,%rax
  mov    %ebx,%edx
  sar    $0x1f,%edx
  sub    %edx,%eax
  lea    (%rax,%rax,2),%eax
  cmp    %eax,%ebx
  je     L36
  movslq %ebx,%rax
  imul   $0xffffffff92492493,%rax,%rax
  shr    $0x20,%rax
  add    %ebx,%eax
  sar    $0x2,%eax
  mov    %ebx,%edx
  sar    $0x1f,%edx
  sub    %edx,%eax
  lea    0x0(,%rax,8),%edx
  sub    %eax,%edx
  cmp    %edx,%ebx
  je     L36
  mov    %ebx,%esi
  mov    %rbp,%rdi
  call   <printf@plt>
  jmp    L36
L2:
  mov    $0x0,%eax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  ret
```

tool_calls: name: unpack_data
arguments: data_tag: D7
type: string

tool: D7: %d 


assistant: ```c
int main() {
  int i;
  i = 0;
  do {
    if (i % 3 && i % 7) {
      printf("%d \n", i);
    }
    i = i + 1;
  } while (i <= 30000);
  return (0);
}
```
user: Demonstrate the C code that generates the assembly output below:

```asm
<main>:
  endbr64
  push   %rbp
  lea    D6(%rip),%rbp
  push   %rbx
  xor    %ebx,%ebx
  sub    $0x8,%rsp
  nopl   0x0(%rax,%rax,1)
L27:
  add    $0x1,%ebx
  cmp    $0x7531,%ebx
  je     L2
L10:
  imul   $0xaaaaaaab,%ebx,%eax
  cmp    $0x55555555,%eax
  jbe    L27
  imul   $0xb6db6db7,%ebx,%eax
  cmp    $0x24924924,%eax
  jbe    L27
  mov    %ebx,%esi
  mov    %rbp,%rdi
  add    $0x1,%ebx
  call   <printf@plt>
  cmp    $0x7531,%ebx
  jne    L10
L2:
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  ret
```

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

tool: D6: %d 


assistant: ```c
int main() {
  int i;
  i = 0;
  do {
    if (i % 3 && i % 7) {
      printf("%d \n", i);
    }
    i = i + 1;
  } while (i <= 30000);
  return (0);
}
```
user: 请将以下的汇编代码转换成C语言代码：

```asm
<main>:
  endbr64
  push   %rbp
  lea    D6(%rip),%rbp
  push   %rbx
  mov    $0x1,%ebx
  sub    $0x8,%rsp
  jmp    L6
  nopl   0x0(%rax,%rax,1)
L25:
  add    $0x1,%ebx
  cmp    $0x7531,%ebx
  je     L43
L6:
  imul   $0xaaaaaaab,%ebx,%eax
  cmp    $0x55555555,%eax
  jbe    L25
  imul   $0xb6db6db7,%ebx,%eax
  cmp    $0x24924924,%eax
  jbe    L25
  mov    %ebx,%esi
  mov    %rbp,%rdi
  add    $0x1,%ebx
  call   <printf@plt>
  cmp    $0x7531,%ebx
  jne    L6
L43:
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  ret
```

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

tool: D6: %d 


assistant: ```c
int main() {
  int i;
  i = 0;
  do {
    if (i % 3 && i % 7) {
      printf("%d \n", i);
    }
    i = i + 1;
  } while (i <= 30000);
  return (0);
}
```
user: 下面的汇编指令对应的C源代码是什么:

```asm
<udev_device_tag_index>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x50,%rsp
  mov    %rdi,-0x38(%rbp)
  mov    %rsi,-0x40(%rbp)
  mov    %edx,-0x44(%rbp)
  cmpl   $0x0,-0x44(%rbp)
  je     L107
  cmpq   $0x0,-0x40(%rbp)
  je     L107
  mov    -0x40(%rbp),%rax
  mov    %rax,%rdi
  call   <udev_device_get_tags_list_entry@plt>
  mov    %rax,-0x20(%rbp)
  jmp    L37
L94:
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <udev_list_entry_get_name@plt>
  mov    %rax,-0x10(%rbp)
  movl   $0x0,-0x24(%rbp)
  mov    -0x38(%rbp),%rax
  mov    %rax,%rdi
  call   <udev_device_get_tags_list_entry@plt>
  mov    %rax,-0x18(%rbp)
  jmp    L108
L16:
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <udev_list_entry_get_name@plt>
  mov    %rax,-0x8(%rbp)
  mov    -0x10(%rbp),%rdx
  mov    -0x8(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L42
  movl   $0x1,-0x24(%rbp)
  jmp    L41
L42:
  mov    -0x18(%rbp),%rax
  mov    %rax,%rdi
  call   <udev_list_entry_get_next@plt>
  mov    %rax,-0x18(%rbp)
L108:
  cmpq   $0x0,-0x18(%rbp)
  jne    L16
L41:
  cmpl   $0x0,-0x24(%rbp)
  jne    L55
  mov    -0x10(%rbp),%rcx
  mov    -0x40(%rbp),%rax
  mov    $0x0,%edx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <udev_device_tag@plt>
L55:
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <udev_list_entry_get_next@plt>
  mov    %rax,-0x20(%rbp)
L37:
  cmpq   $0x0,-0x20(%rbp)
  jne    L94
L107:
  mov    -0x38(%rbp),%rax
  mov    %rax,%rdi
  call   <udev_device_get_tags_list_entry@plt>
  mov    %rax,-0x20(%rbp)
  jmp    L1
L58:
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <udev_list_entry_get_name@plt>
  mov    %rax,%rcx
  mov    -0x44(%rbp),%edx
  mov    -0x38(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <udev_device_tag@plt>
  mov    -0x20(%rbp),%rax
  mov    %rax,%rdi
  call   <udev_list_entry_get_next@plt>
  mov    %rax,-0x20(%rbp)
L1:
  cmpq   $0x0,-0x20(%rbp)
  jne    L58
  mov    $0x0,%eax
  leave
  ret
```

assistant: ```c
int udev_device_tag_index(struct udev_device *dev, struct udev_device *dev_old, bool add) {
  struct udev_list_entry *list_entry;
  bool found;
  if (add && dev_old != NULL) {
    for (list_entry = udev_device_get_tags_list_entry(dev_old); list_entry != NULL; list_entry = udev_list_entry_get_next(list_entry)) {
      const char *tag_old = udev_list_entry_get_name(list_entry);
      struct udev_list_entry *list_entry_current;
      found = false;
      for (list_entry_current = udev_device_get_tags_list_entry(dev); list_entry_current != NULL; list_entry_current = udev_list_entry_get_next(list_entry_current)) {
        const char *tag = udev_list_entry_get_name(list_entry_current);
        if ((strcmp((tag), (tag_old)) == 0)) {
          found = true;
          break;
        }
      }
      if (!found)
        udev_device_tag(dev_old, tag_old, false);
    }
  }
  for (list_entry = udev_device_get_tags_list_entry(dev); list_entry != NULL; list_entry = udev_list_entry_get_next(list_entry))
    udev_device_tag(dev, udev_list_entry_get_name(list_entry), add);
  return 0;
}
```
user: Converte this assembly snippet into its equivalent C code:

```asm
<udev_device_tag_index>:
  endbr64
  push   %r15
  push   %r14
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  sub    $0x8,%rsp
  mov    %rdi,%r13
  mov    %edx,%r14d
  test   %edx,%edx
  je     L63
  mov    %rsi,%r15
  test   %rsi,%rsi
  jne    L26
L63:
  mov    %r13,%rdi
  call   <udev_device_get_tags_list_entry@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L68
L64:
  mov    %rbx,%rdi
  call   <udev_list_entry_get_name@plt>
  mov    %rax,%rsi
  mov    %r14d,%edx
  mov    %r13,%rdi
  call   <udev_device_tag@plt>
  mov    %rbx,%rdi
  call   <udev_list_entry_get_next@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  jne    L64
L68:
  mov    $0x0,%eax
  add    $0x8,%rsp
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
L26:
  mov    %rsi,%rdi
  call   <udev_device_get_tags_list_entry@plt>
  mov    %rax,%r12
  test   %rax,%rax
  jne    L18
  jmp    L63
L83:
  mov    %r12,%rdi
  call   <udev_list_entry_get_next@plt>
  mov    %rax,%r12
  test   %rax,%rax
  je     L63
L18:
  mov    %r12,%rdi
  call   <udev_list_entry_get_name@plt>
  mov    %rax,%rbp
  mov    %r13,%rdi
  call   <udev_device_get_tags_list_entry@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  je     L97
L46:
  mov    %rbx,%rdi
  call   <udev_list_entry_get_name@plt>
  mov    %rax,%rdi
  mov    %rbp,%rsi
  call   <strcmp@plt>
  test   %rax,%rax
  je     L83
  mov    %rbx,%rdi
  call   <udev_list_entry_get_next@plt>
  mov    %rax,%rbx
  test   %rax,%rax
  jne    L46
L97:
  mov    $0x0,%edx
  mov    %rbp,%rsi
  mov    %r15,%rdi
  call   <udev_device_tag@plt>
  jmp    L83
```

assistant: ```c
int udev_device_tag_index(struct udev_device *dev, struct udev_device *dev_old, bool add) {
  struct udev_list_entry *list_entry;
  bool found;
  if (add && dev_old != NULL) {
    for (list_entry = udev_device_get_tags_list_entry(dev_old); list_entry != NULL; list_entry = udev_list_entry_get_next(list_entry)) {
      const char *tag_old = udev_list_entry_get_name(list_entry);
      struct udev_list_entry *list_entry_current;
      found = false;
      for (list_entry_current = udev_device_get_tags_list_entry(dev); list_entry_current != NULL; list_entry_current = udev_list_entry_get_next(list_entry_current)) {
        const char *tag = udev_list_entry_get_name(list_entry_current);
        if ((strcmp((tag), (tag_old)) == 0)) {
          found = true;
          break;
        }
      }
      if (!found)
        udev_device_tag(dev_old, tag_old, false);
    }
  }
  for (list_entry = udev_device_get_tags_list_entry(dev); list_entry != NULL; list_entry = udev_list_entry_get_next(list_entry))
    udev_device_tag(dev, udev_list_entry_get_name(list_entry), add);
  return 0;
}
```
user: What would the C source look like for the assembly code provided here?

```asm
<udev_device_tag_index>:
  endbr64
  push   %r15
  push   %r14
  mov    %edx,%r14d
  push   %r13
  push   %r12
  push   %rbp
  push   %rbx
  mov    %rdi,%rbx
  sub    $0x8,%rsp
  test   %edx,%edx
  je     L38
  mov    %rsi,%r15
  test   %rsi,%rsi
  jne    L23
L38:
  mov    %rbx,%rdi
  call   <udev_device_get_tags_list_entry@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L98
  nopl   0x0(%rax)
L92:
  mov    %rbp,%rdi
  call   <udev_list_entry_get_name@plt>
  mov    %r14d,%edx
  mov    %rbx,%rdi
  mov    %rax,%rsi
  call   <udev_device_tag@plt>
  mov    %rbp,%rdi
  call   <udev_list_entry_get_next@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  jne    L92
L98:
  add    $0x8,%rsp
  xor    %eax,%eax
  pop    %rbx
  pop    %rbp
  pop    %r12
  pop    %r13
  pop    %r14
  pop    %r15
  ret
  nop
L23:
  mov    %rsi,%rdi
  call   <udev_device_get_tags_list_entry@plt>
  mov    %rax,%r13
  test   %rax,%rax
  je     L38
L27:
  mov    %r13,%rdi
  call   <udev_list_entry_get_name@plt>
  mov    %rbx,%rdi
  mov    %rax,%r12
  call   <udev_device_get_tags_list_entry@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  jne    L99
  jmp    L117
  nopl   (%rax)
L56:
  mov    %rbp,%rdi
  call   <udev_list_entry_get_next@plt>
  mov    %rax,%rbp
  test   %rax,%rax
  je     L117
L99:
  mov    %rbp,%rdi
  call   <udev_list_entry_get_name@plt>
  mov    %r12,%rsi
  mov    %rax,%rdi
  call   <strcmp@plt>
  test   %rax,%rax
  jne    L56
  mov    %r13,%rdi
  call   <udev_list_entry_get_next@plt>
  mov    %rax,%r13
  test   %rax,%rax
  jne    L27
  jmp    L38
  nopl   (%rax)
L117:
  xor    %edx,%edx
  mov    %r12,%rsi
  mov    %r15,%rdi
  call   <udev_device_tag@plt>
  mov    %r13,%rdi
  call   <udev_list_entry_get_next@plt>
  mov    %rax,%r13
  test   %rax,%rax
  jne    L27
  jmp    L38
```

assistant: ```c
int udev_device_tag_index(struct udev_device *dev, struct udev_device *dev_old, bool add) {
  struct udev_list_entry *list_entry;
  bool found;
  if (add && dev_old != NULL) {
    for (list_entry = udev_device_get_tags_list_entry(dev_old); list_entry != NULL; list_entry = udev_list_entry_get_next(list_entry)) {
      const char *tag_old = udev_list_entry_get_name(list_entry);
      struct udev_list_entry *list_entry_current;
      found = false;
      for (list_entry_current = udev_device_get_tags_list_entry(dev); list_entry_current != NULL; list_entry_current = udev_list_entry_get_next(list_entry_current)) {
        const char *tag = udev_list_entry_get_name(list_entry_current);
        if ((strcmp((tag), (tag_old)) == 0)) {
          found = true;
          break;
        }
      }
      if (!found)
        udev_device_tag(dev_old, tag_old, false);
    }
  }
  for (list_entry = udev_device_get_tags_list_entry(dev); list_entry != NULL; list_entry = udev_list_entry_get_next(list_entry))
    udev_device_tag(dev, udev_list_entry_get_name(list_entry), add);
  return 0;
}
```