// File: /workspace/github_c_makefile_star2_O3/veltzer[P]xmeltdown/src/xmeltdown.c
// Function: do_planes
void do_planes() {
	int over=0;
	int finished=0;
	int width, xloc, yloc, dist, size, i;
	short** heights;

	heights=(short **) malloc(DisplayPlanes(dpy, screen));
	for (i=0; i < DisplayPlanes(dpy, screen); i++) {
		heights[i]=(short *) calloc(sizeof(short),
			DisplayWidth(dpy, screen));
	}
	while (!over) {
		depth=rnd(DisplayPlanes(dpy, screen));
		width=rnd(MIN_WIDTH)+WIDTH_ADD;

		xloc=calc_xloc(width);

		yloc=DisplayHeight(dpy, screen);
		for (i=xloc; i < (xloc+width); i++) {
			yloc=min(yloc, heights[depth][i]);
		}
		if (yloc == DisplayHeight(dpy, screen))
			continue;
		dist=rnd(yloc/10+MIN_DIST);
		size=rnd(max(yloc+MIN_SIZE, MAX_SIZE));

		XSetPlaneMask(dpy, copygc, 1<<depth);
		XSetPlaneMask(dpy, fillgc, 1<<depth);
		XCopyArea(dpy, win, win, copygc,
			xloc, yloc,
			width, size,
			xloc, yloc+dist);
		XFillRectangle(dpy, win, fillgc,
			xloc, yloc,
			width, dist);
		yloc+=dist;
		for (i=xloc; i < (xloc+width); i++) {
			if ((heights[depth][i] < (DisplayHeight(dpy, screen)-MIN_SIZE)) && (yloc >= (DisplayHeight(dpy, screen)-MIN_SIZE)))
				finished++;
			heights[depth][i]=max(heights[depth][i], yloc);
		}
		if (finished >= (DisplayWidth(dpy, screen)-FINISHED)) {
			XSync(dpy, 0);
			over=1;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq 0x2bda(%rip), %rax      # 0x40c0
movq 0xe8(%rax), %rbx
movslq 0x2bd4(%rip), %r15      # 0x40c8
shlq $0x7, %r15
movslq 0x38(%rbx,%r15), %r14
movq %r14, %rdi
callq 0x1050
movq %rax, %r12
testq %r14, %r14
jle 0x152d
movslq 0x18(%rbx,%r15), %r15
xorl %ebx, %ebx
movl $0x2, %edi
movq %r15, %rsi
callq 0x1110
movq %rax, (%r12,%rbx,8)
incq %rbx
cmpq %rbx, %r14
jne 0x1514
xorl %ebp, %ebp
movq %r12, %rbx
movq %r12, 0x10(%rsp)
callq 0x1130
movq 0x2b7d(%rip), %rcx      # 0x40c0
movq 0xe8(%rcx), %rcx
movslq 0x2b77(%rip), %rdx      # 0x40c8
shlq $0x7, %rdx
movslq 0x38(%rcx,%rdx), %rcx
cqto
idivq %rcx
movl %edx, 0x2b83(%rip)      # 0x40e8
callq 0x1130
movq %rax, %rcx
movabsq $-0x7777777777777777, %rdx # imm = 0x8888888888888889
imulq %rdx
movq %rdx, %r14
addq %rcx, %r14
movq %r14, %rax
shrq $0x3f, %rax
sarq $0x4, %r14
addq %rax, %r14
movq %r14, %rax
shlq $0x5, %rax
addq %r14, %r14
subq %rax, %r14
addq %rcx, %r14
leal 0x14(%r14), %r12d
callq 0x1130
movq 0x2b12(%rip), %rcx      # 0x40c0
movq 0xe8(%rcx), %rcx
movslq 0x2b0c(%rip), %rsi      # 0x40c8
shlq $0x7, %rsi
movslq 0x18(%rcx,%rsi), %rdi
movq %rdi, %r8
addq $0x1e, %r8
cqto
idivq %r8
movl %edx, %r15d
addl $-0x1e, %r15d
movl %edi, %eax
subl %r12d, %eax
testl %r15d, %r15d
movl $0x0, %r8d
cmovlel %r8d, %r15d
addl %r14d, %edx
addl $-0xa, %edx
cmpl %edi, %edx
cmovgl %eax, %r15d
movl 0x1c(%rcx,%rsi), %eax
leal (%r15,%r14), %r8d
addl $0x14, %r8d
movl %eax, %r13d
cmpq $-0x13, %r14
jl 0x1632
movslq 0x2ad6(%rip), %rcx      # 0x40e8
movq (%rbx,%rcx,8), %rcx
movslq %r15d, %rdx
movslq %r8d, %rsi
movl %eax, %r13d
movswl (%rcx,%rdx,2), %edi
cmpl %edi, %r13d
cmovgel %edi, %r13d
incq %rdx
cmpq %rsi, %rdx
jl 0x161f
cmpl %eax, %r13d
je 0x1537
movl %r8d, 0xc(%rsp)
callq 0x1130
movslq %r13d, %rcx
imulq $0x66666667, %rcx, %rcx # imm = 0x66666667
movq %rcx, %rdx
sarq $0x22, %rdx
shrq $0x3f, %rcx
addl %edx, %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
cqto
idivq %rcx
movq %rdx, 0x18(%rsp)
callq 0x1130
cmpl $0x5b, %r13d
movl $0x5a, %ecx
cmovgel %r13d, %ecx
addl $0xa, %ecx
cqto
idivq %rcx
movq %rdx, 0x20(%rsp)
movb 0x2a57(%rip), %cl       # 0x40e8
movl $0x1, %eax
shll %cl, %eax
movq 0x2a21(%rip), %rdi      # 0x40c0
movq 0x2a32(%rip), %rsi      # 0x40d8
movslq %eax, %rdx
callq 0x1120
movq 0x2a0b(%rip), %rdi      # 0x40c0
movq 0x2a24(%rip), %rsi      # 0x40e0
movb 0x2a26(%rip), %cl       # 0x40e8
movl $0x1, %eax
shll %cl, %eax
movslq %eax, %rdx
callq 0x1120
movq 0x29e8(%rip), %rdi      # 0x40c0
movq 0x29f1(%rip), %rdx      # 0x40d0
movq 0x29f2(%rip), %rcx      # 0x40d8
movq 0x18(%rsp), %rax
leal (%r13,%rax), %ebx
movq %rdx, %rsi
movl %r15d, %r8d
movl %r13d, %r9d
pushq %rbx
pushq %r15
pushq 0x30(%rsp)
pushq %r12
callq 0x10a0
addq $0x20, %rsp
movq 0x29ae(%rip), %rdi      # 0x40c0
movq 0x29b7(%rip), %rsi      # 0x40d0
movq 0x29c0(%rip), %rdx      # 0x40e0
subq $0x8, %rsp
movl %r15d, %ecx
movl %r13d, %r8d
movl %r12d, %r9d
pushq 0x20(%rsp)
callq 0x10b0
addq $0x10, %rsp
movq 0x297f(%rip), %rdi      # 0x40c0
cmpq $-0x14, %r14
jle 0x17ad
movslq 0x299a(%rip), %rax      # 0x40e8
movq 0x10(%rsp), %rcx
movq (%rcx,%rax,8), %rdx
movq 0xe8(%rdi), %rax
movslq 0x2963(%rip), %rcx      # 0x40c8
movq %rcx, %rsi
shlq $0x7, %rsi
movl 0x1c(%rax,%rsi), %esi
addl $-0xa, %esi
movslq %r15d, %r8
movslq 0xc(%rsp), %r9
cmpl %esi, %ebx
setge %r10b
movswl (%rdx,%r8,2), %r11d
cmpl %r11d, %esi
setg %r14b
andb %r10b, %r14b
movzbl %r14b, %r10d
addl %r10d, %ebp
cmpl %r11d, %ebx
cmovgel %ebx, %r11d
movw %r11w, (%rdx,%r8,2)
incq %r8
cmpq %r9, %r8
jl 0x177b
jmp 0x17bb
movq 0xe8(%rdi), %rax
movslq 0x290d(%rip), %rcx      # 0x40c8
shlq $0x7, %rcx
movl 0x18(%rax,%rcx), %eax
addl $-0x32, %eax
cmpl %eax, %ebp
movq 0x10(%rsp), %rbx
jl 0x1537
xorl %esi, %esi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1100