// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x134eb
jmp 0x1394b
movq -0x8(%rbp), %rax
cmpq $0x0, 0x40(%rax)
jne 0x134fb
jmp 0x1394b
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
cmpq $0x0, 0x8(%rax)
jg 0x1350f
jmp 0x1394b
movq -0x28(%rbp), %rax
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rax
movq 0x28(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
movq -0x8(%rbp), %rdx
subq 0x10(%rdx), %rcx
addq %rcx, %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq 0x8(%rax), %rax
subq $0x1, %rax
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jge 0x13561
movq $0x0, -0x48(%rbp)
cmpq $0x0, -0x38(%rbp)
jge 0x13573
xorl %eax, %eax
movq %rax, -0xb0(%rbp)
jmp 0x135a3
movq -0x38(%rbp), %rax
cmpq -0x48(%rbp), %rax
jle 0x1358a
movq -0x48(%rbp), %rax
movq %rax, -0xb8(%rbp)
jmp 0x13595
movq -0x38(%rbp), %rax
movq %rax, -0xb8(%rbp)
movq -0xb8(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq -0xb0(%rbp), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x40(%rbp)
jge 0x135c0
xorl %eax, %eax
movq %rax, -0xc0(%rbp)
jmp 0x135f0
movq -0x40(%rbp), %rax
cmpq -0x48(%rbp), %rax
jle 0x135d7
movq -0x48(%rbp), %rax
movq %rax, -0xc8(%rbp)
jmp 0x135e2
movq -0x40(%rbp), %rax
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq -0xc0(%rbp), %rax
movq %rax, -0x40(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x30(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x1361f
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0xd200
movq %rax, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
movq $0x0, -0x60(%rbp)
movq -0x60(%rbp), %rax
movq -0x30(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jge 0x1367e
movq -0x30(%rbp), %rax
movq (%rax), %rax
imulq $0x18, -0x60(%rbp), %rcx
addq %rcx, %rax
testb $0x1, 0x10(%rax)
je 0x1366e
movq -0x60(%rbp), %rax
movq -0x30(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jne 0x13662
jmp 0x1367e
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
jmp 0x13670
movq -0x60(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x60(%rbp)
jmp 0x1362f
movq -0x38(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x68(%rbp), %rax
cmpq -0x40(%rbp), %rax
jg 0x1394b
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq (%rax), %rax
movq -0x68(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rdi
movl $0x3a, %esi
callq 0xd220
movq %rax, -0x78(%rbp)
movq $0x0, -0x88(%rbp)
movq -0x68(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x58(%rbp), %rax
cmpq -0x68(%rbp), %rax
jne 0x13756
movq -0x20(%rbp), %rax
movq %rax, -0xd8(%rbp)
movq -0x18(%rbp), %rdi
callq 0x2b600
movq -0xd8(%rbp), %rdi
movl %eax, %edx
movl $0x12, %esi
callq 0x2b180
movl %eax, -0x8c(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0x18(%rbp), %rdi
callq 0x2b630
movq -0xd0(%rbp), %rdi
movl %eax, %edx
movl $0x12, %esi
callq 0x2b1c0
movl %eax, -0x90(%rbp)
movq -0x18(%rbp), %rdi
movl -0x8c(%rbp), %esi
movl -0x90(%rbp), %edx
movq -0x88(%rbp), %rcx
movq -0x80(%rbp), %r8
callq 0x2b200
jmp 0x13771
movq -0x18(%rbp), %rdi
movq -0x88(%rbp), %rcx
movq -0x80(%rbp), %r8
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %edx, %esi
callq 0x2b200
movq -0x30(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x13938
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0xd200
cmpq $0x0, %rax
je 0x13938
movq -0x70(%rbp), %rax
movq %rax, -0x98(%rbp)
movq $0x0, -0xa0(%rbp)
movq -0x98(%rbp), %rdi
movq -0x30(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0xd6d0
movq %rax, -0xa0(%rbp)
cmpq $0x0, %rax
je 0x13936
cmpq $0x0, -0x78(%rbp)
je 0x137eb
movq -0xa0(%rbp), %rax
cmpq -0x78(%rbp), %rax
jb 0x137eb
jmp 0x13936
movq -0x70(%rbp), %rdi
movq -0xa0(%rbp), %rsi
callq 0x11a20
subq $0x1, %rax
movq %rax, -0x88(%rbp)
movq -0xa0(%rbp), %rax
addq -0x50(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xe8(%rbp)
movq -0x18(%rbp), %rdi
callq 0x2b600
movq -0xe8(%rbp), %rdi
movl %eax, %edx
movl $0x13, %esi
callq 0x2b180
movl %eax, -0xa4(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xe0(%rbp)
movq -0x18(%rbp), %rdi
callq 0x2b630
movq -0xe0(%rbp), %rdi
movl %eax, %edx
movl $0x13, %esi
callq 0x2b1c0
movl %eax, -0xa8(%rbp)
movq -0x18(%rbp), %rdi
movl -0xa4(%rbp), %esi
movl -0xa8(%rbp), %edx
movq -0x88(%rbp), %rcx
movq -0x80(%rbp), %r8
callq 0x2b200
movq -0x50(%rbp), %rax
addq -0x88(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x58(%rbp), %rax
cmpq -0x68(%rbp), %rax
jne 0x13916
movq -0x20(%rbp), %rdi
movl $0x12, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x2b180
movl %eax, -0xa4(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0x18(%rbp), %rdi
callq 0x2b630
movq -0xf0(%rbp), %rdi
movl %eax, %edx
movl $0x12, %esi
callq 0x2b1c0
movl %eax, -0xa8(%rbp)
movq -0x18(%rbp), %rdi
movl -0xa4(%rbp), %esi
movl -0xa8(%rbp), %edx
movq -0x88(%rbp), %rcx
movq -0x80(%rbp), %r8
callq 0x2b200
jmp 0x13931
movq -0x18(%rbp), %rdi
movq -0x88(%rbp), %rcx
movq -0x80(%rbp), %r8
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
movl %edx, %esi
callq 0x2b200
jmp 0x137ad
jmp 0x13938
jmp 0x1393a
movq -0x68(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x68(%rbp)
jmp 0x13686
addq $0xf0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)