// File: jingdao[P]PointCloudApp/pcd.cpp
// Function: PCD::LoadFromMatrix(char const*)
PCD* PCD::LoadFromMatrix(const char* fileName) {
	FILE* f = fopen(fileName, "r");
	if (!f) {
		printf("File not found: %s\n", fileName);
		return NULL;
	}

	int dimensions = -1;
	std::vector<float> arr;
	char buf[256];
	while (fgets(buf,255,f)) {
		char* c = buf;
		while (*c) {
			if (*c<='9'&&*c>='0') {
				float f = (float) strtod(c,&c);
				arr.push_back(f);
			} else if (dimensions<0 && *c=='}') {
				dimensions = arr.size();
			} else if (*c=='}'&&*(c+1)=='}') {
				break;
			} else c++;
		}
		if (*c=='}'&&*(c+1)=='}')
			break;
	}

	fclose(f);
	int numPoints = arr.size()/dimensions;
	PCD* p = new PCD(numPoints);
	int i,j;
	for (i=0;i<numPoints;i++) {
		for (j=0;j<dimensions;j++) {
			p->float_data[i*4+j] = arr[i*dimensions+j];
		}
		p->float_data[i*4+3] = 255.0f;
	}

	return p;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x180, %rsp            # imm = 0x180
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rdi
leaq 0xdab2(%rip), %rsi      # 0x1378c
callq 0x2230
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x5d09
movq -0x10(%rbp), %rsi
leaq 0xd6bb(%rip), %rdi      # 0x133b0
movb $0x0, %al
callq 0x2050
movq $0x0, -0x8(%rbp)
jmp 0x5fb0
movl $0xffffffff, -0x1c(%rbp) # imm = 0xFFFFFFFF
leaq -0x38(%rbp), %rdi
callq 0xab10
movq -0x18(%rbp), %rdx
leaq -0x140(%rbp), %rdi
movl $0xff, %esi
callq 0x2300
movq %rax, -0x178(%rbp)
jmp 0x5d37
movq -0x178(%rbp), %rax
cmpq $0x0, %rax
je 0x5e53
leaq -0x140(%rbp), %rax
movq %rax, -0x158(%rbp)
movq -0x158(%rbp), %rax
cmpb $0x0, (%rax)
je 0x5e2d
movq -0x158(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x39, %eax
jg 0x5dce
movq -0x158(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x30, %eax
jl 0x5dce
movq -0x158(%rbp), %rdi
leaq -0x158(%rbp), %rsi
callq 0x2150
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x15c(%rbp)
leaq -0x38(%rbp), %rdi
leaq -0x15c(%rbp), %rsi
callq 0xab30
jmp 0x5db5
jmp 0x5e28
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x148(%rbp)
movl %eax, -0x14c(%rbp)
jmp 0x5fa5
cmpl $0x0, -0x1c(%rbp)
jge 0x5df1
movq -0x158(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x7d, %eax
jne 0x5df1
leaq -0x38(%rbp), %rdi
callq 0xaba0
movl %eax, -0x1c(%rbp)
jmp 0x5e26
movq -0x158(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x7d, %eax
jne 0x5e12
movq -0x158(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x7d, %eax
jne 0x5e12
jmp 0x5e2d
movq -0x158(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x158(%rbp)
jmp 0x5e26
jmp 0x5e28
jmp 0x5d56
movq -0x158(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x7d, %eax
jne 0x5e4e
movq -0x158(%rbp), %rax
movsbl 0x1(%rax), %eax
cmpl $0x7d, %eax
jne 0x5e4e
jmp 0x5e53
jmp 0x5d19
movq -0x18(%rbp), %rdi
callq 0x21f0
jmp 0x5e5e
leaq -0x38(%rbp), %rdi
callq 0xaba0
movslq -0x1c(%rbp), %rcx
xorl %edx, %edx
divq %rcx
movl %eax, -0x160(%rbp)
movl $0x78, %edi
callq 0x2200
movq %rax, -0x180(%rbp)
jmp 0x5e89
movq -0x180(%rbp), %rdi
movl -0x160(%rbp), %esi
callq 0x41e0
jmp 0x5e9d
movq -0x180(%rbp), %rax
movq %rax, -0x168(%rbp)
movl $0x0, -0x16c(%rbp)
movl -0x16c(%rbp), %eax
cmpl -0x160(%rbp), %eax
jge 0x5f8f
movl $0x0, -0x170(%rbp)
movl -0x170(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x5f54
movl -0x16c(%rbp), %eax
imull -0x1c(%rbp), %eax
addl -0x170(%rbp), %eax
movslq %eax, %rsi
leaq -0x38(%rbp), %rdi
callq 0xabc0
movss (%rax), %xmm0
movq -0x168(%rbp), %rax
movq 0x58(%rax), %rax
movl -0x16c(%rbp), %ecx
shll $0x2, %ecx
addl -0x170(%rbp), %ecx
movslq %ecx, %rcx
movss %xmm0, (%rax,%rcx,4)
movl -0x170(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x170(%rbp)
jmp 0x5ed1
movq -0x180(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x148(%rbp)
movl %eax, -0x14c(%rbp)
movl $0x78, %esi
callq 0x2210
jmp 0x5fa5
movq -0x168(%rbp), %rax
movq 0x58(%rax), %rax
movl -0x16c(%rbp), %ecx
shll $0x2, %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movss 0xd3f2(%rip), %xmm0     # 0x13368
movss %xmm0, (%rax,%rcx,4)
movl -0x16c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x16c(%rbp)
jmp 0x5eb5
movq -0x168(%rbp), %rax
movq %rax, -0x8(%rbp)
leaq -0x38(%rbp), %rdi
callq 0xabe0
jmp 0x5fb0
leaq -0x38(%rbp), %rdi
callq 0xabe0
jmp 0x5fbd
movq -0x8(%rbp), %rax
addq $0x180, %rsp            # imm = 0x180
popq %rbp
retq
movq -0x148(%rbp), %rdi
callq 0x2380
nopl (%rax)