// File: kmyk[P]topcoder-marathon-match-100-same-color-pairs/./SameColorPairs.cpp
// Function: update_compression(int, int, std::array<signed char, 10000ul>&)
void update_compression(int H, int W, array<int8_t, MAX_H * MAX_W> & board) {
    vector<int> stk;
    REP (y, H) {
        for (int x = 0; x < W; ) {
            if (board[y * W + x] < 0) {
                int nx = x - board[y * W + x];
                if (nx < W and board[y * W + nx] < 0) {
                    while (x < W and board[y * W + x] < 0) {
                        stk.push_back(x);
                        x -= board[y * W + x];
                    }
                    while (not stk.empty()) {
                        int px = stk.back();
                        stk.pop_back();
                        board[y * W + px] = px - x;
                    }
                } else {
                    x = nx;
                }
            } else {
                ++ x;
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movq %rdx, -0x10(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x6c50
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x4(%rbp), %eax
jge 0x3689
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x3679
movq -0x10(%rbp), %rdi
movl -0x2c(%rbp), %eax
imull -0x8(%rbp), %eax
addl -0x30(%rbp), %eax
movslq %eax, %rsi
callq 0x72a0
movsbl (%rax), %eax
cmpl $0x0, %eax
jge 0x366b
movl -0x30(%rbp), %eax
movl %eax, -0x4c(%rbp)
movq -0x10(%rbp), %rdi
movl -0x2c(%rbp), %eax
imull -0x8(%rbp), %eax
addl -0x30(%rbp), %eax
movslq %eax, %rsi
callq 0x72a0
movq %rax, %rcx
movl -0x4c(%rbp), %eax
movsbl (%rcx), %ecx
subl %ecx, %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x3663
movq -0x10(%rbp), %rdi
movl -0x2c(%rbp), %eax
imull -0x8(%rbp), %eax
addl -0x34(%rbp), %eax
movslq %eax, %rsi
callq 0x72a0
movsbl (%rax), %eax
cmpl $0x0, %eax
jge 0x3663
jmp 0x358d
movl -0x30(%rbp), %ecx
xorl %eax, %eax
cmpl -0x8(%rbp), %ecx
movb %al, -0x4d(%rbp)
jge 0x35bc
movq -0x10(%rbp), %rdi
movl -0x2c(%rbp), %eax
imull -0x8(%rbp), %eax
addl -0x30(%rbp), %eax
movslq %eax, %rsi
callq 0x72a0
movsbl (%rax), %eax
cmpl $0x0, %eax
setl %al
movb %al, -0x4d(%rbp)
movb -0x4d(%rbp), %al
testb $0x1, %al
jne 0x35c5
jmp 0x3611
leaq -0x28(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x6ca0
jmp 0x35d4
movq -0x10(%rbp), %rdi
movl -0x2c(%rbp), %eax
imull -0x8(%rbp), %eax
addl -0x30(%rbp), %eax
movslq %eax, %rsi
callq 0x72a0
movsbl (%rax), %ecx
movl -0x30(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x30(%rbp)
jmp 0x358d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x6e80
jmp 0x3698
jmp 0x3613
leaq -0x28(%rbp), %rdi
callq 0x72d0
xorb $-0x1, %al
testb $0x1, %al
jne 0x3624
jmp 0x3661
leaq -0x28(%rbp), %rdi
callq 0x7310
movl (%rax), %eax
movl %eax, -0x48(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x7350
movl -0x48(%rbp), %eax
subl -0x30(%rbp), %eax
movb %al, -0x4e(%rbp)
movq -0x10(%rbp), %rdi
movl -0x2c(%rbp), %eax
imull -0x8(%rbp), %eax
addl -0x48(%rbp), %eax
movslq %eax, %rsi
callq 0x72a0
movb -0x4e(%rbp), %cl
movb %cl, (%rax)
jmp 0x3613
jmp 0x3669
movl -0x34(%rbp), %eax
movl %eax, -0x30(%rbp)
jmp 0x3674
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x3505
jmp 0x367b
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x34f2
leaq -0x28(%rbp), %rdi
callq 0x6e80
addq $0x50, %rsp
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x2340
nopw %cs:(%rax,%rax)