

.intel_syntax noprefix

.global GetType
.global GetTypeId

.extern GetResWName
.extern SizeFromRegister
.extern EvalOperand
.extern tstrcat
.extern tstrcpy
.extern tstrlen


.SECTION .text
	.ALIGN	16

GetType:
	mov	qword ptr [rsp+0x20], r9
	push	rsi
	push	rdi
	push	rbx
	push	rbp
	mov	rbp, rsp
	sub	rsp, 40
	mov	rdi, rcx
	mov	rbx, rdx
	mov	rdx, r8
	test	rdx, rdx
	jz	$_002
	cmp	rdi, rdx
	jz	$_001
	mov	rcx, rdi
	call	tstrcpy@PLT
$_001:	mov	rcx, rdi
	call	tstrlen@PLT
	add	rdi, rax
	jmp	$_003

$_002:	mov	byte ptr [rdi], 0
$_003:	mov	eax, dword ptr [rbx+0x3C]
	test	eax, eax
	jz	$_004
	cmp	eax, 3
	jnz	$_006
$_004:	lea	rdx, [DS0000+rip]
	test	eax, eax
	jnz	$_005
	lea	rdx, [DS0001+rip]
$_005:	mov	rcx, rdi
	call	tstrcpy@PLT
	mov	eax, 1
	jmp	$_057

$_006:	cmp	eax, 2
	jne	$_026
	test	byte ptr [rbx+0x40], 0x01
	jne	$_026
	mov	rcx, qword ptr [rbx+0x18]
	mov	ecx, dword ptr [rcx+0x4]
	call	SizeFromRegister@PLT
	xor	ecx, ecx
	cmp	eax, 16
	jc	$_012
	jmp	$_010

$_007:	mov	ecx, 283
	jmp	$_011

$_008:	mov	ecx, 286
	jmp	$_011

$_009:	mov	ecx, 288
	jmp	$_011

$_010:	cmp	eax, 16
	jz	$_007
	cmp	eax, 32
	jz	$_008
	cmp	eax, 64
	jz	$_009
$_011:	jmp	$_025

$_012:	cmp	byte ptr [rbx+0x44], 192
	jz	$_019
	test	byte ptr [rbx+0x44], 0x40
	jz	$_019
	jmp	$_017

$_013:	mov	ecx, 270
	jmp	$_018

$_014:	mov	ecx, 272
	jmp	$_018

$_015:	mov	ecx, 275
	jmp	$_018

$_016:	mov	ecx, 279
	jmp	$_018

$_017:	cmp	eax, 1
	jz	$_013
	cmp	eax, 2
	jz	$_014
	cmp	eax, 4
	jz	$_015
	cmp	eax, 8
	jz	$_016
$_018:	jmp	$_025

$_019:	jmp	$_024

$_020:	mov	ecx, 269
	jmp	$_025

$_021:	mov	ecx, 271
	jmp	$_025

$_022:	mov	ecx, 274
	jmp	$_025

$_023:	mov	ecx, 278
	jmp	$_025

$_024:	cmp	eax, 1
	jz	$_020
	cmp	eax, 2
	jz	$_021
	cmp	eax, 4
	jz	$_022
	cmp	eax, 8
	jz	$_023
$_025:	mov	rdx, rdi
	call	GetResWName@PLT
	mov	eax, 1
	jmp	$_057

$_026:	cmp	dword ptr [rbp+0x40], 0
	jz	$_027
	mov	rdx, rdi
	mov	ecx, 335
	call	GetResWName@PLT
	add	rdi, 3
	jmp	$_028

$_027:	cmp	eax, 1
	jz	$_028
	cmp	eax, 2
	jz	$_028
	xor	eax, eax
	jmp	$_057

$_028:	mov	rdx, qword ptr [rbx+0x50]
	mov	rsi, qword ptr [rbx+0x60]
	cmp	qword ptr [rbx+0x58], 0
	jz	$_029
	mov	rdx, qword ptr [rbx+0x58]
$_029:	test	rdx, rdx
	jz	$_030
	cmp	byte ptr [rdx+0x1D], 0
	jnz	$_031
$_030:	mov	rdx, rdi
	mov	ecx, 335
	call	GetResWName@PLT
	mov	eax, 1
	jmp	$_057

$_031:	cmp	byte ptr [rdx+0x1D], 6
	jne	$_037
	mov	rcx, qword ptr [rbx+0x50]
	mov	eax, dword ptr [rbx+0x3C]
	test	rsi, rsi
	jz	$_033
	test	rcx, rcx
	jnz	$_033
	cmp	eax, 1
	jnz	$_032
	mov	rdx, rdi
	mov	ecx, 335
	call	GetResWName@PLT
	add	rdi, 3
$_032:	mov	rdx, qword ptr [rsi+0x8]
	mov	rcx, rdi
	call	tstrcpy@PLT
	mov	eax, 1
	jmp	$_057

$_033:	mov	rbx, rcx
	test	rbx, rbx
	jz	$_037
	cmp	byte ptr [rbx+0x1E], 196
	jnz	$_034
	mov	rbx, qword ptr [rbx+0x28]
$_034:	cmp	qword ptr [rbx+0x50], 0
	jz	$_036
	cmp	byte ptr [rbx+0x1E], 195
	jz	$_035
	cmp	byte ptr [rbx+0x4A], 196
	jnz	$_036
$_035:	mov	rbx, qword ptr [rbx+0x50]
$_036:	cmp	byte ptr [rdx+0x1E], 193
	jnz	$_037
	cmp	word ptr [rbx+0x6E], 1
	jnz	$_037
	mov	rsi, qword ptr [rdx+0x8]
	mov	rdx, qword ptr [rbx+0x8]
	mov	rcx, rdi
	call	tstrcpy@PLT
	lea	rdx, [DS0002+rip]
	mov	rcx, rdi
	call	tstrcat@PLT
	mov	rdx, rsi
	mov	rcx, rdi
	call	tstrcat@PLT
	mov	eax, 1
	jmp	$_057

$_037:	mov	rbx, rdx
	cmp	byte ptr [rbx+0x1E], 196
	jnz	$_038
	cmp	qword ptr [rbx+0x28], 0
	jz	$_038
	mov	rbx, qword ptr [rbx+0x28]
$_038:	cmp	qword ptr [rbx+0x50], 0
	jz	$_041
	cmp	byte ptr [rbx+0x1E], 195
	jz	$_039
	cmp	byte ptr [rbx+0x4A], 196
	jnz	$_041
$_039:	cmp	byte ptr [rbx+0x1E], 195
	jnz	$_040
	mov	rdx, rdi
	mov	ecx, 335
	call	GetResWName@PLT
	add	rdi, 3
	cmp	byte ptr [rbx+0x49], 2
	jnz	$_040
	mov	rdx, rdi
	mov	ecx, 335
	call	GetResWName@PLT
	add	rdi, 3
$_040:	mov	rbx, qword ptr [rbx+0x50]
$_041:	cmp	byte ptr [rbx+0x1D], 7
	jnz	$_042
	cmp	word ptr [rbx+0x6E], 1
	jnz	$_042
	mov	rdx, qword ptr [rbx+0x8]
	mov	rcx, rdi
	call	tstrcpy@PLT
	mov	eax, 1
	jmp	$_057

$_042:	test	rsi, rsi
	jz	$_043
	cmp	byte ptr [rsi+0x1D], 7
	jnz	$_043
	cmp	word ptr [rsi+0x6E], 1
	jnz	$_043
	mov	rdx, qword ptr [rsi+0x8]
	mov	rcx, rdi
	call	tstrcpy@PLT
	mov	eax, 1
	jmp	$_057

$_043:	mov	al, byte ptr [rbx+0x1D]
	cmp	al, 1
	jz	$_044
	cmp	al, 2
	jz	$_044
	cmp	al, 5
	jz	$_044
	cmp	al, 6
	jz	$_044
	cmp	al, 7
	jne	$_056
$_044:	mov	cl, byte ptr [rbx+0x1E]
	jmp	$_053

	mov	eax, 269
	jmp	$_055

	mov	eax, 270
	jmp	$_055

	mov	eax, 271
	jmp	$_055

	mov	eax, 272
	jmp	$_055

	mov	eax, 273
	jmp	$_055

	mov	eax, 274
	jmp	$_055

	mov	eax, 275
	jmp	$_055

	mov	eax, 276
	jmp	$_055

	mov	eax, 277
	jmp	$_055

	mov	eax, 278
	jmp	$_055

	mov	eax, 279
	jmp	$_055

	mov	eax, 280
	jmp	$_055

	mov	eax, 281
	jmp	$_055

	mov	eax, 282
	jmp	$_055

	mov	eax, 283
	jmp	$_055

$_045:	mov	eax, 284
	jmp	$_055

	mov	eax, 285
	jmp	$_055

	mov	eax, 286
	jmp	$_055

	mov	eax, 288
	jmp	$_055

$_046:	mov	eax, 605
	jmp	$_055

$_047:	mov	eax, 290
	jmp	$_055

$_048:	mov	eax, 291
	jmp	$_055

$_049:	mov	rdx, rdi
	mov	ecx, 335
	call	GetResWName@PLT
	add	rdi, 3
	mov	cl, byte ptr [rbx+0x1E]
	cmp	byte ptr [rbx+0x49], 1
	jnz	$_051
	cmp	cl, byte ptr [rbx+0x4A]
	jz	$_051
	cmp	byte ptr [rbx+0x4A], 192
	jz	$_050
	mov	cl, byte ptr [rbx+0x4A]
	jmp	$_053

$_050:	jmp	$_052

$_051:	cmp	byte ptr [rbx+0x49], 2
	jnz	$_052
	mov	rdx, rdi
	mov	ecx, 335
	call	GetResWName@PLT
$_052:	mov	eax, 1
	jmp	$_057

	jmp	$_055

LC005A: mov	eax, 1
	jmp	$_057

	jmp	$_055

$_053:	cmp	cl, 71
	ja	$_054
	movsx	r10, cl
	lea	r11, [LC005B+rip]
	movzx	r10, byte ptr [r11+r10+0x26]
	movzx	r10, word ptr [r11+r10*2]
	lea	r11, [LC005A+rip]
	sub	r11, r10
	jmp	r11

$_054:	cmp	cl, 79
	je	$_045
	cmp	cl, 128
	je	$_046
	cmp	cl, 129
	je	$_047
	cmp	cl, 130
	je	$_048
	cmp	cl, 195
	je	$_049
	jmp	LC005A

$_055:	mov	rdx, rdi
	mov	ecx, eax
	call	GetResWName@PLT
	mov	eax, 1
	jmp	$_057

$_056:	xor	eax, eax
$_057:	leave
	pop	rbx
	pop	rdi
	pop	rsi
	ret

GetTypeId:
	mov	qword ptr [rsp+0x8], rcx
	mov	qword ptr [rsp+0x10], rdx
	push	rsi
	push	rdi
	push	rbx
	push	rbp
	mov	rbp, rsp
	sub	rsp, 424
	mov	rbx, rdx
	jmp	$_060

$_058:	cmp	byte ptr [rbx], 8
	jnz	$_059
	cmp	dword ptr [rbx+0x8], 1684939886
	jnz	$_059
	mov	rax, qword ptr [rbx+0x10]
	mov	byte ptr [rax], 63
	jmp	$_061

$_059:	add	rbx, 32
$_060:	cmp	byte ptr [rbx], 0
	jnz	$_058
$_061:	cmp	byte ptr [rbx], 0
	jnz	$_062
	cmp	byte ptr [rbx+0x20], 40
	jnz	$_062
	add	rbx, 32
	jmp	$_064

$_062:	cmp	byte ptr [rbx], 0
	jz	$_063
	add	rbx, 32
	jmp	$_064

$_063:	mov	rbx, qword ptr [rbp+0x30]
$_064:	cmp	byte ptr [rbx], 40
	jz	$_065
	xor	eax, eax
	jmp	$_079

$_065:	add	rbx, 32
	mov	byte ptr [rbp-0x170], 0
	cmp	byte ptr [rbx+0x20], 44
	jnz	$_066
	mov	rdx, qword ptr [rbx+0x10]
	lea	rcx, [rbp-0x170]
	call	tstrcpy@PLT
	add	rbx, 64
