// File: /workspace/github_c_makefile_star2_O0/enzo1982[P]smooth/classes/graphics/backends/xlib/bitmapxlib.cpp
// Function: smooth::GUI::BitmapXLib::CreateBitmap(smooth::GUI::Size const&, int)
S::Bool S::GUI::BitmapXLib::CreateBitmap(const Size &nSize, Int nDepth)
{
	if (display == NIL) return False;

	DeleteBitmap();

	if (nDepth == -1)		  nDepth = XDefaultDepth(display, XDefaultScreen(display));
	if (nDepth != 24 && nDepth != 32) nDepth = 24;

	/* Find best fit for pixel format.
	 */
	int			 count	 = 0;
	int			 index	 = 0;
	XPixmapFormatValues	*formats = XListPixmapFormats(display, &count);

	for (Int i = 0; i < count; i++)
	{
		if (Math::Abs(formats[i].depth - nDepth) < Math::Abs(formats[index].depth - nDepth)) index = i;

		if (formats[i].depth == nDepth) break;
	}

	/* Allocate and create image.
	 */
	bytes	= new UnsignedByte [nSize.cy * nSize.cx * (formats[index].bits_per_pixel / 8) + nSize.cy * (((nSize.cx * formats[index].bits_per_pixel) % formats[index].scanline_pad) / 8)];
	bitmap	= XCreateImage(display, XDefaultVisual(display, XDefaultScreen(display)), formats[index].depth, ZPixmap, 0, (char *) bytes, nSize.cx, nSize.cy, formats[index].scanline_pad, 0);

	if (bitmap == NIL) { delete [] (UnsignedByte *) bytes; XFree(formats); return False; }

	size	= nSize;
	depth	= formats[index].depth;
	bpp	= formats[index].bits_per_pixel;
	align	= formats[index].scanline_pad / 8;

	XFree(formats);

	return True;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpq $0x0, 0x20(%rax)
jne 0x12031e
movb $0x0, -0x1(%rbp)
jmp 0x1205ba
movq -0x40(%rbp), %rdi
movq (%rdi), %rax
callq *0x18(%rax)
cmpl $-0x1, -0x1c(%rbp)
jne 0x120351
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rcx
movq %rcx, -0x48(%rbp)
movq 0x20(%rax), %rdi
callq 0x5c6c0
movq -0x48(%rbp), %rdi
movl %eax, %esi
callq 0x5dca0
movl %eax, -0x1c(%rbp)
cmpl $0x18, -0x1c(%rbp)
je 0x120364
cmpl $0x20, -0x1c(%rbp)
je 0x120364
movl $0x18, -0x1c(%rbp)
movq -0x40(%rbp), %rax
movl $0x0, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movq 0x20(%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x5b990
movq %rax, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x1203ff
movq -0x30(%rbp), %rax
movslq -0x34(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %edi
subl -0x1c(%rbp), %edi
callq 0x5c600
movl %eax, -0x4c(%rbp)
movq -0x30(%rbp), %rax
movslq -0x24(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %edi
subl -0x1c(%rbp), %edi
callq 0x5c600
movl %eax, %ecx
movl -0x4c(%rbp), %eax
cmpl %ecx, %eax
jge 0x1203da
movl -0x34(%rbp), %eax
movl %eax, -0x24(%rbp)
movq -0x30(%rbp), %rax
movslq -0x34(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl (%rax), %eax
cmpl -0x1c(%rbp), %eax
jne 0x1203f2
jmp 0x1203ff
jmp 0x1203f4
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x12038e
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x18(%rbp), %rcx
imull (%rcx), %eax
movl %eax, -0x68(%rbp)
movq -0x30(%rbp), %rax
movslq -0x24(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x68(%rbp), %eax
imull %ecx, %eax
movl %eax, -0x64(%rbp)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x18(%rbp), %rax
movl (%rax), %eax
movq -0x30(%rbp), %rdx
movslq -0x24(%rbp), %rsi
imulq $0xc, %rsi, %rsi
addq %rsi, %rdx
imull 0x4(%rdx), %eax
movq -0x30(%rbp), %rsi
movslq -0x24(%rbp), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rsi
cltd
idivl 0x8(%rsi)
movl %edx, %eax
movl $0x8, %esi
cltd
idivl %esi
movl %eax, %edx
movl -0x64(%rbp), %eax
imull %edx, %ecx
addl %ecx, %eax
movslq %eax, %rdi
callq 0x5ab20
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x18(%rax)
movq 0x20(%rax), %rcx
movq %rcx, -0x58(%rbp)
movq 0x20(%rax), %rcx
movq %rcx, -0x60(%rbp)
movq 0x20(%rax), %rdi
callq 0x5c6c0
movq -0x60(%rbp), %rdi
movl %eax, %esi
callq 0x5b9f0
movq -0x58(%rbp), %rdi
movq %rax, %rsi
movq -0x40(%rbp), %rax
movq -0x30(%rbp), %rcx
movslq -0x24(%rbp), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
movl (%rcx), %edx
movq 0x18(%rax), %r9
movq -0x18(%rbp), %rax
movl (%rax), %r11d
movq -0x18(%rbp), %rax
movl 0x4(%rax), %r10d
movq -0x30(%rbp), %rax
movslq -0x24(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl $0x2, %ecx
xorl %r8d, %r8d
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movl $0x0, 0x18(%rsp)
callq 0x5dde0
movq %rax, %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x28(%rax)
cmpq $0x0, 0x28(%rax)
jne 0x120552
movq -0x40(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x70(%rbp)
cmpq $0x0, %rax
je 0x120543
movq -0x70(%rbp), %rdi
callq 0x5a5e0
movq -0x30(%rbp), %rdi
callq 0x5c780
movb $0x0, -0x1(%rbp)
jmp 0x1205ba
movq -0x40(%rbp), %rax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
movq %rcx, 0x10(%rax)
movq -0x30(%rbp), %rcx
movslq -0x24(%rbp), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
movl (%rcx), %ecx
movb %cl, 0xa(%rax)
movq -0x30(%rbp), %rcx
movslq -0x24(%rbp), %rdx
imulq $0xc, %rdx, %rdx
addq %rdx, %rcx
movl 0x4(%rcx), %ecx
movb %cl, 0xb(%rax)
movq -0x30(%rbp), %rax
movslq -0x24(%rbp), %rcx
imulq $0xc, %rcx, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0x40(%rbp), %rax
movb %cl, 0xc(%rax)
movq -0x30(%rbp), %rdi
callq 0x5c780
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
andb $0x1, %al
addq $0x90, %rsp
popq %rbp
retq
nopl (%rax,%rax)