// File: /workspace/github_c_makefile_star2_O2/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 0x1cb6f
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %r15
leaq 0x80(%rsp), %r11
movq (%r11), %rdx
movq 0x8(%r11), %rsi
movq 0x10(%r11), %rdi
movq 0x18(%r11), %r9
orq $-0x1, 0x20(%rsp)
cmpl $0x3, %ebp
ja 0x1c88d
leaq 0x8(%r14), %r12
movl %ebp, %r10d
leaq 0x10471(%rip), %rax     # 0x2cba8
movq %r10, 0x38(%rsp)
movslq (%rax,%r10,4), %r10
addq %rax, %r10
jmpq *%r10
movq %r8, %r13
negq %r13
testb %cl, %cl
cmoveq %r8, %r13
movq (%r12), %rax
addq %rax, %r13
cmpq %rsi, %r13
setle %sil
cmpq %rdx, %r13
setg %dl
andb %sil, %dl
cmpb $0x1, %dl
je 0x1c7ff
jmp 0x1c88d
movq %r8, %r13
negq %r13
testb %cl, %cl
cmovneq %r8, %r13
movq 0x10(%r14), %rax
addq %rax, %r13
cmpq %rdx, %r13
setge %dl
cmpq %rsi, %r13
jmp 0x1c7b1
movq %r8, %r13
negq %r13
testb %cl, %cl
cmovneq %r8, %r13
movq 0x20(%r14), %rax
addq %rax, %r13
cmpq %rdi, %r13
setge %dl
cmpq %r9, %r13
setl %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x1c88d
movq %r13, %rdx
incq %rdx
movq %r13, 0x20(%rsp)
incq %rax
jmp 0x1c80d
movq %r8, %r13
negq %r13
testb %cl, %cl
cmoveq %r8, %r13
movq 0x18(%r14), %rax
addq %rax, %r13
cmpq %r9, %r13
setle %dl
cmpq %rdi, %r13
setg %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x1c88d
movq %r13, %rdx
decq %rdx
movq %r13, 0x20(%rsp)
decq %rax
movq %rax, 0x28(%rsp)
movq %rdx, 0x30(%rsp)
testq %r13, %r13
js 0x1c88d
leaq 0x10395(%rip), %rax     # 0x2cbb8
movq 0x38(%rsp), %rdx
movslq (%rax,%rdx,4), %rdx
addq %rax, %rdx
movq %r12, 0x40(%rsp)
jmpq *%rdx
testb %cl, %cl
je 0x1ca3c
movups (%r11), %xmm0
movups 0x10(%r11), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq 0x20(%rsp), %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x1cb80
leaq 0x80(%rsp), %rax
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %r15, %rdi
movq %r14, %rsi
leaq 0x20(%rsp), %rdx
callq 0x1cc23
jmp 0x1ca86
xorl %ebx, %ebx
jmp 0x1cb6f
testb %cl, %cl
je 0x1c997
movups (%r11), %xmm0
movups 0x10(%r11), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq 0x20(%rsp), %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x1ccb4
leaq 0x80(%rsp), %rax
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %r15, %rdi
movq %r14, %rsi
leaq 0x20(%rsp), %rdx
callq 0x1cd57
jmp 0x1c9e1
testb %cl, %cl
je 0x1c9ea
movups (%r11), %xmm0
movups 0x10(%r11), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq 0x20(%rsp), %rdx
movq %r15, %rdi
movq %r14, %rsi
movq %r11, %r12
callq 0x1cf1a
movups (%r12), %xmm0
movups 0x10(%r12), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %r15, %rdi
movq %r14, %rsi
leaq 0x20(%rsp), %rdx
callq 0x1cfbc
jmp 0x1ca33
testb %cl, %cl
je 0x1ca8b
movups (%r11), %xmm0
movups 0x10(%r11), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq 0x20(%rsp), %rdx
movq %r15, %rdi
movq %r14, %rsi
movq %r11, %r12
callq 0x1cde8
movups (%r12), %xmm0
movups 0x10(%r12), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %r15, %rdi
movq %r14, %rsi
leaq 0x20(%rsp), %rdx
callq 0x1ce8a
jmp 0x1cad4
movups (%r11), %xmm0
movups 0x10(%r11), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq 0x20(%rsp), %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x1cd57
leaq 0x80(%rsp), %rax
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %r15, %rdi
movq %r14, %rsi
leaq 0x20(%rsp), %rdx
callq 0x1ccb4
leaq 0x10(%r14), %rax
jmp 0x1cad8
movups (%r11), %xmm0
movups 0x10(%r11), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq 0x20(%rsp), %rdx
movq %r15, %rdi
movq %r14, %rsi
movq %r11, %r12
callq 0x1cfbc
movups (%r12), %xmm0
movups 0x10(%r12), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %r15, %rdi
movq %r14, %rsi
leaq 0x20(%rsp), %rdx
callq 0x1cf1a
leaq 0x20(%r14), %rax
jmp 0x1cad8
movups (%r11), %xmm0
movups 0x10(%r11), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq 0x20(%rsp), %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x1cc23
leaq 0x80(%rsp), %rax
movups (%rax), %xmm0
movups 0x10(%rax), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %r15, %rdi
movq %r14, %rsi
leaq 0x20(%rsp), %rdx
callq 0x1cb80
movq %r12, %rax
jmp 0x1cad8
movups (%r11), %xmm0
movups 0x10(%r11), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
leaq 0x20(%rsp), %rdx
movq %r15, %rdi
movq %r14, %rsi
movq %r11, %r12
callq 0x1ce8a
movups (%r12), %xmm0
movups 0x10(%r12), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
movq %r15, %rdi
movq %r14, %rsi
leaq 0x20(%rsp), %rdx
callq 0x1cde8
leaq 0x18(%r14), %rax
movq %r13, (%rax)
movq %r15, %rdi
movq %r14, %rsi
callq 0x1c2a3
leaq 0x1012b(%rip), %r13     # 0x2cc18
leaq 0x100d4(%rip), %r12     # 0x2cbc8
movl (%rax), %ecx
decl %ecx
cmpl $0x2, %ecx
ja 0x1cb5f
cmpl $0x3, %ebp
ja 0x1cb5f
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 0x1cb5f
movq %rdx, (%rax,%rcx)
jmp 0x1cb5f
movq 0x10(%r14), %rdx
cmpq 0x8(%rax,%rcx), %rdx
jle 0x1cb5f
movq %rdx, 0x8(%rax,%rcx)
jmp 0x1cb5f
movq 0x20(%r14), %rdx
cmpq 0x18(%rax,%rcx), %rdx
jle 0x1cb5f
movq %rdx, 0x18(%rax,%rcx)
jmp 0x1cb5f
movq 0x18(%r14), %rdx
cmpq 0x10(%rax,%rcx), %rdx
jge 0x1cb5f
movq %rdx, 0x10(%rax,%rcx)
movq %r15, %rdi
movq %rax, %rsi
callq 0x1c2a3
testq %rax, %rax
jne 0x1caf4
movl %ebx, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq