// File: /workspace/github_c_makefile_star2_O3/veltzer[P]xmeltdown/src/stickman.c
// Function: HandleMotion
void HandleMotion(XMotionEvent* pevent)
{
	int newx, newy, oldx, oldy;
	double newtheta, totaltheta, newr;
	RayPtr fooray;

	DrawSkel(&bones, set_gc, buffer[0]);
	newx=pevent->x;
	newy=pevent->y;

	oldx=targetray->anchor->x;
	oldy=targetray->anchor->y;
/*
** Spin the ray around its anchor
*/
	if (ButtonDown == 1) {
		if (oldx == newx)
			newx++;
		newtheta=atan((double)(oldy-newy)/(double)(oldx-newx));
		if (oldx > newx) newtheta+=M_PI;
		for (totaltheta=0, fooray=targetray->anchor; fooray; fooray=fooray->anchor) {
			totaltheta+=fooray->t;
		}
		targetray->t=newtheta-totaltheta;
		DrawSkel(&bones, unset_gc, buffer[0]);
		FlashRay (targetray);
	}
	if (ButtonDown == 2) {
		bones.waistx=newx+offsetx;
		bones.waisty=newy+offsety;
		DrawSkel(&bones, unset_gc, buffer[0]);
		DrawSkel(&bones, dotted_gc, buffer[0]);
	}
/*
** Stretch the ray out from its anchor
*/
	if (ButtonDown == 3) {
		newr=FindDistance(newx, newy, targetray->anchor);
		targetray->r=newr;
		DrawSkel(&bones, unset_gc, buffer[0]);
		FlashRay (targetray);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
movq 0x3cd1(%rip), %rsi      # 0x5248
leaq 0x3d82(%rip), %r14      # 0x5300
movq (%r14), %rdx
leaq 0x3b40(%rip), %rdi      # 0x50c8
callq 0x1848
movl 0x40(%rbx), %ecx
movl 0x44(%rbx), %r15d
movl 0x3cc6(%rip), %eax      # 0x5260
cmpl $0x1, %eax
jne 0x15fd
movq 0x3cc2(%rip), %rax      # 0x5268
movq 0x18(%rax), %rax
movl 0x10(%rax), %ebx
movl 0x14(%rax), %eax
xorl %ebp, %ebp
cmpl %ecx, %ebx
sete %bpl
addl %ecx, %ebp
subl %r15d, %eax
cvtsi2sd %eax, %xmm0
movl %ebx, %eax
subl %ebp, %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
callq 0x10c0
cmpl %ebp, %ebx
jle 0x15de
addsd 0x1a2a(%rip), %xmm0     # 0x3008
movq 0x3c83(%rip), %rax      # 0x5268
movq 0x18(%rax), %rcx
xorpd %xmm1, %xmm1
testq %rcx, %rcx
je 0x1601
addsd 0x8(%rcx), %xmm1
movq 0x18(%rcx), %rcx
jmp 0x15ed
movl %ecx, %ebp
jmp 0x165b
subsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rax)
movq 0x3c47(%rip), %rsi      # 0x5258
movq (%r14), %rdx
leaq 0x3aad(%rip), %rdi      # 0x50c8
callq 0x1848
movq 0x3c41(%rip), %rax      # 0x5268
leaq 0x3cb2(%rip), %rcx      # 0x52e0
movq (%rcx), %rdi
movq (%r14), %rsi
movq 0x3c15(%rip), %rdx      # 0x5250
movl 0x10(%rax), %ecx
movl 0x14(%rax), %r8d
movq 0x18(%rax), %rax
movl 0x10(%rax), %r9d
movl 0x14(%rax), %eax
movl %eax, (%rsp)
callq 0x10d0
movl 0x3c05(%rip), %eax      # 0x5260
cmpl $0x2, %eax
jne 0x16ae
movl 0x3c0a(%rip), %eax      # 0x5270
addl %ebp, %eax
movl %eax, 0x3a5e(%rip)      # 0x50cc
leaq 0x3a53(%rip), %rbx      # 0x50c8
movl 0x3bf9(%rip), %eax      # 0x5274
addl %r15d, %eax
movl %eax, 0x3a4c(%rip)      # 0x50d0
movq 0x3bcd(%rip), %rsi      # 0x5258
movq (%r14), %rdx
movq %rbx, %rdi
callq 0x1848
movq 0x3bb3(%rip), %rsi      # 0x5250
movq (%r14), %rdx
movq %rbx, %rdi
callq 0x1848
movl 0x3bb2(%rip), %eax      # 0x5260
cmpl $0x3, %eax
jne 0x172c
movq 0x3bae(%rip), %rax      # 0x5268
movq 0x18(%rax), %rcx
subl 0x10(%rcx), %ebp
subl 0x14(%rcx), %r15d
imull %ebp, %ebp
imull %r15d, %r15d
addl %ebp, %r15d
xorps %xmm0, %xmm0
cvtsi2sd %r15, %xmm0
sqrtsd %xmm0, %xmm0
cvttsd2si %xmm0, %ecx
movl %ecx, (%rax)
movq 0x3b70(%rip), %rsi      # 0x5258
movq (%r14), %rdx
leaq 0x39d6(%rip), %rdi      # 0x50c8
callq 0x1848
movq 0x3b6a(%rip), %rax      # 0x5268
leaq 0x3bdb(%rip), %rcx      # 0x52e0
movq (%rcx), %rdi
movq (%r14), %rsi
movq 0x3b3e(%rip), %rdx      # 0x5250
movl 0x10(%rax), %ecx
movl 0x14(%rax), %r8d
movq 0x18(%rax), %rax
movl 0x10(%rax), %r9d
movl 0x14(%rax), %eax
movl %eax, (%rsp)
callq 0x10d0
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq