// File: /workspace/github_c_makefile_star2_O1/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 0x2854(%rip), %rax      # 0x40c0
movq 0xe8(%rax), %rax
movslq 0x284e(%rip), %rcx      # 0x40c8
shlq $0x7, %rcx
movslq 0x18(%rax,%rcx), %rsi
movl $0x2, %edi
callq 0x1110
movq %rax, %rbx
xorl %ebp, %ebp
movl $0x0, 0x4(%rsp)
xorl %r14d, %r14d
movl %r14d, 0x8(%rsp)
callq 0x1130
movq 0x2812(%rip), %rcx      # 0x40c0
movq 0xe8(%rcx), %rcx
movslq 0x280c(%rip), %rdx      # 0x40c8
shlq $0x7, %rdx
movslq 0x38(%rcx,%rdx), %rcx
cqto
idivq %rcx
movl %edx, 0x2818(%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), %r15d
callq 0x1130
movq 0x27a7(%rip), %rcx      # 0x40c0
movq 0xe8(%rcx), %rcx
movslq 0x27a1(%rip), %rsi      # 0x40c8
shlq $0x7, %rsi
movslq 0x18(%rcx,%rsi), %rdi
movq %rdi, %r8
addq $0x1e, %r8
cqto
idivq %r8
movl %edx, %r12d
addl $-0x1e, %r12d
movl %edi, %eax
subl %r15d, %eax
testl %r12d, %r12d
cmovlel %ebp, %r12d
addl %r14d, %edx
addl $-0xa, %edx
cmpl %edi, %edx
cmovgl %eax, %r12d
movl 0x1c(%rcx,%rsi), %eax
leal (%r12,%r14), %edi
addl $0x14, %edi
movl %eax, %r13d
cmpq $-0x13, %r14
jl 0x198b
movslq %r12d, %rcx
movslq %edi, %rdx
movl %eax, %r13d
movswl (%rbx,%rcx,2), %esi
cmpl %esi, %r13d
cmovgel %esi, %r13d
incq %rcx
cmpq %rdx, %rcx
jl 0x1978
cmpl %eax, %r13d
je 0x18a2
movl %edi, 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, 0x10(%rsp)
callq 0x1130
cmpl $0x5b, %r13d
movl $0x5a, %ecx
cmovgel %r13d, %ecx
addl $0xa, %ecx
cqto
idivq %rcx
movq %rdx, %rax
movq 0x26d8(%rip), %rdi      # 0x40c0
movq 0x26e1(%rip), %rdx      # 0x40d0
movq 0x26e2(%rip), %rcx      # 0x40d8
movq 0x10(%rsp), %rsi
leal (%r13,%rsi), %ebp
movq %rdx, %rsi
movl %r12d, %r8d
movl %r13d, %r9d
pushq %rbp
pushq %r12
pushq %rax
pushq %r15
callq 0x10a0
addq $0x20, %rsp
movq 0x26a1(%rip), %rdi      # 0x40c0
movq 0x26aa(%rip), %rsi      # 0x40d0
movq 0x26b3(%rip), %rdx      # 0x40e0
subq $0x8, %rsp
movl %r12d, %ecx
movl %r13d, %r8d
movl %r15d, %r9d
pushq 0x18(%rsp)
callq 0x10b0
addq $0x10, %rsp
cmpq $-0x13, %r14
jl 0x1aa7
movq 0x266c(%rip), %rax      # 0x40c0
movq 0xe8(%rax), %rax
movslq 0x2666(%rip), %rcx      # 0x40c8
shlq $0x7, %rcx
movl 0x1c(%rax,%rcx), %eax
addl $-0xa, %eax
movslq %r12d, %rcx
movslq 0xc(%rsp), %rdx
movl 0x8(%rsp), %r14d
cmpl %eax, %ebp
setge %sil
movswl (%rbx,%rcx,2), %edi
cmpl %edi, %eax
setg %r8b
andb %sil, %r8b
movzbl %r8b, %esi
addl %esi, %r14d
cmpl %edi, %ebp
cmovgel %ebp, %edi
movw %di, (%rbx,%rcx,2)
incq %rcx
cmpq %rdx, %rcx
jl 0x1a7a
jmp 0x1aac
movl 0x8(%rsp), %r14d
movq 0x260d(%rip), %rdi      # 0x40c0
movq 0xe8(%rdi), %rax
movslq 0x2607(%rip), %rcx      # 0x40c8
shlq $0x7, %rcx
movl 0x18(%rax,%rcx), %eax
addl $-0x32, %eax
cmpl %eax, %r14d
jl 0x1ae0
xorl %esi, %esi
callq 0x1100
movl $0x1, 0x4(%rsp)
movl $0x3e8, %edi            # imm = 0x3E8
callq 0x10d0
cmpl $0x0, 0x4(%rsp)
movl $0x0, %ebp
je 0x189d
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq