// File: /workspace/github_c_makefile_star2_O3/justy989[P]ce/ce_syntax.c
// Function: ce_syntax_highlight_c
void ce_syntax_highlight_c(CeView_t* view, CeRangeList_t* highlight_range_list, CeDrawColorList_t* draw_color_list,
                           CeSyntaxDef_t* syntax_defs, void* user_data){
     if(!view->buffer) return;
     if(view->buffer->line_count <= 0) return;
     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;
     bool multiline_comment = false;
     bool in_visual = false;
     CeRangeNode_t* range_node = highlight_range_list->head;

     check_visual_start(range_node, min, draw_color_list, syntax_defs, &in_visual);

     int prepass_min = min - SEARCH_BACK_LINES;
     if(prepass_min < 0) prepass_min = 0;

     // pre-pass to check if we are in a multiline comment
     for(int64_t y = prepass_min; y < min; y++){
          char* line = view->buffer->lines[y];
          int64_t line_len = ce_utf8_strlen(line);

          for(int64_t x = 0; x < line_len; ++x){
               char* str = ce_utf8_iterate_to(line, x);

               if(multiline_comment){
                    if(match_c_multiline_comment_end(str)){
                         multiline_comment = false;
                    }
               }else{
                    if((match_len = match_c_multiline_comment(str))){
                         multiline_comment = true;
                         x += (match_len - 1);
                    }
               }
          }
     }

     for(int64_t y = min; y <= max; ++y){
          char* line = view->buffer->lines[y];
          int64_t line_len = ce_utf8_strlen(line);
          int64_t current_match_len = 1;
          CePoint_t match_point = {0, y};

          if(multiline_comment){
               change_draw_color(draw_color_list, syntax_defs, CE_SYNTAX_COLOR_COMMENT, match_point);
          }

          ce_syntax_highlight_visual(&range_node, &in_visual, match_point, draw_color_list, syntax_defs);

          if(in_visual && line_len == 0) change_draw_color(draw_color_list, syntax_defs, CE_SYNTAX_COLOR_VISUAL, match_point);

          for(int64_t x = 0; x < line_len; ++x){
               char* str = ce_utf8_iterate_to(line, x);
               match_point.x = x;

               ce_syntax_highlight_visual(&range_node, &in_visual, match_point, draw_color_list, syntax_defs);

               if(current_match_len <= 1){
                    if(multiline_comment){
                         if((match_len = match_c_multiline_comment_end(str))){
                              multiline_comment = false;
                         }else if(((view->cursor.y != y) || (x > view->cursor.x)) && (match_len = match_trailing_whitespace(str))){
                              change_draw_color(draw_color_list, syntax_defs, CE_SYNTAX_COLOR_TRAILING_WHITESPACE, match_point);
                              ce_draw_color_list_insert(draw_color_list, ce_syntax_def_get_fg(syntax_defs, CE_SYNTAX_COLOR_NORMAL, CE_COLOR_DEFAULT),
                                                        ce_syntax_def_get_bg(syntax_defs, CE_SYNTAX_COLOR_NORMAL, CE_COLOR_DEFAULT),
                                                        (CePoint_t){0, match_point.y + 1});
                         }
                    }else{
                         if((match_len = match_c_type(str, line, false))){
                              change_draw_color(draw_color_list, syntax_defs, CE_SYNTAX_COLOR_TYPE, match_point);
                         }else if((match_len = match_c_keyword(str, line))){
                              change_draw_color(draw_color_list, syntax_defs, CE_SYNTAX_COLOR_KEYWORD, match_point);
                         }else if((match_len = match_c_control(str, line))){
                              change_draw_color(draw_color_list, syntax_defs, CE_SYNTAX_COLOR_CONTROL, match_point);
                         }else if((match_len = match_caps_var(str, line))){
                              change_draw_color(draw_color_list, syntax_defs, CE_SYNTAX_COLOR_CAPS_VAR, match_point);
                         }else if((match_len = match_c_comment(str))){
                              change_draw_color(draw_color_list, syntax_defs, CE_SYNTAX_COLOR_COMMENT, match_point);
                         }else if((match_len = match_c_string(str))){
                              change_draw_color(draw_color_list, syntax_defs, CE_SYNTAX_COLOR_STRING, match_point);
                         }else if((match_len = match_c_character_literal(str))){
                              change_draw_color(draw_color_list, syntax_defs, CE_SYNTAX_COLOR_CHAR_LITERAL, match_point);
                         }else if((match_len = match_c_literal(str, line))){
                              change_draw_color(draw_color_list, syntax_defs, CE_SYNTAX_COLOR_NUMBER_LITERAL, match_point);
                         }else if((match_len = match_c_preproc(str))){
                              change_draw_color(draw_color_list, syntax_defs, CE_SYNTAX_COLOR_PREPROCESSOR, match_point);
                         }else if((match_len = match_c_multiline_comment(str))){
                              change_draw_color(draw_color_list, syntax_defs, CE_SYNTAX_COLOR_COMMENT, match_point);
                              multiline_comment = true;
                         }else if(((view->cursor.y != y) || (x > view->cursor.x)) && (match_len = match_trailing_whitespace(str))){
                              change_draw_color(draw_color_list, syntax_defs, CE_SYNTAX_COLOR_TRAILING_WHITESPACE, match_point);
                              ce_draw_color_list_insert(draw_color_list, ce_syntax_def_get_fg(syntax_defs, CE_SYNTAX_COLOR_NORMAL, CE_COLOR_DEFAULT),
                                                        ce_syntax_def_get_bg(syntax_defs, CE_SYNTAX_COLOR_NORMAL, CE_COLOR_DEFAULT),
                                                        (CePoint_t){0, match_point.y + 1});
                         }else if(!draw_color_list->tail || (draw_color_list->tail->fg != CE_COLOR_DEFAULT || draw_color_list->tail->bg != CE_COLOR_DEFAULT)){
                              change_draw_color(draw_color_list, syntax_defs, CE_SYNTAX_COLOR_NORMAL, match_point);
                         }
                    }

                    if(match_len) current_match_len = match_len;
               }else{
                    current_match_len--;
               }

               if(in_visual) change_draw_color(draw_color_list, syntax_defs, CE_SYNTAX_COLOR_VISUAL, match_point);
          }

          check_visual_mode_end(range_node, &in_visual, match_point.y, line_len, draw_color_list);
     }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, 0x10(%rsp)
movq %rdi, 0x28(%rsp)
movq 0x40(%rdi), %rax
testq %rax, %rax
je 0x203a0
movq 0x8(%rax), %r8
testq %r8, %r8
jle 0x203a0
movq 0x28(%rsp), %rdi
movq 0x18(%rdi), %rax
movq 0x28(%rdi), %rdx
subq 0x10(%rdi), %rax
addq %rdx, %rax
decq %r8
cmpq %r8, %rdx
movq %r8, %r12
cmovlq %rdx, %r12
xorl %r14d, %r14d
testq %rdx, %rdx
cmovsq %r14, %r12
cmpq %r8, %rax
cmovlq %rax, %r8
testq %rax, %rax
cmovsq %r14, %r8
movq %r8, 0x38(%rsp)
leaq 0xf(%rsp), %r8
movb $0x0, (%r8)
movq (%rsi), %rdi
movq %rdi, 0x50(%rsp)
movq %r12, %rsi
movq 0x10(%rsp), %rdx
movq %rcx, 0x18(%rsp)
callq 0x1fbd2
leal -0x400(%r12), %ebx
testl %ebx, %ebx
cmovlel %r14d, %ebx
cmpq %rbx, %r12
jle 0x1ff42
xorl %r14d, %r14d
movq 0x28(%rsp), %rax
movq 0x40(%rax), %rax
movq (%rax), %rax
movq (%rax,%rbx,8), %r15
movq %r15, %rdi
callq 0xe445
testq %rax, %rax
jle 0x1ff3a
movq %rax, %r13
xorl %ebp, %ebp
movq %r15, %rdi
movq %rbp, %rsi
callq 0xe577
testb $0x1, %r14b
je 0x1ff0e
movzbl (%rax), %ecx
subl $0x2a, %ecx
jne 0x1ff26
movzbl 0x1(%rax), %eax
movl $0x2f, %ecx
subl %eax, %ecx
jmp 0x1ff28
movq %rax, %rdi
callq 0x203af
testq %rax, %rax
je 0x1ff32
addq %rax, %rbp
decq %rbp
movb $0x1, %r14b
jmp 0x1ff32
negl %ecx
testl %ecx, %ecx
movzbl %r14b, %r14d
cmovel %ecx, %r14d
incq %rbp
cmpq %r13, %rbp
jl 0x1fee8
incq %rbx
cmpq %r12, %rbx
jne 0x1fec6
movq 0x38(%rsp), %r15
cmpq %r15, %r12
movq 0x18(%rsp), %rbx
jg 0x203a0
incq %r15
movq %r15, 0x38(%rsp)
movq 0x28(%rsp), %rax
movq 0x40(%rax), %rax
movq (%rax), %rax
movq (%rax,%r12,8), %rbp
movq %rbp, %rdi
callq 0xe445
movq %rax, 0x30(%rsp)
testb $0x1, %r14b
je 0x1ff97
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
movl $0x5, %edx
xorl %ecx, %ecx
movq %r12, %r8
callq 0x203f4
leaq 0x50(%rsp), %rdi
leaq 0xf(%rsp), %rsi
xorl %edx, %edx
movq %r12, 0x20(%rsp)
movq %r12, %rcx
movq 0x10(%rsp), %r8
movq %rbx, %r9
callq 0x1fc6a
cmpb $0x1, 0xf(%rsp)
jne 0x1ffe8
cmpq $0x0, 0x30(%rsp)
jne 0x1ffe8
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
movl $0xc, %edx
xorl %ecx, %ecx
movq 0x20(%rsp), %r12
movq %r12, %r8
callq 0x203f4
jmp 0x20367
cmpq $0x0, 0x30(%rsp)
movq 0x20(%rsp), %r12
jle 0x20367
movq %rbp, 0x48(%rsp)
leaq 0x1(%r12), %rax
movq %rax, 0x40(%rsp)
movl $0x1, %r13d
xorl %ebp, %ebp
movq 0x48(%rsp), %rdi
movq %rbp, %rsi
callq 0xe577
movq %rax, %r15
leaq 0x50(%rsp), %rdi
leaq 0xf(%rsp), %rsi
movq %rbp, %rdx
movq %r12, %rcx
movq 0x10(%rsp), %r8
movq %rbx, %r9
callq 0x1fc6a
cmpq $0x1, %r13
jg 0x20060
testb $0x1, %r14b
je 0x20068
movzbl (%r15), %eax
subl $0x2a, %eax
jne 0x2009d
movzbl 0x1(%r15), %ecx
movl $0x2f, %eax
subl %ecx, %eax
jmp 0x2009f
decq %r13
jmp 0x201c9
movq %r15, %rdi
movq 0x48(%rsp), %r12
movq %r12, %rsi
xorl %edx, %edx
callq 0x20474
testq %rax, %rax
je 0x2011d
movq %rax, %rbx
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %r15
movq %r15, %rsi
movl $0x1, %edx
jmp 0x201b3
negl %eax
testl %eax, %eax
je 0x20150
movq 0x28(%rsp), %rax
cmpq %r12, 0x38(%rax)
jne 0x200c1
movq 0x28(%rsp), %rax
cmpq 0x30(%rax), %rbp
jle 0x201c9
movq %r15, %rdi
callq 0x20433
testq %rax, %rax
je 0x201c9
movq %rax, %r15
movq 0x10(%rsp), %r13
movq %r13, %rdi
movq %rbx, %rsi
movl $0xb, %edx
movq %rbp, %rcx
movq %r12, %r8
callq 0x203f4
movl (%rbx), %esi
cmpl $-0x2, %esi
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmovel %eax, %esi
movl 0x4(%rbx), %edx
cmpl $-0x2, %edx
cmovel %eax, %edx
movq %r13, %rdi
xorl %ecx, %ecx
movq 0x40(%rsp), %r8
callq 0x1f8e9
movq %r15, %r13
jmp 0x201c9
movl $0x17, %ecx
movq %r15, %rdi
movq %r12, %rsi
leaq 0x1a331(%rip), %rdx     # 0x3a460
callq 0x224e2
testq %rax, %rax
je 0x2015b
movq %rax, %rbx
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %r15
movq %r15, %rsi
movl $0x2, %edx
jmp 0x201b3
movl $0x2, %r13d
xorl %r14d, %r14d
jmp 0x201c9
movl $0x5, %ecx
movq %r15, %rdi
movq %r12, %rsi
leaq 0x1a3b3(%rip), %rdx     # 0x3a520
callq 0x224e2
testq %rax, %rax
je 0x2018e
movq %rax, %rbx
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %r15
movq %r15, %rsi
movl $0x3, %edx
jmp 0x201b3
movq %r15, %rdi
movq %r12, %rsi
callq 0x20508
testq %rax, %rax
je 0x201fb
movq %rax, %rbx
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %r15
movq %r15, %rsi
movl $0x4, %edx
movq %rbp, %rcx
movq 0x20(%rsp), %r12
movq %r12, %r8
callq 0x203f4
movq %rbx, %r13
movq %r15, %rbx
cmpb $0x1, 0xf(%rsp)
jne 0x201e8
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
movl $0xc, %edx
movq %rbp, %rcx
movq %r12, %r8
callq 0x203f4
incq %rbp
cmpq %rbp, 0x30(%rsp)
jne 0x20010
jmp 0x2036e
cmpb $0x2f, (%r15)
movq 0x20(%rsp), %r12
jne 0x20234
cmpb $0x2f, 0x1(%r15)
jne 0x20234
movq %r15, %rdi
callq 0x22496
testq %rax, %rax
je 0x20234
movq %rax, %rbx
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %r15
movq %r15, %rsi
movl $0x5, %edx
jmp 0x202c7
movq %r15, %rdi
callq 0x205c1
testq %rax, %rax
je 0x20258
movq %rax, %rbx
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %r15
movq %r15, %rsi
movl $0x6, %edx
jmp 0x202c7
movq %r15, %rdi
callq 0x20605
testq %rax, %rax
je 0x2027c
movq %rax, %rbx
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %r15
movq %r15, %rsi
movl $0x7, %edx
jmp 0x202c7
movq %r15, %rdi
movq 0x48(%rsp), %rsi
callq 0x20643
testq %rax, %rax
je 0x202a5
movq %rax, %rbx
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %r15
movq %r15, %rsi
movl $0x8, %edx
jmp 0x202c7
movq %r15, %rdi
callq 0x2080a
testq %rax, %rax
je 0x202cf
movq %rax, %rbx
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %r15
movq %r15, %rsi
movl $0xa, %edx
movq %rbp, %rcx
jmp 0x201bb
movq %r15, %rdi
callq 0x203af
testq %rax, %rax
je 0x20304
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rbx
movq %rbx, %rsi
movl $0x5, %edx
movq %rbp, %rcx
movq %r12, %r8
movq %rax, %r13
callq 0x203f4
movb $0x1, %r14b
jmp 0x201c9
movq 0x28(%rsp), %rax
cmpq %r12, 0x38(%rax)
movq 0x18(%rsp), %rbx
jne 0x2031f
movq 0x28(%rsp), %rax
cmpq 0x30(%rax), %rbp
jle 0x20330
movq %r15, %rdi
callq 0x20433
testq %rax, %rax
jne 0x200d2
movq 0x10(%rsp), %rax
movq 0x8(%rax), %rax
testq %rax, %rax
je 0x2034d
cmpl $-0x1, (%rax)
jne 0x2034d
cmpl $-0x1, 0x4(%rax)
je 0x201c9
movq 0x10(%rsp), %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %rbp, %rcx
movq %r12, %r8
callq 0x203f4
jmp 0x201c9
leaq 0x1(%r12), %r13
jmp 0x20378
movq 0x38(%rsp), %r15
movq 0x40(%rsp), %r13
movq 0x50(%rsp), %rdi
leaq 0xf(%rsp), %rsi
movq %r12, %rdx
movq 0x30(%rsp), %rcx
movq 0x10(%rsp), %r8
callq 0x1fdad
movq %r13, %r12
cmpq %r15, %r13
jne 0x1ff5d
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq