// File: /workspace/github_cpp_makefile_star2_O1/6851-2021[P]Cache-Oblivious-Data-Structures/static_search_trees/static_search_trees.cpp
// Function: co_static_search_tree::update_4_base_case(int, int, int, int, int)
inline int co_static_search_tree::update_4_base_case(int block_index, int range_left, int og_height, int index, int value) {
    /*
                                    0
                    1                                   2
            3               6                   9                 12
        4       5       7       8           10       11      13          14                    
    */
    int leafs_og_height = og_height - 3;
    int leaf_index = (index - range_left) >> (leafs_og_height - 1);
    if(leaf_index == 0) {
        this->tree[block_index + 4] = value;
        this->tree[block_index + 3] = max(this->tree[block_index + 4], this->tree[block_index + 5]);
        this->tree[block_index + 1] = max(this->tree[block_index + 3], this->tree[block_index + 6]);
        this->tree[block_index + 0] = max(this->tree[block_index + 1], this->tree[block_index + 2]);
    }
    else if(leaf_index == 1) {
        this->tree[block_index + 5] = value;
        this->tree[block_index + 3] = max(this->tree[block_index + 4], this->tree[block_index + 5]);
        this->tree[block_index + 1] = max(this->tree[block_index + 3], this->tree[block_index + 6]);
        this->tree[block_index + 0] = max(this->tree[block_index + 1], this->tree[block_index + 2]);
    }
    else if(leaf_index == 2) {
        this->tree[block_index + 7] = value;
        this->tree[block_index + 6] = max(this->tree[block_index + 7], this->tree[block_index + 8]);
        this->tree[block_index + 1] = max(this->tree[block_index + 3], this->tree[block_index + 6]);
        this->tree[block_index + 0] = max(this->tree[block_index + 1], this->tree[block_index + 2]);
    }
    else if(leaf_index == 3) {
        this->tree[block_index + 8] = value;
        this->tree[block_index + 6] = max(this->tree[block_index + 7], this->tree[block_index + 8]);
        this->tree[block_index + 1] = max(this->tree[block_index + 3], this->tree[block_index + 6]);
        this->tree[block_index + 0] = max(this->tree[block_index + 1], this->tree[block_index + 2]);
    }
    else if(leaf_index == 4) {
        this->tree[block_index + 10] = value;
        this->tree[block_index + 9] = max(this->tree[block_index + 10], this->tree[block_index + 11]);
        this->tree[block_index + 2] = max(this->tree[block_index + 9], this->tree[block_index + 12]);
        this->tree[block_index + 0] = max(this->tree[block_index + 1], this->tree[block_index + 2]);
    }
    else if(leaf_index == 5){
        this->tree[block_index + 11] = value;
        this->tree[block_index + 9] = max(this->tree[block_index + 10], this->tree[block_index + 11]);
        this->tree[block_index + 2] = max(this->tree[block_index + 9], this->tree[block_index + 12]);
        this->tree[block_index + 0] = max(this->tree[block_index + 1], this->tree[block_index + 2]);
    }
    else if(leaf_index == 6){
        this->tree[block_index + 13] = value;
        this->tree[block_index + 12] = max(this->tree[block_index + 13], this->tree[block_index + 14]);
        this->tree[block_index + 2] = max(this->tree[block_index + 9], this->tree[block_index + 12]);
        this->tree[block_index + 0] = max(this->tree[block_index + 1], this->tree[block_index + 2]);
    }
    else if(leaf_index == 7){
        this->tree[block_index + 14] = value;
        this->tree[block_index + 12] = max(this->tree[block_index + 13], this->tree[block_index + 14]);
        this->tree[block_index + 2] = max(this->tree[block_index + 9], this->tree[block_index + 12]);
        this->tree[block_index + 0] = max(this->tree[block_index + 1], this->tree[block_index + 2]);
    }
    return this->tree[block_index];
}

// Assembly:
subl %edx, %r8d
addb $-0x4, %cl
sarl %cl, %r8d
movslq %esi, %rax
cmpl $0x7, %r8d
ja 0x26ab
leaq 0x1ba3(%rip), %rcx      # 0x4144
movslq (%rcx,%r8,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
movq (%rdi), %rcx
movl %r9d, 0x10(%rcx,%rax,4)
movl 0x8(%rcx,%rax,4), %edx
movl 0x14(%rcx,%rax,4), %esi
jmp 0x2626
movq (%rdi), %rcx
movl %r9d, 0x28(%rcx,%rax,4)
movl 0x4(%rcx,%rax,4), %edx
movl 0x2c(%rcx,%rax,4), %esi
jmp 0x265b
movq (%rdi), %rcx
movl %r9d, 0x1c(%rcx,%rax,4)
movl 0x20(%rcx,%rax,4), %edx
jmp 0x25eb
movq (%rdi), %rcx
movl %r9d, 0x20(%rcx,%rax,4)
movl 0x1c(%rcx,%rax,4), %edx
cmpl %r9d, %edx
cmovgl %edx, %r9d
movl %r9d, 0x18(%rcx,%rax,4)
movl 0x8(%rcx,%rax,4), %edx
movl 0xc(%rcx,%rax,4), %esi
cmpl %r9d, %esi
cmovgl %esi, %r9d
jmp 0x263d
movq (%rdi), %rcx
movl %r9d, 0x38(%rcx,%rax,4)
movl 0x34(%rcx,%rax,4), %edx
jmp 0x2680
movq (%rdi), %rcx
movl %r9d, 0x14(%rcx,%rax,4)
movl 0x8(%rcx,%rax,4), %edx
movl 0x10(%rcx,%rax,4), %esi
cmpl %r9d, %esi
cmovgl %esi, %r9d
movl %r9d, 0xc(%rcx,%rax,4)
movl 0x18(%rcx,%rax,4), %esi
cmpl %esi, %r9d
cmovlel %esi, %r9d
movl %r9d, 0x4(%rcx,%rax,4)
cmpl %edx, %r9d
cmovlel %edx, %r9d
jmp 0x26a7
movq (%rdi), %rcx
movl %r9d, 0x2c(%rcx,%rax,4)
movl 0x4(%rcx,%rax,4), %edx
movl 0x28(%rcx,%rax,4), %esi
cmpl %r9d, %esi
cmovgl %esi, %r9d
movl %r9d, 0x24(%rcx,%rax,4)
movl 0x30(%rcx,%rax,4), %esi
cmpl %esi, %r9d
cmovlel %esi, %r9d
jmp 0x269b
movq (%rdi), %rcx
movl %r9d, 0x34(%rcx,%rax,4)
movl 0x38(%rcx,%rax,4), %edx
cmpl %r9d, %edx
cmovgl %edx, %r9d
movl %r9d, 0x30(%rcx,%rax,4)
movl 0x4(%rcx,%rax,4), %edx
movl 0x24(%rcx,%rax,4), %esi
cmpl %r9d, %esi
cmovgl %esi, %r9d
movl %r9d, 0x8(%rcx,%rax,4)
cmpl %r9d, %edx
cmovgl %edx, %r9d
movl %r9d, (%rcx,%rax,4)
movq (%rdi), %rcx
movl (%rcx,%rax,4), %eax
retq