// File: /workspace/github_c_makefile_star2_O0/justy989[P]ce/ce_layout.c
// Function: resize_rect
static ResizeRectResult_t resize_rect(CeRect_t* rect, CeRect_t bounds, CeDirection_t direction, bool expand, int64_t amount){
     ResizeRectResult_t result = {-1, -1, -1};

     switch(direction){
     default:
          break;
     case CE_LEFT:
     {
          int64_t new_left = rect->left;

          if(expand){
               new_left -= amount;
          }else{
               new_left += amount;
          }

          if(new_left < bounds.left || new_left > bounds.right) return result;

          int64_t new_adjacent = new_left - 1;
          if(new_adjacent < bounds.left || new_adjacent > bounds.right) return result;

          result.new_value = new_left;
          result.adjacent_old_value = rect->left - 1;
          result.adjacent_new_value = new_adjacent;
          return result;
     } break;
     case CE_RIGHT:
     {
          int64_t new_right = rect->right;

          if(expand){
               new_right += amount;
          }else{
               new_right -= amount;
          }

          if(new_right < bounds.left || new_right > bounds.right) return result;

          int64_t new_adjacent = new_right + 1;
          if(new_adjacent < bounds.left || new_adjacent > bounds.right) return result;

          result.new_value = new_right;
          result.adjacent_old_value = rect->right + 1;
          result.adjacent_new_value = new_adjacent;
          return result;
     } break;
     case CE_UP:
     {
          int64_t new_top = rect->top;

          if(expand){
               new_top -= amount;
          }else{
               new_top += amount;
          }

          if(new_top < bounds.top || new_top > bounds.bottom) return result;

          int64_t new_adjacent = new_top - 1;
          if(new_adjacent < bounds.top || new_adjacent > bounds.bottom) return result;

          result.new_value = new_top;
          result.adjacent_old_value = rect->top - 1;
          result.adjacent_new_value = new_adjacent;
          return result;
     } break;
     case CE_DOWN:
     {
          int64_t new_bottom = rect->bottom;

          if(expand){
               new_bottom += amount;
          }else{
               new_bottom -= amount;
          }

          if(new_bottom < bounds.top || new_bottom > bounds.bottom) return result;

          int64_t new_adjacent = new_bottom + 1;
          if(new_adjacent < bounds.top || new_adjacent > bounds.bottom) return result;

          result.new_value = new_bottom;
          result.adjacent_old_value = rect->bottom + 1;
          result.adjacent_new_value = new_adjacent;
          return result;
     } break;
     }

     return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x78(%rbp)
movb %cl, %al
movq %rdi, %rcx
movq %rcx, -0x70(%rbp)
leaq 0x10(%rbp), %rcx
movq %rcx, -0x68(%rbp)
movq %rsi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
andb $0x1, %al
movb %al, -0xd(%rbp)
movq %r8, -0x18(%rbp)
movups 0x1bbe0(%rip), %xmm0    # 0x44bc0
movups %xmm0, (%rdi)
movq $-0x1, 0x10(%rdi)
movl -0xc(%rbp), %eax
movq %rax, -0x60(%rbp)
subq $0x3, %rax
ja 0x2900c
movq -0x60(%rbp), %rax
leaq 0x1bb5d(%rip), %rcx     # 0x44b60
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
jmp 0x29296
movq -0x8(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x20(%rbp)
testb $0x1, -0xd(%rbp)
je 0x29033
movq -0x18(%rbp), %rcx
movq -0x20(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x20(%rbp)
jmp 0x2903f
movq -0x18(%rbp), %rax
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x68(%rbp), %rcx
movq -0x20(%rbp), %rax
cmpq (%rcx), %rax
jl 0x2905a
movq -0x68(%rbp), %rcx
movq -0x20(%rbp), %rax
cmpq 0x8(%rcx), %rax
jle 0x2905f
jmp 0x29298
movq -0x68(%rbp), %rcx
movq -0x20(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
cmpq (%rcx), %rax
jl 0x29086
movq -0x68(%rbp), %rcx
movq -0x28(%rbp), %rax
cmpq 0x8(%rcx), %rax
jle 0x2908b
jmp 0x29298
movq -0x78(%rbp), %rax
movq -0x20(%rbp), %rcx
movq %rcx, (%rax)
movq -0x8(%rbp), %rcx
movq (%rcx), %rcx
subq $0x1, %rcx
movq %rcx, 0x8(%rax)
movq -0x28(%rbp), %rcx
movq %rcx, 0x10(%rax)
jmp 0x29298
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x30(%rbp)
testb $0x1, -0xd(%rbp)
je 0x290d2
movq -0x18(%rbp), %rax
addq -0x30(%rbp), %rax
movq %rax, -0x30(%rbp)
jmp 0x290e1
movq -0x18(%rbp), %rcx
movq -0x30(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x68(%rbp), %rcx
movq -0x30(%rbp), %rax
cmpq (%rcx), %rax
jl 0x290fc
movq -0x68(%rbp), %rcx
movq -0x30(%rbp), %rax
cmpq 0x8(%rcx), %rax
jle 0x29101
jmp 0x29298
movq -0x68(%rbp), %rcx
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
cmpq (%rcx), %rax
jl 0x29128
movq -0x68(%rbp), %rcx
movq -0x38(%rbp), %rax
cmpq 0x8(%rcx), %rax
jle 0x2912d
jmp 0x29298
movq -0x78(%rbp), %rax
movq -0x30(%rbp), %rcx
movq %rcx, (%rax)
movq -0x8(%rbp), %rcx
movq 0x8(%rcx), %rcx
addq $0x1, %rcx
movq %rcx, 0x8(%rax)
movq -0x38(%rbp), %rcx
movq %rcx, 0x10(%rax)
jmp 0x29298
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x40(%rbp)
testb $0x1, -0xd(%rbp)
je 0x29178
movq -0x18(%rbp), %rcx
movq -0x40(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x40(%rbp)
jmp 0x29184
movq -0x18(%rbp), %rax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x68(%rbp), %rcx
movq -0x40(%rbp), %rax
cmpq 0x10(%rcx), %rax
jl 0x291a0
movq -0x68(%rbp), %rcx
movq -0x40(%rbp), %rax
cmpq 0x18(%rcx), %rax
jle 0x291a5
jmp 0x29298
movq -0x68(%rbp), %rcx
movq -0x40(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq 0x10(%rcx), %rax
jl 0x291cd
movq -0x68(%rbp), %rcx
movq -0x48(%rbp), %rax
cmpq 0x18(%rcx), %rax
jle 0x291d2
jmp 0x29298
movq -0x78(%rbp), %rax
movq -0x40(%rbp), %rcx
movq %rcx, (%rax)
movq -0x8(%rbp), %rcx
movq 0x10(%rcx), %rcx
subq $0x1, %rcx
movq %rcx, 0x8(%rax)
movq -0x48(%rbp), %rcx
movq %rcx, 0x10(%rax)
jmp 0x29298
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x50(%rbp)
testb $0x1, -0xd(%rbp)
je 0x2921a
movq -0x18(%rbp), %rax
addq -0x50(%rbp), %rax
movq %rax, -0x50(%rbp)
jmp 0x29229
movq -0x18(%rbp), %rcx
movq -0x50(%rbp), %rax
subq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x68(%rbp), %rcx
movq -0x50(%rbp), %rax
cmpq 0x10(%rcx), %rax
jl 0x29245
movq -0x68(%rbp), %rcx
movq -0x50(%rbp), %rax
cmpq 0x18(%rcx), %rax
jle 0x29247
jmp 0x29298
movq -0x68(%rbp), %rcx
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
cmpq 0x10(%rcx), %rax
jl 0x2926f
movq -0x68(%rbp), %rcx
movq -0x58(%rbp), %rax
cmpq 0x18(%rcx), %rax
jle 0x29271
jmp 0x29298
movq -0x78(%rbp), %rax
movq -0x50(%rbp), %rcx
movq %rcx, (%rax)
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
addq $0x1, %rcx
movq %rcx, 0x8(%rax)
movq -0x58(%rbp), %rcx
movq %rcx, 0x10(%rax)
jmp 0x29298
jmp 0x29298
movq -0x70(%rbp), %rax
popq %rbp
retq
nop