	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	_mktime]
;
; Line 10:	{
;
_mktime:
	PUSH	EBP
	MOV	EBP,ESP
	SUB	ESP,BYTE 024H
	PUSH	EBX
	PUSH	ESI
	PUSH	EDI
	LEA	ESI,[EBP+0FFFFFFDCH]
	MOV	EDI,DWORD _days
;
; Line 15:		int i = 0;
;
	MOV	EBX,00H
;
; Line 16:		struct tm t = *timeptr;
;
	MOV	EAX,DWORD [EBP+08H]
	LEA	ECX,[ESI+00H]
	PUSH	ESI
	PUSH	EDI
	LEA	ESI,[EAX+00H]
	MOV	EDI,ECX
	CLD
	MOV	ECX,09H
	REP	MOVSD
	POP	EDI
	POP	ESI
;
; Line 17:		t.tm_year += 1900;
;
	ADD	DWORD [ESI+014H],076CH
;
; Line 19:		if (t.tm_hour<0) {
;
	CMP	DWORD [ESI+08H],BYTE 00H
	JGE	NEAR	L_1
;
; Line 20:			t.tm_hour = 23;
;
	MOV	DWORD [ESI+08H],017H
;
; Line 21:			t.tm_mday--;
;
	DEC	DWORD [ESI+0CH]
;
; Line 22:			if (t.tm_mday < 1) {
;
	CMP	DWORD [ESI+0CH],BYTE 01H
	JGE	SHORT	L_3
;
; Line 23:				t.tm_mon--;
;
	DEC	DWORD [ESI+010H]
;
; Line 24:				if (t.tm_mon <0) {
;
	CMP	DWORD [ESI+010H],BYTE 00H
	JGE	SHORT	L_5
;
; Line 25:					t.tm_mon = 11;
;
	MOV	DWORD [ESI+010H],0BH
;
; Line 26:					t.tm_year--;
;
	DEC	DWORD [ESI+014H]
;
; Line 27:				}
;
L_5:
;
; Line 28:				t.tm_mday = _monthdays[t.tm_mon];
;
	MOV	EAX,DWORD [ESI+010H]
	MOVSX	EAX,BYTE [EAX+__monthdays+00H]
	MOV	DWORD [ESI+0CH],EAX
;
; Line 29:			}
;
L_3:
;
; Line 30:		}
;
L_1:
;
; Line 31:		if (t.tm_year < 1970 || t.tm_year > 2038)
;
	CMP	DWORD [ESI+014H],07B2H
	JL	SHORT	L_9
	CMP	DWORD [ESI+014H],07F6H
	JLE	SHORT	L_7
L_9:
;
; Line 32:			return -1;
;
	MOV	EAX,0FFFFFFFFH
	JMP	L_10
L_7:
;
; Line 33:		if (!((t.tm_year - 1972)%4))
;
	MOV	EAX,DWORD [ESI+014H]
	SUB	EAX,07B4H
	AND	EAX,BYTE 03H
	JNE	SHORT	L_11
;
; Line 34:			_monthdays[1] = 29;
;
	MOV	BYTE [01H+__monthdays],01DH
	JMP	L_12
L_11:
;
; Line 36:			_monthdays[1] = 28;
;
	MOV	BYTE [01H+__monthdays],01CH
L_12:
;
; Line 37:		days = (t.tm_year - 1970)*365;
;
	MOV	EAX,DWORD [ESI+014H]
	SUB	EAX,07B2H
	IMUL	EAX,DWORD 016DH
	MOV	DWORD [EDI+00H],EAX
;
; Line 38:		days += (t.tm_year -1969)/4;
;
	MOV	EAX,DWORD [ESI+014H]
	SUB	EAX,07B1H
	JNS	SHORT	L_13
	ADD	EAX,BYTE 03H
L_13:
	SAR	EAX,02H
	ADD	DWORD [EDI+00H],EAX
	MOV	EBX,00H
	JMP	L_16
L_14:
;
; Line 40:			days += _monthdays[i];
;
	MOVSX	EAX,BYTE [EBX+__monthdays+00H]
	ADD	DWORD [EDI+00H],EAX
;
; Line 39:		for (i=0; i < t.tm_mon; i++)
;
L_15:
	INC	EBX
L_16:
	CMP	EBX,DWORD [ESI+010H]
	JL	SHORT	L_14
L_17:
;
; Line 41:		days += t.tm_mday-1;
;
	MOV	EAX,DWORD [ESI+0CH]
	DEC	EAX
	ADD	DWORD [EDI+00H],EAX
;
; Line 42:		days *=24;
;
	MOV	EAX,018H
	IMUL	EAX,DWORD [EDI+00H]
	MOV	DWORD [EDI+00H],EAX
;
; Line 43:		days += t.tm_hour;
;
	MOV	EAX,DWORD [ESI+08H]
	ADD	DWORD [EDI+00H],EAX
;
; Line 44:		days *=60;
;
	MOV	EAX,03CH
	IMUL	EAX,DWORD [EDI+00H]
	MOV	DWORD [EDI+00H],EAX
;
; Line 45:		days += t.tm_min;
;
	MOV	EAX,DWORD [ESI+04H]
	ADD	DWORD [EDI+00H],EAX
;
; Line 46:		days *=60;
;
	MOV	EAX,03CH
	IMUL	EAX,DWORD [EDI+00H]
	MOV	DWORD [EDI+00H],EAX
;
; Line 47:		days += t.tm_sec;
;
	MOV	EAX,DWORD [ESI+00H]
	ADD	DWORD [EDI+00H],EAX
;
; Line 48:		return days;
;
	MOV	EAX,DWORD [EDI+00H]
L_10:
	POP	EDI
	POP	ESI
	POP	EBX
	MOV	ESP,EBP
	POP	EBP
	RET

SECTION _DATA

__monthdays	DB	01FH,01CH,01FH,01EH,01FH,01EH,01FH,01FH,01EH,01FH,01EH,01FH
SECTION _BSS

_days	RESB	04H
