// File: /workspace/github_c_makefile_star2_O3/justy989[P]ce/ce_layout.c
// Function: ce_layout_resize_rect
bool ce_layout_resize_rect(CeLayout_t* root, CeLayout_t* layout, CeRect_t rect, CeDirection_t direction, bool expand, int64_t amount){
     switch(layout->type){
     default:
          break;
     case CE_LAYOUT_TYPE_VIEW:
     {
          ResizeRectResult_t result = resize_rect(&layout->view.rect, rect, direction, expand, amount);

          if(result.new_value < 0) return false;

          switch(direction){
          default:
               break;
          case CE_LEFT:
               if(expand){
                    resize_opposites_left(root, layout, rect, &result);
                    resize_shareds_left(root, layout, rect, &result);
               }else{
                    resize_shareds_left(root, layout, rect, &result);
                    resize_opposites_left(root, layout, rect, &result);
               }

               layout->view.rect.left = result.new_value;
               break;
          case CE_RIGHT:
               if(expand){
                    resize_opposites_right(root, layout, rect, &result);
                    resize_shareds_right(root, layout, rect, &result);
               }else{
                    resize_shareds_right(root, layout, rect, &result);
                    resize_opposites_right(root, layout, rect, &result);
               }

               layout->view.rect.right = result.new_value;
               break;
          case CE_UP:
               if(expand){
                    resize_opposites_up(root, layout, rect, &result);
                    resize_shareds_up(root, layout, rect, &result);
               }else{
                    resize_shareds_up(root, layout, rect, &result);
                    resize_opposites_up(root, layout, rect, &result);
               }

               layout->view.rect.top = result.new_value;
               break;
          case CE_DOWN:
               if(expand){
                    resize_opposites_down(root, layout, rect, &result);
                    resize_shareds_down(root, layout, rect, &result);
               }else{
                    resize_shareds_down(root, layout, rect, &result);
                    resize_opposites_down(root, layout, rect, &result);
               }

               layout->view.rect.bottom = result.new_value;
               break;
          }

          // Update parent rect
          CeLayout_t* parent = ce_layout_find_parent(root, layout);
          do{
              CeRect_t* parent_rect = NULL;
              switch(parent->type){
              default:
                  break;
              case CE_LAYOUT_TYPE_LIST:
                  parent_rect = &parent->list.rect;
                  break;
              case CE_LAYOUT_TYPE_TAB:
                  parent_rect = &parent->tab.rect;
                  break;
              case CE_LAYOUT_TYPE_TAB_LIST:
                  parent_rect = &parent->tab_list.rect;
                  break;
              }
              if(parent_rect){
                   switch(direction){
                   default:
                        break;
                   case CE_LEFT:
                        if(layout->view.rect.left < parent_rect->left){
                            parent_rect->left = layout->view.rect.left;
                        }
                        break;
                   case CE_RIGHT:
                        if(layout->view.rect.right > parent_rect->right){
                            parent_rect->right = layout->view.rect.right;
                        }
                        break;
                   case CE_UP:
                        if(layout->view.rect.top < parent_rect->top){
                            parent_rect->top = layout->view.rect.top;
                        }
                        break;
                   case CE_DOWN:
                        if(layout->view.rect.bottom > parent_rect->bottom){
                            parent_rect->bottom = layout->view.rect.bottom;
                        }
                        break;
                   }

              }
              parent = ce_layout_find_parent(root, parent);
          }while(parent);

     } break;
     case CE_LAYOUT_TYPE_LIST:
          break;
     case CE_LAYOUT_TYPE_TAB:
          break;
     case CE_LAYOUT_TYPE_TAB_LIST:
          break;
     }

     return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movb $0x1, %bl
cmpl $0x0, (%rsi)
jne 0x1e927
movl %edx, %ebp
movq %rdi, %r15
leaq 0x80(%rsp), %rax
movq (%rax), %r11
movq 0x8(%rax), %r9
movq 0x10(%rax), %rdi
movq 0x18(%rax), %r10
movq $-0x1, 0x8(%rsp)
cmpl $0x3, %edx
ja 0x1e6d8
movq %rsi, %r14
leaq 0x8(%rsi), %r12
movl %ebp, %edx
leaq 0x1166e(%rip), %rax     # 0x2fc10
movq %rdx, 0x38(%rsp)
movslq (%rax,%rdx,4), %rdx
addq %rax, %rdx
jmpq *%rdx
movq %r8, %r13
negq %r13
testb %cl, %cl
cmoveq %r8, %r13
movq (%r12), %rax
addq %rax, %r13
cmpq %r9, %r13
setle %dl
cmpq %r11, %r13
jmp 0x1e645
movq %r8, %r13
negq %r13
testb %cl, %cl
cmovneq %r8, %r13
movq 0x10(%r14), %rax
addq %rax, %r13
cmpq %r11, %r13
setge %dl
cmpq %r9, %r13
jmp 0x1e608
movq %r8, %r13
negq %r13
testb %cl, %cl
cmovneq %r8, %r13
movq 0x20(%r14), %rax
addq %rax, %r13
cmpq %rdi, %r13
setge %dl
cmpq %r10, %r13
setl %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x1e6d8
movq %r13, %rdx
incq %rdx
movq %r13, 0x8(%rsp)
incq %rax
jmp 0x1e664
movq %r8, %r13
negq %r13
testb %cl, %cl
cmoveq %r8, %r13
movq 0x18(%r14), %rax
addq %rax, %r13
cmpq %r10, %r13
setle %dl
cmpq %rdi, %r13
setg %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x1e6d8
movq %r13, %rdx
decq %rdx
movq %r13, 0x8(%rsp)
decq %rax
movq %rax, 0x10(%rsp)
movq %rdx, 0x18(%rsp)
testq %r13, %r13
js 0x1e6d8
leaq 0x115a6(%rip), %rax     # 0x2fc20
movq 0x38(%rsp), %rdx
movslq (%rax,%rdx,4), %rdx
addq %rax, %rdx
movq %r12, 0x40(%rsp)
jmpq *%rdx
movq %rdi, %rax
testb %cl, %cl
movq %rdi, 0x30(%rsp)
movq %r10, 0x20(%rsp)
je 0x1e824
movq 0x18(%r14), %rsi
leaq 0x8(%rsp), %r8
movq %r15, %rdi
movq %rax, %rdx
movq %r10, %rcx
callq 0x1e938
movq %r15, %rdi
movq %r14, %rsi
movq 0x30(%rsp), %rdx
movq 0x20(%rsp), %rcx
leaq 0x8(%rsp), %r8
callq 0x1e9d8
jmp 0x1e855
xorl %ebx, %ebx
jmp 0x1e927
movq %rdi, %rax
testb %cl, %cl
movq %rdi, 0x30(%rsp)
movq %r10, 0x20(%rsp)
je 0x1e7b2
movq 0x18(%r14), %rsi
leaq 0x8(%rsp), %r8
movq %r15, %rdi
movq %rax, %rdx
movq %r10, %rcx
callq 0x1ea62
movq %r15, %rdi
movq %r14, %rsi
movq 0x30(%rsp), %rdx
movq 0x20(%rsp), %rcx
leaq 0x8(%rsp), %r8
callq 0x1eb02
jmp 0x1e7e3
testb %cl, %cl
movq %r9, 0x28(%rsp)
je 0x1e7ec
movq 0x8(%r14), %rsi
leaq 0x8(%rsp), %r8
movq %r15, %rdi
movq %r11, %rdx
movq %r9, %rcx
movq %r11, %r12
callq 0x1ecb9
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq 0x28(%rsp), %rcx
leaq 0x8(%rsp), %r8
callq 0x1ed59
jmp 0x1e81e
testb %cl, %cl
movq %r9, 0x28(%rsp)
je 0x1e85a
movq 0x8(%r14), %rsi
leaq 0x8(%rsp), %r8
movq %r15, %rdi
movq %r11, %rdx
movq %r9, %rcx
movq %r11, %r12
callq 0x1eb8c
movq %r15, %rdi
movq %r14, %rsi
movq %r12, %rdx
movq 0x28(%rsp), %rcx
leaq 0x8(%rsp), %r8
callq 0x1ec2c
jmp 0x1e88c
leaq 0x8(%rsp), %r8
movq %r15, %rdi
movq %r14, %rsi
movq %rax, %rdx
movq %r10, %rcx
callq 0x1eb02
movq 0x18(%r14), %rsi
movq %r15, %rdi
movq 0x30(%rsp), %rdx
movq 0x20(%rsp), %rcx
leaq 0x8(%rsp), %r8
callq 0x1ea62
leaq 0x10(%r14), %rax
jmp 0x1e890
leaq 0x8(%rsp), %r8
movq %r15, %rdi
movq %r14, %rsi
movq %r11, %rdx
movq %r9, %rcx
movq %r11, %r12
callq 0x1ed59
movq 0x8(%r14), %rsi
movq %r15, %rdi
movq %r12, %rdx
movq 0x28(%rsp), %rcx
leaq 0x8(%rsp), %r8
callq 0x1ecb9
leaq 0x20(%r14), %rax
jmp 0x1e890
leaq 0x8(%rsp), %r8
movq %r15, %rdi
movq %r14, %rsi
movq %rax, %rdx
movq %r10, %rcx
callq 0x1e9d8
movq 0x18(%r14), %rsi
movq %r15, %rdi
movq 0x30(%rsp), %rdx
movq 0x20(%rsp), %rcx
leaq 0x8(%rsp), %r8
callq 0x1e938
movq %r12, %rax
jmp 0x1e890
leaq 0x8(%rsp), %r8
movq %r15, %rdi
movq %r14, %rsi
movq %r11, %rdx
movq %r9, %rcx
movq %r11, %r12
callq 0x1ec2c
movq 0x8(%r14), %rsi
movq %r15, %rdi
movq %r12, %rdx
movq 0x28(%rsp), %rcx
leaq 0x8(%rsp), %r8
callq 0x1eb8c
leaq 0x18(%r14), %rax
movq %r13, (%rax)
movq %r15, %rdi
movq %r14, %rsi
callq 0x1e10f
leaq 0x113db(%rip), %r13     # 0x2fc80
leaq 0x11384(%rip), %r12     # 0x2fc30
movl (%rax), %ecx
decl %ecx
cmpl $0x2, %ecx
ja 0x1e917
cmpl $0x3, %ebp
ja 0x1e917
movl %ecx, %ecx
movq (%r13,%rcx,8), %rcx
movq 0x38(%rsp), %rdx
movslq (%r12,%rdx,4), %rdx
addq %r12, %rdx
jmpq *%rdx
movq 0x40(%rsp), %rdx
movq (%rdx), %rdx
cmpq (%rax,%rcx), %rdx
jge 0x1e917
movq %rdx, (%rax,%rcx)
jmp 0x1e917
movq 0x10(%r14), %rdx
cmpq 0x8(%rax,%rcx), %rdx
jle 0x1e917
movq %rdx, 0x8(%rax,%rcx)
jmp 0x1e917
movq 0x20(%r14), %rdx
cmpq 0x18(%rax,%rcx), %rdx
jle 0x1e917
movq %rdx, 0x18(%rax,%rcx)
jmp 0x1e917
movq 0x18(%r14), %rdx
cmpq 0x10(%rax,%rcx), %rdx
jge 0x1e917
movq %rdx, 0x10(%rax,%rcx)
movq %r15, %rdi
movq %rax, %rsi
callq 0x1e10f
testq %rax, %rax
jne 0x1e8ac
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq