	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	_fgetpos]
;
; Line 7:	{
;
_fgetpos:
	PUSH	EBP
	MOV	EBP,ESP
	PUSH	ESI
	PUSH	EDI
	MOV	ESI,DWORD [EBP+08H]
	MOV	EDI,DWORD [EBP+0CH]
;
; Line 8:		if (stream->token == 0x444c) {
;
	MOVSX	EAX,WORD [ESI+01DH]
	CMP	EAX,0444CH
	JNE	NEAR	L_1
;
; Line 9:			*curpos = _ll_getpos(stream->fd);
;
	PUSH	DWORD [ESI+08H]
	CALL	__ll_getpos
	POP	ECX
	MOV	DWORD [EDI+00H],EAX
;
; Line 10:			if (*curpos < 0) {
;
	CMP	DWORD [EDI+00H],BYTE 00H
	JGE	SHORT	L_3
;
; Line 11:				stream->flags |= 0x0010                   ;
;
	BTS	DWORD [ESI+04H],04H
;
; Line 12:				errno = 40       ;
;
	MOV	DWORD [_errno],028H
;
; Line 13:				return (-1)             ;
;
	MOV	EAX,0FFFFFFFFH
	JMP	L_5
L_3:
;
; Line 15:			if (stream->level > 0 && stream->buffer)
;
	CMP	DWORD [ESI+00H],BYTE 00H
	JLE	SHORT	L_6
	CMP	DWORD [ESI+011H],BYTE 00H
	JE	SHORT	L_6
;
; Line 16:				*curpos -= stream->level;
;
	MOV	EAX,DWORD [ESI+00H]
	SUB	DWORD [EDI+00H],EAX
	JMP	L_7
L_6:
;
; Line 18:				if (stream->level < 0 && stream->buffer)
;
	CMP	DWORD [ESI+00H],BYTE 00H
	JGE	SHORT	L_8
	CMP	DWORD [ESI+011H],BYTE 00H
	JE	SHORT	L_8
;
; Line 19:					*curpos += stream->bsize + stream->level;
;
	MOV	EAX,DWORD [ESI+0DH]
	ADD	EAX,DWORD [ESI+00H]
	ADD	DWORD [EDI+00H],EAX
L_8:
L_7:
;
; Line 20:			return 0;
;
	MOV	EAX,00H
	JMP	L_5
L_1:
;
; Line 22:		_dos_errno = errno = 2       ;
;
	MOV	DWORD [_errno],02H
	MOV	DWORD [__dos_errno],02H
;
; Line 23:		return (-1)             ;
;
	MOV	EAX,0FFFFFFFFH
L_5:
	POP	EDI
	POP	ESI
	POP	EBP
	RET


SECTION _TEXT
[EXTERN	__ll_getpos]

SECTION _DATA
[EXTERN	__dos_errno]
[EXTERN	_errno]
