// File: /workspace/github_c_makefile_star2_O1/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 0x3cc7(%rip), %rsi      # 0x5248
leaq 0x3d78(%rip), %r14      # 0x5300
movq (%r14), %rdx
leaq 0x3b3e(%rip), %rdi      # 0x50d0
callq 0x18b0
movl 0x40(%rbx), %eax
movl 0x44(%rbx), %r15d
cmpl $0x1, 0x3cbb(%rip)      # 0x5260
jne 0x1605
movq 0x3cba(%rip), %rcx      # 0x5268
movq 0x18(%rcx), %rcx
movl 0x10(%rcx), %ebx
movl 0x14(%rcx), %ecx
xorl %ebp, %ebp
cmpl %eax, %ebx
sete %bpl
addl %eax, %ebp
subl %r15d, %ecx
cvtsi2sd %ecx, %xmm0
movl %ebx, %eax
subl %ebp, %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
callq 0x10c0
cmpl %ebp, %ebx
jle 0x15e6
addsd 0x1a22(%rip), %xmm0     # 0x3008
movq 0x3c7b(%rip), %rax      # 0x5268
movq 0x18(%rax), %rcx
xorpd %xmm1, %xmm1
testq %rcx, %rcx
je 0x1609
addsd 0x8(%rcx), %xmm1
movq 0x18(%rcx), %rcx
jmp 0x15f5
movl %eax, %ebp
jmp 0x165d
subsd %xmm1, %xmm0
movsd %xmm0, 0x8(%rax)
movq 0x3c3f(%rip), %rsi      # 0x5258
movq (%r14), %rdx
leaq 0x3aad(%rip), %rdi      # 0x50d0
callq 0x18b0
movq 0x3c39(%rip), %rax      # 0x5268
leaq 0x3caa(%rip), %rcx      # 0x52e0
movq (%rcx), %rdi
movq (%r14), %rsi
movq 0x3c0d(%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
cmpl $0x2, 0x3bfc(%rip)      # 0x5260
jne 0x16ae
movl 0x3c04(%rip), %eax      # 0x5270
addl %ebp, %eax
movl %eax, 0x3a60(%rip)      # 0x50d4
leaq 0x3a55(%rip), %rbx      # 0x50d0
movl 0x3bf3(%rip), %eax      # 0x5274
addl %r15d, %eax
movl %eax, 0x3a4e(%rip)      # 0x50d8
movq 0x3bc7(%rip), %rsi      # 0x5258
movq (%r14), %rdx
movq %rbx, %rdi
callq 0x18b0
movq 0x3bad(%rip), %rsi      # 0x5250
movq (%r14), %rdx
movq %rbx, %rdi
callq 0x18b0
cmpl $0x3, 0x3bab(%rip)      # 0x5260
jne 0x174c
movq 0x3ba6(%rip), %rax      # 0x5268
movq 0x18(%rax), %rax
subl 0x10(%rax), %ebp
subl 0x14(%rax), %r15d
imull %ebp, %ebp
imull %r15d, %r15d
addl %ebp, %r15d
xorps %xmm0, %xmm0
cvtsi2sd %r15, %xmm0
xorpd %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jb 0x16ef
sqrtsd %xmm0, %xmm0
jmp 0x16f4
callq 0x1150
cvttsd2si %xmm0, %eax
movq 0x3b69(%rip), %rcx      # 0x5268
movl %eax, (%rcx)
movq 0x3b50(%rip), %rsi      # 0x5258
movq (%r14), %rdx
leaq 0x39be(%rip), %rdi      # 0x50d0
callq 0x18b0
movq 0x3b4a(%rip), %rax      # 0x5268
leaq 0x3bbb(%rip), %rcx      # 0x52e0
movq (%rcx), %rdi
movq (%r14), %rsi
movq 0x3b1e(%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