	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 18:	{
;
_oneflush:
	PUSH	EBP
	MOV	EBP,ESP
	SUB	ESP,BYTE 010H
	PUSH	EBX
	PUSH	ESI
	PUSH	EDI
	MOV	ESI,DWORD [EBP+08H]
	MOV	EDI,DWORD _errno
;
; Line 19:		int rv = 0, lvl;
;
	MOV	EBX,00H
;
; Line 20:		if (stream->token == 0x444c) {
;
	MOVSX	EAX,WORD [ESI+01DH]
	CMP	EAX,0444CH
	JNE	NEAR	L_1
;
; Line 21:			if (stream->buffer)
;
	CMP	DWORD [ESI+011H],BYTE 00H
	JE	NEAR	L_3
;
; Line 22:				if (stream->flags & 0x0100                   ) {
;
	MOV	EAX,DWORD [ESI+04H]
	AND	EAX,0100H
	JE	NEAR	L_5
;
; Line 23:					if (!(stream->flags & 0x0040                   )) {
;
	MOV	EAX,DWORD [ESI+04H]
	AND	EAX,BYTE 040H
	JNE	NEAR	L_7
;
; Line 25:						char *p = localbuf, *q = (char *) stream->buffer;
;
	MOV	DWORD [EBP+0FFFFFFF4H],DWORD _localbuf
	MOV	EAX,DWORD [ESI+011H]
	MOV	DWORD [EBP+0FFFFFFF8H],EAX
	MOV	EAX,DWORD [ESI+0DH]
	NEG	EAX
	MOV	DWORD [EBP+0FFFFFFF0H],EAX
	JMP	L_11
L_9:
;
; Line 27:							if (p >= localbuf + 511-1) {
;
	MOV	EAX,DWORD _localbuf
	SUB	EAX,0FFFFFE02H
	CMP	DWORD [EBP+0FFFFFFF4H],EAX
	JB	NEAR	L_13
;
; Line 28:								rv = _ll_write(stream->fd,localbuf,p-localbuf);
;
	MOV	EAX,DWORD _localbuf
	MOV	ECX,DWORD [EBP+0FFFFFFF4H]
	SUB	ECX,EAX
	PUSH	ECX
	PUSH	DWORD _localbuf
	PUSH	DWORD [ESI+08H]
	CALL	__ll_write
	ADD	ESP,BYTE 0CH
	MOV	EBX,EAX
;
; Line 29:								if (rv < 0)
;
	TEST	EBX,EBX
	JNGE	NEAR	L_12
;
; Line 30:									break;
;
L_15:
;
; Line 31:								p = localbuf;
;
	MOV	DWORD [EBP+0FFFFFFF4H],DWORD _localbuf
;
; Line 32:							}
;
L_13:
;
; Line 33:							if ((*p++ = *q++) == '\n') {
;
	MOV	EAX,DWORD [EBP+0FFFFFFF8H]
	INC	DWORD [EBP+0FFFFFFF8H]
	MOV	ECX,DWORD [EBP+0FFFFFFF4H]
	INC	DWORD [EBP+0FFFFFFF4H]
	MOV	AL,BYTE [EAX+00H]
	MOV	BYTE [ECX+00H],AL
	MOVSX	EAX,AL
	CMP	EAX,BYTE 0AH
	JNE	SHORT	L_17
;
; Line 34:								*(p-1) = '\r';
;
	MOV	EAX,DWORD [EBP+0FFFFFFF4H]
	DEC	EAX
	MOV	BYTE [EAX+00H],0DH
;
; Line 35:								*p++ = '\n';
;
	MOV	EAX,DWORD [EBP+0FFFFFFF4H]
	INC	DWORD [EBP+0FFFFFFF4H]
	MOV	BYTE [EAX+00H],0AH
;
; Line 36:							}
;
L_17:
;
; Line 37:						}
;
;
; Line 26:						for (i=-stream->bsize; i< stream->level; i++) {
;
L_10:
	INC	DWORD [EBP+0FFFFFFF0H]
L_11:
	MOV	EAX,DWORD [EBP+0FFFFFFF0H]
	CMP	EAX,DWORD [ESI+00H]
	JL	NEAR	L_9
L_12:
;
; Line 38:						if (p != localbuf && rv >=0 ) {
;
	MOV	EAX,DWORD _localbuf
	CMP	DWORD [EBP+0FFFFFFF4H],EAX
	JE	NEAR	L_19
	TEST	EBX,EBX
	JL	NEAR	L_19
;
; Line 39:							rv = _ll_write(stream->fd,localbuf,p-localbuf);
;
	MOV	EAX,DWORD _localbuf
	MOV	ECX,DWORD [EBP+0FFFFFFF4H]
	SUB	ECX,EAX
	PUSH	ECX
	PUSH	DWORD _localbuf
	PUSH	DWORD [ESI+08H]
	CALL	__ll_write
	ADD	ESP,BYTE 0CH
	MOV	EBX,EAX
;
; Line 40:						}
;
L_19:
;
; Line 41:					}
;
	JMP	L_8
L_7:
;
; Line 43:						rv = _ll_write(stream->fd,stream->buffer,stream->bsize + stream->level);
;
	MOV	EAX,DWORD [ESI+0DH]
	ADD	EAX,DWORD [ESI+00H]
	PUSH	EAX
	PUSH	DWORD [ESI+011H]
	PUSH	DWORD [ESI+08H]
	CALL	__ll_write
	ADD	ESP,BYTE 0CH
	MOV	EBX,EAX
;
; Line 44:					}
;
L_8:
;
; Line 45:					if (rv < 0) {
;
	TEST	EBX,EBX
	JGE	SHORT	L_21
;
; Line 46:						stream->flags |= 0x0010                   ;
;
	BTS	DWORD [ESI+04H],04H
;
; Line 47:						errno = 28       ;
;
	MOV	DWORD [EDI+00H],01CH
;
; Line 48:						rv = (-1)             ;
;
	MOV	EBX,0FFFFFFFFH
;
; Line 49:					}
;
	JMP	L_22
L_21:
;
; Line 50:					else rv = 0;
;
	MOV	EBX,00H
L_22:
;
; Line 51:					stream->level = 0;
;
	MOV	DWORD [ESI+00H],00H
;
; Line 52:				}
;
	JMP	L_6
L_5:
;
; Line 53:				else if (stream->flags & 0x0001                   ) {
;
	MOV	EAX,DWORD [ESI+04H]
	AND	EAX,BYTE 01H
	JE	NEAR	L_23
;
; Line 54:					if (stream->level > 0) {
;
	CMP	DWORD [ESI+00H],BYTE 00H
	JLE	NEAR	L_25
;
; Line 55:						rv = _ll_seek(stream->fd,-stream->level+1,1);
;
	PUSH	BYTE 01H
	MOV	EAX,DWORD [ESI+00H]
	NEG	EAX
	INC	EAX
	PUSH	EAX
	PUSH	DWORD [ESI+08H]
	CALL	__ll_seek
	ADD	ESP,BYTE 0CH
	MOV	EBX,EAX
;
; Line 56:						if (rv < 0) {
;
	TEST	EBX,EBX
	JGE	SHORT	L_27
;
; Line 57:							stream->flags |= 0x0010                   ;
;
	BTS	DWORD [ESI+04H],04H
;
; Line 58:							errno = 28       ;
;
	MOV	DWORD [EDI+00H],01CH
;
; Line 59:							rv = (-1)             ;
;
	MOV	EBX,0FFFFFFFFH
;
; Line 60:						}
;
L_27:
;
; Line 61:					}
;
	JMP	L_26
L_25:
;
; Line 62:					else rv = 0;
;
	MOV	EBX,00H
L_26:
;
; Line 63:					memset(stream->buffer,0,stream->bsize);
;
	PUSH	DWORD [ESI+0DH]
	PUSH	BYTE 00H
	PUSH	DWORD [ESI+011H]
	CALL	_memset
	ADD	ESP,BYTE 0CH
;
; Line 64:					stream->level = 0;
;
	MOV	DWORD [ESI+00H],00H
;
; Line 65:				}
;
L_23:
L_6:
L_3:
;
; Line 66:			stream->hold = 0;
;
	MOV	BYTE [ESI+0CH],00H
;
; Line 67:			stream->curp = stream->buffer;
;
	MOV	EAX,DWORD [ESI+011H]
	MOV	DWORD [ESI+015H],EAX
;
; Line 68:			stream->flags &= ~(0x0080                    | 0x0100                   );
;
	AND	DWORD [ESI+04H],0FFFFFE7FH
;
; Line 69:			return rv;			
;
	MOV	EAX,EBX
	JMP	L_29
L_1:
;
; Line 72:			errno = _dos_errno = 2       ;
;
	MOV	DWORD [__dos_errno],02H
	MOV	DWORD [EDI+00H],02H
;
; Line 73:			return (-1)             ;
;
	MOV	EAX,0FFFFFFFFH
L_2:
;
; Line 75:	}
;
L_29:
	POP	EDI
	POP	ESI
	POP	EBX
	MOV	ESP,EBP
	POP	EBP
	RET
