// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq 0x2818(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
cmpl $0x2, (%rax)
je 0x17c88
movb $0x0, -0x1(%rbp)
jmp 0x17f57
movq -0x10(%rbp), %rax
movq 0x2818(%rax), %rdi
callq 0x29e90
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x17d0b
movq -0x28(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x17cf4
movq -0x18(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x28(%rbp), %rax
movq $0x0, -0x38(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x38(%rbp), %rcx
movq %rcx, 0x28(%rax)
movq -0x30(%rbp), %rcx
movq %rcx, 0x30(%rax)
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x2dd0(%rax)
movb $0x1, -0x1(%rbp)
jmp 0x17f57
leaq 0x2c12b(%rip), %rdi     # 0x43e26
movb $0x0, %al
callq 0xd8f0
movb $0x0, -0x1(%rbp)
jmp 0x17f57
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x281b0
movq %rax, -0x40(%rbp)
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
cmpq $0x0, -0x40(%rbp)
je 0x17d70
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x40(%rbp), %rsi
callq 0x281b0
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x17d64
movq -0x50(%rbp), %rax
cmpl $0x2, (%rax)
jne 0x17d66
jmp 0x17d70
movq -0x50(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x17d38
cmpq $0x0, -0x40(%rbp)
je 0x17d85
movq -0x40(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x17d91
movq -0x20(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x40(%rbp)
movb $0x1, -0x51(%rbp)
movb $0x1, -0x52(%rbp)
movq -0x20(%rbp), %rdi
movb -0x51(%rbp), %cl
movb -0x52(%rbp), %al
andb $0x1, %cl
andb $0x1, %al
movzbl %cl, %esi
movzbl %al, %edx
callq 0x27cf0
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
jne 0x17dc7
movb $0x0, -0x1(%rbp)
jmp 0x17f57
movq -0x18(%rbp), %rcx
movq -0x60(%rbp), %rax
movq %rcx, 0x48(%rax)
movq -0x60(%rbp), %rax
movq $0x0, -0x70(%rbp)
movq $0x0, -0x68(%rbp)
movq -0x70(%rbp), %rcx
movq %rcx, 0x28(%rax)
movq -0x68(%rbp), %rcx
movq %rcx, 0x30(%rax)
movq -0x60(%rbp), %rax
movb $0x1, 0x58(%rax)
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x80(%rbp)
movq -0x40(%rbp), %rax
movq 0x38(%rax), %rax
movq %rax, -0x78(%rbp)
movq -0x10(%rbp), %rax
movq 0x2818(%rax), %rdi
movq -0x80(%rbp), %rsi
movq -0x78(%rbp), %rdx
callq 0x29d60
movq %rax, -0x88(%rbp)
movq -0x60(%rbp), %rax
movq 0x20(%rax), %rax
movq -0x60(%rbp), %rcx
subq 0x18(%rcx), %rax
movq %rax, -0x90(%rbp)
cmpq $0x0, -0x88(%rbp)
je 0x17f38
movq -0x10(%rbp), %rax
movslq 0x26f8(%rax), %rax
cmpq -0x90(%rbp), %rax
jge 0x17f38
movq -0x10(%rbp), %rax
movslq 0x26f8(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x18(%rcx), %rax
jge 0x17f38
movq -0x90(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq 0x26f8(%rcx), %rcx
subq %rcx, %rax
movq %rax, -0x98(%rbp)
movq -0x10(%rbp), %rax
movq 0x2818(%rax), %rdi
movq -0x88(%rbp), %rsi
movq -0x10(%rbp), %rax
movq -0x98(%rbp), %r8
movl $0x3, %edx
movl $0x1, %ecx
movq (%rax), %r9
movq %r9, (%rsp)
movq 0x8(%rax), %r9
movq %r9, 0x8(%rsp)
movq 0x10(%rax), %r9
movq %r9, 0x10(%rsp)
movq 0x18(%rax), %rax
movq %rax, 0x18(%rsp)
callq 0x289a0
movq -0x40(%rbp), %rax
cmpl $0x0, (%rax)
je 0x17f36
movq -0x40(%rbp), %rdi
movq -0x40(%rbp), %rax
addq $0x8, %rax
addq $0x18, %rax
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rcx
movq %rcx, 0x10(%rsp)
movq 0x18(%rax), %rax
movq %rax, 0x18(%rsp)
callq 0x285c0
jmp 0x17f38
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x2dd0(%rax)
movq -0x48(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x10(%rax)
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)