// File: /workspace/github_c_makefile_star2_O2/justy989[P]ce/ce_app.c
// Function: ce_syntax_highlight_completions
void ce_syntax_highlight_completions(CeView_t* view, CeRangeList_t* highlight_range_list, CeDrawColorList_t* draw_color_list,
                                     CeSyntaxDef_t* syntax_defs, void* user_data){
     if(!user_data) return;
     if(!view->buffer) return;
     if(view->buffer->line_count <= 0) return;
     CeComplete_t* complete = user_data;
     int64_t min = view->scroll.y;
     int64_t max = min + (view->rect.bottom - view->rect.top);
     int64_t clamp_max = (view->buffer->line_count - 1);
     if(clamp_max < 0) clamp_max = 0;
     CE_CLAMP(min, 0, clamp_max);
     CE_CLAMP(max, 0, clamp_max);
     int64_t match_len = 0;
     if(complete->current_match) match_len = strlen(complete->current_match);

     // figure out which line to highlight
     int64_t selected = 0;
     for(int64_t i = 0; i < complete->count; i++){
          if(complete->elements[i].match){
               if(i == complete->current) break;
               selected++;
          }
     }

     for(int64_t y = min; y <= max; ++y){
          char* line = view->buffer->lines[y];
          char* end_of_match = strchr(line, ':');
          CePoint_t match_point = {0, y};

          if(selected == y){
               int fg = ce_syntax_def_get_fg(syntax_defs, CE_SYNTAX_COLOR_COMPLETE_SELECTED, ce_draw_color_list_last_fg_color(draw_color_list));
               int bg = ce_syntax_def_get_bg(syntax_defs, CE_SYNTAX_COLOR_COMPLETE_SELECTED, ce_draw_color_list_last_bg_color(draw_color_list));
               ce_draw_color_list_insert(draw_color_list, fg, bg, match_point);
          }else{
               ce_draw_color_list_insert(draw_color_list, CE_COLOR_DEFAULT, CE_COLOR_DEFAULT, match_point);
          }

          if(complete->current_match && strlen(complete->current_match)){
               char* prev_match = line;
               char* match = NULL;
               while((match = strstr(prev_match, complete->current_match))){
                    if(end_of_match && match >= end_of_match) break;
                    match_point.x = ce_utf8_strlen_between(line, match) - 1;
                    prev_match = match + match_len;
                    int fg = ce_syntax_def_get_fg(syntax_defs, CE_SYNTAX_COLOR_COMPLETE_MATCH, ce_draw_color_list_last_fg_color(draw_color_list));
                    int bg = ce_syntax_def_get_bg(syntax_defs, CE_SYNTAX_COLOR_COMPLETE_MATCH, ce_draw_color_list_last_bg_color(draw_color_list));
                    ce_draw_color_list_insert(draw_color_list, fg, bg, match_point);

                    match_point.x += match_len;

                    if(selected == y){
                         fg = ce_syntax_def_get_fg(syntax_defs, CE_SYNTAX_COLOR_COMPLETE_SELECTED, CE_COLOR_DEFAULT);
                         bg = ce_syntax_def_get_bg(syntax_defs, CE_SYNTAX_COLOR_COMPLETE_SELECTED, ce_draw_color_list_last_bg_color(draw_color_list));
                         ce_draw_color_list_insert(draw_color_list, fg, bg, match_point);
                    }else{
                         ce_draw_color_list_insert(draw_color_list, CE_COLOR_DEFAULT, CE_COLOR_DEFAULT, match_point);
                    }
               }
          }
     }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, (%rsp)
movq %rdi, 0x8(%rsp)
testq %r8, %r8
je 0x10a6a
movq 0x8(%rsp), %rax
movq 0x40(%rax), %rax
testq %rax, %rax
je 0x10a6a
movq 0x8(%rax), %rax
testq %rax, %rax
jle 0x10a6a
movq %r8, %r14
movq %rcx, %rbx
movq %rax, %rsi
movq 0x8(%rsp), %rdx
movq 0x18(%rdx), %rax
movq 0x28(%rdx), %rcx
subq 0x10(%rdx), %rax
addq %rcx, %rax
decq %rsi
cmpq %rsi, %rcx
movq %rsi, %r15
cmovlq %rcx, %r15
xorl %edi, %edi
testq %rcx, %rcx
cmovsq %rdi, %r15
cmpq %rsi, %rax
cmovlq %rax, %rsi
testq %rax, %rax
movl $0x0, %eax
movq %rax, 0x10(%rsp)
cmovsq %rdi, %rsi
movq %rsi, 0x38(%rsp)
movq 0x10(%r8), %rdi
testq %rdi, %rdi
je 0x1085b
callq 0xd210
movq %rax, 0x10(%rsp)
movq 0x8(%r14), %rax
xorl %ecx, %ecx
testq %rax, %rax
cmovleq %rcx, %rax
pushq $0x10
popq %rdx
xorl %r13d, %r13d
movq %rbx, 0x18(%rsp)
movq %r14, 0x40(%rsp)
cmpq %rcx, %rax
movq %r13, 0x28(%rsp)
je 0x10a5f
movq (%r14), %rsi
cmpb $0x1, (%rsi,%rdx)
jne 0x1089c
cmpq 0x18(%r14), %rcx
je 0x10a5f
incq %r13
incq %rcx
addq $0x18, %rdx
jmp 0x10878
movq 0x8(%rsp), %rax
movq 0x40(%rax), %rax
movq (%rax), %rax
movq (%rax,%r15,8), %rdi
pushq $0x3a
popq %rsi
movq %rdi, 0x20(%rsp)
callq 0xd230
movq %rax, 0x48(%rsp)
cmpq %r15, %r13
movq %r15, 0x30(%rsp)
jne 0x10912
movq (%rsp), %r15
movq %r15, %rdi
callq 0x1dcdf
pushq $0x12
popq %rbp
movq %rbx, %rdi
movl %ebp, %esi
movl %eax, %edx
callq 0x1dac4
movl %eax, %r12d
movq %r15, %rdi
callq 0x1dcef
movq %rbx, %rdi
movl %ebp, %esi
movl %eax, %edx
callq 0x1dad0
movq %r15, %rdi
movl %r12d, %esi
movl %eax, %edx
xorl %ecx, %ecx
movq %r13, %r8
jmp 0x10920
pushq $-0x1
popq %rdx
movq (%rsp), %rdi
movl %edx, %esi
xorl %ecx, %ecx
movq %r15, %r8
callq 0x1dadd
movq 0x10(%r14), %rsi
testq %rsi, %rsi
je 0x10a4d
cmpb $0x0, (%rsi)
je 0x10a4d
movq 0x20(%rsp), %r12
movq 0x48(%rsp), %r15
testq %r15, %r15
sete %bl
movq %r12, %rdi
callq 0xd6f0
movq %rax, %r12
cmpq %r15, %rax
setb %al
testq %r12, %r12
je 0x10a4d
orb %al, %bl
je 0x10a4d
movq 0x20(%rsp), %rdi
movq %r12, %rsi
callq 0xfc01
movq %rax, %rbp
decq %rax
movq %rax, 0x50(%rsp)
movq (%rsp), %r13
movq %r13, %rdi
callq 0x1dcdf
pushq $0x13
popq %r14
movq 0x18(%rsp), %r15
movq %r15, %rdi
movl %r14d, %esi
movl %eax, %edx
callq 0x1dac4
movl %eax, %ebx
movq %r13, %rdi
callq 0x1dcef
movq %r15, %rdi
movl %r14d, %esi
movl %eax, %edx
callq 0x1dad0
movq %r13, %rdi
movl %ebx, %esi
movl %eax, %edx
movq 0x50(%rsp), %rcx
movq 0x30(%rsp), %rbx
movq %rbx, %r8
callq 0x1dadd
movq 0x10(%rsp), %rax
addq %rax, %rbp
decq %rbp
movq 0x28(%rsp), %r13
cmpq %rbx, %r13
jne 0x10a26
pushq $0x12
popq %rsi
pushq $-0x1
popq %rdx
movq %r15, %rdi
callq 0x1dac4
movl %eax, %r14d
movq (%rsp), %rbx
movq %rbx, %rdi
callq 0x1dcef
movq %r15, %rdi
pushq $0x12
popq %rsi
movl %eax, %edx
callq 0x1dad0
movq %rbx, %rdi
movl %r14d, %esi
movl %eax, %edx
movq %rbp, %rcx
movq %r13, %r8
jmp 0x10a35
pushq $-0x1
popq %rdx
movq (%rsp), %rdi
movl %edx, %esi
movq %rbp, %rcx
movq %rbx, %r8
callq 0x1dadd
addq 0x10(%rsp), %r12
movq 0x40(%rsp), %r14
movq 0x10(%r14), %rsi
jmp 0x10940
movq 0x30(%rsp), %r15
incq %r15
movq 0x18(%rsp), %rbx
movq 0x28(%rsp), %r13
cmpq 0x38(%rsp), %r15
jle 0x108a5
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq