// File: ksraj123[P]RAW12-to-bitmap-AVI/main.cpp
// Function: main
int main()
{
    std::cout << "//////// !!!! KUMAR SAURABH RAJ !!!! ///////" << std::endl;

    std::cout << "Loading Raw12 Image" << std::endl;
    ImageLoader raw12Img("test_image/test_image.raw12");
    raw12Img.LoadImage();

    ImageProcessor debayer;
    debayer.SeperateChannels(raw12Img.cfa);

    std::cout << "Printing 5 by 5 tiles\n" << std::endl;
    std::cout << "CFA" << std::endl;
    OutputWriter::Print5by5tile(raw12Img.cfa);
    std::cout << "Red Channel before debayering" << std::endl;
    OutputWriter::Print5by5tile(debayer.redChannel);
    std::cout << "Green Channel before debayering" << std::endl;
    OutputWriter::Print5by5tile(debayer.greenChannel);
    std::cout << "Blue Channel before debayering" << std::endl;
    OutputWriter::Print5by5tile(debayer.blueChannel);

    std::cout << "Debayering channels" << std::endl;
    std::cout << "Debayering Red Channel" << std::endl;
    debayer.Red();
    std::cout << "Debayering Green Channel" << std::endl;
    debayer.Green();
    std::cout << "Debayering Blue Channel" << std::endl;
    debayer.Blue();

    std::cout << "Writing output" << std::endl;
    OutputWriter debayeredImage;

    std::cout << "Writing 8 bit PPM channels" << std::endl;
    std::cout << "Writing Red channel" << std::endl;

    debayeredImage.WritePpm("red", &debayer);
    std::cout << "Writing Green channel" << std::endl;
    debayeredImage.WritePpm("blue", &debayer);
    std::cout << "Writing Blue Channel" << std::endl;
    debayeredImage.WritePpm("green", &debayer); 

    std::cout << "Writing Debayered BMP image" << std::endl;
    debayeredImage.WriteBmp(&debayer);
    std::cout << "Writing Debayered Image into AVI" << std::endl;
    debayeredImage.WriteAvi();


    std::cout << "Please check ./results folder after sometime for output images" << std::endl;
    std::cout << "!!!!Thank you for using my program!!!!" << std::endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x3d0, %rsp            # imm = 0x3D0
movq 0x6a1e(%rip), %rdi      # 0x8fd0
movq %rdi, -0x320(%rbp)
leaq 0x3a44(%rip), %rsi      # 0x6004
callq 0x21e0
movq %rax, %rdi
movq 0x69f1(%rip), %rsi      # 0x8fc0
movq %rsi, -0x318(%rbp)
callq 0x2200
movq -0x320(%rbp), %rdi
leaq 0x3a48(%rip), %rsi      # 0x6031
callq 0x21e0
movq -0x318(%rbp), %rsi
movq %rax, %rdi
callq 0x2200
leaq -0x259(%rbp), %rdi
movq %rdi, -0x310(%rbp)
callq 0x2340
movq -0x310(%rbp), %rdx
leaq 0x3a27(%rip), %rsi      # 0x6045
leaq -0x258(%rbp), %rdi
callq 0x2d20
jmp 0x262c
leaq -0x238(%rbp), %rdi
leaq -0x258(%rbp), %rsi
callq 0x3070
jmp 0x2641
leaq -0x258(%rbp), %rdi
callq 0x2150
leaq -0x259(%rbp), %rdi
callq 0x2220
leaq -0x238(%rbp), %rdi
callq 0x31e0
jmp 0x2667
leaq -0x288(%rbp), %rdi
callq 0x4b90
jmp 0x2675
movq -0x8(%rbp), %rsi
leaq -0x288(%rbp), %rdi
callq 0x4cc0
jmp 0x2687
movq 0x6942(%rip), %rdi      # 0x8fd0
leaq 0x39cc(%rip), %rsi      # 0x6061
callq 0x21e0
movq %rax, -0x328(%rbp)
jmp 0x26a3
movq -0x328(%rbp), %rdi
movq 0x690f(%rip), %rsi      # 0x8fc0
callq 0x2200
jmp 0x26b8
movq 0x6911(%rip), %rdi      # 0x8fd0
leaq 0x39b2(%rip), %rsi      # 0x6078
callq 0x21e0
movq %rax, -0x330(%rbp)
jmp 0x26d4
movq -0x330(%rbp), %rdi
movq 0x68de(%rip), %rsi      # 0x8fc0
callq 0x2200
jmp 0x26e9
movq -0x8(%rbp), %rdi
callq 0x3310
jmp 0x26f4
movq 0x68d5(%rip), %rdi      # 0x8fd0
leaq 0x397a(%rip), %rsi      # 0x607c
callq 0x21e0
movq %rax, -0x338(%rbp)
jmp 0x2710
movq -0x338(%rbp), %rdi
movq 0x68a2(%rip), %rsi      # 0x8fc0
callq 0x2200
jmp 0x2725
movq -0x288(%rbp), %rdi
callq 0x3310
jmp 0x2733
movq 0x6896(%rip), %rdi      # 0x8fd0
leaq 0x3959(%rip), %rsi      # 0x609a
callq 0x21e0
movq %rax, -0x340(%rbp)
jmp 0x274f
movq -0x340(%rbp), %rdi
movq 0x6863(%rip), %rsi      # 0x8fc0
callq 0x2200
jmp 0x2764
movq -0x278(%rbp), %rdi
callq 0x3310
jmp 0x2772
movq 0x6857(%rip), %rdi      # 0x8fd0
leaq 0x393a(%rip), %rsi      # 0x60ba
callq 0x21e0
movq %rax, -0x348(%rbp)
jmp 0x278e
movq -0x348(%rbp), %rdi
movq 0x6824(%rip), %rsi      # 0x8fc0
callq 0x2200
jmp 0x27a3
movq -0x280(%rbp), %rdi
callq 0x3310
jmp 0x27b1
movq 0x6818(%rip), %rdi      # 0x8fd0
leaq 0x391a(%rip), %rsi      # 0x60d9
callq 0x21e0
movq %rax, -0x350(%rbp)
jmp 0x27cd
movq -0x350(%rbp), %rdi
movq 0x67e5(%rip), %rsi      # 0x8fc0
callq 0x2200
jmp 0x27e2
movq 0x67e7(%rip), %rdi      # 0x8fd0
leaq 0x38fd(%rip), %rsi      # 0x60ed
callq 0x21e0
movq %rax, -0x358(%rbp)
jmp 0x27fe
movq -0x358(%rbp), %rdi
movq 0x67b4(%rip), %rsi      # 0x8fc0
callq 0x2200
jmp 0x2813
leaq -0x288(%rbp), %rdi
callq 0x4eb0
jmp 0x2821
movq 0x67a8(%rip), %rdi      # 0x8fd0
leaq 0x38d5(%rip), %rsi      # 0x6104
callq 0x21e0
movq %rax, -0x360(%rbp)
jmp 0x283d
movq -0x360(%rbp), %rdi
movq 0x6775(%rip), %rsi      # 0x8fc0
callq 0x2200
jmp 0x2852
leaq -0x288(%rbp), %rdi
callq 0x51e0
jmp 0x2860
movq 0x6769(%rip), %rdi      # 0x8fd0
leaq 0x38af(%rip), %rsi      # 0x611d
callq 0x21e0
movq %rax, -0x368(%rbp)
jmp 0x287c
movq -0x368(%rbp), %rdi
movq 0x6736(%rip), %rsi      # 0x8fc0
callq 0x2200
jmp 0x2891
leaq -0x288(%rbp), %rdi
callq 0x5040
jmp 0x289f
movq 0x672a(%rip), %rdi      # 0x8fd0
leaq 0x3888(%rip), %rsi      # 0x6135
callq 0x21e0
movq %rax, -0x370(%rbp)
jmp 0x28bb
movq -0x370(%rbp), %rdi
movq 0x66f7(%rip), %rsi      # 0x8fc0
callq 0x2200
jmp 0x28d0
movq 0x66f9(%rip), %rdi      # 0x8fd0
leaq 0x3866(%rip), %rsi      # 0x6144
callq 0x21e0
movq %rax, -0x378(%rbp)
jmp 0x28ec
movq -0x378(%rbp), %rdi
movq 0x66c6(%rip), %rsi      # 0x8fc0
callq 0x2200
jmp 0x2901
movq 0x66c8(%rip), %rdi      # 0x8fd0
leaq 0x3850(%rip), %rsi      # 0x615f
callq 0x21e0
movq %rax, -0x380(%rbp)
jmp 0x291d
movq -0x380(%rbp), %rdi
movq 0x6695(%rip), %rsi      # 0x8fc0
callq 0x2200
jmp 0x2932
leaq -0x2b1(%rbp), %rdi
movq %rdi, -0x388(%rbp)
callq 0x2340
movq -0x388(%rbp), %rdx
leaq 0x3820(%rip), %rsi      # 0x6173
leaq -0x2b0(%rbp), %rdi
callq 0x2d20
jmp 0x2961
leaq -0x290(%rbp), %rdi
leaq -0x2b0(%rbp), %rsi
leaq -0x288(%rbp), %rdx
callq 0x33a0
jmp 0x297d
leaq -0x2b0(%rbp), %rdi
callq 0x2150
leaq -0x2b1(%rbp), %rdi
callq 0x2220
movq 0x6634(%rip), %rdi      # 0x8fd0
leaq 0x37d4(%rip), %rsi      # 0x6177
callq 0x21e0
movq %rax, -0x390(%rbp)
jmp 0x29b1
movq -0x390(%rbp), %rdi
movq 0x6601(%rip), %rsi      # 0x8fc0
callq 0x2200
jmp 0x29c6
leaq -0x2d9(%rbp), %rdi
movq %rdi, -0x398(%rbp)
callq 0x2340
movq -0x398(%rbp), %rdx
leaq 0x37a6(%rip), %rsi      # 0x618d
leaq -0x2d8(%rbp), %rdi
callq 0x2d20
jmp 0x29f5
leaq -0x290(%rbp), %rdi
leaq -0x2d8(%rbp), %rsi
leaq -0x288(%rbp), %rdx
callq 0x33a0
jmp 0x2a11
leaq -0x2d8(%rbp), %rdi
callq 0x2150
leaq -0x2d9(%rbp), %rdi
callq 0x2220
movq 0x65a0(%rip), %rdi      # 0x8fd0
leaq 0x375b(%rip), %rsi      # 0x6192
callq 0x21e0
movq %rax, -0x3a0(%rbp)
jmp 0x2a45
movq -0x3a0(%rbp), %rdi
movq 0x656d(%rip), %rsi      # 0x8fc0
callq 0x2200
jmp 0x2a5a
leaq -0x301(%rbp), %rdi
movq %rdi, -0x3a8(%rbp)
callq 0x2340
movq -0x3a8(%rbp), %rdx
leaq 0x372c(%rip), %rsi      # 0x61a7
leaq -0x300(%rbp), %rdi
callq 0x2d20
jmp 0x2a89
leaq -0x290(%rbp), %rdi
leaq -0x300(%rbp), %rsi
leaq -0x288(%rbp), %rdx
callq 0x33a0
jmp 0x2aa5
leaq -0x300(%rbp), %rdi
callq 0x2150
leaq -0x301(%rbp), %rdi
callq 0x2220
movq 0x650c(%rip), %rdi      # 0x8fd0
leaq 0x36e2(%rip), %rsi      # 0x61ad
callq 0x21e0
movq %rax, -0x3b0(%rbp)
jmp 0x2ad9
movq -0x3b0(%rbp), %rdi
movq 0x64d9(%rip), %rsi      # 0x8fc0
callq 0x2200
jmp 0x2aee
leaq -0x290(%rbp), %rdi
leaq -0x288(%rbp), %rsi
callq 0x3a70
jmp 0x2b03
movq 0x64c6(%rip), %rdi      # 0x8fd0
leaq 0x36b8(%rip), %rsi      # 0x61c9
callq 0x21e0
movq %rax, -0x3b8(%rbp)
jmp 0x2b1f
movq -0x3b8(%rbp), %rdi
movq 0x6493(%rip), %rsi      # 0x8fc0
callq 0x2200
jmp 0x2b34
leaq -0x290(%rbp), %rdi
callq 0x3e30
jmp 0x2b42
movq 0x6487(%rip), %rdi      # 0x8fd0
leaq 0x369a(%rip), %rsi      # 0x61ea
callq 0x21e0
movq %rax, -0x3c0(%rbp)
jmp 0x2b5e
movq -0x3c0(%rbp), %rdi
movq 0x6454(%rip), %rsi      # 0x8fc0
callq 0x2200
jmp 0x2b73
movq 0x6456(%rip), %rdi      # 0x8fd0
leaq 0x36a8(%rip), %rsi      # 0x6229
callq 0x21e0
movq %rax, -0x3c8(%rbp)
jmp 0x2b8f
movq -0x3c8(%rbp), %rdi
movq 0x6423(%rip), %rsi      # 0x8fc0
callq 0x2200
jmp 0x2ba4
leaq -0x288(%rbp), %rdi
callq 0x4c40
leaq -0x238(%rbp), %rdi
callq 0x3160
xorl %eax, %eax
addq $0x3d0, %rsp            # imm = 0x3D0
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
jmp 0x2bf9
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
leaq -0x258(%rbp), %rdi
callq 0x2150
leaq -0x259(%rbp), %rdi
callq 0x2220
jmp 0x2d0e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
jmp 0x2d02
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
jmp 0x2cf6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
jmp 0x2c6a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
leaq -0x2b0(%rbp), %rdi
callq 0x2150
leaq -0x2b1(%rbp), %rdi
callq 0x2220
jmp 0x2cf6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
jmp 0x2caa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
leaq -0x2d8(%rbp), %rdi
callq 0x2150
leaq -0x2d9(%rbp), %rdi
callq 0x2220
jmp 0x2cf6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
jmp 0x2cea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x268(%rbp)
movl %eax, -0x26c(%rbp)
leaq -0x300(%rbp), %rdi
callq 0x2150
leaq -0x301(%rbp), %rdi
callq 0x2220
leaq -0x288(%rbp), %rdi
callq 0x4c40
leaq -0x238(%rbp), %rdi
callq 0x3160
movq -0x268(%rbp), %rdi
callq 0x2330
nopw (%rax,%rax)