user: Please show me the C implementation that matches the assembly code listed below:

```asm
<gui_nicklist_add_to_infolist>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x40,%rsp
  mov    %rdi,-0x28(%rbp)
  mov    %rsi,-0x30(%rbp)
  mov    %rdx,-0x38(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  cmpq   $0x0,-0x28(%rbp)
  je     L27
  cmpq   $0x0,-0x30(%rbp)
  jne    L177
L27:
  mov    $0x0,%eax
  jmp    L4
L177:
  cmpq   $0x0,-0x38(%rbp)
  je     L68
  mov    -0x38(%rbp),%rax
  mov    $0x5,%edx
  lea    D15(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  jne    L68
  mov    -0x38(%rbp),%rax
  lea    0x5(%rax),%rdx
  mov    -0x30(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <gui_nicklist_search_nick@plt>
  mov    %rax,-0x10(%rbp)
  mov    -0x10(%rbp),%rax
  test   %rax,%rax
  jne    L82
  mov    $0x0,%eax
  jmp    L4
L82:
  mov    -0x10(%rbp),%rdx
  mov    -0x28(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <gui_nicklist_add_nick_to_infolist@plt>
  jmp    L4
L68:
  cmpq   $0x0,-0x38(%rbp)
  je     L103
  mov    -0x38(%rbp),%rax
  mov    $0x6,%edx
  lea    D12(%rip),%rcx
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <strncmp@plt>
  test   %rax,%rax
  jne    L103
  mov    -0x38(%rbp),%rax
  lea    0x6(%rax),%rdx
  mov    -0x30(%rbp),%rax
  mov    $0x0,%esi
  mov    %rax,%rdi
  call   <gui_nicklist_search_group@plt>
  mov    %rax,-0x18(%rbp)
  mov    -0x18(%rbp),%rax
  test   %rax,%rax
  jne    L127
  mov    $0x0,%eax
  jmp    L4
L127:
  mov    -0x18(%rbp),%rdx
  mov    -0x28(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <gui_nicklist_add_group_to_infolist@plt>
  jmp    L4
L103:
  movq   $0x0,-0x18(%rbp)
  movq   $0x0,-0x10(%rbp)
  lea    -0x10(%rbp),%rdx
  lea    -0x18(%rbp),%rcx
  mov    -0x30(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <gui_nicklist_get_next_item@plt>
  jmp    L46
L69:
  mov    -0x10(%rbp),%rax
  test   %rax,%rax
  je     L77
  mov    -0x10(%rbp),%rdx
  mov    -0x28(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <gui_nicklist_add_nick_to_infolist@plt>
  jmp    L110
L77:
  mov    -0x18(%rbp),%rdx
  mov    -0x28(%rbp),%rax
  mov    %rdx,%rsi
  mov    %rax,%rdi
  call   <gui_nicklist_add_group_to_infolist@plt>
L110:
  lea    -0x10(%rbp),%rdx
  lea    -0x18(%rbp),%rcx
  mov    -0x30(%rbp),%rax
  mov    %rcx,%rsi
  mov    %rax,%rdi
  call   <gui_nicklist_get_next_item@plt>
L46:
  mov    -0x18(%rbp),%rax
  test   %rax,%rax
  jne    L69
  mov    -0x10(%rbp),%rax
  test   %rax,%rax
  jne    L69
  mov    $0x1,%eax
L4:
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L101
  call   <__stack_chk_fail@plt>
L101:
  leave
  ret
```

tool_calls: name: read_data
arguments: label: D15
type_infered: string
name: read_data
arguments: label: D12
type_infered: string

tool: D15: nick_

tool: D12: group_

assistant: ```c
int gui_nicklist_add_to_infolist(struct t_infolist *infolist, struct t_gui_buffer *buffer, const char *name) {
  struct t_gui_nick_group *ptr_group;
  struct t_gui_nick *ptr_nick;
  if (!infolist || !buffer)
    return 0;
  if (name && (strncmp(name, "nick_", 5) == 0)) {
    ptr_nick = gui_nicklist_search_nick(buffer, NULL, name + 5);
    if (!ptr_nick)
      return 0;
    return gui_nicklist_add_nick_to_infolist(infolist, ptr_nick);
  }
  if (name && (strncmp(name, "group_", 6) == 0)) {
    ptr_group = gui_nicklist_search_group(buffer, NULL, name + 6);
    if (!ptr_group)
      return 0;
    return gui_nicklist_add_group_to_infolist(infolist, ptr_group);
  }
  ptr_group = NULL;
  ptr_nick = NULL;
  gui_nicklist_get_next_item(buffer, &ptr_group, &ptr_nick);
  while (ptr_group || ptr_nick) {
    if (ptr_nick)
      gui_nicklist_add_nick_to_infolist(infolist, ptr_nick);
    else
      gui_nicklist_add_group_to_infolist(infolist, ptr_group);
    gui_nicklist_get_next_item(buffer, &ptr_group, &ptr_nick);
  }
  return 1;
}
```