// File: /workspace/github_cpp_makefile_star2_O3/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 0x1d4e(%rip), %rsi      # 0x7538
leaq 0x1d50(%rip), %rdx      # 0x7541
movq %rdi, 0x10(%rsp)
callq 0x5ee4
movl $0x0, 0x60(%r15)
movb $0x0, 0x64(%r15)
testl %r14d, %r14d
je 0x58d3
testl %ebx, %ebx
je 0x58d3
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)
testq %r12, %r12
je 0x5855
xorl %eax, %eax
movq 0x38(%r15), %rcx
movl %r13d, (%rcx,%rax,4)
incq %rax
cmpq %rax, %r12
jne 0x5845
leaq 0x2(%r15), %rax
leaq 0x1c(%r15), %rcx
movabsq $0x2800000036, %rdx     # imm = 0x2800000036
movq %rdx, 0xa(%r15)
testb %bpl, %bpl
je 0x5881
shll $0x2, %r12d
andl $0x1ffffffc, %r12d      # imm = 0x1FFFFFFC
movw $0x20, %dx
jmp 0x58ba
movl 0x12(%r15), %edx
leal (%rdx,%rdx,2), %esi
leal (%rdx,%rdx,2), %edx
addl $0x3, %edx
testl %esi, %esi
cmovnsl %esi, %edx
andl $-0x4, %edx
subl %esi, %edx
leal 0x4(%rdx), %esi
movl %esi, 0x60(%r15)
shll $0x3, %r14d
leal (%r14,%r14,2), %esi
shrl $0x3, %esi
leal (%rdx,%rsi), %r12d
addl $0x4, %r12d
imull %ebx, %r12d
movw $0x18, %dx
movw %dx, (%rcx)
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 0x1c5b(%rip), %rsi      # 0x7542
movq %rax, %rdi
callq 0x20d0
movq 0x46fa(%rip), %rsi      # 0x9ff0
movq 0x46c3(%rip), %rdx      # 0x9fc0
movq %r14, %rdi
callq 0x2370
movq %rax, %rbx
movq %r14, %rdi
callq 0x2190
jmp 0x5915
movq %rax, %rbx
movq 0x10(%rsp), %rax
movq (%rax), %rdi
cmpq 0x8(%rsp), %rdi
je 0x5934
movq 0x8(%rsp), %rax
movq (%rax), %rsi
incq %rsi
callq 0x2220
movq %rbx, %rdi
callq 0x23a0