// File: /workspace/github_cpp_makefile_star2_O1/dgboy2000[P]compress/compress.cpp
// Function: DATCompression::diff_decompress(std::vector<int, std::allocator<int>>)
vector<int> DATCompression::diff_decompress(vector<int> compressed) {
    vector<int> decompressed;
    int x, y, L;
    
    x = compressed[0];
    y = compressed[1];
    L = compressed[2];
    
    decompressed.push_back(x);
    decompressed.push_back(y);
    decompressed.push_back(L);
    
    vector<int>::iterator viter = compressed.begin();
    viter++;
    viter++;
    viter++;
    
    for (int x_ind=0; x_ind < x; ++x_ind) {
        for (int y_ind=0; y_ind < y; ++y_ind) {
            int val = *(viter++);
            val = 256 * val + *(viter++);

            decompressed.push_back(val);
            
            for (int L_ind=1; L_ind < L; ++L_ind) {
                int diff = *(viter++);
                if (diff < 255) {
                    if (diff % 2 == 0) val = val - diff/2;
                    else val = val + (diff+1)/2;
                    decompressed.push_back(val);
                    continue;
                }
                
                val = *(viter++);
                val = 256 * val + *(viter++);
                decompressed.push_back(val);
            }
        }
    }
    
    if (viter != compressed.end()) {
        printf("ERROR: finished decompressing before the end of the compressed string!\n");
        exit(1);
    }
    
    return decompressed;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdx, %r14
movq %rdi, %rbx
xorps %xmm0, %xmm0
movups %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq (%rdx), %rcx
movl (%rcx), %eax
movl %eax, 0xc(%rsp)
movl 0x4(%rcx), %edx
movl %edx, 0x8(%rsp)
movl 0x8(%rcx), %ecx
movl %ecx, 0x4(%rsp)
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x42b1
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x42be
leaq 0xc(%rsp), %rdx
movq %rbx, %rdi
callq 0x62c2
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x42d8
movl 0x8(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x42e5
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
callq 0x62c2
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x42ff
movl 0x4(%rsp), %eax
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x430c
leaq 0x4(%rsp), %rdx
movq %rbx, %rdi
callq 0x62c2
movq %r14, 0x10(%rsp)
movq (%r14), %r12
addq $0xc, %r12
cmpl $0x0, 0xc(%rsp)
jle 0x4418
xorl %ebp, %ebp
movq %rsp, %r15
cmpl $0x0, 0x8(%rsp)
jle 0x440c
xorl %r13d, %r13d
movl (%r12), %eax
movl %eax, (%rsp)
shll $0x8, %eax
addl 0x4(%r12), %eax
movl %eax, (%rsp)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x435e
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x4369
movq %rbx, %rdi
movq %r15, %rdx
callq 0x62c2
addq $0x8, %r12
cmpl $0x2, 0x4(%rsp)
jl 0x43fe
movl $0x1, %r14d
movl (%r12), %ecx
cmpl $0xfe, %ecx
jg 0x4398
movl (%rsp), %eax
testb $0x1, %cl
jne 0x43c6
sarl %ecx
subl %ecx, %eax
jmp 0x43cc
movl 0x4(%r12), %eax
movl %eax, (%rsp)
shll $0x8, %eax
addl 0x8(%r12), %eax
addq $0xc, %r12
movl %eax, (%rsp)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
jne 0x43dd
movq %rbx, %rdi
movq %r15, %rdx
callq 0x62c2
jmp 0x43f4
incl %ecx
sarl %ecx
addl %ecx, %eax
addq $0x4, %r12
movl %eax, (%rsp)
movq 0x8(%rbx), %rsi
cmpq 0x10(%rbx), %rsi
je 0x43e9
movl %eax, (%rsi)
addq $0x4, %rsi
movq %rsi, 0x8(%rbx)
jmp 0x43f4
movq %rbx, %rdi
movq %r15, %rdx
callq 0x62c2
incl %r14d
cmpl 0x4(%rsp), %r14d
jl 0x437e
incl %r13d
cmpl 0x8(%rsp), %r13d
jl 0x4336
incl %ebp
cmpl 0xc(%rsp), %ebp
jl 0x4328
movq 0x10(%rsp), %rax
cmpq 0x8(%rax), %r12
jne 0x4435
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x3dd2(%rip), %rdi      # 0x820e
callq 0x2240
movl $0x1, %edi
callq 0x2200
jmp 0x444f
jmp 0x444f
movq %rax, %r14
movq (%rbx), %rdi
testq %rdi, %rdi
je 0x4466
movq 0x10(%rbx), %rsi
subq %rdi, %rsi
callq 0x21b0
movq %r14, %rdi
callq 0x22c0