// File: /workspace/github_c_makefile_star2_O0/kobolt[P]curses-collection/playlist/list.c
// Function: list_filter_apply
int list_filter_apply(char *filter)
{
  int i;

  /* Just ignore everything if an invalid filter is given. */
  if (list_filter_produces_size(filter) == 0)
    return -1;

  play_block(); /* Entering critical section. */

  /* Free old filtered list first, if it exists. */
  if (list_filtered != NULL) {
    for (i = 0; i < list_filtered_size; i++) {
      free(list_filtered[i]);
    }
    free(list_filtered);
    list_filtered = NULL;
  }

  /* Use the empty string to disable the filter. */
  if (strlen(filter) == 0) {
    list = list_original;
    list_size = list_original_size;
    goto list_filter_apply_done;
  }

  list_filtered = (char **)malloc(sizeof(char *));
  if (list_filtered == NULL)
    return -1;

  list_filtered_size = 0;
  for (i = 0; i < list_original_size; i++) {
    if (list_cmp(filter, list_original[i]) == 0) {
      list_filtered[list_filtered_size] = (char *)malloc(sizeof(char) * 
        (strlen(list_original[i]) + 1));
      if (list_filtered[list_filtered_size] == NULL)
        return -1;
      strncpy(list_filtered[list_filtered_size], 
        list_original[i], strlen(list_original[i]) + 1);

      list_filtered_size++;
      list_filtered = (char **)realloc(list_filtered, sizeof(char *) *
        (list_filtered_size + 1));
      if (list_filtered == NULL)
        return -1;
    }
  }

  /* This should not happen, as size is checked earlier, but just in case... */
  if (list_filtered_size == 0) {
    free(list_filtered);
    list_filtered = NULL;

    list = list_original;
    list_size = list_original_size;
    goto list_filter_apply_done;
  }

  list = list_filtered;
  list_size = list_filtered_size;

list_filter_apply_done:
  play_unblock(); /* Leaving critical section. */
  play_cancel();
  list_current = 0;
  play_execute(list[list_current]);
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
callq 0x38c0
cmpl $0x0, %eax
jne 0x3636
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x38b0
callq 0x3ca0
cmpq $0x0, 0x2bdd(%rip)      # 0x6220
je 0x368d
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl 0x2bd3(%rip), %eax      # 0x6228
jge 0x3676
movq 0x2bc2(%rip), %rax      # 0x6220
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x2050
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x364c
movq 0x2ba3(%rip), %rdi      # 0x6220
callq 0x2050
movq $0x0, 0x2b93(%rip) # 0x6220
movq -0x10(%rbp), %rdi
callq 0x20d0
cmpq $0x0, %rax
jne 0x36bb
movq 0x2b5d(%rip), %rax      # 0x6200
movq %rax, 0x2b66(%rip)      # 0x6210
movl 0x2b58(%rip), %eax      # 0x6208
movl %eax, 0x2b62(%rip)      # 0x6218
jmp 0x387e
movl $0x8, %edi
callq 0x21c0
movq %rax, 0x2b54(%rip)      # 0x6220
cmpq $0x0, 0x2b4c(%rip)      # 0x6220
jne 0x36e2
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x38b0
movl $0x0, 0x2b3c(%rip)      # 0x6228
movl $0x0, -0x14(%rbp)
movl -0x14(%rbp), %eax
cmpl 0x2b0c(%rip), %eax      # 0x6208
jge 0x3828
movq -0x10(%rbp), %rdi
movq 0x2af3(%rip), %rax      # 0x6200
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x3930
cmpl $0x0, %eax
jne 0x3818
movq 0x2ad6(%rip), %rax      # 0x6200
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x20d0
movq %rax, %rdi
addq $0x1, %rdi
shlq $0x0, %rdi
callq 0x21c0
movq %rax, %rdx
movq 0x2acf(%rip), %rax      # 0x6220
movslq 0x2ad0(%rip), %rcx      # 0x6228
movq %rdx, (%rax,%rcx,8)
movq 0x2abd(%rip), %rax      # 0x6220
movslq 0x2abe(%rip), %rcx      # 0x6228
cmpq $0x0, (%rax,%rcx,8)
jne 0x377d
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x38b0
movq 0x2a9c(%rip), %rax      # 0x6220
movslq 0x2a9d(%rip), %rcx      # 0x6228
movq (%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
movq 0x2a66(%rip), %rax      # 0x6200
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x20(%rbp)
movq 0x2a53(%rip), %rax      # 0x6200
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x20d0
movq -0x28(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq %rax, %rdx
addq $0x1, %rdx
callq 0x2080
movl 0x2a54(%rip), %eax      # 0x6228
addl $0x1, %eax
movl %eax, 0x2a4b(%rip)      # 0x6228
movq 0x2a3c(%rip), %rdi      # 0x6220
movl 0x2a3e(%rip), %eax      # 0x6228
addl $0x1, %eax
movslq %eax, %rsi
shlq $0x3, %rsi
callq 0x21e0
movq %rax, 0x2a20(%rip)      # 0x6220
cmpq $0x0, 0x2a18(%rip)      # 0x6220
jne 0x3816
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x38b0
jmp 0x3818
jmp 0x381a
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x36f3
cmpl $0x0, 0x29f9(%rip)      # 0x6228
jne 0x3864
movq 0x29e8(%rip), %rdi      # 0x6220
callq 0x2050
movq $0x0, 0x29d8(%rip) # 0x6220
movq 0x29b1(%rip), %rax      # 0x6200
movq %rax, 0x29ba(%rip)      # 0x6210
movl 0x29ac(%rip), %eax      # 0x6208
movl %eax, 0x29b6(%rip)      # 0x6218
jmp 0x387e
movq 0x29b5(%rip), %rax      # 0x6220
movq %rax, 0x299e(%rip)      # 0x6210
movl 0x29b0(%rip), %eax      # 0x6228
movl %eax, 0x299a(%rip)      # 0x6218
callq 0x3ce0
callq 0x3ae0
movl $0x0, 0x2902(%rip)      # 0x6194
movq 0x2977(%rip), %rax      # 0x6210
movslq 0x28f4(%rip), %rcx      # 0x6194
movq (%rax,%rcx,8), %rdi
callq 0x3b70
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)