// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq 0x3bb5(%rip), %rsi      # 0x5248
leaq 0x3c66(%rip), %rax      # 0x5300
movq (%rax), %rdx
leaq 0x3a2c(%rip), %rdi      # 0x50d0
callq 0x1ab0
movq -0x8(%rbp), %rax
movl 0x40(%rax), %eax
movl %eax, -0xc(%rbp)
movq -0x8(%rbp), %rax
movl 0x44(%rax), %eax
movl %eax, -0x10(%rbp)
movq 0x3ba4(%rip), %rax      # 0x5268
movq 0x18(%rax), %rax
movl 0x10(%rax), %eax
movl %eax, -0x14(%rbp)
movq 0x3b93(%rip), %rax      # 0x5268
movq 0x18(%rax), %rax
movl 0x14(%rax), %eax
movl %eax, -0x18(%rbp)
cmpl $0x1, 0x3b7a(%rip)      # 0x5260
jne 0x17b7
movl -0x14(%rbp), %eax
cmpl -0xc(%rbp), %eax
jne 0x16fd
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
movl -0x18(%rbp), %eax
subl -0x10(%rbp), %eax
cvtsi2sd %eax, %xmm0
movl -0x14(%rbp), %eax
subl -0xc(%rbp), %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
callq 0x10c0
movsd %xmm0, -0x20(%rbp)
movl -0x14(%rbp), %eax
cmpl -0xc(%rbp), %eax
jle 0x1739
movsd 0x18d9(%rip), %xmm0     # 0x3008
addsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x20(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x28(%rbp)
movq 0x3b20(%rip), %rax      # 0x5268
movq 0x18(%rax), %rax
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x38(%rbp)
je 0x1778
movq -0x38(%rbp), %rax
movsd 0x8(%rax), %xmm0
addsd -0x28(%rbp), %xmm0
movsd %xmm0, -0x28(%rbp)
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x38(%rbp)
jmp 0x1750
movsd -0x20(%rbp), %xmm0
subsd -0x28(%rbp), %xmm0
movq 0x3adf(%rip), %rax      # 0x5268
movsd %xmm0, 0x8(%rax)
movq 0x3ac3(%rip), %rsi      # 0x5258
leaq 0x3b64(%rip), %rax      # 0x5300
movq (%rax), %rdx
leaq 0x392a(%rip), %rdi      # 0x50d0
callq 0x1ab0
movq 0x3ab6(%rip), %rdi      # 0x5268
callq 0x1880
cmpl $0x2, 0x3aa2(%rip)      # 0x5260
jne 0x1818
movl -0xc(%rbp), %eax
addl 0x3aa7(%rip), %eax      # 0x5270
movl %eax, 0x3905(%rip)      # 0x50d4
movl -0x10(%rbp), %eax
addl 0x3a9c(%rip), %eax      # 0x5274
movl %eax, 0x38fa(%rip)      # 0x50d8
movq 0x3a73(%rip), %rsi      # 0x5258
leaq 0x3b14(%rip), %rax      # 0x5300
movq (%rax), %rdx
leaq 0x38da(%rip), %rdi      # 0x50d0
callq 0x1ab0
movq 0x3a4e(%rip), %rsi      # 0x5250
leaq 0x3af7(%rip), %rax      # 0x5300
movq (%rax), %rdx
leaq 0x38bd(%rip), %rdi      # 0x50d0
callq 0x1ab0
cmpl $0x3, 0x3a41(%rip)      # 0x5260
jne 0x1873
movl -0xc(%rbp), %edi
movl -0x10(%rbp), %esi
movq 0x3a3a(%rip), %rax      # 0x5268
movq 0x18(%rax), %rdx
callq 0x18e0
movsd %xmm0, -0x30(%rbp)
cvttsd2si -0x30(%rbp), %ecx
movq 0x3a20(%rip), %rax      # 0x5268
movl %ecx, (%rax)
movq 0x3a07(%rip), %rsi      # 0x5258
leaq 0x3aa8(%rip), %rax      # 0x5300
movq (%rax), %rdx
leaq 0x386e(%rip), %rdi      # 0x50d0
callq 0x1ab0
movq 0x39fa(%rip), %rdi      # 0x5268
callq 0x1880
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)