// File: /workspace/github_cpp_makefile_star2_O1/iibrahimli[P]adsa_project/src/../include/bmp.hpp
// Function: BMP_image::BMP_image(unsigned int, unsigned int, pixel4, bool)
BMP_image(unsigned int width, unsigned int height, pixel fill_color = WHITE, bool has_alpha = true){

        if (width <= 0 || height <= 0) {
            throw std::runtime_error("The image width and height must be positive numbers");
        }

        info_h.width = width;
        info_h.height = height;

        neg_height = true;

        // don't hold padding bytes
        data = new pixel[width * height];

        // fill pixels array
        for(int i=0; i<width*height; ++i) data[i] = fill_color;

        info_h.size = sizeof(BMP_info_header);
        file_h.pxl_offset = sizeof(BMP_file_header) + sizeof(BMP_info_header);

        if (has_alpha) {
            info_h.bit_count = 32;
            file_h.file_size = file_h.pxl_offset + width * height * info_h.bit_count/8;
        }
        else {
            info_h.bit_count = 24;
            padding = 4 - ((info_h.width * info_h.bit_count/8) % 4);
            file_h.file_size = file_h.pxl_offset + (width * info_h.bit_count/8 + padding) * height;
        }

    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r8d, %ebp
movl %ecx, %r13d
movl %edx, %ebx
movl %esi, %r14d
movq %rdi, %r15
movw $0x4d42, (%rdi)         # imm = 0x4D42
xorps %xmm0, %xmm0
movups %xmm0, 0x2(%rdi)
xorl %eax, %eax
movq %rax, 0x12(%rdi)
movw $0x1, 0x1a(%rdi)
movups %xmm0, 0x1c(%rdi)
movups %xmm0, 0x26(%rdi)
movq %rax, 0x38(%rdi)
addq $0x40, %rdi
leaq 0x50(%r15), %rax
movq %rax, 0x8(%rsp)
movq %rax, 0x40(%r15)
leaq 0x1d66(%rip), %rsi      # 0x7538
leaq 0x1d68(%rip), %rdx      # 0x7541
movq %rdi, 0x10(%rsp)
callq 0x5ece
movl $0x0, 0x60(%r15)
movb $0x0, 0x64(%r15)
testl %r14d, %r14d
je 0x58bd
testl %ebx, %ebx
je 0x58bd
movl %r14d, 0x12(%r15)
movl %ebx, 0x16(%r15)
movb $0x1, 0x64(%r15)
movl %ebx, %r12d
imull %r14d, %r12d
leaq (,%r12,4), %rdi
callq 0x2030
movq %rax, 0x38(%r15)
testl %r12d, %r12d
je 0x5840
movl %r12d, %eax
xorl %ecx, %ecx
movq 0x38(%r15), %rdx
movl %r13d, (%rdx,%rcx,4)
incq %rcx
cmpq %rcx, %rax
jne 0x5830
leaq 0x2(%r15), %rax
movabsq $0x2800000036, %rcx     # imm = 0x2800000036
movq %rcx, 0xa(%r15)
testb %bpl, %bpl
je 0x586b
movw $0x20, 0x1c(%r15)
shll $0x2, %r12d
andl $0x1ffffffc, %r12d      # imm = 0x1FFFFFFC
jmp 0x58a7
movw $0x18, 0x1c(%r15)
movl 0x12(%r15), %ecx
leal (%rcx,%rcx,2), %edx
leal (%rcx,%rcx,2), %ecx
addl $0x3, %ecx
testl %edx, %edx
cmovnsl %edx, %ecx
andl $-0x4, %ecx
subl %edx, %ecx
leal 0x4(%rcx), %edx
movl %edx, 0x60(%r15)
shll $0x3, %r14d
leal (%r14,%r14,2), %edx
shrl $0x3, %edx
leal (%rcx,%rdx), %r12d
addl $0x4, %r12d
imull %ebx, %r12d
addl $0x36, %r12d
movl %r12d, (%rax)
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x2110
movq %rax, %r14
leaq 0x1c71(%rip), %rsi      # 0x7542
movq %rax, %rdi
callq 0x20d0
movq 0x4710(%rip), %rsi      # 0x9ff0
movq 0x46d9(%rip), %rdx      # 0x9fc0
movq %r14, %rdi
callq 0x2370
movq %rax, %rbx
movq %r14, %rdi
callq 0x2190
jmp 0x58ff
movq %rax, %rbx
movq 0x10(%rsp), %rax
movq (%rax), %rdi
cmpq 0x8(%rsp), %rdi
je 0x591e
movq 0x8(%rsp), %rax
movq (%rax), %rsi
incq %rsi
callq 0x2220
movq %rbx, %rdi
callq 0x23a0