// File: /workspace/github_c_makefile_star2_O1/justy989[P]ce/ce_app.c
// Function: ce_app_open_popup_view
bool ce_app_open_popup_view(CeApp_t* app, CeBuffer_t* buffer){
     CeLayout_t* tab_layout = app->tab_list_layout->tab_list.current;
     if(tab_layout->type != CE_LAYOUT_TYPE_TAB){
         return false;
     }

     // If the split already exists, just re-use it.
     CeLayout_t* popup_layout = ce_layout_find_popup(app->tab_list_layout);
     if(popup_layout){
         if(popup_layout->type == CE_LAYOUT_TYPE_VIEW){
             popup_layout->view.buffer = buffer;
             popup_layout->view.scroll = (CePoint_t){0, 0};
             app->last_popup_buffer = buffer;
             return true;
         }
         ce_log("error layout at active view position not view type\n");
         return false;
     }

     // Find the highest level parent layout that isn't a tab, which should be a list.
     CeLayout_t* parent_layout = ce_layout_find_parent(tab_layout->tab.root, tab_layout->tab.current);
     CeLayout_t* save_current = tab_layout->tab.current;
     CeLayout_t* new_parent_layout = NULL;
     while(parent_layout){
         new_parent_layout = ce_layout_find_parent(tab_layout->tab.root, parent_layout);
         if(!new_parent_layout || new_parent_layout->type == CE_LAYOUT_TYPE_TAB){
             break;
         }
         parent_layout = new_parent_layout;
     }
     if(parent_layout != NULL){
         tab_layout->tab.current = parent_layout;
     }else{
         parent_layout = tab_layout->tab.current;
     }

     // split the layout
     bool vertical = true;
     bool always_add_last = true;
     CeLayout_t* new_layout = ce_layout_split(tab_layout, vertical, always_add_last);
     if(new_layout == NULL){
         return false;
     }
     new_layout->view.buffer = buffer;
     new_layout->view.scroll = (CePoint_t){0, 0};
     new_layout->popup = true;

     // shrink the window after the even split.
     CePoint_t parent_point = {parent_layout->list.rect.left, parent_layout->list.rect.bottom};
     CeLayout_t* layout_to_resize = ce_layout_find_at(app->tab_list_layout, parent_point);
     int64_t current_popup_height = (new_layout->view.rect.bottom - new_layout->view.rect.top);
     if(layout_to_resize && app->config_options.popup_view_height < current_popup_height &&
        app->config_options.popup_view_height < app->terminal_rect.bottom){
         int64_t popup_resize_delta = current_popup_height - app->config_options.popup_view_height;
         ce_layout_resize_rect(app->tab_list_layout, layout_to_resize, app->terminal_rect, CE_DOWN, true, popup_resize_delta);
         if(parent_layout->type != CE_LAYOUT_TYPE_VIEW){
             ce_layout_distribute_rect(parent_layout, parent_layout->list.rect);
         }
     }
     app->last_popup_buffer = buffer;
     tab_layout->tab.current = save_current;
     return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %r14
movq 0x2818(%rdi), %rdi
movq 0x10(%rdi), %r15
cmpl $0x2, (%r15)
jne 0x13cd2
movq %rsi, %rbx
callq 0x1ee5d
testq %rax, %rax
je 0x13cd9
cmpl $0x0, (%rax)
je 0x13d13
leaq 0x1c1af(%rip), %rdi     # 0x2fe73
xorl %ebp, %ebp
xorl %eax, %eax
callq 0xd954
jmp 0x13df6
xorl %ebp, %ebp
jmp 0x13df6
movq 0x8(%r15), %rdi
movq 0x10(%r15), %rsi
callq 0x1dde1
movq 0x10(%r15), %rcx
movq %rcx, 0x20(%rsp)
testq %rax, %rax
je 0x13d2a
movq %rax, %r12
movq 0x8(%r15), %rdi
movq %rax, %rsi
callq 0x1dde1
testq %rax, %rax
je 0x13d0d
cmpl $0x2, (%rax)
jne 0x13cef
movq %r12, 0x10(%r15)
jmp 0x13d2e
movq %rbx, 0x48(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rax)
movq %rbx, 0x2dd0(%r14)
jmp 0x13df3
movq 0x10(%r15), %r12
movq %r15, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0x1db50
testq %rax, %rax
setne %bpl
je 0x13df6
movq %rax, %r13
movq %rbx, 0x48(%rax)
xorps %xmm0, %xmm0
movups %xmm0, 0x28(%rax)
movb $0x1, 0x58(%rax)
movq 0x20(%r12), %rsi
movq 0x38(%r12), %rdx
movq 0x2818(%r14), %rdi
callq 0x1ed8e
testq %rax, %rax
je 0x13de3
movq 0x20(%r13), %r8
subq 0x18(%r13), %r8
movslq 0x26f8(%r14), %rcx
subq %rcx, %r8
jle 0x13de3
cmpq %rcx, 0x18(%r14)
jle 0x13de3
movq 0x2818(%r14), %rdi
movups (%r14), %xmm0
movups 0x10(%r14), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %rax, %rsi
movl $0x3, %edx
movl $0x1, %ecx
callq 0x1e2d4
cmpl $0x0, (%r12)
je 0x13de3
leaq 0x20(%r12), %rax
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %r12, %rdi
callq 0x1e0a5
movq %rbx, 0x2dd0(%r14)
movq 0x20(%rsp), %rax
movq %rax, 0x10(%r15)
movb $0x1, %bpl
movl %ebp, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq