// File: 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:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movl %r8d, -0x18(%rbp)
movl %r9d, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x30(%rbp)
movl -0x14(%rbp), %eax
subl $0x3, %eax
movl %eax, -0x20(%rbp)
movl -0x18(%rbp), %eax
subl -0x10(%rbp), %eax
movl -0x20(%rbp), %ecx
subl $0x1, %ecx
sarl %cl, %eax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jne 0x362a
movq -0x30(%rbp), %rax
movl -0x1c(%rbp), %esi
movq (%rax), %rcx
movl -0xc(%rbp), %edx
addl $0x4, %edx
movslq %edx, %rdx
movl %esi, (%rcx,%rdx,4)
movq (%rax), %rdi
movl -0xc(%rbp), %ecx
addl $0x4, %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rdi
movq (%rax), %rsi
movl -0xc(%rbp), %eax
addl $0x5, %eax
cltq
shlq $0x2, %rax
addq %rax, %rsi
callq 0x31c0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movl (%rcx), %esi
movq (%rax), %rcx
movl -0xc(%rbp), %edx
addl $0x3, %edx
movslq %edx, %rdx
movl %esi, (%rcx,%rdx,4)
movq (%rax), %rdi
movl -0xc(%rbp), %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rdi
movq (%rax), %rsi
movl -0xc(%rbp), %eax
addl $0x6, %eax
cltq
shlq $0x2, %rax
addq %rax, %rsi
callq 0x31c0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movl (%rcx), %esi
movq (%rax), %rcx
movl -0xc(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
movl %esi, (%rcx,%rdx,4)
movq (%rax), %rdi
movl -0xc(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rdi
movq (%rax), %rsi
movl -0xc(%rbp), %eax
addl $0x2, %eax
cltq
shlq $0x2, %rax
addq %rax, %rsi
callq 0x31c0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movl (%rcx), %edx
movq (%rax), %rax
movl -0xc(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x3ca0
cmpl $0x1, -0x24(%rbp)
jne 0x3715
movq -0x30(%rbp), %rax
movl -0x1c(%rbp), %esi
movq (%rax), %rcx
movl -0xc(%rbp), %edx
addl $0x5, %edx
movslq %edx, %rdx
movl %esi, (%rcx,%rdx,4)
movq (%rax), %rdi
movl -0xc(%rbp), %ecx
addl $0x4, %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rdi
movq (%rax), %rsi
movl -0xc(%rbp), %eax
addl $0x5, %eax
cltq
shlq $0x2, %rax
addq %rax, %rsi
callq 0x31c0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movl (%rcx), %esi
movq (%rax), %rcx
movl -0xc(%rbp), %edx
addl $0x3, %edx
movslq %edx, %rdx
movl %esi, (%rcx,%rdx,4)
movq (%rax), %rdi
movl -0xc(%rbp), %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rdi
movq (%rax), %rsi
movl -0xc(%rbp), %eax
addl $0x6, %eax
cltq
shlq $0x2, %rax
addq %rax, %rsi
callq 0x31c0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movl (%rcx), %esi
movq (%rax), %rcx
movl -0xc(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
movl %esi, (%rcx,%rdx,4)
movq (%rax), %rdi
movl -0xc(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rdi
movq (%rax), %rsi
movl -0xc(%rbp), %eax
addl $0x2, %eax
cltq
shlq $0x2, %rax
addq %rax, %rsi
callq 0x31c0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movl (%rcx), %edx
movq (%rax), %rax
movl -0xc(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x3c9e
cmpl $0x2, -0x24(%rbp)
jne 0x3800
movq -0x30(%rbp), %rax
movl -0x1c(%rbp), %esi
movq (%rax), %rcx
movl -0xc(%rbp), %edx
addl $0x7, %edx
movslq %edx, %rdx
movl %esi, (%rcx,%rdx,4)
movq (%rax), %rdi
movl -0xc(%rbp), %ecx
addl $0x7, %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rdi
movq (%rax), %rsi
movl -0xc(%rbp), %eax
addl $0x8, %eax
cltq
shlq $0x2, %rax
addq %rax, %rsi
callq 0x31c0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movl (%rcx), %esi
movq (%rax), %rcx
movl -0xc(%rbp), %edx
addl $0x6, %edx
movslq %edx, %rdx
movl %esi, (%rcx,%rdx,4)
movq (%rax), %rdi
movl -0xc(%rbp), %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rdi
movq (%rax), %rsi
movl -0xc(%rbp), %eax
addl $0x6, %eax
cltq
shlq $0x2, %rax
addq %rax, %rsi
callq 0x31c0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movl (%rcx), %esi
movq (%rax), %rcx
movl -0xc(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
movl %esi, (%rcx,%rdx,4)
movq (%rax), %rdi
movl -0xc(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rdi
movq (%rax), %rsi
movl -0xc(%rbp), %eax
addl $0x2, %eax
cltq
shlq $0x2, %rax
addq %rax, %rsi
callq 0x31c0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movl (%rcx), %edx
movq (%rax), %rax
movl -0xc(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x3c9c
cmpl $0x3, -0x24(%rbp)
jne 0x38eb
movq -0x30(%rbp), %rax
movl -0x1c(%rbp), %esi
movq (%rax), %rcx
movl -0xc(%rbp), %edx
addl $0x8, %edx
movslq %edx, %rdx
movl %esi, (%rcx,%rdx,4)
movq (%rax), %rdi
movl -0xc(%rbp), %ecx
addl $0x7, %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rdi
movq (%rax), %rsi
movl -0xc(%rbp), %eax
addl $0x8, %eax
cltq
shlq $0x2, %rax
addq %rax, %rsi
callq 0x31c0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movl (%rcx), %esi
movq (%rax), %rcx
movl -0xc(%rbp), %edx
addl $0x6, %edx
movslq %edx, %rdx
movl %esi, (%rcx,%rdx,4)
movq (%rax), %rdi
movl -0xc(%rbp), %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rdi
movq (%rax), %rsi
movl -0xc(%rbp), %eax
addl $0x6, %eax
cltq
shlq $0x2, %rax
addq %rax, %rsi
callq 0x31c0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movl (%rcx), %esi
movq (%rax), %rcx
movl -0xc(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
movl %esi, (%rcx,%rdx,4)
movq (%rax), %rdi
movl -0xc(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rdi
movq (%rax), %rsi
movl -0xc(%rbp), %eax
addl $0x2, %eax
cltq
shlq $0x2, %rax
addq %rax, %rsi
callq 0x31c0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movl (%rcx), %edx
movq (%rax), %rax
movl -0xc(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x3c9a
cmpl $0x4, -0x24(%rbp)
jne 0x39d6
movq -0x30(%rbp), %rax
movl -0x1c(%rbp), %esi
movq (%rax), %rcx
movl -0xc(%rbp), %edx
addl $0xa, %edx
movslq %edx, %rdx
movl %esi, (%rcx,%rdx,4)
movq (%rax), %rdi
movl -0xc(%rbp), %ecx
addl $0xa, %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rdi
movq (%rax), %rsi
movl -0xc(%rbp), %eax
addl $0xb, %eax
cltq
shlq $0x2, %rax
addq %rax, %rsi
callq 0x31c0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movl (%rcx), %esi
movq (%rax), %rcx
movl -0xc(%rbp), %edx
addl $0x9, %edx
movslq %edx, %rdx
movl %esi, (%rcx,%rdx,4)
movq (%rax), %rdi
movl -0xc(%rbp), %ecx
addl $0x9, %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rdi
movq (%rax), %rsi
movl -0xc(%rbp), %eax
addl $0xc, %eax
cltq
shlq $0x2, %rax
addq %rax, %rsi
callq 0x31c0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movl (%rcx), %esi
movq (%rax), %rcx
movl -0xc(%rbp), %edx
addl $0x2, %edx
movslq %edx, %rdx
movl %esi, (%rcx,%rdx,4)
movq (%rax), %rdi
movl -0xc(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rdi
movq (%rax), %rsi
movl -0xc(%rbp), %eax
addl $0x2, %eax
cltq
shlq $0x2, %rax
addq %rax, %rsi
callq 0x31c0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movl (%rcx), %edx
movq (%rax), %rax
movl -0xc(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x3c98
cmpl $0x5, -0x24(%rbp)
jne 0x3ac1
movq -0x30(%rbp), %rax
movl -0x1c(%rbp), %esi
movq (%rax), %rcx
movl -0xc(%rbp), %edx
addl $0xb, %edx
movslq %edx, %rdx
movl %esi, (%rcx,%rdx,4)
movq (%rax), %rdi
movl -0xc(%rbp), %ecx
addl $0xa, %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rdi
movq (%rax), %rsi
movl -0xc(%rbp), %eax
addl $0xb, %eax
cltq
shlq $0x2, %rax
addq %rax, %rsi
callq 0x31c0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movl (%rcx), %esi
movq (%rax), %rcx
movl -0xc(%rbp), %edx
addl $0x9, %edx
movslq %edx, %rdx
movl %esi, (%rcx,%rdx,4)
movq (%rax), %rdi
movl -0xc(%rbp), %ecx
addl $0x9, %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rdi
movq (%rax), %rsi
movl -0xc(%rbp), %eax
addl $0xc, %eax
cltq
shlq $0x2, %rax
addq %rax, %rsi
callq 0x31c0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movl (%rcx), %esi
movq (%rax), %rcx
movl -0xc(%rbp), %edx
addl $0x2, %edx
movslq %edx, %rdx
movl %esi, (%rcx,%rdx,4)
movq (%rax), %rdi
movl -0xc(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rdi
movq (%rax), %rsi
movl -0xc(%rbp), %eax
addl $0x2, %eax
cltq
shlq $0x2, %rax
addq %rax, %rsi
callq 0x31c0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movl (%rcx), %edx
movq (%rax), %rax
movl -0xc(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x3c96
cmpl $0x6, -0x24(%rbp)
jne 0x3bac
movq -0x30(%rbp), %rax
movl -0x1c(%rbp), %esi
movq (%rax), %rcx
movl -0xc(%rbp), %edx
addl $0xd, %edx
movslq %edx, %rdx
movl %esi, (%rcx,%rdx,4)
movq (%rax), %rdi
movl -0xc(%rbp), %ecx
addl $0xd, %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rdi
movq (%rax), %rsi
movl -0xc(%rbp), %eax
addl $0xe, %eax
cltq
shlq $0x2, %rax
addq %rax, %rsi
callq 0x31c0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movl (%rcx), %esi
movq (%rax), %rcx
movl -0xc(%rbp), %edx
addl $0xc, %edx
movslq %edx, %rdx
movl %esi, (%rcx,%rdx,4)
movq (%rax), %rdi
movl -0xc(%rbp), %ecx
addl $0x9, %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rdi
movq (%rax), %rsi
movl -0xc(%rbp), %eax
addl $0xc, %eax
cltq
shlq $0x2, %rax
addq %rax, %rsi
callq 0x31c0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movl (%rcx), %esi
movq (%rax), %rcx
movl -0xc(%rbp), %edx
addl $0x2, %edx
movslq %edx, %rdx
movl %esi, (%rcx,%rdx,4)
movq (%rax), %rdi
movl -0xc(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rdi
movq (%rax), %rsi
movl -0xc(%rbp), %eax
addl $0x2, %eax
cltq
shlq $0x2, %rax
addq %rax, %rsi
callq 0x31c0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movl (%rcx), %edx
movq (%rax), %rax
movl -0xc(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x3c94
cmpl $0x7, -0x24(%rbp)
jne 0x3c92
movq -0x30(%rbp), %rax
movl -0x1c(%rbp), %esi
movq (%rax), %rcx
movl -0xc(%rbp), %edx
addl $0xe, %edx
movslq %edx, %rdx
movl %esi, (%rcx,%rdx,4)
movq (%rax), %rdi
movl -0xc(%rbp), %ecx
addl $0xd, %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rdi
movq (%rax), %rsi
movl -0xc(%rbp), %eax
addl $0xe, %eax
cltq
shlq $0x2, %rax
addq %rax, %rsi
callq 0x31c0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movl (%rcx), %esi
movq (%rax), %rcx
movl -0xc(%rbp), %edx
addl $0xc, %edx
movslq %edx, %rdx
movl %esi, (%rcx,%rdx,4)
movq (%rax), %rdi
movl -0xc(%rbp), %ecx
addl $0x9, %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rdi
movq (%rax), %rsi
movl -0xc(%rbp), %eax
addl $0xc, %eax
cltq
shlq $0x2, %rax
addq %rax, %rsi
callq 0x31c0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movl (%rcx), %esi
movq (%rax), %rcx
movl -0xc(%rbp), %edx
addl $0x2, %edx
movslq %edx, %rdx
movl %esi, (%rcx,%rdx,4)
movq (%rax), %rdi
movl -0xc(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x2, %rcx
addq %rcx, %rdi
movq (%rax), %rsi
movl -0xc(%rbp), %eax
addl $0x2, %eax
cltq
shlq $0x2, %rax
addq %rax, %rsi
callq 0x31c0
movq %rax, %rcx
movq -0x30(%rbp), %rax
movl (%rcx), %edx
movq (%rax), %rax
movl -0xc(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
jmp 0x3c94
jmp 0x3c96
jmp 0x3c98
jmp 0x3c9a
jmp 0x3c9c
jmp 0x3c9e
jmp 0x3ca0
movq -0x30(%rbp), %rax
movq (%rax), %rax
movslq -0xc(%rbp), %rcx
movl (%rax,%rcx,4), %eax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop