SkipName	proc	near
	add	si,seName
	xor	ah,ah
	mov	al,es:[si].B0
	inc	ax
	add	si,ax
	ret
SkipName	endp

StoreUnitName	proc	near
	mov	si,es:uhName
	jmp	StoreName
StoreUnitName	endp

StoreName	proc	near
	test	d3caa,8000h
	jz	@@3
	mov	al,es:[si].seName.B0
	xor	ah,ah
	inc	ax
	cmp	Phase,0
	je	@@1
	cmp	Phase,8000h
	jne	@@2
	push	si di
	add	si,seName+1
	call	GetMem
	push	ds es es
	call	StartBuf
	pop	ds
	dec	ax
	mov	cx,ax
	cld
	rep	movsb
	xor	al,al
	stosb
	pop	es
	pop	ds
	call	StopBuf
	pop	di
	pop	si
@@1:	add	NamePoolSize.W0,ax
	adc	NamePoolSize.W2,0
@@2:	inc	Cnt.NameCount
@@3:	ret
StoreName	endp

StoreUnit	proc	near
	mov	si,es:uhName
	call	SkipName
	xor	ax,ax
	cwd
	jmp	short @@3
@@1:	call	SkipName
	cmp	es:[si].usChecksum,0
	je	@@3
	cmp	Phase,20h
	jne	@@2
	push	es
	mov	es,es:[si].usAddress
	mov	ax,es:uhNumber
	call	StartBuf
	stosw
	xor	ax,ax
	stosw
	mov	ax,dx
	stosw
	mov	ax,-2
	stosw
	xor	ax,ax
	stosw
	stosw
	call	StopBuf
	pop	es
	mov	dx,Cnt.ScopeCount
@@2:	inc	Cnt.ScopeCount
@@3:	mov	si,es:[si].usNext
	or	si,si
	jnz	@@1
	ret
StoreUnit	endp

HashIterator	proc	near
	push	di si bx cx
	mov	cx,es:[bx]
	shr	cx,1
	inc	cx
@@1:	inc	bx
	inc	bx
	mov	si,es:[bx]
	jmp	short @@3
@@2:	push	bx
	mov	bl,es:[si].seName.B0
	mov	bh,0
	lea	di,[si+size TSymbol+bx]
	mov	al,es:[si].seType
	and	al,not t_Private
	call	HashIterFunc
	pop	bx
	mov	si,es:[si].sePrev
@@3:	or	si,si
	jnz	@@2
	loop	@@1
	pop	cx bx si di
	ret
HashIterator	endp

l039b	proc	near
	call	l03a2
	call	l03d4
	ret
l039b	endp

l03a2	proc	near
	mov	d3cec,0
	mov	ax,es
	cmp	ax,LastUnit
	jne	@@1
	call	l0962
@@1:	lea	ax,l0751
	mov	bx,es:uhDebugHash
	cmp	bx,es:uhInterface
	je	@@2
	lea	ax,l0745
@@2:	call	CustomHashIter
	test	d3caa,2
	jz	@@3
	inc	Cnt.SegmentCount
@@3:	ret
l03a2	endp

l03d4	proc	near
	mov	bx,es:uhDebugHash
	cmp	bx,es:uhInterface
	je	@@1
	lea	ax,l073a
	jmp	short CustomHashIter
@@1:	ret
l03d4	endp

CustomHashIter	proc	near
	mov	HashIterFunc,ax
	call	HashIterator
	lea	ax,l0751
	mov	HashIterFunc,ax
	ret
CustomHashIter	endp

DoCountProcInfoSize	proc	near
	cmp	al,t_Proc
	je	_DoCountProcInfoSize
	cmp	al,t_Type
	jne	@@5
	push	es di
	mov	bx,es:[di].tsType.Segm
	mov	di,es:[di].tdType.Offs
	mov	es,es:[bx]
	cmp	es:[di].tdType,ttObject
	jne	@@4
	mov	ax,es:[di].rtFirst
	or	ax,ax
	jz	@@4
	push	si
	mov	si,ax
@@1:	push	bx
	mov	bl,es:[si].seName.B0
	xor	bh,bh
	lea	di,[si+size TSymbol+bx]
	pop	bx
	mov	al,es:[si].seType
	and	al,not t_Private
	cmp	al,t_Proc
	jne	@@2
	call	_DoCountProcInfoSize
	mov	si,es:[di].psType.tdNext
	jmp	short @@3
