// File: hansfilipelo[P]floodfill/src/main.cpp
// Function: main
int main(int argc, char* argv[])
{
    vector< vector<int> > map;
    srand(0);
    int size = 100;

    cout << "Before: " << endl;
    // Generate random map between 1-10
    for (int i = 0; i < size; i++){
        map.push_back(vector<int>());
        for(int j = 0; j < size; j++){
            int tmp = i/10;
            map.at(i).push_back(tmp);
            cout << tmp << " ";
        }
        cout << endl;
    }
    
    int middle = map.size()/2;
    Utils::flood_fill(&map, map.size()/2, map.at(0).size()/2, map.at(middle).at(middle), -1);

    cout << endl << "After: " << endl;

    for (int i = 0; i < map.size(); i++){
        for (int j = 0; j < map.at(0).size(); j++ ){
            cout << map.at(i).at(j) << " ";
        }
        cout << endl;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x2be0
xorl %edi, %edi
callq 0x1090
movl $0x64, -0x2c(%rbp)
movq 0x5781(%rip), %rdi      # 0x7fd8
leaq 0x280a(%rip), %rsi      # 0x5068
callq 0x10a0
movq %rax, -0x80(%rbp)
jmp 0x2869
movq -0x80(%rbp), %rdi
movq 0x5754(%rip), %rsi      # 0x7fc8
callq 0x10d0
jmp 0x287b
movl $0x0, -0x40(%rbp)
movl -0x40(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x29ab
xorps %xmm0, %xmm0
movaps %xmm0, -0x60(%rbp)
movq $0x0, -0x50(%rbp)
leaq -0x60(%rbp), %rdi
movq %rdi, -0x88(%rbp)
callq 0x2c30
movq -0x88(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x2c00
jmp 0x28bf
leaq -0x60(%rbp), %rdi
callq 0x2c50
movl $0x0, -0x64(%rbp)
movl -0x64(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x2986
movslq -0x40(%rbp), %rax
imulq $0x66666667, %rax, %rax # imm = 0x66666667
movq %rax, %rcx
shrq $0x3f, %rcx
sarq $0x22, %rax
addl %ecx, %eax
movl %eax, -0x68(%rbp)
movslq -0x40(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x16a0
movq %rax, -0x90(%rbp)
jmp 0x290c
movq -0x90(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x2cb0
jmp 0x291e
movl -0x68(%rbp), %esi
movq 0x56b0(%rip), %rdi      # 0x7fd8
callq 0x1110
movq %rax, -0x98(%rbp)
jmp 0x2936
movq -0x98(%rbp), %rdi
leaq 0x272b(%rip), %rsi      # 0x506f
callq 0x10a0
jmp 0x294b
jmp 0x294d
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x28cf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x2bc3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x2c50
jmp 0x2bc3
movq 0x564b(%rip), %rdi      # 0x7fd8
movq 0x5634(%rip), %rsi      # 0x7fc8
callq 0x10d0
jmp 0x299b
jmp 0x299d
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x2882
leaq -0x28(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq 0x1700
movq -0xb0(%rbp), %rdi
shrq %rax
movl %eax, -0x6c(%rbp)
callq 0x1700
movq -0xb0(%rbp), %rdi
shrq %rax
movl %eax, -0xa4(%rbp)
xorl %eax, %eax
movl %eax, %esi
callq 0x16a0
movq %rax, -0xa0(%rbp)
jmp 0x29ef
movq -0xa0(%rbp), %rdi
callq 0x16e0
shrq %rax
movl %eax, -0xbc(%rbp)
movslq -0x6c(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x16a0
movq %rax, -0xb8(%rbp)
jmp 0x2a1a
movq -0xb8(%rbp), %rdi
movslq -0x6c(%rbp), %rsi
callq 0x1870
movq %rax, -0xc8(%rbp)
jmp 0x2a33
movl -0xbc(%rbp), %edx
movl -0xa4(%rbp), %esi
movq -0xc8(%rbp), %rax
movl (%rax), %ecx
leaq -0x28(%rbp), %rdi
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
callq 0x12b0
jmp 0x2a59
movq 0x5578(%rip), %rdi      # 0x7fd8
movq 0x5561(%rip), %rsi      # 0x7fc8
callq 0x10d0
movq %rax, -0xd0(%rbp)
jmp 0x2a75
movq -0xd0(%rbp), %rdi
leaq 0x25ee(%rip), %rsi      # 0x5071
callq 0x10a0
movq %rax, -0xd8(%rbp)
jmp 0x2a91
movq -0xd8(%rbp), %rdi
movq 0x5529(%rip), %rsi      # 0x7fc8
callq 0x10d0
jmp 0x2aa6
movl $0x0, -0x70(%rbp)
movslq -0x70(%rbp), %rax
movq %rax, -0xe0(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x1700
movq %rax, %rcx
movq -0xe0(%rbp), %rax
cmpq %rcx, %rax
jae 0x2bae
movl $0x0, -0x74(%rbp)
movslq -0x74(%rbp), %rax
movq %rax, -0xf0(%rbp)
xorl %eax, %eax
movl %eax, %esi
leaq -0x28(%rbp), %rdi
callq 0x16a0
movq %rax, -0xe8(%rbp)
jmp 0x2afc
movq -0xe8(%rbp), %rdi
callq 0x16e0
movq %rax, %rcx
movq -0xf0(%rbp), %rax
cmpq %rcx, %rax
jae 0x2b89
movslq -0x70(%rbp), %rsi
leaq -0x28(%rbp), %rdi
callq 0x16a0
movq %rax, -0xf8(%rbp)
jmp 0x2b2d
movq -0xf8(%rbp), %rdi
movslq -0x74(%rbp), %rsi
callq 0x1870
movq %rax, -0x100(%rbp)
jmp 0x2b46
movq -0x100(%rbp), %rax
movl (%rax), %esi
movq 0x5482(%rip), %rdi      # 0x7fd8
callq 0x1110
movq %rax, -0x108(%rbp)
jmp 0x2b64
movq -0x108(%rbp), %rdi
leaq 0x24fd(%rip), %rsi      # 0x506f
callq 0x10a0
jmp 0x2b79
jmp 0x2b7b
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0x2adb
movq 0x5448(%rip), %rdi      # 0x7fd8
movq 0x5431(%rip), %rsi      # 0x7fc8
callq 0x10d0
jmp 0x2b9e
jmp 0x2ba0
movl -0x70(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x70(%rbp)
jmp 0x2aad
leaq -0x28(%rbp), %rdi
callq 0x2d20
movl -0x4(%rbp), %eax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
leaq -0x28(%rbp), %rdi
callq 0x2d20
movq -0x38(%rbp), %rdi
callq 0x1120
nopw %cs:(%rax,%rax)
nop