	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	_strtoul]
;
; Line 4:	{
;
_strtoul:
	PUSH	EBP
	MOV	EBP,ESP
	SUB	ESP,BYTE 04H
	PUSH	EBX
	PUSH	ESI
	PUSH	EDI
	MOV	ESI,DWORD [EBP+08H]
	MOV	EDI,DWORD [EBP+0CH]
;
; Line 5:		int val = 0;
;
	MOV	DWORD [EBP+0FFFFFFFCH],00H
	JMP	L_1
L_3:
	INC	ESI
L_1:
;
; Line 7:		while ((_ctype[ (*s) ] & (1            ))) s++;
;
	MOVSX	EAX,BYTE [ESI+00H]
	MOVZX	EAX,BYTE [EAX+__ctype+00H]
	AND	EAX,BYTE 01H
	JNE	SHORT	L_3
L_2:
;
; Line 9:		if (*s == '0') {
;
	MOVSX	EAX,BYTE [ESI+00H]
	CMP	EAX,BYTE 030H
	JNE	NEAR	L_4
;
; Line 10:			radix = 8;
;
	MOV	DWORD [EBP+010H],08H
;
; Line 11:			s++;
;
	INC	ESI
;
; Line 12:			if (*s == 'x' || *s == 'X') {
;
	MOVSX	EAX,BYTE [ESI+00H]
	CMP	EAX,BYTE 078H
	JE	SHORT	L_8
	MOVSX	EAX,BYTE [ESI+00H]
	CMP	EAX,BYTE 058H
	JNE	SHORT	L_6
L_8:
;
; Line 13:				radix = 16;
;
	MOV	DWORD [EBP+010H],010H
;
; Line 14:				s++;
;
	INC	ESI
;
; Line 15:			}
;
L_6:
;
; Line 16:		}
;
L_4:
	JMP	L_9
L_11:
;
; Line 18:			unsigned temp = toupper(*s++)-'0';
;
	MOV	EAX,ESI
	INC	ESI
	MOVSX	EAX,BYTE [EAX+00H]
	PUSH	EAX
	CALL	_toupper
	POP	ECX
	SUB	EAX,BYTE 030H
	MOV	EBX,EAX
;
; Line 19:			if (temp >= 10)
;
	CMP	EBX,BYTE 0AH
	JB	SHORT	L_12
;
; Line 20:				temp -= 7;
;
	SUB	EBX,BYTE 07H
L_12:
;
; Line 21:			if (temp >= radix) {
;
	CMP	EBX,DWORD [EBP+010H]
	JB	SHORT	L_14
;
; Line 22:				s--;
;
	DEC	ESI
;
; Line 23:				break;
;
	JMP	L_10
L_14:
;
; Line 25:			val*= radix;
;
	MOV	EAX,DWORD [EBP+010H]
	IMUL	EAX,DWORD [EBP+0FFFFFFFCH]
	MOV	DWORD [EBP+0FFFFFFFCH],EAX
;
; Line 26:			val += temp;
;
	ADD	DWORD [EBP+0FFFFFFFCH],EBX
;
; Line 27:		}
;
L_9:
;
; Line 17:		while((_ctype[ (*s) ] & ((2             | (4             | 8            ))))) {
;
	MOVSX	EAX,BYTE [ESI+00H]
	MOVZX	EAX,BYTE [EAX+__ctype+00H]
	AND	EAX,BYTE 0EH
	JNE	NEAR	L_11
L_10:
;
; Line 28:		if (endptr)
;
	TEST	EDI,EDI
	JE	SHORT	L_16
;
; Line 29:			*endptr = s;
;
	MOV	DWORD [EDI+00H],ESI
L_16:
;
; Line 30:		return val;
;
	MOV	EAX,DWORD [EBP+0FFFFFFFCH]
L_18:
	POP	EDI
	POP	ESI
	POP	EBX
	MOV	ESP,EBP
	POP	EBP
	RET


SECTION _TEXT
[EXTERN	_toupper]

SECTION _DATA
[EXTERN	__ctype]
