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

	heights=(short *) calloc(sizeof(short), DisplayWidth(dpy, screen));
	over=0;
	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[i]);
		}
		if (yloc == DisplayHeight(dpy, screen))
			continue;
		dist=rnd(yloc/10+MIN_DIST);
		size=rnd(max(yloc+MIN_SIZE, MAX_SIZE));

		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[i] < (DisplayHeight(dpy, screen)-MIN_SIZE)) && (yloc >= (DisplayHeight(dpy, screen)-MIN_SIZE)))
				finished++;
			heights[i]=max(heights[i], yloc);
		}
		if (finished >= (DisplayWidth(dpy, screen)-FINISHED)) {
			XSync(dpy, 0);
			over=1;
		}
		usleep(USLEEP);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq 0x2934(%rip), %rax      # 0x40c0
movq 0xe8(%rax), %rax
movslq 0x292e(%rip), %rcx      # 0x40c8
shlq $0x7, %rcx
movslq 0x18(%rax,%rcx), %rsi
pushq $0x2
popq %rdi
callq 0x1110
movq %rax, %rbx
xorl %r15d, %r15d
pushq $0x1e
popq %r14
xorl %ebp, %ebp
testl %ebp, %ebp
jne 0x198d
movl %r15d, 0x4(%rsp)
callq 0x1130
movq 0x28f0(%rip), %rcx      # 0x40c0
movq 0xe8(%rcx), %rcx
movslq 0x28ea(%rip), %rdx      # 0x40c8
shlq $0x7, %rdx
movslq 0x38(%rcx,%rdx), %rcx
cqto
idivq %rcx
movl %edx, 0x28f6(%rip)      # 0x40e8
callq 0x1130
cqto
idivq %r14
movq %rdx, %r12
leal 0x14(%rdx), %edi
movq %rdi, 0x10(%rsp)
callq 0x172b
movl %eax, %r15d
movq 0x28aa(%rip), %rax      # 0x40c0
movq 0xe8(%rax), %rax
movslq 0x28a4(%rip), %rcx      # 0x40c8
shlq $0x7, %rcx
movl 0x1c(%rax,%rcx), %eax
leal (%r12,%r15), %ecx
addl $0x14, %ecx
movslq %r15d, %r13
movslq %ecx, %rbp
movq %r13, %rcx
movl %eax, %r12d
cmpq %rbp, %rcx
jge 0x1854
movswl (%rbx,%rcx,2), %edx
cmpl %edx, %r12d
cmovgel %edx, %r12d
incq %rcx
jmp 0x183f
cmpl %eax, %r12d
je 0x17c4
callq 0x1130
movq %rax, %rcx
movl %r12d, %eax
cltd
pushq $0xa
popq %rsi
idivl %esi
addl $0x2, %eax
movslq %eax, %rsi
movq %rcx, %rax
cqto
idivq %rsi
movq %rdx, 0x8(%rsp)
callq 0x1130
cmpl $0x5b, %r12d
pushq $0x5a
popq %rcx
cmovgel %r12d, %ecx
addl $0xa, %ecx
cqto
idivq %rcx
movq %rdx, %rax
movq 0x281d(%rip), %rdi      # 0x40c0
movq 0x2826(%rip), %rdx      # 0x40d0
movq 0x2827(%rip), %rcx      # 0x40d8
movq 0x8(%rsp), %rsi
leal (%r12,%rsi), %r14d
movq %rdx, %rsi
movl %r15d, %r8d
movl %r12d, %r9d
pushq %r14
pushq %r15
pushq %rax
pushq 0x28(%rsp)
callq 0x10a0
addq $0x20, %rsp
movq 0x27e4(%rip), %rdi      # 0x40c0
movq 0x27ed(%rip), %rsi      # 0x40d0
movq 0x27f6(%rip), %rdx      # 0x40e0
subq $0x8, %rsp
movl %r15d, %ecx
movl %r12d, %r8d
movq 0x18(%rsp), %r9
pushq 0x10(%rsp)
callq 0x10b0
addq $0x10, %rsp
movq 0x27b3(%rip), %rdi      # 0x40c0
movslq 0x27b4(%rip), %rax      # 0x40c8
shlq $0x7, %rax
movl 0x4(%rsp), %r15d
cmpq %rbp, %r13
jge 0x195b
movswl (%rbx,%r13,2), %ecx
movq 0xe8(%rdi), %rdx
movl 0x1c(%rdx,%rax), %edx
addl $-0xa, %edx
cmpl %ecx, %edx
setg %sil
cmpl %edx, %r14d
setge %dl
andb %sil, %dl
movzbl %dl, %edx
addl %edx, %r15d
cmpl %ecx, %r14d
cmovgel %r14d, %ecx
movw %cx, (%rbx,%r13,2)
incq %r13
jmp 0x191d
movq 0xe8(%rdi), %rcx
movl 0x18(%rcx,%rax), %eax
addl $-0x32, %eax
xorl %ebp, %ebp
cmpl %eax, %r15d
jl 0x197a
xorl %esi, %esi
callq 0x1100
pushq $0x1
popq %rbp
movl $0x3e8, %edi            # imm = 0x3E8
callq 0x10d0
pushq $0x1e
popq %r14
jmp 0x17b7
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq