// File: /workspace/github_c_makefile_star2_O1/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 0x8(%r8), %rax
movq 0x30(%r9), %r8
cmpq %r8, %rax
cmovlq %rax, %r8
addq (%rcx), %rsi
subq 0x20(%rcx), %rsi
movq %rdx, %rax
subq 0x28(%rcx), %rax
movq %rdi, %rbx
addq 0x10(%rcx), %rax
cmpq %rdx, %r8
jge 0x12ea0
movq %rax, 0x18(%rbx)
subq %r8, %rax
movl $0x10, %edx
jmp 0x12eb3
leaq 0x1(%rax), %rdx
movq %rdx, 0x10(%rbx)
addq %r8, %rax
incq %rax
movl $0x18, %edx
movq %rax, (%rbx,%rdx)
movq %rsi, (%rbx)
movq 0x40(%rcx), %rax
cmpb $0x0, 0x50(%rax)
jne 0x12edb
movl (%r9), %edi
movq 0x8(%rax), %rsi
movq 0x10(%rcx), %rdx
movq 0x18(%rcx), %rcx
callq 0x10815
addq %rax, (%rbx)
movq 0x30(%rsp), %r12
cmpq $0x0, 0x8(%r14)
jle 0x12f0a
xorl %r15d, %r15d
xorl %r13d, %r13d
movq %r14, %rdi
movq %r15, %rsi
callq 0xee0e
cmpq %r13, %rax
cmovgq %rax, %r13
incq %r15
cmpq 0x8(%r14), %r15
jl 0x12eed
jmp 0x12f0d
xorl %r13d, %r13d
movq (%rbx), %rcx
addq %rcx, %r13
movq %r13, 0x8(%rbx)
movq 0x8(%r12), %rax
cmpq %rax, %rcx
jl 0x12f28
leaq -0x1(%rax), %rcx
movq %rcx, (%rbx)
cmpq %rax, %r13
jl 0x12f34
decq %rax
movq %rax, 0x8(%rbx)
movq 0x18(%r12), %rax
cmpq %rax, 0x18(%rbx)
jl 0x12f46
decq %rax
movq %rax, 0x18(%rbx)
movq 0x18(%r12), %rax
cmpq %rax, 0x10(%rbx)
jl 0x12f58
decq %rax
movq %rax, 0x10(%rbx)
cmpq $0x0, (%rbx)
jns 0x12f65
movq $0x0, (%rbx)
cmpq $0x0, 0x8(%rbx)
jns 0x12f74
movq $0x0, 0x8(%rbx)
cmpq $0x0, 0x18(%rbx)
jns 0x12f83
movq $0x0, 0x18(%rbx)
cmpq $0x0, 0x10(%rbx)
jns 0x12f92
movq $0x0, 0x10(%rbx)
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
retq