	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
[GLOBAL	_fileinit]
;
; Line 17:	{
;
_fileinit:
;
; Line 18:		_ll_init();
;
	CALL	__ll_init
;
; Line 19:	}
;
	RET
[GLOBAL	_closeall]
;
; Line 22:	{
;
_closeall:
	PUSH	EBX
;
; Line 24:		if (!_abterm)
;
	CMP	DWORD [__abterm],BYTE 00H
	JNE	NEAR	L_1
	MOV	EBX,DWORD [_maxfiles]
	DEC	EBX
	JMP	L_5
L_3:
;
; Line 26:				fclose(_pstreams[i]);
;
	PUSH	DWORD [EBX*4+__pstreams+00H]
	CALL	_fclose
	POP	ECX
;
; Line 27:			}
;
;
; Line 25:			for (i=maxfiles-1; i >=0; i--) {
;
L_4:
	DEC	EBX
L_5:
	TEST	EBX,EBX
	JGE	SHORT	L_3
L_6:
L_1:
;
; Line 28:	}
;
	POP	EBX
	RET
[GLOBAL	__basefclose]
;
; Line 30:	{
;
__basefclose:
	PUSH	EBP
	MOV	EBP,ESP
	SUB	ESP,BYTE 08H
	PUSH	EBX
	PUSH	ESI
	PUSH	EDI
	MOV	ESI,DWORD [EBP+08H]
;
; Line 32:		if (stream->token == 0x444c && maxfiles) {
;
	MOVSX	EAX,WORD [ESI+01DH]
	CMP	EAX,0444CH
	JNE	NEAR	L_7
	CMP	DWORD [_maxfiles],BYTE 00H
	JE	NEAR	L_7
;
; Line 33:			int tempflag = stream->istemp;
;
	MOV	EAX,DWORD [ESI+019H]
	MOV	DWORD [EBP+0FFFFFFF8H],EAX
;
; Line 35:			fflush(stream);
;
	PUSH	ESI
	CALL	_fflush
	POP	ECX
;
; Line 36:			stream->token = (short)-1;
;
	MOV	WORD [ESI+01DH],0FFFFFFFFH
;
; Line 37:			if (maxfiles > 1) {
;
	CMP	DWORD [_maxfiles],BYTE 01H
	JLE	NEAR	L_9
	MOV	EBX,00H
	JMP	L_13
L_11:
;
; Line 39:					if (_pstreams[i] == stream) {
;
	CMP	DWORD [EBX*4+__pstreams+00H],ESI
	JNE	NEAR	L_15
;
; Line 40:						fname = _filenames[i];
;
	MOV	EAX,DWORD [EBX*4+__filenames+00H]
	MOV	DWORD [EBP+0FFFFFFFCH],EAX
;
; Line 41:						_pstreams[i] = _pstreams[maxfiles-1];
;
	MOV	EAX,DWORD [_maxfiles]
	DEC	EAX
	MOV	EAX,DWORD [EAX*4+__pstreams+00H]
	MOV	DWORD [EBX*4+__pstreams+00H],EAX
;
; Line 42:						_filenames[i] = _filenames[maxfiles-1];
;
	MOV	EAX,DWORD [_maxfiles]
	DEC	EAX
	MOV	EAX,DWORD [EAX*4+__filenames+00H]
	MOV	DWORD [EBX*4+__filenames+00H],EAX
;
; Line 43:						break ;
;
	JMP	L_14
L_15:
;
; Line 38:				for (i=0; i < maxfiles; i++)
;
L_12:
	INC	EBX
L_13:
	CMP	EBX,DWORD [_maxfiles]
	JL	NEAR	L_11
L_14:
;
; Line 45:				maxfiles--;
;
	DEC	DWORD [_maxfiles]
;
; Line 46:			}
;
L_9:
;
; Line 47:			rv = _ll_close(stream->fd);
;
	PUSH	DWORD [ESI+08H]
	CALL	__ll_close
	POP	ECX
	MOV	EDI,EAX
;
; Line 48:			if (tempflag && fname)
;
	CMP	DWORD [EBP+0FFFFFFF8H],BYTE 00H
	JE	SHORT	L_17
	CMP	DWORD [EBP+0FFFFFFFCH],BYTE 00H
	JE	SHORT	L_17
;
; Line 49:				rv &= remove(fname);
;
	PUSH	DWORD [EBP+0FFFFFFFCH]
	CALL	_remove
	POP	ECX
	AND	EDI,EAX
L_17:
;
; Line 50:			if (fname)
;
	CMP	DWORD [EBP+0FFFFFFFCH],BYTE 00H
	JE	SHORT	L_19
;
; Line 51:				free(fname);
;
	PUSH	DWORD [EBP+0FFFFFFFCH]
	CALL	_free
	POP	ECX
L_19:
;
; Line 52:			if (stream->flags & 0x0004                   )
;
	MOV	EAX,DWORD [ESI+04H]
	AND	EAX,BYTE 04H
	JE	SHORT	L_21
;
; Line 53:				free(stream->buffer);
;
	PUSH	DWORD [ESI+011H]
	CALL	_free
	POP	ECX
L_21:
;
; Line 54:			if (release)
;
	CMP	DWORD [EBP+0CH],BYTE 00H
	JE	SHORT	L_23
;
; Line 55:				free(stream);
;
	PUSH	ESI
	CALL	_free
	POP	ECX
L_23:
;
; Line 56:			if (!rv)
;
	TEST	EDI,EDI
	JNE	SHORT	L_25
;
; Line 57:				return 0;
;
	MOV	EAX,00H
	JMP	L_27
L_25:
;
; Line 59:				return (-1)             ;
;
	MOV	EAX,0FFFFFFFFH
	JMP	L_27
L_26:
;
; Line 61:		}
;
	JMP	L_8
L_7:
;
; Line 63:			errno = _dos_errno = 2       ;
;
	MOV	DWORD [__dos_errno],02H
	MOV	DWORD [_errno],02H
;
; Line 64:			return (-1)             ;
;
	MOV	EAX,0FFFFFFFFH
L_8:
;
; Line 66:	}
;
L_27:
	POP	EDI
	POP	ESI
	POP	EBX
	MOV	ESP,EBP
	POP	EBP
	RET
[GLOBAL	_fclose]
;
; Line 68:	{
;
_fclose:
	PUSH	EBP
	MOV	EBP,ESP
;
; Line 69:		return _basefclose(stream,1);
;
	PUSH	BYTE 01H
	PUSH	DWORD [EBP+08H]
	CALL	__basefclose
	ADD	ESP,BYTE 08H
L_28:
	POP	EBP
	RET

SECTION _DATA
SECTION _BSS
[GLOBAL	__pstreams]

__pstreams	RESB	050H
[GLOBAL	__filenames]

__filenames	RESB	050H
[GLOBAL	_maxfiles]

_maxfiles	RESB	04H
SECTION cstartup
	DD	_fileinit,139
SECTION crundown
	DD	_closeall,11

SECTION _TEXT
[EXTERN	_remove]
[EXTERN	_free]
[EXTERN	__ll_close]
[EXTERN	__ll_init]
[EXTERN	_fflush]

SECTION _DATA
[EXTERN	__dos_errno]
[EXTERN	__abterm]
[EXTERN	_errno]
