@lqsort		LEA	lbC000034(PC),A1
		MOVEQ	#4,D1

@qsort		SUBQ.W	#4,SP
		MOVEM.L	D4-D7/A2/A3/A5/A6,-(SP)
		MOVE.L	D1,D6
		MOVE.L	D0,D7
		MOVE.L	A0,A5
		MOVE.L	A1,$20(SP)
		MOVEQ	#1,D0
		CMP.L	D0,D7
		BLS	lbC000184
		MOVE.L	A5,A3
		ADD.L	D6,A3
		MOVE.L	D7,D0
		SUBQ.L	#2,D0
		BNE.S	lbC000102
		MOVE.L	A3,-(SP)
		MOVE.L	A5,-(SP)
		MOVE.L	A5,A0
		MOVE.L	A3,A1
		MOVE.L	$28(SP),A6
		JSR	(A6)
		ADDQ.W	#8,SP
		TST.L	D0
		BLE	lbC000184
		MOVE.L	D6,D0
		MOVE.L	A5,A0
		MOVE.L	A3,A1
		JSR	@__swmem(PC)
		BRA	lbC000184
lbC000102	MOVE.L	D7,D0
		LSR.L	#1,D0
		MOVE.L	D6,D1
		JSR	__CXM22(PC)
		MOVE.L	A5,A1
		ADD.L	D0,A1
		MOVE.L	D6,D0
		MOVE.L	A5,A0
		JSR	@__swmem(PC)
		MOVE.L	A5,A2
		MOVEQ	#0,D5
		MOVEQ	#1,D4
		BRA.S	lbC00014A
lbC000120	MOVE.L	A5,-(SP)
		MOVE.L	A3,-(SP)
		MOVE.L	A3,A0
		MOVE.L	A5,A1
		MOVE.L	$28(SP),A6
		JSR	(A6)
		ADDQ.W	#8,SP
		TST.L	D0
		BPL.S	lbC000146
		ADDQ.L	#1,D5
		ADD.L	D6,A2
		CMP.L	A3,A2
		BEQ.S	lbC000146
		MOVE.L	D6,D0
		MOVE.L	A3,A0
		MOVE.L	A2,A1
		JSR	@__swmem(PC)
lbC000146	ADD.L	D6,A3
		ADDQ.L	#1,D4
lbC00014A	CMP.L	D7,D4
		BCS.S	lbC000120
		CMP.L	A5,A2
		BEQ.S	lbC00015C
		MOVE.L	D6,D0
		MOVE.L	A5,A0
		MOVE.L	A2,A1
		JSR	@__swmem(PC)
lbC00015C	MOVE.L	$20(SP),A3
		MOVE.L	D5,D0
		MOVE.L	D6,D1
		MOVE.L	A5,A0
		MOVE.L	A3,A1
		BSR	@qsort
		MOVE.L	A2,A0
		ADD.L	D6,A0
		MOVE.L	D7,D0
		SUB.L	D5,D0
		SUBQ.L	#1,D0
		MOVE.L	D6,D1
		MOVE.L	A3,A1
		MOVEM.L	(SP)+,D4-D7/A2/A3/A5/A6
		ADDQ.L	#4,SP
		BRA	@qsort
lbC000184	MOVEM.L	(SP)+,D4-D7/A2/A3/A5/A6
		ADDQ.W	#4,SP
		RTS

lbC000034	MOVE.L	(A1),D0
		MOVE.L	(A0),D1
		CMP.L	D0,D1
		BNE.S	lbC000040
		MOVEQ	#0,D0
		BRA.S	lbC00004A
lbC000040	CMP.L	(A1),D1
		BLE.S	lbC000048
		MOVEQ	#1,D0
		BRA.S	lbC00004A
lbC000048	MOVEQ	#-$1,D0
lbC00004A	RTS

@__swmem	TST.L	D0
		BLE.S	lbC00007A
lbC000070	MOVE.B	(A0),D1
		MOVE.B	(A1),(A0)+
		MOVE.B	D1,(A1)+
		SUBQ.L	#1,D0
		BNE.S	lbC000070
lbC00007A	RTS

__CXM22		MOVEM.L	D1-D3,-(SP)
		MOVE.L	D0,D2
		BEQ.S	lbC0000A4
		TST.L	D1
		BNE.S	lbC00008C
		CLR.L	D0
		BRA.S	lbC0000A4
lbC00008C	MOVE.L	D0,D3
		MULU	D1,D3
		SWAP	D2
		MULU.W	D1,D2
		SWAP	D2
		CLR.W	D2
		ADD.L	D2,D3
		SWAP	D1
		MULU.W	D1,D0
		SWAP	D0
		CLR.W	D0
		ADD.L	D3,D0
lbC0000A4	MOVEM.L	(SP)+,D1-D3
		RTS