@@2:	mov	si,es:[di].vsNext
@@3:	or	si,si
	jnz	@@1
	pop	si
@@4:	pop	di es
@@5:	ret
DoCountProcInfoSize	endp

_DoCountProcInfoSize	proc	near
	test	es:[di].psFlags,pfInline
	jnz	@@3
	mov	bx,es:[di].psProcMap
	add	bx,es:uhProcMap
	mov	ax,bx
	test	es:[bx].pmFlags.B0,4
	jz	@@1
	cmp	es:[bx].pmStub,0
	je	@@3
	mov	ax,ProcInfoSize
	mov	es:[bx].pmStub,ax
	mov	bx,es:[bx].pmCodeMap
	add	bx,es:uhEndMaps
	mov	es:[bx].smAddr,0
	mov	ax,6
	jmp	short @@2
@@1:	mov	bx,es:[bx].pmCodeMap
	add	bx,es:uhCodeMap
	cmp	es:[bx].smAddr,-1
	je	@@3
	mov	bx,ax
	mov	ax,ProcInfoSize
	mov	es:[bx].pmStub,ax
	mov	ax,6
	cmp	es:[bx].pmEntryPoint,-1
	je	@@2
	mov	ax,10
@@2:	add	ProcInfoSize,ax
	jc	@@4
	mov	bx,es:[di].psHash
	or	bx,bx
	jz	@@3
	call	HashIterator
@@3:	ret
@@4:	jmp	OutOfMemory
_DoCountProcInfoSize	endp

l04b2	proc	near
	mov	cx,es:[si].trSymbol
	jcxz	@@1
	xchg	si,cx
	mov	bl,es:[si].seName.B0
	mov	bh,0
	lea	bx,[si+size TSymbol+bx]
	mov	bx,es:[bx].psHash
	xchg	si,cx
	call	l09b8
	call	HashIterator
@@1:	ret
l04b2	endp

l04cf	proc	near
	mov	cx,es:[si].trSymbol
	jcxz	@@1
	push	di
	mov	di,cx
	mov	bl,es:[di].seName.B0
	xor	bh,bh
	lea	di,[di+size TSymbol+bx]
	mov	bx,es:[di].psHash
	push	es
	mov	di,es:[di].psProcMap
	add	di,es:uhProcMap
	mov	di,es:[di].pmStub
	mov	es,ProcInfo
	mov	cx,es:[di+8]
	mov	ax,9
	cwd
	mul	cx
	call	GetMem
	call	StartBuf
	mov	d3cb6,di
	pop	es
	push	Cnt.SymbolCount
	call	l09b8
	call	HashIterator
	pop	ax
	call	l1b6b
	pop	di
@@1:	ret
l04cf	endp

l051a	proc	near
	mov	cx,es:[si].trSymbol
	jcxz	@@2
	push	di
	mov	di,cx
	mov	bl,es:[di].seName.B0
	xor	bh,bh
	lea	di,[di+size TSymbol+bx]
	mov	bx,es:[di].psHash
	push	di
	mov	d3ced,0
	push	di Cnt.SymbolCount
	call	l09b8
	call	HashIterator
	pop	ax si
	push	es
	mov	si,es:[si].psProcMap
	add	si,es:uhProcMap
	mov	si,es:[si].pmStub
	mov	es,ProcInfo
	sub	ax,Cnt.SymbolCount
	neg	ax
	mov	es:[si+8],ax
	mov	ax,Cnt.ScopeCount
	mov	es:[si+6],ax
	pop	es
	inc	Cnt.ScopeCount
	pop	di
	cmp	d3ced,0
	je	@@1
	mov	di,es:[di].psProcMap
	add	di,es:uhProcMap
	or	es:[di].pmFlags.B0,20h
@@1:	pop	di
@@2:	ret
l051a	endp

TraceIterator	proc	near
	mov	si,es:uhTrace
	cmp	si,es:uhEndTrace
	je	@@4
	mov	d3cea,ax
	mov	di,es:uhCodeMap
	jmp	short @@3
@@1:	cmp	es:[di].smAddr,-1
	je	@@2
	mov	si,es:[di].smTrace
	cmp	si,-1
	je	@@2
	add	si,es:uhTrace
	call	d3cea
@@2:	add	di,size TSegMap
@@3:	cmp	di,es:uhConstMap
	jne	@@1
@@4:	ret
TraceIterator	endp

l05ba	proc	near
	mov	ax,es
	cmp	ax,LastUnit
	je	@@3
	push	d3caa Phase
	mov	Phase,0
	mov	d3caa,0
	lea	si,Cnt
	mov	cx,size Cnt shr 1
@@1:	lodsw
	push	ax
	loop	@@1
	mov	bx,es:uhDebugHash
	call	HashIterator
	lea	ax,l04b2
	call	TraceIterator
	lea	si,Cnt+size Cnt-2
	mov	cx,size Cnt shr 1
@@2:	pop	[si]
	dec	si
	dec	si
	loop	@@2
	pop	Phase d3caa
@@3:	ret
l05ba	endp

l0603	proc	near
	mov	si,es:uhTrace
	cmp	si,es:uhEndTrace
	je	@@4
	mov	si,es:uhSources
	xor	bh,bh
	jmp	short @@3
@@1:	cmp	es:[si].slFileType,fdIncludeDir
	jb	@@2
	cmp	es:[si].slFileType,fdUnitDir
	ja	@@2
	call	StoreSourceFile
	push	si
	add	si,size TSourceList-size TSymbol
	call	StoreName
	pop	si
@@2:	mov	bl,es:[si].slName.B0
	lea	si,[si+size TSourceList+bx]
@@3:	cmp	si,es:uhTrace
	jb	@@1
@@4:	ret
l0603	endp

l063e	proc	near
	xor	dx,dx
	mov	bx,-1
	lea	ax,l0651
	call	TraceIterator
	or	dx,dx
	jz	@@1
	call	StoreCorrel
@@1:	ret
l063e	endp

l0651	proc	near
	mov	ax,es:[si].trSource
	cmp	ax,bx
	je	@@2
	cmp	bx,-1
	je	@@1
	push	ax
	call	StoreCorrel
	pop	ax
	xor	dx,dx
@@1:	xchg	ax,bx
@@2:	call	l066a
	ret
l0651	endp

l066a	proc	near
	push	si ds es
	pop	ds
	mov	cx,[si+8]
	add	si,10
@@1:	lodsb
	or	al,al
	js	@@2
	cbw
	jmp	short @@3
@@2:	and	al,7fh
	mov	ah,al
	lodsb
@@3:	or	ax,ax
	jz	@@4
	inc	dx
@@4:	loop	@@1
	pop	ds
	pop	si
	ret
l066a	endp

l068b	proc	near
	mov	si,es:[si]
	or	si,si
	jnz	@@1
	jmp	@@3
@@1:	mov	ax,es:[di]
	mov	d3cc8,ax
	mov	ax,es:[di+2]
	mov	d3cca,ax
	push	es di es
	mov	bl,es:[si+3]
	xor	bh,bh
	lea	si,[bx+si+4]
	mov	di,es:[si+2]
	add	di,es:[0ch]
	mov	ax,es:[di+6]
	add	d3cc8,ax
	sub	d3cca,ax
	mov	di,es:[di]
	mov	es,ProcInfo
	mov	dx,es:[di]
	mov	ax,es:[di+8]
	mov	cx,Cnt.SegmentCount
	pop	es
	test	byte ptr es:[si],10h
	jnz	@@2
	mov	si,es:[si+4]
	or	si,si
	jz	@@2
	mov	bl,es:[si+3]
	xor	bh,bh
	lea	si,[bx+si+4]
	mov	di,es:[si+2]
	add	di,es:[0ch]
	mov	di,es:[di]
	mov	es,ProcInfo
	mov	cx,es:[di+6]
@@2:	mov	bx,ax
	call	StartBuf
	mov	ax,Cnt.SymbolCount
	stosw
	mov	ax,bx
	stosw
	add	Cnt.SymbolCount,ax
	mov	ax,cx
	stosw
	mov	ax,dx
	stosw
	mov	ax,d3cc8
	stosw
	mov	ax,d3cca
	stosw
	call	StopBuf
	pop	di es
	inc	Cnt.ScopeCount
@@3:	ret
l068b	endp

l0729	proc	near
	mov	bx,es:[bx+2]
	add	bx,es:[0ch]
	mov	bx,es:[bx]
	mov	es,ProcInfo
	ret
l0729	endp
