// File: /workspace/github_cpp_makefile_star2_O2/halsafar[P]libtmx-parser/main.cpp
// Function: main
int main()
{
	printf("tmxparser::main()\n");

	tmxparser::TmxReturn error;
	tmxparser::TmxMap map;

	// test from file
	error = tmxparser::parseFromFile("./test_files/test_xml_level.tmx", &map, "test/textures/");

	// test from memory
	/*FILE* fp;
	fp = fopen("example.tmx", "rb");
	fseek( fp, 0, SEEK_SET );
	fgetc( fp );
	fseek( fp, 0, SEEK_END );
	size_t size = ftell( fp );
	fseek( fp, 0, SEEK_SET );

	char* charBuffer = new char[size+1];
	size_t read = fread( charBuffer, 1, size, fp );

	t = tmxparser::parseFromMemory(charBuffer, size, &map);*/

	if (!error)
	{
		printTmxMapData(&map);

		tmxparser::TmxRect rect;
		rect.u = 0; rect.v = 0; rect.u2 = 0; rect.v2 = 0;
		for (auto it : map.layerCollection[0].tiles)
		{
			tmxparser::calculateTileCoordinatesUV(map.tilesetCollection[it.tilesetIndex], it.tileFlatIndex, 0.5f, true, rect);
			printf("Tileset[%u]@Tile[%u]=Rect( (%f, %f)->(%f, %f) )\n", it.tilesetIndex, it.tileFlatIndex, rect.u, rect.v, rect.u2, rect.v2);
		}
	}
	else
	{
		printf("error parsing file");
	}

	return error;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x158, %rsp            # imm = 0x158
leaq 0x5d9a(%rip), %rdi      # 0x10922
callq 0x4330
leaq -0x170(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
movb %cl, (%rax)
leaq -0x138(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq -0x118(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq -0xd8(%rbp), %rax
movq %rax, -0x30(%rax)
movq $0x1, -0x28(%rax)
xorps %xmm0, %xmm0
movups %xmm0, -0x20(%rax)
movl $0x3f800000, -0x10(%rax) # imm = 0x3F800000
movups %xmm0, -0x8(%rax)
movups %xmm0, 0x8(%rax)
movups %xmm0, 0x18(%rax)
movups %xmm0, 0x28(%rax)
movups %xmm0, 0x38(%rax)
movups %xmm0, 0x48(%rax)
movups %xmm0, 0x58(%rax)
leaq 0x5ca6(%rip), %rsi      # 0x108af
leaq -0x50(%rbp), %rdi
leaq -0x2a(%rbp), %rdx
callq 0x40d0
leaq 0x5cb2(%rip), %rsi      # 0x108cf
leaq -0x70(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x40d0
leaq -0x50(%rbp), %rdi
leaq -0x180(%rbp), %rsi
leaq -0x70(%rbp), %rdx
callq 0x460c
movl %eax, %ebx
leaq -0x70(%rbp), %rdi
callq 0x4478
leaq -0x50(%rbp), %rdi
callq 0x4478
testl %ebx, %ebx
je 0xac69
leaq 0x5cb2(%rip), %rdi      # 0x1090f
xorl %eax, %eax
callq 0x4050
jmp 0xacf9
movl %ebx, -0x30(%rbp)
leaq -0x180(%rbp), %rbx
movq %rbx, %rdi
callq 0xaa4f
xorps %xmm0, %xmm0
leaq -0x50(%rbp), %rax
movaps %xmm0, (%rax)
movq 0xc8(%rbx), %rax
movq 0x68(%rax), %r14
movq 0x70(%rax), %r15
leaq 0x5c43(%rip), %r12      # 0x108de
cmpq %r15, %r14
je 0xacf6
movl 0x4(%r14), %ebx
movl 0x8(%r14), %r13d
imulq $0x108, %rbx, %rdi      # imm = 0x108
addq -0xd0(%rbp), %rdi
movl %r13d, %esi
movss 0x5917(%rip), %xmm0     # 0x105d8
pushq $0x1
popq %rdx
leaq -0x50(%rbp), %rcx
callq 0x67de
cvtss2sd -0x50(%rbp), %xmm0
cvtss2sd -0x4c(%rbp), %xmm1
cvtss2sd -0x48(%rbp), %xmm2
cvtss2sd -0x44(%rbp), %xmm3
movq %r12, %rdi
movl %ebx, %esi
movl %r13d, %edx
movb $0x4, %al
callq 0x4050
addq $0x10, %r14
jmp 0xac9b
movl -0x30(%rbp), %ebx
leaq -0x180(%rbp), %rdi
callq 0xad4e
movl %ebx, %eax
addq $0x158, %rsp            # imm = 0x158
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x70(%rbp), %rdi
callq 0x4478
jmp 0xad2a
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x4478
jmp 0xad3a
jmp 0xad37
movq %rax, %rbx
leaq -0x180(%rbp), %rdi
callq 0xad4e
movq %rbx, %rdi
callq 0x43d0