// File: /workspace/github_c_makefile_star2_O0/justy989[P]ce/ce_commands.c
// Function: delete_layout
static bool delete_layout(CeApp_t* app){
     CeView_t* view = NULL;
     CeRect_t view_rect = {};
     int64_t current_index = 0;
     CeLayout_t* tab_layout = app->tab_list_layout->tab_list.current;

     for(int64_t i = 0; i < app->tab_list_layout->tab_list.tab_count; i++){
          if(app->tab_list_layout->tab_list.current == app->tab_list_layout->tab_list.tabs[i]){
               current_index = i;
               break;
          }
     }

     CeLayout_t* parent_of_current = ce_layout_find_parent(tab_layout->tab.root, tab_layout->tab.current);

     // check if this is the only view, and ignore the delete request
     if(app->tab_list_layout->tab_list.tab_count == 1 &&
        tab_layout->tab.root->type == CE_LAYOUT_TYPE_LIST &&
        tab_layout->tab.root->list.layout_count == 1 &&
        parent_of_current == tab_layout->tab.root){
          return false;
     }

     if(app->input_complete_func) return false;

     if(!get_view_info_from_tab(tab_layout, &view, &view_rect)){
          return false;
     }

     CePoint_t cursor = {0, 0};
     if(view) cursor = view_cursor_on_screen(view, app->config_options.tab_width, app->config_options.line_number);

     if(app->tab_list_layout->tab_list.tab_count > 1 && ce_layout_tab_get_layout_count(tab_layout) == 1){
          ce_layout_delete(app->tab_list_layout, tab_layout);
          if(current_index >= app->tab_list_layout->tab_list.tab_count){
               current_index = app->tab_list_layout->tab_list.tab_count - 1;
          }
          app->tab_list_layout->tab_list.current = app->tab_list_layout->tab_list.tabs[current_index];
          tab_layout = app->tab_list_layout->tab_list.current;
     }else{
          ce_layout_delete(tab_layout, tab_layout->tab.current);
     }

     CeLayout_t* layout = ce_layout_find_at(tab_layout, cursor);
     if(layout) tab_layout->tab.current = layout;

     return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
leaq -0x38(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0xd290
movq $0x0, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x2818(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x2818(%rcx), %rcx
cmpq 0x18(%rcx), %rax
jge 0x1d571
movq -0x10(%rbp), %rax
movq 0x2818(%rax), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
movq 0x2818(%rcx), %rcx
movq 0x8(%rcx), %rcx
movq -0x50(%rbp), %rdx
cmpq (%rcx,%rdx,8), %rax
jne 0x1d561
movq -0x50(%rbp), %rax
movq %rax, -0x40(%rbp)
jmp 0x1d571
jmp 0x1d563
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x1d51a
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rdi
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x281b0
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq 0x2818(%rax), %rax
cmpq $0x1, 0x18(%rax)
jne 0x1d5cf
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
cmpl $0x1, (%rax)
jne 0x1d5cf
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
cmpq $0x1, 0x10(%rax)
jne 0x1d5cf
movq -0x58(%rbp), %rax
movq -0x48(%rbp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x1d5cf
movb $0x0, -0x1(%rbp)
jmp 0x1d72e
movq -0x10(%rbp), %rax
cmpq $0x0, 0x27f8(%rax)
je 0x1d5e6
movb $0x0, -0x1(%rbp)
jmp 0x1d72e
movq -0x48(%rbp), %rdi
leaq -0x18(%rbp), %rsi
leaq -0x38(%rbp), %rdx
callq 0x1caf0
testb $0x1, %al
jne 0x1d604
movb $0x0, -0x1(%rbp)
jmp 0x1d72e
leaq -0x68(%rbp), %rdi
xorl %esi, %esi
movl $0x10, %edx
callq 0xd290
cmpq $0x0, -0x18(%rbp)
je 0x1d651
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x1a58(%rax), %rsi
movq -0x10(%rbp), %rax
movl 0x1a50(%rax), %edx
callq 0x14260
movq %rax, -0x78(%rbp)
movq %rdx, -0x70(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rax
movq 0x2818(%rax), %rax
cmpq $0x1, 0x18(%rax)
jle 0x1d6f1
movq -0x48(%rbp), %rdi
callq 0x2a670
cmpq $0x1, %rax
jne 0x1d6f1
movq -0x10(%rbp), %rax
movq 0x2818(%rax), %rdi
movq -0x48(%rbp), %rsi
callq 0x29f70
movq -0x40(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x2818(%rcx), %rcx
cmpq 0x18(%rcx), %rax
jl 0x1d6b6
movq -0x10(%rbp), %rax
movq 0x2818(%rax), %rax
movq 0x18(%rax), %rax
subq $0x1, %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x2818(%rax), %rax
movq 0x8(%rax), %rax
movq -0x40(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
movq -0x10(%rbp), %rax
movq 0x2818(%rax), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
movq 0x2818(%rax), %rax
movq 0x10(%rax), %rax
movq %rax, -0x48(%rbp)
jmp 0x1d702
movq -0x48(%rbp), %rdi
movq -0x48(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x29f70
movq -0x48(%rbp), %rdi
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
callq 0x29d60
movq %rax, -0x80(%rbp)
cmpq $0x0, -0x80(%rbp)
je 0x1d72a
movq -0x80(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, 0x10(%rax)
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x80, %rsp
popq %rbp
retq
nopl (%rax)