// File: /workspace/github_c_makefile_star2_O0/kyx0r[P]xkeyboard/xkeyboard.c
// Function: scale_pic
Pixmap scale_pic(struct scaledata *p, int kw, int kh, int num)
{
	Pixmap px;
	int x, y, w, h, pel, bpp, sx, sy, o, r, g, b;
	XImage *myimage;

	w = kw * sn / sd;
	h = kh * sn / sd;

	px = XCreatePixmap(dpy, mywindow, w, h,
		DefaultDepth(dpy, myscreen));
	if(!(myimage = XGetImage(dpy, px,
	   0, 0, w, h, AllPlanes, ZPixmap))) {
		fprintf(stderr, "XGetImage failed for num %d {%d, %d}\n", num, kw, kh);
		exit(1);
	}
	/* 
	   to not resize
	   sx = sy = 256;
	 */
	sx = p->pgm->width * 256 / w;
	sy = p->pgm->height * 256 / h; 
	bpp = myimage->bits_per_pixel / 8;

	for (y = 0; y < h; y++)
		for (x = 0; x < w; x++) {
			o = myimage->bytes_per_line * y + x * bpp;
			pel = p->pgm->data[((sy * y)>>8) * p->pgm->width +
				((sx * x)>>8)];
			if (getenv("COLORKEYS") &&
			    (!num || num == 6 || num == 9 || num == 11)) {
				r = pel * 9 / 8;
				g = pel * 9 / 8;
				b = pel * 11 / 8;
				if (b > 255)
					b = 255;
				if (r > 255)
					r = 255;
				if (g > 255)
					g = 255;
			} else {
				r = g = b = pel;
			}
			if (myimage->depth == 16) {
				pel = ((r<<8)&63488)|((g<<3)&2016)|
					((b>>3)&31);
				myimage->data[o] = pel;
				myimage->data[o + 1] = (pel >> 8);
			} else if (myimage->depth == 15) {
				pel = ((r<<7)&31744)|((g<<2)&992)|
					((b>>3)&31);
				myimage->data[o] = pel;
				myimage->data[o + 1] = (pel >> 8);
			} else if (myimage->depth >= 24 ) {	/* 24/32 bpp */
				myimage->data[o] = r;
				myimage->data[o + 1] = g;
				myimage->data[o + 2] = b;
			} else {	/* 8bpp */
				myimage->data[o] = pel;
			}
	}
	XPutImage(dpy, px, mygc, myimage, 0, 0, 0, 0, w, h);
	XDestroyImage(myimage);
	return px;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movl -0xc(%rbp), %eax
imull 0x16ffe(%rip), %eax     # 0x19a30
cltd
idivl 0x16ffb(%rip)           # 0x19a34
movl %eax, -0x2c(%rbp)
movl -0x10(%rbp), %eax
imull 0x16fea(%rip), %eax     # 0x19a30
cltd
idivl 0x16fe7(%rip)           # 0x19a34
movl %eax, -0x30(%rbp)
movq 0x16da1(%rip), %rdi     # 0x197f8
movq 0x16f12(%rip), %rsi     # 0x19970
movl -0x2c(%rbp), %edx
movl -0x30(%rbp), %ecx
movq 0x16d8d(%rip), %rax     # 0x197f8
movq 0xe8(%rax), %rax
movslq 0x16d87(%rip), %r8      # 0x19800
shlq $0x7, %r8
addq %r8, %rax
movl 0x38(%rax), %r8d
callq 0x2390
movq %rax, -0x20(%rbp)
movq 0x16d64(%rip), %rdi     # 0x197f8
movq -0x20(%rbp), %rsi
movl -0x2c(%rbp), %r8d
movl -0x30(%rbp), %r9d
xorl %ecx, %ecx
movl %ecx, %edx
movq $-0x1, (%rsp)
movl $0x2, 0x8(%rsp)
callq 0x23a0
movq %rax, -0x58(%rbp)
cmpq $0x0, %rax
jne 0x2aef
movq 0x652e(%rip), %rax      # 0x8ff8
movq (%rax), %rdi
movl -0x14(%rbp), %edx
movl -0xc(%rbp), %ecx
movl -0x10(%rbp), %r8d
leaq 0x46eb(%rip), %rsi      # 0x71c9
movb $0x0, %al
callq 0x21a0
movl $0x1, %edi
callq 0x2360
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movl (%rax), %eax
shll $0x8, %eax
cltd
idivl -0x2c(%rbp)
movl %eax, -0x3c(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movl 0x4(%rax), %eax
shll $0x8, %eax
cltd
idivl -0x30(%rbp)
movl %eax, -0x40(%rbp)
movq -0x58(%rbp), %rax
movl 0x30(%rax), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, -0x38(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x30(%rbp), %eax
jge 0x2d86
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x2d76
movq -0x58(%rbp), %rax
movl 0x2c(%rax), %eax
imull -0x28(%rbp), %eax
movl -0x24(%rbp), %ecx
imull -0x38(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x44(%rbp)
movq -0x8(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rax
movl -0x40(%rbp), %ecx
imull -0x28(%rbp), %ecx
sarl $0x8, %ecx
movq -0x8(%rbp), %rdx
movq 0x8(%rdx), %rdx
imull (%rdx), %ecx
movl -0x3c(%rbp), %edx
imull -0x24(%rbp), %edx
sarl $0x8, %edx
addl %edx, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movl %eax, -0x34(%rbp)
leaq 0x464a(%rip), %rdi      # 0x71ef
callq 0x2040
cmpq $0x0, %rax
je 0x2c27
cmpl $0x0, -0x14(%rbp)
je 0x2bc8
cmpl $0x6, -0x14(%rbp)
je 0x2bc8
cmpl $0x9, -0x14(%rbp)
je 0x2bc8
cmpl $0xb, -0x14(%rbp)
jne 0x2c27
imull $0x9, -0x34(%rbp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, -0x48(%rbp)
imull $0x9, -0x34(%rbp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, -0x4c(%rbp)
imull $0xb, -0x34(%rbp), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, -0x50(%rbp)
cmpl $0xff, -0x50(%rbp)
jle 0x2c05
movl $0xff, -0x50(%rbp)
cmpl $0xff, -0x48(%rbp)
jle 0x2c15
movl $0xff, -0x48(%rbp)
cmpl $0xff, -0x4c(%rbp)
jle 0x2c25
movl $0xff, -0x4c(%rbp)
jmp 0x2c33
movl -0x34(%rbp), %eax
movl %eax, -0x50(%rbp)
movl %eax, -0x4c(%rbp)
movl %eax, -0x48(%rbp)
movq -0x58(%rbp), %rax
cmpl $0x10, 0x28(%rax)
jne 0x2c99
movl -0x48(%rbp), %eax
shll $0x8, %eax
andl $0xf800, %eax           # imm = 0xF800
movl -0x4c(%rbp), %ecx
shll $0x3, %ecx
andl $0x7e0, %ecx            # imm = 0x7E0
orl %ecx, %eax
movl -0x50(%rbp), %ecx
sarl $0x3, %ecx
andl $0x1f, %ecx
orl %ecx, %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movb %al, %dl
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x44(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x34(%rbp), %eax
sarl $0x8, %eax
movb %al, %dl
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x44(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
jmp 0x2d66
movq -0x58(%rbp), %rax
cmpl $0xf, 0x28(%rax)
jne 0x2cfc
movl -0x48(%rbp), %eax
shll $0x7, %eax
andl $0x7c00, %eax           # imm = 0x7C00
movl -0x4c(%rbp), %ecx
shll $0x2, %ecx
andl $0x3e0, %ecx            # imm = 0x3E0
orl %ecx, %eax
movl -0x50(%rbp), %ecx
sarl $0x3, %ecx
andl $0x1f, %ecx
orl %ecx, %eax
movl %eax, -0x34(%rbp)
movl -0x34(%rbp), %eax
movb %al, %dl
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x44(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x34(%rbp), %eax
sarl $0x8, %eax
movb %al, %dl
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x44(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
jmp 0x2d64
movq -0x58(%rbp), %rax
cmpl $0x18, 0x28(%rax)
jl 0x2d4e
movl -0x48(%rbp), %eax
movb %al, %dl
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x44(%rbp), %rcx
movb %dl, (%rax,%rcx)
movl -0x4c(%rbp), %eax
movb %al, %dl
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x44(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
movl -0x50(%rbp), %eax
movb %al, %dl
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rax
movl -0x44(%rbp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movb %dl, (%rax,%rcx)
jmp 0x2d62
movl -0x34(%rbp), %eax
movb %al, %dl
movq -0x58(%rbp), %rax
movq 0x10(%rax), %rax
movslq -0x44(%rbp), %rcx
movb %dl, (%rax,%rcx)
jmp 0x2d64
jmp 0x2d66
jmp 0x2d68
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x2b44
jmp 0x2d78
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0x2b31
movq 0x16a6b(%rip), %rdi     # 0x197f8
movq -0x20(%rbp), %rsi
movq 0x16c78(%rip), %rdx     # 0x19a10
movq -0x58(%rbp), %rcx
movl -0x2c(%rbp), %r10d
movl -0x30(%rbp), %eax
xorl %r9d, %r9d
movl %r9d, %r8d
movl $0x0, (%rsp)
movl $0x0, 0x8(%rsp)
movl %r10d, 0x10(%rsp)
movl %eax, 0x18(%rsp)
callq 0x2320
movq -0x58(%rbp), %rax
movq 0x60(%rax), %rax
movq -0x58(%rbp), %rdi
callq *%rax
movq -0x20(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)