// File: brianwu02[P]ImageProcessing/sharpen.cpp
// Function: main
int main(int argc, char** argv) {

    int sz, fctr;
    imageP I1, I2, tmp_img, final_img; 
    
    cout << "in   : " << argv[1] << endl;
    cout << "sz   : " << argv[2] << endl;
    cout << "fctr : " << argv[3] << endl;
    cout << "out  : " << argv[4] << endl;


    I1 = IP_readImage(argv[1]);
    sz = atoi(argv[2]);
    fctr = atoi(argv[3]);

    I2 = NEWIMAGE;
    tmp_img = NEWIMAGE;
    final_img = NEWIMAGE;

    if ((sz & 1) == 0) {
        cerr << "sz: " << sz << "is not odd" << endl;
        exit(1);
    }


    blur(I1, tmp_img, sz, sz, I2);

    IP_freeImage(tmp_img);

    sharpen(I1, I2, fctr, final_img);

    IP_freeImage(I1);
    IP_freeImage(I2);

    IP_saveImage(final_img, argv[4]);
    IP_freeImage(final_img);

    cout << "done!" << endl;
    
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq 0x3ca3(%rip), %rdi      # 0x4fd0
leaq 0x1cd0(%rip), %rsi      # 0x3004
callq 0x10a0
movq %rax, %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x10a0
movq %rax, %rdi
movq 0x3c6d(%rip), %rsi      # 0x4fc0
callq 0x10b0
movq 0x3c71(%rip), %rdi      # 0x4fd0
leaq 0x1ca6(%rip), %rsi      # 0x300c
callq 0x10a0
movq %rax, %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rsi
callq 0x10a0
movq %rax, %rdi
movq 0x3c3b(%rip), %rsi      # 0x4fc0
callq 0x10b0
movq 0x3c3f(%rip), %rdi      # 0x4fd0
leaq 0x1c7c(%rip), %rsi      # 0x3014
callq 0x10a0
movq %rax, %rdi
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rsi
callq 0x10a0
movq %rax, %rdi
movq 0x3c09(%rip), %rsi      # 0x4fc0
callq 0x10b0
movq 0x3c0d(%rip), %rdi      # 0x4fd0
leaq 0x1c52(%rip), %rsi      # 0x301c
callq 0x10a0
movq %rax, %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rsi
callq 0x10a0
movq %rax, %rdi
movq 0x3bd7(%rip), %rsi      # 0x4fc0
callq 0x10b0
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x1c40
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x1150
movl %eax, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x1150
movl %eax, -0x18(%rbp)
movl $0x10, %edi
callq 0x1110
movq %rax, -0x28(%rbp)
movl $0x10, %edi
callq 0x1110
movq %rax, -0x30(%rbp)
movl $0x10, %edi
callq 0x1110
movq %rax, -0x38(%rbp)
movl -0x14(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x149a
movq 0x3b95(%rip), %rdi      # 0x4ff0
leaq 0x1bc2(%rip), %rsi      # 0x3024
callq 0x10a0
movq %rax, %rdi
movl -0x14(%rbp), %esi
callq 0x1160
movq %rax, %rdi
leaq 0x1bad(%rip), %rsi      # 0x3029
callq 0x10a0
movq %rax, %rdi
movq 0x3b35(%rip), %rsi      # 0x4fc0
callq 0x10b0
movl $0x1, %edi
callq 0x10e0
movq -0x20(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl -0x14(%rbp), %edx
movl -0x14(%rbp), %ecx
movq -0x28(%rbp), %r8
callq 0x1530
movq -0x30(%rbp), %rdi
callq 0x2160
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
movl -0x18(%rbp), %edx
movq -0x38(%rbp), %rcx
callq 0x1a80
movq -0x20(%rbp), %rdi
callq 0x2160
movq -0x28(%rbp), %rdi
callq 0x2160
movq -0x38(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rsi
callq 0x1f60
movq -0x38(%rbp), %rdi
callq 0x2160
movq 0x3acf(%rip), %rdi      # 0x4fd0
leaq 0x1b2c(%rip), %rsi      # 0x3034
callq 0x10a0
movq %rax, %rdi
movq 0x3aa9(%rip), %rsi      # 0x4fc0
callq 0x10b0
movl $0x1, %eax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)