// File: CMU-SAFARI[P]ramulator/src/StatType.cpp
// Function: Stats::Histogram::grow_out()
void
Histogram::grow_out()
{
    int size = cvec.size();
    int zero = size / 2; // round down!
    int top_half = zero + (size - zero + 1) / 2; // round up!
    int bottom_half = (size - zero) / 2; // round down!

    // grow down
    int low_pair = zero - 1;
    for (int i = zero - 1; i >= bottom_half; i--) {
        cvec[i] = cvec[low_pair];
        if (low_pair - 1 >= 0)
            cvec[i] += cvec[low_pair - 1];
        low_pair -= 2;
    }
    assert(low_pair == 0 || low_pair == -1 || low_pair == -2);

    for (int i = bottom_half - 1; i >= 0; i--)
        cvec[i] = Counter();

    // grow up
    int high_pair = zero;
    for (int i = zero; i < top_half; i++) {
        cvec[i] = cvec[high_pair];
        if (high_pair + 1 < size)
            cvec[i] += cvec[high_pair + 1];
        high_pair += 2;
    }
    assert(high_pair == size || high_pair == size + 1);

    for (int i = top_half; i < size; i++)
        cvec[i] = Counter();

    max_bucket *= 2;
    min_bucket *= 2;
    bucket_size *= 2;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x40(%rbp)
addq $0xb0, %rdi
callq 0x1fabe0
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0xc(%rbp), %eax
subl -0x10(%rbp), %eax
addl $0x1, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x34(%rbp), %eax
addl %ecx, %eax
movl %eax, -0x14(%rbp)
movl -0xc(%rbp), %eax
subl -0x10(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, -0x18(%rbp)
movl -0x10(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x10(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x20(%rbp)
movl -0x20(%rbp), %eax
cmpl -0x18(%rbp), %eax
jl 0x225100
movq -0x40(%rbp), %rdi
addq $0xb0, %rdi
movslq -0x1c(%rbp), %rsi
callq 0x2e5e0
movq -0x40(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x48(%rbp)
addq $0xb0, %rdi
movslq -0x20(%rbp), %rsi
callq 0x2e5e0
movsd -0x48(%rbp), %xmm0
movsd %xmm0, (%rax)
movl -0x1c(%rbp), %eax
subl $0x1, %eax
cmpl $0x0, %eax
jl 0x2250e9
movq -0x40(%rbp), %rdi
addq $0xb0, %rdi
movl -0x1c(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0x2e5e0
movq -0x40(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x50(%rbp)
addq $0xb0, %rdi
movslq -0x20(%rbp), %rsi
callq 0x2e5e0
movsd -0x50(%rbp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movl -0x1c(%rbp), %eax
subl $0x2, %eax
movl %eax, -0x1c(%rbp)
movl -0x20(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x225055
movb $0x1, %al
cmpl $0x0, -0x1c(%rbp)
movb %al, -0x51(%rbp)
je 0x225120
movb $0x1, %al
cmpl $-0x1, -0x1c(%rbp)
movb %al, -0x51(%rbp)
je 0x225120
cmpl $-0x2, -0x1c(%rbp)
sete %al
movb %al, -0x51(%rbp)
movb -0x51(%rbp), %al
testb $0x1, %al
jne 0x225129
jmp 0x22512b
jmp 0x22514a
leaq 0x3e746(%rip), %rdi     # 0x263878
leaq 0x3e771(%rip), %rsi     # 0x2638aa
movl $0x21, %edx
leaq 0x3e776(%rip), %rcx     # 0x2638bb
callq 0xc280
movl -0x18(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jl 0x22517f
movq -0x40(%rbp), %rdi
addq $0xb0, %rdi
movslq -0x24(%rbp), %rsi
callq 0x2e5e0
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movl -0x24(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x225153
movl -0x10(%rbp), %eax
movl %eax, -0x28(%rbp)
movl -0x10(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x14(%rbp), %eax
jge 0x225236
movq -0x40(%rbp), %rdi
addq $0xb0, %rdi
movslq -0x28(%rbp), %rsi
callq 0x2e5e0
movq -0x40(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x60(%rbp)
addq $0xb0, %rdi
movslq -0x2c(%rbp), %rsi
callq 0x2e5e0
movsd -0x60(%rbp), %xmm0
movsd %xmm0, (%rax)
movl -0x28(%rbp), %eax
addl $0x1, %eax
cmpl -0xc(%rbp), %eax
jge 0x22521f
movq -0x40(%rbp), %rdi
addq $0xb0, %rdi
movl -0x28(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rsi
callq 0x2e5e0
movq -0x40(%rbp), %rdi
movsd (%rax), %xmm0
movsd %xmm0, -0x68(%rbp)
addq $0xb0, %rdi
movslq -0x2c(%rbp), %rsi
callq 0x2e5e0
movsd -0x68(%rbp), %xmm0
addsd (%rax), %xmm0
movsd %xmm0, (%rax)
movl -0x28(%rbp), %eax
addl $0x2, %eax
movl %eax, -0x28(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x22518b
movl -0x28(%rbp), %ecx
movb $0x1, %al
cmpl -0xc(%rbp), %ecx
movb %al, -0x69(%rbp)
je 0x225254
movl -0x28(%rbp), %eax
movl -0xc(%rbp), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
sete %al
movb %al, -0x69(%rbp)
movb -0x69(%rbp), %al
testb $0x1, %al
jne 0x22525d
jmp 0x22525f
jmp 0x22527e
leaq 0x3e677(%rip), %rdi     # 0x2638dd
leaq 0x3e63d(%rip), %rsi     # 0x2638aa
movl $0x2e, %edx
leaq 0x3e642(%rip), %rcx     # 0x2638bb
callq 0xc280
movl -0x14(%rbp), %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x2252b2
movq -0x40(%rbp), %rdi
addq $0xb0, %rdi
movslq -0x30(%rbp), %rsi
callq 0x2e5e0
xorps %xmm0, %xmm0
movsd %xmm0, (%rax)
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x225284
movq -0x40(%rbp), %rax
movsd 0x3e5b2(%rip), %xmm0    # 0x263870
mulsd 0x80(%rax), %xmm0
movsd %xmm0, 0x80(%rax)
movsd 0x3e59a(%rip), %xmm0    # 0x263870
mulsd 0x78(%rax), %xmm0
movsd %xmm0, 0x78(%rax)
movsd 0x3e588(%rip), %xmm0    # 0x263870
mulsd 0x88(%rax), %xmm0
movsd %xmm0, 0x88(%rax)
addq $0x70, %rsp
popq %rbp
retq
nop