// File: /workspace/github_c_makefile_star2_O3/justy989[P]ce/ce_app.c
// Function: build_clangd_completion_view
void build_clangd_completion_view(CeView_t* view,
                                  CePoint_t start,
                                  CeView_t* completed_view,
                                  CeBuffer_t* buffer,
                                  CeConfigOptions_t* config_options,
                                  CeRect_t* terminal_rect){
     int64_t view_height = 0;
     if(buffer->line_count > config_options->completion_line_limit){
          view_height = config_options->completion_line_limit;
     }else{
          view_height = buffer->line_count;
     }

     CePoint_t view_start = (CePoint_t){completed_view->rect.left + (start.x - completed_view->scroll.x),
                                        completed_view->rect.top + (start.y - completed_view->scroll.y)};

     if(start.y > view_height){
          view->rect.bottom = view_start.y;
          view->rect.top = view->rect.bottom - view_height;
     }else{
          view->rect.top = view_start.y + 1;
          view->rect.bottom = view->rect.top + view_height;
     }

     view->rect.left = view_start.x;
     if(!completed_view->buffer->no_line_numbers){
          view->rect.left += ce_line_number_column_width(config_options->line_number,
                                                         completed_view->buffer->line_count,
                                                         completed_view->rect.top,
                                                         completed_view->rect.bottom);
     }

     int64_t longest_line = 0;
     for(int64_t i = 0; i < buffer->line_count; i++){
          int64_t line_len = ce_buffer_line_len(buffer, i);
          if(line_len > longest_line){
               longest_line = line_len;
          }
     }
     view->rect.right = view->rect.left + longest_line;

     // Clamp to the view.
     if(view->rect.left >= terminal_rect->right){
          view->rect.left = terminal_rect->right - 1;
     }
     if(view->rect.right >= terminal_rect->right){
          view->rect.right = terminal_rect->right - 1;
     }
     if(view->rect.bottom >= terminal_rect->bottom){
          view->rect.bottom = terminal_rect->bottom - 1;
     }
     if(view->rect.top >= terminal_rect->bottom){
          view->rect.top = terminal_rect->bottom - 1;
     }
     if(view->rect.left < 0){
          view->rect.left = 0;
     }
     if(view->rect.right < 0){
          view->rect.right = 0;
     }
     if(view->rect.bottom < 0){
          view->rect.bottom = 0;
     }
     if(view->rect.top < 0){
          view->rect.top = 0;
     }
}

// Assembly:
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
movq %r8, %r14
movq %rdi, %rbx
movq 0x8(%r8), %rax
movq 0x30(%r9), %rdi
cmpq %rdi, %rax
cmovlq %rax, %rdi
addq (%rcx), %rsi
subq 0x20(%rcx), %rsi
movq 0x10(%rcx), %r8
movq %rdx, %r10
subq 0x28(%rcx), %r10
leaq (%r10,%r8), %r11
movq %r11, %r15
subq %rdi, %r15
cmpq %rdx, %rdi
leaq 0x1(%r10,%r8), %rdx
leaq 0x1(%rdi,%r11), %rdi
cmovlq %r11, %rdi
cmovlq %r15, %rdx
movq %rdi, 0x18(%rbx)
movq %rdx, 0x10(%rbx)
movq %rsi, (%rbx)
movq 0x40(%rcx), %rdx
cmpb $0x0, 0x50(%rdx)
jne 0x12cd8
movl (%r9), %edi
movq 0x8(%rdx), %rsi
movq 0x10(%rcx), %rdx
movq 0x18(%rcx), %rcx
callq 0x1068a
movq %rax, %rsi
addq (%rbx), %rsi
movq %rsi, (%rbx)
movq 0x8(%r14), %rax
movq 0x30(%rsp), %r13
testq %rax, %rax
jle 0x12d08
xorl %r15d, %r15d
xorl %r12d, %r12d
movq %r14, %rdi
movq %r15, %rsi
callq 0xec84
cmpq %r12, %rax
cmovgq %rax, %r12
incq %r15
cmpq 0x8(%r14), %r15
jl 0x12ce8
movq (%rbx), %rsi
jmp 0x12d0b
xorl %r12d, %r12d
addq %rsi, %r12
movq %r12, 0x8(%rbx)
movq 0x8(%r13), %rax
cmpq %rax, %rsi
jl 0x12d22
leaq -0x1(%rax), %rsi
movq %rsi, (%rbx)
cmpq %rax, %r12
jl 0x12d31
decq %rax
movq %rax, 0x8(%rbx)
movq %rax, %r12
movq 0x18(%rbx), %rax
movq 0x18(%r13), %rdx
cmpq %rdx, %rax
jl 0x12d4c
decq %rdx
movq %rdx, 0x18(%rbx)
movq %rdx, %rax
movq 0x18(%r13), %rdx
movq 0x10(%rbx), %rcx
cmpq %rdx, %rcx
jl 0x12d5f
decq %rdx
movq %rdx, 0x10(%rbx)
movq %rdx, %rcx
testq %rsi, %rsi
jns 0x12d6b
movq $0x0, (%rbx)
testq %r12, %r12
jns 0x12d78
movq $0x0, 0x8(%rbx)
testq %rax, %rax
jns 0x12d85
movq $0x0, 0x18(%rbx)
testq %rcx, %rcx
jns 0x12d92
movq $0x0, 0x10(%rbx)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq