// File: /workspace/github_c_makefile_star2_O1/justy989[P]ce/ce_syntax.c
// Function: ce_syntax_highlight_diff
void ce_syntax_highlight_diff(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);
     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);

     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};

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

          if(*line == '+'){
               change_draw_color(draw_color_list, syntax_defs, CE_SYNTAX_COLOR_DIFF_ADD, match_point);
               current_match_len = line_len + 1;
          }else if(*line == '-'){
               change_draw_color(draw_color_list, syntax_defs, CE_SYNTAX_COLOR_DIFF_REMOVE, match_point);
               current_match_len = line_len + 1;
          }else if(*line == '#'){
               change_draw_color(draw_color_list, syntax_defs, CE_SYNTAX_COLOR_DIFF_COMMENT, match_point);
               current_match_len = line_len + 1;
          }else if(strncmp(line, "@@", 2) == 0){
               char* end = strstr(line + 2, "@@");
               if(end){
                    change_draw_color(draw_color_list, syntax_defs, CE_SYNTAX_COLOR_DIFF_HEADER, match_point);
                    current_match_len = ce_utf8_strlen_between(line, end + 2);
               }
          }else{
               change_draw_color(draw_color_list, syntax_defs, CE_SYNTAX_COLOR_NORMAL, match_point);
          }

          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){
               match_point.x = x;

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

               if(current_match_len <= 1){
                    change_draw_color(draw_color_list, syntax_defs, CE_SYNTAX_COLOR_NORMAL, match_point);
               }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 $0x28, %rsp
movq %rdi, 0x18(%rsp)
movq 0x40(%rdi), %rax
testq %rax, %rax
je 0x2228a
movq 0x8(%rax), %r15
testq %r15, %r15
jle 0x2228a
movq %rcx, %rbx
movq %rdx, %r14
movq 0x18(%rsp), %rdx
movq 0x18(%rdx), %rax
movq 0x28(%rdx), %rcx
subq 0x10(%rdx), %rax
addq %rcx, %rax
decq %r15
cmpq %r15, %rcx
movq %r15, %r12
cmovlq %rcx, %r12
xorl %edx, %edx
testq %rcx, %rcx
cmovsq %rdx, %r12
cmpq %r15, %rax
cmovlq %rax, %r15
testq %rax, %rax
cmovsq %rdx, %r15
leaq 0xf(%rsp), %r8
movb $0x0, (%r8)
movq (%rsi), %rdi
movq %rdi, 0x10(%rsp)
movq %r12, %rsi
movq %r14, %rdx
movq %rbx, %rcx
callq 0x1fc76
cmpq %r15, %r12
jg 0x2228a
leaq 0xf(%rsp), %rbp
movq %r15, 0x20(%rsp)
movq 0x18(%rsp), %rax
movq 0x40(%rax), %rax
movq (%rax), %rax
movq (%rax,%r12,8), %r13
movq %r13, %rdi
callq 0xe485
movq %rax, %r15
leaq 0x10(%rsp), %rdi
movq %rbp, %rsi
xorl %edx, %edx
movq %r12, %rcx
movq %r14, %r8
movq %rbx, %r9
callq 0x1fd0c
movzbl (%r13), %eax
cmpl $0x23, %eax
je 0x22152
cmpl $0x2d, %eax
leaq 0xed3d(%rip), %rbp      # 0x30e6e
je 0x22145
cmpl $0x2b, %eax
jne 0x2216d
movq %r14, %rdi
movq %rbx, %rsi
movl $0xe, %edx
jmp 0x2215d
movq %r14, %rdi
movq %rbx, %rsi
movl $0xf, %edx
jmp 0x2215d
movq %r14, %rdi
movq %rbx, %rsi
movl $0x11, %edx
xorl %ecx, %ecx
movq %r12, %r8
callq 0x2045f
leaq 0x1(%r15), %r13
jmp 0x221d6
movl $0x2, %edx
movq %r13, %rdi
movq %rbp, %rsi
callq 0xd0d0
testl %eax, %eax
je 0x2219b
movq %r14, %rdi
movq %rbx, %rsi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r12, %r8
callq 0x2045f
movl $0x1, %r13d
jmp 0x221d6
leaq 0x2(%r13), %rdi
movq %rbp, %rsi
callq 0xd6f0
testq %rax, %rax
je 0x22193
movq %rax, %rbp
movq %r14, %rdi
movq %rbx, %rsi
movl $0x10, %edx
xorl %ecx, %ecx
movq %r12, %r8
callq 0x2045f
addq $0x2, %rbp
movq %r13, %rdi
movq %rbp, %rsi
callq 0x10101
movq %rax, %r13
cmpb $0x1, 0xf(%rsp)
jne 0x221f7
testq %r15, %r15
jne 0x221f7
movq %r14, %rdi
movq %rbx, %rsi
movl $0xc, %edx
xorl %ecx, %ecx
movq %r12, %r8
callq 0x2045f
testq %r15, %r15
jle 0x2225c
xorl %ebp, %ebp
leaq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rsi
movq %rbp, %rdx
movq %r12, %rcx
movq %r14, %r8
movq %rbx, %r9
callq 0x1fd0c
cmpq $0x1, %r13
jg 0x22234
movq %r14, %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %rbp, %rcx
movq %r12, %r8
callq 0x2045f
jmp 0x22237
decq %r13
cmpb $0x1, 0xf(%rsp)
jne 0x22254
movq %r14, %rdi
movq %rbx, %rsi
movl $0xc, %edx
movq %rbp, %rcx
movq %r12, %r8
callq 0x2045f
incq %rbp
cmpq %rbp, %r15
jne 0x221fe
movq 0x10(%rsp), %rdi
leaq 0xf(%rsp), %rbp
movq %rbp, %rsi
movq %r12, %rdx
movq %r15, %rcx
movq %r14, %r8
callq 0x1fe4e
leaq 0x1(%r12), %rax
cmpq 0x20(%rsp), %r12
movq %rax, %r12
jne 0x220ea
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq