	SECTION _TEXT CLASS=CODE USE32
	SECTION _DATA CLASS=DATA USE32
	SECTION _BSS  CLASS=BSS USE32
	SECTION _CONST  CLASS=CONST USE32
	SECTION _STRING  CLASS=STRING USE32
	SECTION cstartup CLASS=INITDATA USE32
	SECTION crundown CLASS=EXITDATA USE32
	SECTION cppinit  CLASS=CPPINIT USE32
	SECTION cppexit  CLASS=CPPEXIT USE32
	GROUP DGROUP _DATA _BSS _CONST _STRING

SECTION _TEXT
;
; Line 15:	{
;
_memdelete:
	PUSH	EBX
	PUSH	ESI
;
; Line 16:		BLKHEAD *p = _allocbloc;
;
	MOV	EBX,DWORD [__allocbloc]
	JMP	L_1
L_3:
;
; Line 18:			BLKHEAD *n = p->next;
;
	MOV	ESI,DWORD [EBX+00H]
;
; Line 19:			_ll_free(p);
;
	PUSH	EBX
	CALL	__ll_free
	POP	ECX
;
; Line 20:			p = n;
;
	MOV	EBX,ESI
;
; Line 21:		}
;
L_1:
;
; Line 17:		while (p) {
;
	TEST	EBX,EBX
	JNE	SHORT	L_3
L_2:
;
; Line 22:	}
;
	POP	ESI
	POP	EBX
	RET
;
; Line 25:	{
;
_init_block:
	PUSH	EBP
	MOV	EBP,ESP
	PUSH	EBX
	PUSH	ESI
	PUSH	EDI
;
; Line 26:		size_t ns = size+sizeof(BLKHEAD);
;
	MOV	EBX,DWORD [EBP+08H]
	ADD	EBX,BYTE 08H
;
; Line 29:		if (ns < 256*1024	 )
;
	CMP	EBX,040000H
	JNC	SHORT	L_4
;
; Line 30:			ns = 256*1024	 ;
;
	MOV	EBX,040000H
L_4:
;
; Line 31:		nb = _ll_malloc(ns);
;
	PUSH	EBX
	CALL	__ll_malloc
	POP	ECX
	MOV	ESI,EAX
;
; Line 32:		if (!nb)
;
	TEST	ESI,ESI
	JNE	SHORT	L_6
;
; Line 33:			return 0;
;
	MOV	EAX,00H
	JMP	L_8
L_6:
;
; Line 34:		nb->next = _allocbloc;
;
	MOV	EAX,DWORD [__allocbloc]
	MOV	DWORD [ESI+00H],EAX
;
; Line 35:		_allocbloc = nb;
;
	MOV	DWORD [__allocbloc],ESI
;
; Line 36:		list = nb->freemem = nb + 1 ;
;
	LEA	EAX,[ESI+08H]
	MOV	DWORD [ESI+04H],EAX
	MOV	EDI,EAX
;
; Line 37:		list->size = ns - sizeof(BLKHEAD) ;
;
	LEA	EAX,[EBX+0FFFFFFF8H]
	MOV	DWORD [EDI+00H],EAX
;
; Line 38:		list->next = 0;
;
	MOV	DWORD [EDI+04H],00H
;
; Line 39:		_newfree = nb;
;
	MOV	DWORD [__newfree],ESI
;
; Line 40:		return 1;
;
	MOV	EAX,01H
L_8:
	POP	EDI
	POP	ESI
	POP	EBX
	POP	EBP
	RET
;
; Line 43:	{
;
_split:
	PUSH	EBP
	MOV	EBP,ESP
	SUB	ESP,BYTE 04H
	PUSH	EBX
	PUSH	ESI
	PUSH	EDI
	MOV	ESI,DWORD [EBP+08H]
	MOV	EBX,DWORD [EBP+0CH]
;
; Line 46:		rv = (FREELIST *)(((char *)p)+size);
;
	MOV	EDI,ESI
	ADD	EDI,EBX
;
; Line 47:		rv->size = p->size - size ;
;
	MOV	EAX,DWORD [ESI+00H]
	SUB	EAX,EBX
	MOV	DWORD [EDI+00H],EAX
;
; Line 48:		rv->next = 0;
;
	MOV	DWORD [EDI+04H],00H
;
; Line 49:		*slist = rv;
;
	MOV	EAX,DWORD [EBP+010H]
	MOV	DWORD [EAX+00H],EDI
;
; Line 50:		p->size = size ;
;
	MOV	DWORD [ESI+00H],EBX
;
; Line 51:	 	return ++p;
;
	ADD	ESI,BYTE 08H
	MOV	EAX,ESI
L_9:
	POP	EDI
	POP	ESI
	POP	EBX
	MOV	ESP,EBP
	POP	EBP
	RET
[GLOBAL	_malloc]
;
; Line 54:	{
;
_malloc:
	PUSH	EBP
	MOV	EBP,ESP
	SUB	ESP,BYTE 08H
	PUSH	EBX
	PUSH	ESI
	PUSH	EDI
	MOV	EDI,DWORD __newfree
;
; Line 59:		if (!size)
;
	CMP	DWORD [EBP+08H],BYTE 00H
	JNE	SHORT	L_10
;
; Line 60:			return 0;
;
	MOV	EAX,00H
	JMP	L_12
L_10:
;
; Line 61:		size +=3;
;
	ADD	DWORD [EBP+08H],BYTE 03H
;
; Line 62:		size &= 0xfffffffc;
;
	AND	DWORD [EBP+08H],BYTE 0FFFFFFFCH
;
; Line 64:		siz1 = size + sizeof(FREELIST);
;
	MOV	EBX,DWORD [EBP+08H]
	ADD	EBX,BYTE 08H
;
; Line 67:		slist = &_mallocchains[(siz1 >> 2) % 32		 ];
;
	MOV	EAX,EBX
	SAR	EAX,02H
	AND	EAX,BYTE 01FH
	SHL	EAX,02H
	MOV	ECX,DWORD __mallocchains
	ADD	ECX,EAX
	MOV	DWORD [EBP+0FFFFFFFCH],ECX
	JMP	L_13
L_15:
;
; Line 69:			p = *slist;
;
	MOV	EAX,DWORD [EBP+0FFFFFFFCH]
	MOV	ESI,DWORD [EAX+00H]
;
; Line 70:			if (p->size == siz1) {
;
	CMP	DWORD [ESI+00H],EBX
	JNE	SHORT	L_16
;
; Line 71:			 	*slist = p->next;
;
	MOV	EAX,DWORD [EBP+0FFFFFFFCH]
	MOV	ECX,DWORD [ESI+04H]
	MOV	DWORD [EAX+00H],ECX
;
; Line 72:	 			return ++p;
;
	ADD	ESI,BYTE 08H
	MOV	EAX,ESI
	JMP	L_12
L_16:
;
; Line 74:			slist = &p->next;
;
	LEA	EAX,[ESI+04H]
	MOV	DWORD [EBP+0FFFFFFFCH],EAX
;
; Line 75:		}
;
L_13:
;
; Line 68:		while (*slist) {
;
	MOV	EAX,DWORD [EBP+0FFFFFFFCH]
	CMP	DWORD [EAX+00H],BYTE 00H
	JNE	NEAR	L_15
L_14:
;
; Line 77:		head = _newfree ;
;
	MOV	EAX,DWORD [EDI+00H]
	MOV	DWORD [EBP+0FFFFFFF8H],EAX
	JMP	L_18
L_20:
;
; Line 79:			p = head->freemem ;
;
	MOV	EAX,DWORD [EBP+0FFFFFFF8H]
	MOV	ESI,DWORD [EAX+04H]
;
; Line 80:			if (p) {
;
	TEST	ESI,ESI
	JE	NEAR	L_21
;
; Line 81:				if (p->size == siz1) {
;
	CMP	DWORD [ESI+00H],EBX
	JNE	SHORT	L_23
;
; Line 82:				 	head->freemem = 0;
;
	MOV	EAX,DWORD [EBP+0FFFFFFF8H]
	MOV	DWORD [EAX+04H],00H
;
; Line 83:	 				return ++p;
;
	ADD	ESI,BYTE 08H
	MOV	EAX,ESI
	JMP	L_12
L_23:
;
; Line 85:				else if (p->size > siz1+sizeof(FREELIST))
;
	LEA	EAX,[EBX+08H]
	CMP	DWORD [ESI+00H],EAX
	JBE	SHORT	L_25
;
; Line 86:					return split(p,siz1,&head->freemem);
;
	MOV	EAX,DWORD [EBP+0FFFFFFF8H]
	ADD	EAX,BYTE 04H
	PUSH	EAX
	PUSH	EBX
	PUSH	ESI
	CALL	_split
	ADD	ESP,BYTE 0CH
	JMP	L_12
L_25:
L_24:
;
; Line 87:			}
;
L_21:
;
; Line 88:			head = head->next ;
;
	MOV	EAX,DWORD [EBP+0FFFFFFF8H]
	MOV	EAX,DWORD [EAX+00H]
	MOV	DWORD [EBP+0FFFFFFF8H],EAX
;
; Line 89:		}
;
L_18:
;
; Line 78:		while (head) {
;
	CMP	DWORD [EBP+0FFFFFFF8H],BYTE 00H
	JNE	NEAR	L_20
L_19:
;
; Line 91:		if (!init_block(siz1)) {
;
	PUSH	EBX
	CALL	_init_block
	POP	ECX
	TEST	EAX,EAX
	JNE	SHORT	L_27
;
; Line 92:			return 0;
;
	MOV	EAX,00H
	JMP	L_12
L_27:
;
; Line 95:		p = _newfree->freemem;
;
	MOV	EAX,DWORD [EDI+00H]
	MOV	ESI,DWORD [EAX+04H]
;
; Line 96:		if (p->size == siz1) {
;
	CMP	DWORD [ESI+00H],EBX
	JNE	SHORT	L_29
;
; Line 97:			 	_newfree->freemem = p->next ;
;
	MOV	EAX,DWORD [EDI+00H]
	MOV	ECX,DWORD [ESI+04H]
	MOV	DWORD [EAX+04H],ECX
;
; Line 98:	 			return ++p;
;
	ADD	ESI,BYTE 08H
	MOV	EAX,ESI
	JMP	L_12
L_29:
;
; Line 101:		return split(p,siz1,&_newfree->freemem);
;
	MOV	EAX,DWORD [EDI+00H]
	ADD	EAX,BYTE 04H
	PUSH	EAX
	PUSH	EBX
	PUSH	ESI
	CALL	_split
	ADD	ESP,BYTE 0CH
L_12:
	POP	EDI
	POP	ESI
	POP	EBX
	MOV	ESP,EBP
	POP	EBP
	RET

SECTION _DATA
SECTION _BSS
[GLOBAL	__mallocchains]

__mallocchains	RESB	080H
[GLOBAL	__allocbloc]

__allocbloc	RESB	04H
[GLOBAL	__newfree]

__newfree	RESB	04H
SECTION crundown
	DD	_memdelete,5

SECTION _TEXT
[EXTERN	__ll_malloc]
[EXTERN	__ll_free]