[GLOBAL	_fflush]
;
; Line 77:	{
;
_fflush:
	PUSH	EBP
	MOV	EBP,ESP
	PUSH	EBX
	PUSH	ESI
	PUSH	EDI
	MOV	EDI,DWORD [EBP+08H]
;
; Line 79:		if (stream)
;
	TEST	EDI,EDI
	JE	SHORT	L_30
;
; Line 80:			return(oneflush(stream));
;
	PUSH	EDI
	CALL	_oneflush
	POP	ECX
	JMP	L_32
L_30:
	MOV	EBX,00H
	JMP	L_35
L_33:
;
; Line 84:				rv |= oneflush(_pstreams[i]);
;
	PUSH	DWORD [EBX*4+__pstreams+00H]
	CALL	_oneflush
	POP	ECX
	OR	ESI,EAX
;
; Line 83:			for (i=0; i < maxfiles; i++)
;
L_34:
	INC	EBX
L_35:
	CMP	EBX,DWORD [_maxfiles]
	JL	SHORT	L_33
L_36:
;
; Line 85:		}
;
L_31:
;
; Line 86:		return rv;
;
	MOV	EAX,ESI
L_32:
	POP	EDI
	POP	ESI
	POP	EBX
	POP	EBP
	RET

SECTION _DATA
SECTION _BSS

_localbuf	RESB	01FFH

SECTION _TEXT
[EXTERN	__ll_seek]
[EXTERN	__ll_write]
[EXTERN	_memset]

SECTION _DATA
[EXTERN	_maxfiles]
[EXTERN	__pstreams]
[EXTERN	__dos_errno]
[EXTERN	_errno]
