	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	_gets]
;
; Line 4:	{
;
_gets:
	PUSH	EBP
	MOV	EBP,ESP
	PUSH	EBX
	PUSH	ESI
	PUSH	EDI
	MOV	EDI,DWORD [EBP+08H]
;
; Line 5:		int i = 0,rv;
;
	MOV	ESI,00H
	JMP	L_1
L_3:
;
; Line 7:			rv = ((--(((_pstreams[0]))->level) > 0) ? (unsigned char)(*((_pstreams[0]))->curp++) :     _fgetc ((_pstreams[0])));
;
	MOV	EAX,DWORD [__pstreams]
	DEC	DWORD [EAX+00H]
	CMP	DWORD [EAX+00H],BYTE 00H
	JLE	SHORT	L_4
	MOV	EAX,DWORD [__pstreams]
	PUSH	DWORD [EAX+015H]
	INC	DWORD [EAX+015H]
	POP	EAX
	MOVZX	EAX,BYTE [EAX+00H]
	JMP	L_5
L_4:
	PUSH	DWORD [__pstreams]
	CALL	__fgetc
	POP	ECX
L_5:
	MOV	EBX,EAX
;
; Line 8:			if (rv == (-1)             )
;
	CMP	EBX,BYTE 0FFFFFFFFH
	JE	SHORT	L_2
;
; Line 9:				break;
;
L_6:
;
; Line 10:			buf[i++] = (char)rv;
;
	MOV	EAX,ESI
	INC	ESI
	MOV	BYTE [EDI+EAX+00H],BL
;
; Line 11:			if (rv == '\n') 
;
	CMP	EBX,BYTE 0AH
	JE	SHORT	L_2
;
; Line 12:				break;
;
L_8:
;
; Line 13:		}
;
L_1:
;
; Line 6:		while (1) {
;
	JMP	L_3
L_2:
;
; Line 14:		if (!i)
;
	TEST	ESI,ESI
	JNE	SHORT	L_10
;
; Line 15:			i = 1;
;
	MOV	ESI,01H
L_10:
;
; Line 16:		buf[i-1] = 0;
;
	MOV	BYTE [EDI+ESI+0FFFFFFFFH+00H],00H
;
; Line 17:		if (rv == (-1)             )
;
	CMP	EBX,BYTE 0FFFFFFFFH
	JNE	SHORT	L_12
;
; Line 18:			return 0;
;
	MOV	EAX,00H
	JMP	L_14
L_12:
;
; Line 19:		else return buf;
;
	MOV	EAX,EDI
L_13:
;
; Line 20:	}
;
L_14:
	POP	EDI
	POP	ESI
	POP	EBX
	POP	EBP
	RET


SECTION _TEXT
[EXTERN	__fgetc]

SECTION _DATA
[EXTERN	__pstreams]