$_066:	xor	esi, esi
	cmp	byte ptr [rbx], 7
	jnz	$_067
	cmp	dword ptr [rbx+0x4], 339
	jnz	$_067
	add	rbx, 32
	inc	esi
$_067:	mov	rax, rbx
	sub	rax, qword ptr [rbp+0x30]
	mov	ecx, 32
	xor	edx, edx
	div	ecx
	mov	ecx, eax
	mov	dword ptr [rbp-0x4], eax
	xor	eax, eax
	mov	edx, 1
$_068:	cmp	byte ptr [rbx], 0
	jz	$_074
	jmp	$_072

$_069:	inc	edx
	test	eax, eax
	jnz	$_070
	cmp	byte ptr [rbx-0x20], 8
	jnz	$_070
	mov	eax, ecx
$_070:	jmp	$_073

$_071:	dec	edx
	jnz	$_073
	jmp	$_074

$_072:	cmp	byte ptr [rbx], 40
	jz	$_069
	cmp	byte ptr [rbx], 41
	jz	$_071
$_073:	add	rbx, 32
	inc	ecx
	jmp	$_068

$_074:	mov	edi, ecx
	test	eax, eax
	jz	$_076
	mov	ecx, eax
	mov	byte ptr [rsp+0x20], 0
	lea	r9, [rbp-0x70]
	mov	r8d, ecx
	mov	rdx, qword ptr [rbp+0x30]
	lea	rcx, [rbp-0x4]
	call	EvalOperand@PLT
	cmp	eax, -1
	jnz	$_075
	xor	eax, eax
	jmp	$_079

$_075:	xor	eax, eax
	cmp	byte ptr [rbp-0x2C], 129
	jnz	$_076
	inc	eax
$_076:	test	eax, eax
	jnz	$_077
	mov	byte ptr [rsp+0x20], 0
	lea	r9, [rbp-0x70]
	mov	r8d, edi
	mov	rdx, qword ptr [rbp+0x30]
	lea	rcx, [rbp-0x4]
	call	EvalOperand@PLT
	cmp	eax, -1
	jnz	$_077
	xor	eax, eax
	jmp	$_079

$_077:	xor	ecx, ecx
	cmp	byte ptr [rbp-0x170], 0
	jz	$_078
	lea	rcx, [rbp-0x170]
$_078:	mov	r9d, esi
	mov	r8, rcx
	lea	rdx, [rbp-0x70]
	mov	rcx, qword ptr [rbp+0x28]
	call	GetType
$_079:	leave
	pop	rbx
	pop	rdi
	pop	rsi
	ret


.SECTION .data
	.ALIGN	16

DS0000:
	.byte  0x66, 0x6C, 0x74, 0x00

DS0001:
	.byte  0x69, 0x6D, 0x6D, 0x00

DS0002:
	.byte  0x2E, 0x00

LC005B:
	.byte  0x24, 0x01, 0x1A, 0x01, 0x10, 0x01, 0x06, 0x01
	.byte  0xFC, 0x00, 0xF2, 0x00, 0xE8, 0x00, 0xDE, 0x00
	.byte  0xD4, 0x00, 0xCA, 0x00, 0xC0, 0x00, 0xB6, 0x00
	.byte  0xAC, 0x00, 0xA2, 0x00, 0x98, 0x00, 0x84, 0x00
	.byte  0x7A, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x02
	.byte  0x12, 0x05, 0x12, 0x08, 0x12, 0x09, 0x12, 0x0C
	.byte  0x12, 0x12, 0x12, 0x12, 0x12, 0x0E, 0x12, 0x12
	.byte  0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12
	.byte  0x12, 0x12, 0x12, 0x12, 0x12, 0x10, 0x12, 0x04
	.byte  0x12, 0x07, 0x12, 0x12, 0x12, 0x0B, 0x12, 0x0D
	.byte  0x12, 0x12, 0x12, 0x12, 0x12, 0x0F, 0x12, 0x12
	.byte  0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12
	.byte  0x12, 0x12, 0x12, 0x12, 0x12, 0x11, 0x01, 0x03
	.byte  0x12, 0x06, 0x12, 0x12, 0x12, 0x0A


.att_syntax prefix
