// File: /workspace/github_c_makefile_star2_O2/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), %rax
movq %rdx, %r8
subq 0x28(%rcx), %r8
leaq (%r8,%rax), %r10
movq %r10, %r11
subq %rdi, %r11
cmpq %rdx, %rdi
leaq 0x1(%r8,%rax), %rax
leaq 0x1(%rdi,%r10), %rdx
cmovlq %r10, %rdx
cmovlq %r11, %rax
movq %rdx, 0x18(%rbx)
movq %rax, 0x10(%rbx)
movq %rsi, (%rbx)
movq 0x40(%rcx), %rax
cmpb $0x0, 0x50(%rax)
jne 0x12509
movl (%r9), %edi
movq 0x8(%rax), %rsi
movq 0x10(%rcx), %rdx
movq 0x18(%rcx), %rcx
callq 0x10283
addq %rax, (%rbx)
movq 0x30(%rsp), %r13
xorl %r12d, %r12d
xorl %r15d, %r15d
cmpq 0x8(%r14), %r15
jge 0x12531
movq %r14, %rdi
movq %r15, %rsi
callq 0xea7c
cmpq %r12, %rax
cmovgq %rax, %r12
incq %r15
jmp 0x12514
movq (%rbx), %rax
addq %rax, %r12
movq %r12, 0x8(%rbx)
movq 0x8(%r13), %rcx
cmpq %rcx, %rax
jl 0x1254b
leaq -0x1(%rcx), %rax
movq %rax, (%rbx)
cmpq %rcx, %r12
jl 0x1255a
decq %rcx
movq %rcx, 0x8(%rbx)
movq %rcx, %r12
movq 0x18(%rbx), %rcx
movq 0x18(%r13), %rsi
cmpq %rsi, %rcx
jl 0x12575
decq %rsi
movq %rsi, 0x18(%rbx)
movq %rsi, %rcx
movq 0x18(%r13), %rsi
movq 0x10(%rbx), %rdx
cmpq %rsi, %rdx
jl 0x12588
decq %rsi
movq %rsi, 0x10(%rbx)
movq %rsi, %rdx
testq %rax, %rax
jns 0x12591
andq $0x0, (%rbx)
testq %r12, %r12
jns 0x1259b
andq $0x0, 0x8(%rbx)
testq %rcx, %rcx
jns 0x125a5
andq $0x0, 0x18(%rbx)
testq %rdx, %rdx
jns 0x125af
andq $0x0, 0x10(%rbx)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq