// File: /workspace/github_c_makefile_star2_O3/OnionIoT[P]lv_example/lvgl/src/lv_core/lv_obj.c
// Function: lv_obj_align
void lv_obj_align(lv_obj_t * obj, const lv_obj_t * base, lv_align_t align, lv_coord_t x_mod, lv_coord_t y_mod)
{
    LV_ASSERT_OBJ(obj, LV_OBJX_NAME);

    lv_coord_t new_x = lv_obj_get_x(obj);
    lv_coord_t new_y = lv_obj_get_y(obj);

    if(base == NULL) {
        base = lv_obj_get_parent(obj);
    }

    LV_ASSERT_OBJ(base, LV_OBJX_NAME);


    switch(align) {
        case LV_ALIGN_CENTER:
            new_x = lv_obj_get_width(base) / 2 - lv_obj_get_width(obj) / 2;
            new_y = lv_obj_get_height(base) / 2 - lv_obj_get_height(obj) / 2;
            break;

        case LV_ALIGN_IN_TOP_LEFT:
            new_x = 0;
            new_y = 0;
            break;
        case LV_ALIGN_IN_TOP_MID:
            new_x = lv_obj_get_width(base) / 2 - lv_obj_get_width(obj) / 2;
            new_y = 0;
            break;

        case LV_ALIGN_IN_TOP_RIGHT:
            new_x = lv_obj_get_width(base) - lv_obj_get_width(obj);
            new_y = 0;
            break;

        case LV_ALIGN_IN_BOTTOM_LEFT:
            new_x = 0;
            new_y = lv_obj_get_height(base) - lv_obj_get_height(obj);
            break;
        case LV_ALIGN_IN_BOTTOM_MID:
            new_x = lv_obj_get_width(base) / 2 - lv_obj_get_width(obj) / 2;
            new_y = lv_obj_get_height(base) - lv_obj_get_height(obj);
            break;

        case LV_ALIGN_IN_BOTTOM_RIGHT:
            new_x = lv_obj_get_width(base) - lv_obj_get_width(obj);
            new_y = lv_obj_get_height(base) - lv_obj_get_height(obj);
            break;

        case LV_ALIGN_IN_LEFT_MID:
            new_x = 0;
            new_y = lv_obj_get_height(base) / 2 - lv_obj_get_height(obj) / 2;
            break;

        case LV_ALIGN_IN_RIGHT_MID:
            new_x = lv_obj_get_width(base) - lv_obj_get_width(obj);
            new_y = lv_obj_get_height(base) / 2 - lv_obj_get_height(obj) / 2;
            break;

        case LV_ALIGN_OUT_TOP_LEFT:
            new_x = 0;
            new_y = -lv_obj_get_height(obj);
            break;

        case LV_ALIGN_OUT_TOP_MID:
            new_x = lv_obj_get_width(base) / 2 - lv_obj_get_width(obj) / 2;
            new_y = -lv_obj_get_height(obj);
            break;

        case LV_ALIGN_OUT_TOP_RIGHT:
            new_x = lv_obj_get_width(base) - lv_obj_get_width(obj);
            new_y = -lv_obj_get_height(obj);
            break;

        case LV_ALIGN_OUT_BOTTOM_LEFT:
            new_x = 0;
            new_y = lv_obj_get_height(base);
            break;

        case LV_ALIGN_OUT_BOTTOM_MID:
            new_x = lv_obj_get_width(base) / 2 - lv_obj_get_width(obj) / 2;
            new_y = lv_obj_get_height(base);
            break;

        case LV_ALIGN_OUT_BOTTOM_RIGHT:
            new_x = lv_obj_get_width(base) - lv_obj_get_width(obj);
            new_y = lv_obj_get_height(base);
            break;

        case LV_ALIGN_OUT_LEFT_TOP:
            new_x = -lv_obj_get_width(obj);
            new_y = 0;
            break;

        case LV_ALIGN_OUT_LEFT_MID:
            new_x = -lv_obj_get_width(obj);
            new_y = lv_obj_get_height(base) / 2 - lv_obj_get_height(obj) / 2;
            break;

        case LV_ALIGN_OUT_LEFT_BOTTOM:
            new_x = -lv_obj_get_width(obj);
            new_y = lv_obj_get_height(base) - lv_obj_get_height(obj);
            break;

        case LV_ALIGN_OUT_RIGHT_TOP:
            new_x = lv_obj_get_width(base);
            new_y = 0;
            break;

        case LV_ALIGN_OUT_RIGHT_MID:
            new_x = lv_obj_get_width(base);
            new_y = lv_obj_get_height(base) / 2 - lv_obj_get_height(obj) / 2;
            break;

        case LV_ALIGN_OUT_RIGHT_BOTTOM:
            new_x = lv_obj_get_width(base);
            new_y = lv_obj_get_height(base) - lv_obj_get_height(obj);
            break;
    }

    /*Bring together the coordination system of base and obj*/
    lv_obj_t * par        = lv_obj_get_parent(obj);
    lv_coord_t base_abs_x = base->coords.x1;
    lv_coord_t base_abs_y = base->coords.y1;
    lv_coord_t par_abs_x  = par->coords.x1;
    lv_coord_t par_abs_y  = par->coords.y1;
    new_x += x_mod + base_abs_x;
    new_y += y_mod + base_abs_y;
    new_x -= par_abs_x;
    new_y -= par_abs_y;

    lv_obj_set_pos(obj, new_x, new_y);

#if LV_USE_OBJ_REALIGN
    /*Save the last align parameters to use them in `lv_obj_realign`*/
    obj->realign.align       = align;
    obj->realign.xofs        = x_mod;
    obj->realign.yofs        = y_mod;
    obj->realign.base        = base;
    obj->realign.origo_align = 0;
#endif
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %r8d, %ebp
movl %ecx, %r14d
movl %edx, %r12d
movq %rsi, %r15
movq %rdi, %rbx
callq 0x80e4
testb %al, %al
je 0x5838
movl %ebp, 0x4(%rsp)
movq %rbx, %rdi
callq 0x4bdd
movl %eax, %r13d
movq %rbx, %rdi
callq 0x4c15
movl %eax, %ebp
testq %r15, %r15
jne 0x57d9
movq %rbx, %rdi
callq 0x4ab5
movq %rax, %r15
movq %r15, %rdi
callq 0x80e4
testb %al, %al
je 0x5849
cmpb $0x14, %r12b
movl %r12d, (%rsp)
ja 0x5ac2
movzbl %r12b, %eax
leaq 0x3993e(%rip), %rcx     # 0x3f13c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r15, %rdi
callq 0x566d
movzwl %ax, %ecx
shrl $0xf, %ecx
addl %eax, %ecx
movswl %cx, %r13d
sarl %r13d
movq %rbx, %rdi
callq 0x566d
movzwl %ax, %ecx
shrl $0xf, %ecx
addl %eax, %ecx
movswl %cx, %eax
sarl %eax
jmp 0x5a86
leaq 0x399a5(%rip), %rdi     # 0x3f1e4
movq %rbx, %rsi
callq 0x8294
jmp 0x5847
leaq 0x39994(%rip), %rdi     # 0x3f1e4
movq %r15, %rsi
callq 0x8294
jmp 0x5858
movq %rbx, %rdi
callq 0x566d
movl %eax, %r13d
negl %r13d
jmp 0x5a96
movq %r15, %rdi
callq 0x566d
movl %eax, %r13d
movq %rbx, %rdi
callq 0x566d
jmp 0x59e5
movq %r15, %rdi
callq 0x566d
movl %eax, %r13d
movq %rbx, %rdi
callq 0x566d
jmp 0x5a62
movq %r15, %rdi
callq 0x5697
movl %eax, %ebp
movq %rbx, %rdi
callq 0x5697
jmp 0x595a
movq %r15, %rdi
callq 0x5697
movl %eax, %ebp
jmp 0x5960
movq %rbx, %rdi
callq 0x5697
movl %eax, %ebp
negl %ebp
jmp 0x5960
movq %r15, %rdi
callq 0x566d
movzwl %ax, %ecx
shrl $0xf, %ecx
addl %eax, %ecx
movswl %cx, %r13d
sarl %r13d
movq %rbx, %rdi
callq 0x566d
movzwl %ax, %ecx
shrl $0xf, %ecx
addl %eax, %ecx
movswl %cx, %eax
sarl %eax
jmp 0x5928
movq %rbx, %rdi
callq 0x566d
movl %eax, %r13d
negl %r13d
jmp 0x5a2f
movq %r15, %rdi
callq 0x566d
movl %eax, %r13d
movq %rbx, %rdi
callq 0x566d
subl %eax, %r13d
jmp 0x5a2f
movq %r15, %rdi
callq 0x5697
movzwl %ax, %ecx
shrl $0xf, %ecx
addl %eax, %ecx
movswl %cx, %ebp
sarl %ebp
movq %rbx, %rdi
callq 0x5697
movzwl %ax, %ecx
shrl $0xf, %ecx
addl %eax, %ecx
movswl %cx, %eax
sarl %eax
subl %eax, %ebp
jmp 0x5960
xorl %ebp, %ebp
xorl %r13d, %r13d
jmp 0x5ac2
movq %rbx, %rdi
callq 0x566d
movl %eax, %r13d
negl %r13d
jmp 0x5a0d
movq %r15, %rdi
callq 0x566d
movl %eax, %r13d
jmp 0x5a0d
movq %r15, %rdi
callq 0x566d
movzwl %ax, %ecx
shrl $0xf, %ecx
addl %eax, %ecx
movswl %cx, %r13d
sarl %r13d
movq %rbx, %rdi
callq 0x566d
movzwl %ax, %ecx
shrl $0xf, %ecx
addl %eax, %ecx
movswl %cx, %eax
sarl %eax
jmp 0x5a0a
movq %r15, %rdi
callq 0x566d
movzwl %ax, %ecx
shrl $0xf, %ecx
addl %eax, %ecx
movswl %cx, %r13d
sarl %r13d
movq %rbx, %rdi
callq 0x566d
movzwl %ax, %ecx
shrl $0xf, %ecx
addl %eax, %ecx
movswl %cx, %eax
sarl %eax
subl %eax, %r13d
movq %r15, %rdi
callq 0x5697
movl %eax, %ebp
jmp 0x5ac2
movq %r15, %rdi
callq 0x566d
movl %eax, %r13d
movq %rbx, %rdi
callq 0x566d
subl %eax, %r13d
movq %r15, %rdi
callq 0x5697
movl %eax, %ebp
movq %rbx, %rdi
callq 0x5697
jmp 0x5ac0
movq %r15, %rdi
callq 0x566d
movl %eax, %r13d
xorl %ebp, %ebp
jmp 0x5ac2
movq %r15, %rdi
callq 0x566d
movzwl %ax, %ecx
shrl $0xf, %ecx
addl %eax, %ecx
movswl %cx, %r13d
sarl %r13d
movq %rbx, %rdi
callq 0x566d
movzwl %ax, %ecx
shrl $0xf, %ecx
addl %eax, %ecx
movswl %cx, %eax
sarl %eax
subl %eax, %r13d
movq %rbx, %rdi
callq 0x5697
movl %eax, %ebp
negl %ebp
jmp 0x5ac2
movq %r15, %rdi
callq 0x566d
movl %eax, %r13d
movq %rbx, %rdi
callq 0x566d
subl %eax, %r13d
jmp 0x5a96
movq %r15, %rdi
callq 0x566d
movl %eax, %r13d
movq %r15, %rdi
callq 0x5697
movzwl %ax, %ecx
shrl $0xf, %ecx
addl %eax, %ecx
movswl %cx, %ebp
sarl %ebp
movq %rbx, %rdi
callq 0x5697
movzwl %ax, %ecx
shrl $0xf, %ecx
addl %eax, %ecx
movswl %cx, %eax
sarl %eax
subl %eax, %ebp
movq %rbx, %rdi
callq 0x4ab5
addl %r14d, %r13d
addw 0x20(%r15), %r13w
subw 0x20(%rax), %r13w
movl %r14d, %r12d
movl 0x4(%rsp), %r14d
addl %r14d, %ebp
addw 0x22(%r15), %bp
subw 0x22(%rax), %bp
movswl %r13w, %esi
movswl %bp, %edx
movq %rbx, %rdi
callq 0x4ad8
movl (%rsp), %eax
movb %al, 0x6c(%rbx)
movw %r12w, 0x68(%rbx)
movw %r14w, 0x6a(%rbx)
movq %r15, 0x60(%rbx)
andb $-0x3, 0x6d(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq