// File: titusnicolae[P]imgdiff2/imgdiff.cpp
// Function: main
int main (int argc, char *argv[])
{
    if(argc<3)
    {
        cout<<"missing argument";
        return 0;
    }

    string file1(argv[1]);
    string file2(argv[2]);

    if(file1.size()>4 and file1.substr(file1.size()-4)!=".png" and
       file2.size()>4 and file2.substr(file2.size()-4)!=".png")
    {
        cout<<"File type not png";
        return 0;
    }

    PNG png1 = PNG(argv[1]);
    png1.hash();
    PNG png2 = PNG(argv[2]);
    png2.hash();
    PNG diff = PNG(png1.w, png1.h, png1.data, "diff.png");
    vector<Point> missing;
    for(auto& e: png1.asd)
    {
        if(png2.asd.find(e.first) == png2.asd.end())
        {
            for(auto& f: e.second)
            {
                missing.push_back(f);
            }
        }
    }
    for(auto& e: missing)
    {
        for(int i=0;i<8;i++)
        {
            for(int j=0;j<8;j++)
            {
                diff.red(e.x+i,e.y+j) = 255;
            }
        }
    }
    diff.save();

    return 0;
}

// Assembly:
subq $0x3d8, %rsp            # imm = 0x3D8
movl $0x0, 0x3d4(%rsp)
movl %edi, 0x3d0(%rsp)
movq %rsi, 0x3c8(%rsp)
cmpl $0x3, 0x3d0(%rsp)
jge 0x27ee
movq 0x21806(%rip), %rdi     # 0x23fd8
leaq 0x19850(%rip), %rsi     # 0x1c029
callq 0x2170
movl $0x0, 0x3d4(%rsp)
jmp 0x3118
movq 0x3c8(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x80(%rsp)
leaq 0x3a7(%rsp), %rdi
movq %rdi, 0x88(%rsp)
callq 0x2350
movq 0x80(%rsp), %rsi
movq 0x88(%rsp), %rdx
leaq 0x3a8(%rsp), %rdi
callq 0x2280
jmp 0x2836
leaq 0x3a7(%rsp), %rdi
callq 0x21d0
movq 0x3c8(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x70(%rsp)
leaq 0x36f(%rsp), %rdi
movq %rdi, 0x78(%rsp)
callq 0x2350
movq 0x70(%rsp), %rsi
movq 0x78(%rsp), %rdx
leaq 0x370(%rsp), %rdi
callq 0x2280
jmp 0x287f
leaq 0x36f(%rsp), %rdi
callq 0x21d0
leaq 0x3a8(%rsp), %rdi
callq 0x2130
movq %rax, %rcx
movb $0x0, 0x347(%rsp)
movb $0x0, 0x31f(%rsp)
xorl %eax, %eax
cmpq $0x4, %rcx
movb %al, 0x6f(%rsp)
jbe 0x299f
leaq 0x3a8(%rsp), %rdi
movq %rdi, 0x60(%rsp)
callq 0x2130
movq 0x60(%rsp), %rsi
movq %rax, %rdx
addq $-0x4, %rdx
leaq 0x348(%rsp), %rdi
movq $-0x1, %rcx
callq 0x21b0
jmp 0x28f0
movb $0x1, 0x347(%rsp)
leaq 0x19751(%rip), %rsi     # 0x1c050
leaq 0x348(%rsp), %rdi
callq 0x31b0
movb %al, 0x5f(%rsp)
jmp 0x2912
movb 0x5f(%rsp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, 0x6f(%rsp)
jne 0x2923
jmp 0x299f
leaq 0x370(%rsp), %rdi
callq 0x2130
movq %rax, %rcx
xorl %eax, %eax
cmpq $0x4, %rcx
movb %al, 0x6f(%rsp)
jbe 0x299f
leaq 0x370(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0x2130
movq 0x50(%rsp), %rsi
movq %rax, %rdx
addq $-0x4, %rdx
leaq 0x320(%rsp), %rdi
movq $-0x1, %rcx
callq 0x21b0
jmp 0x2973
movb $0x1, 0x31f(%rsp)
leaq 0x196ce(%rip), %rsi     # 0x1c050
leaq 0x320(%rsp), %rdi
callq 0x31b0
movb %al, 0x4f(%rsp)
jmp 0x2995
movb 0x4f(%rsp), %al
movb %al, 0x6f(%rsp)
jmp 0x299f
movb 0x6f(%rsp), %al
movb %al, 0x4e(%rsp)
testb $0x1, 0x31f(%rsp)
jne 0x29b3
jmp 0x29c0
leaq 0x320(%rsp), %rdi
callq 0x2120
testb $0x1, 0x347(%rsp)
jne 0x29cc
jmp 0x29d9
leaq 0x348(%rsp), %rdi
callq 0x2120
movb 0x4e(%rsp), %al
testb $0x1, %al
jne 0x29e6
jmp 0x2ade
movq 0x215eb(%rip), %rdi     # 0x23fd8
leaq 0x19646(%rip), %rsi     # 0x1c03a
callq 0x2170
jmp 0x29fb
movl $0x0, 0x3d4(%rsp)
movl $0x1, 0x318(%rsp)
jmp 0x30e0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x398(%rsp)
movl %eax, 0x394(%rsp)
leaq 0x3a7(%rsp), %rdi
callq 0x21d0
jmp 0x3127
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x398(%rsp)
movl %eax, 0x394(%rsp)
leaq 0x36f(%rsp), %rdi
callq 0x21d0
jmp 0x3109
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x398(%rsp)
movl %eax, 0x394(%rsp)
jmp 0x30fc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x398(%rsp)
movl %eax, 0x394(%rsp)
jmp 0x2ac0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x398(%rsp)
movl %eax, 0x394(%rsp)
testb $0x1, 0x31f(%rsp)
jne 0x2ab1
jmp 0x2abe
leaq 0x320(%rsp), %rdi
callq 0x2120
jmp 0x2ac0
testb $0x1, 0x347(%rsp)
jne 0x2acc
jmp 0x2ad9
leaq 0x348(%rsp), %rdi
callq 0x2120
jmp 0x30fc
movq 0x3c8(%rsp), %rax
movq 0x8(%rax), %rax
movq %rax, 0x38(%rsp)
leaq 0x27f(%rsp), %rdi
movq %rdi, 0x40(%rsp)
callq 0x2350
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
leaq 0x280(%rsp), %rdi
callq 0x2280
jmp 0x2b1a
leaq 0x2a0(%rsp), %rdi
leaq 0x280(%rsp), %rsi
callq 0x31e0
jmp 0x2b31
leaq 0x280(%rsp), %rdi
callq 0x2120
leaq 0x27f(%rsp), %rdi
callq 0x21d0
leaq 0x2a0(%rsp), %rdi
callq 0x3430
jmp 0x2b5a
movq 0x3c8(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x28(%rsp)
leaq 0x1df(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0x2350
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %rdx
leaq 0x1e0(%rsp), %rdi
callq 0x2280
jmp 0x2b96
leaq 0x200(%rsp), %rdi
leaq 0x1e0(%rsp), %rsi
callq 0x31e0
jmp 0x2bad
leaq 0x1e0(%rsp), %rdi
callq 0x2120
leaq 0x1df(%rsp), %rdi
callq 0x21d0
leaq 0x200(%rsp), %rdi
callq 0x3430
jmp 0x2bd6
movl 0x2c0(%rsp), %eax
movl %eax, 0x20(%rsp)
movl 0x2c4(%rsp), %eax
movl %eax, 0x24(%rsp)
leaq 0x2c8(%rsp), %rsi
leaq 0x148(%rsp), %rdi
callq 0x35e0
jmp 0x2c03
leaq 0x127(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x2350
movq 0x18(%rsp), %rdx
leaq 0x1942b(%rip), %rsi     # 0x1c04c
leaq 0x128(%rsp), %rdi
callq 0x2280
jmp 0x2c30
movl 0x24(%rsp), %edx
movl 0x20(%rsp), %esi
leaq 0x160(%rsp), %rdi
leaq 0x148(%rsp), %rcx
leaq 0x128(%rsp), %r8
callq 0x36e0
jmp 0x2c57
leaq 0x128(%rsp), %rdi
callq 0x2120
leaq 0x127(%rsp), %rdi
callq 0x21d0
leaq 0x148(%rsp), %rdi
callq 0x3150
leaq 0x108(%rsp), %rdi
callq 0x37a0
leaq 0x2a0(%rsp), %rax
addq $0x40, %rax
movq %rax, 0x100(%rsp)
movq 0x100(%rsp), %rdi
callq 0x37b0
movq %rax, 0xf8(%rsp)
movq 0x100(%rsp), %rdi
callq 0x37e0
movq %rax, 0xf0(%rsp)
leaq 0xf8(%rsp), %rdi
leaq 0xf0(%rsp), %rsi
callq 0x3810
testb $0x1, %al
jne 0x2ce7
jmp 0x2f58
leaq 0xf8(%rsp), %rdi
callq 0x3830
movq %rax, 0xe8(%rsp)
leaq 0x240(%rsp), %rdi
movq 0xe8(%rsp), %rsi
callq 0x3870
movq %rax, 0x10(%rsp)
jmp 0x2d18
movq 0x10(%rsp), %rax
movq %rax, 0xe0(%rsp)
leaq 0x200(%rsp), %rdi
addq $0x40, %rdi
callq 0x37e0
movq %rax, 0xd8(%rsp)
leaq 0xe0(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
callq 0x3850
testb $0x1, %al
jne 0x2d5c
jmp 0x2f44
movq 0xe8(%rsp), %rax
addq $0x8, %rax
movq %rax, 0xd0(%rsp)
movq 0xd0(%rsp), %rdi
callq 0x38a0
movq %rax, 0xc8(%rsp)
movq 0xd0(%rsp), %rdi
callq 0x38d0
movq %rax, 0xc0(%rsp)
leaq 0xc8(%rsp), %rdi
leaq 0xc0(%rsp), %rsi
callq 0x3900
testb $0x1, %al
jne 0x2db8
jmp 0x2f42
leaq 0xc8(%rsp), %rdi
callq 0x3940
movq %rax, 0xb8(%rsp)
movq 0xb8(%rsp), %rsi
leaq 0x108(%rsp), %rdi
callq 0x3950
jmp 0x2de4
jmp 0x2de6
leaq 0xc8(%rsp), %rdi
callq 0x39c0
jmp 0x2d9a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x398(%rsp)
movl %eax, 0x394(%rsp)
jmp 0x2e2c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x398(%rsp)
movl %eax, 0x394(%rsp)
leaq 0x280(%rsp), %rdi
callq 0x2120
leaq 0x27f(%rsp), %rdi
callq 0x21d0
jmp 0x30fc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x398(%rsp)
movl %eax, 0x394(%rsp)
jmp 0x30d1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x398(%rsp)
movl %eax, 0x394(%rsp)
jmp 0x2e8e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x398(%rsp)
movl %eax, 0x394(%rsp)
leaq 0x1e0(%rsp), %rdi
callq 0x2120
leaq 0x1df(%rsp), %rdi
callq 0x21d0
jmp 0x30d1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x398(%rsp)
movl %eax, 0x394(%rsp)
jmp 0x30c4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x398(%rsp)
movl %eax, 0x394(%rsp)
jmp 0x2ef0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x398(%rsp)
movl %eax, 0x394(%rsp)
leaq 0x128(%rsp), %rdi
callq 0x2120
leaq 0x127(%rsp), %rdi
callq 0x21d0
leaq 0x148(%rsp), %rdi
callq 0x3150
jmp 0x30c4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x398(%rsp)
movl %eax, 0x394(%rsp)
leaq 0x108(%rsp), %rdi
callq 0x3a90
leaq 0x160(%rsp), %rdi
callq 0x3af0
jmp 0x30c4
jmp 0x2f44
jmp 0x2f46
leaq 0xf8(%rsp), %rdi
callq 0x39e0
jmp 0x2cc9
leaq 0x108(%rsp), %rax
movq %rax, 0xb0(%rsp)
movq 0xb0(%rsp), %rdi
callq 0x38a0
movq %rax, 0xa8(%rsp)
movq 0xb0(%rsp), %rdi
callq 0x38d0
movq %rax, 0xa0(%rsp)
leaq 0xa8(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x3900
testb $0x1, %al
jne 0x2fb0
jmp 0x3069
leaq 0xa8(%rsp), %rdi
callq 0x3940
movq %rax, 0x98(%rsp)
movl $0x0, 0x94(%rsp)
cmpl $0x8, 0x94(%rsp)
jge 0x3055
movl $0x0, 0x90(%rsp)
cmpl $0x8, 0x90(%rsp)
jge 0x303d
movq 0x98(%rsp), %rcx
movl 0x94(%rsp), %eax
movl (%rcx), %esi
movl 0x4(%rcx), %edx
addl %eax, %esi
movl 0x90(%rsp), %eax
addl %eax, %edx
leaq 0x160(%rsp), %rdi
callq 0x3a10
movq %rax, 0x8(%rsp)
jmp 0x3022
movq 0x8(%rsp), %rax
movb $-0x1, (%rax)
movl 0x90(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x90(%rsp)
jmp 0x2fe5
jmp 0x303f
movl 0x94(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x94(%rsp)
jmp 0x2fd0
jmp 0x3057
leaq 0xa8(%rsp), %rdi
callq 0x39c0
jmp 0x2f92
leaq 0x160(%rsp), %rdi
callq 0x3a50
jmp 0x3078
movl $0x0, 0x3d4(%rsp)
movl $0x1, 0x318(%rsp)
leaq 0x108(%rsp), %rdi
callq 0x3a90
leaq 0x160(%rsp), %rdi
callq 0x3af0
leaq 0x200(%rsp), %rdi
callq 0x3af0
leaq 0x2a0(%rsp), %rdi
callq 0x3af0
jmp 0x30e0
leaq 0x200(%rsp), %rdi
callq 0x3af0
leaq 0x2a0(%rsp), %rdi
callq 0x3af0
jmp 0x30fc
leaq 0x370(%rsp), %rdi
callq 0x2120
leaq 0x3a8(%rsp), %rdi
callq 0x2120
jmp 0x3118
leaq 0x370(%rsp), %rdi
callq 0x2120
leaq 0x3a8(%rsp), %rdi
callq 0x2120
jmp 0x3127
movl 0x3d4(%rsp), %eax
addq $0x3d8, %rsp            # imm = 0x3D8
retq
movq 0x398(%rsp), %rdi
callq 0x2340
nopw %cs:(%rax,%rax)
nop