// File: /workspace/github_c_makefile_star2_O0/justy989[P]ce/ce_complete.c
// Function: ce_complete_match
void ce_complete_match(CeComplete_t* complete, const char* match){
     if(complete->count == 0) return;
     if(strlen(match)){
          for(int64_t i = 0; i < complete->count; i++){
               const char* str = strstr(complete->elements[i].string, match);
               complete->elements[i].match = (str != NULL);

               // any options that are an identical match, override the current selection
               if(strcmp(match, complete->elements[i].string) == 0) complete->current = i;
          }
     }else{
          for(int64_t i = 0; i < complete->count; i++){
               complete->elements[i].match = true;
          }
     }

     // if our current no longer matches, find another that matches
     if(complete->current >= 0){
          if(!complete->elements[complete->current].match){
               bool found_match = false;

               for(int64_t i = complete->current + 1; i != complete->current; i++){
                    if(i >= complete->count) i = 0;
                    if(complete->elements[i].match){
                         complete->current = i;
                         found_match = true;
                         break;
                    }

                    if(i == 0 && complete->current == 0) break;
               }

               // if no matches, use invalid index
               if(!found_match) complete->current = -1;
          }
     }else{
          for(int64_t i = 0; i < complete->count; i++){
               if(complete->elements[i].match){
                    complete->current = i;
                    break;
               }
          }
     }

     if(complete->current >= 0){
          free(complete->current_match);
          complete->current_match = strdup(match);
     }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x8(%rax)
jne 0x22310
jmp 0x2252b
movq -0x10(%rbp), %rdi
callq 0xd200
cmpq $0x0, %rax
je 0x223b6
movq $0x0, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jge 0x223b4
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0x18, -0x18(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rdi
movq -0x10(%rbp), %rsi
callq 0xd6d0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
setne %cl
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0x18, -0x18(%rbp), %rdx
addq %rdx, %rax
andb $0x1, %cl
movb %cl, 0x10(%rax)
movq -0x10(%rbp), %rdi
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0x18, -0x18(%rbp), %rcx
addq %rcx, %rax
movq (%rax), %rsi
callq 0xd370
cmpl $0x0, %eax
jne 0x223a1
movq -0x18(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x18(%rax)
jmp 0x223a3
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
jmp 0x2232b
jmp 0x223ef
movq $0x0, -0x28(%rbp)
movq -0x28(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jge 0x223ed
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0x18, -0x28(%rbp), %rcx
addq %rcx, %rax
movb $0x1, 0x10(%rax)
movq -0x28(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x28(%rbp)
jmp 0x223be
jmp 0x223ef
movq -0x8(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jl 0x224b4
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rbp), %rcx
imulq $0x18, 0x18(%rcx), %rcx
addq %rcx, %rax
testb $0x1, 0x10(%rax)
jne 0x224b2
movb $0x0, -0x29(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq 0x18(%rcx), %rax
je 0x2249e
movq -0x38(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jl 0x22453
movq $0x0, -0x38(%rbp)
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0x18, -0x38(%rbp), %rcx
addq %rcx, %rax
testb $0x1, 0x10(%rax)
je 0x2247a
movq -0x38(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x18(%rax)
movb $0x1, -0x29(%rbp)
jmp 0x2249e
cmpq $0x0, -0x38(%rbp)
jne 0x2248e
movq -0x8(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x2248e
jmp 0x2249e
jmp 0x22490
movq -0x38(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
jmp 0x2242f
testb $0x1, -0x29(%rbp)
jne 0x224b0
movq -0x8(%rbp), %rax
movq $-0x1, 0x18(%rax)
jmp 0x224b2
jmp 0x224ff
movq $0x0, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq -0x8(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jge 0x224fd
movq -0x8(%rbp), %rax
movq (%rax), %rax
imulq $0x18, -0x40(%rbp), %rcx
addq %rcx, %rax
testb $0x1, 0x10(%rax)
je 0x224ed
movq -0x40(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x18(%rax)
jmp 0x224fd
jmp 0x224ef
movq -0x40(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
jmp 0x224bc
jmp 0x224ff
movq -0x8(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jl 0x2252b
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0xd090
movq -0x10(%rbp), %rdi
callq 0xd620
movq %rax, %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x10(%rax)
addq $0x40, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)