// File: /workspace/github_cpp_makefile_star2_O2/jingdao[P]PointCloudApp/pcd.cpp
// Function: PCD::loadDescriptor(char const*)
void PCD::loadDescriptor(const char* filename) {
	FILE* f = fopen(filename,"r");
	if (!f) {
		printf("File not found: %s\n", filename);
		return;
	}
	char buf[256];
	int numDescriptors=0,count=0;
	while (fgets(buf, 256, f)) {
		if (sscanf(buf, "POINTS %d", &numDescriptors) == 1) {
			if (numDescriptors!=numPoints) {
				printf("Number of descriptors does not match number of points!\n");
				return;
			}
		} else if (sscanf(buf,"COUNT %d",&count)==1) {
		} else if (strncmp(buf,"DATA ascii",10)==0) 
			break;
	}
	float val,sum,maxSum=0;
	char* c;
	float* values = new float[numDescriptors];
	for (int i=0;i<numDescriptors;i++) {
		fgets(buf,256,f);
		sum=0;
		c = buf;
		for (int j=0;j<count;j++) {
			val = strtod(c,&c);
			sum += val * val;
		}
		values[i] = sum;
		if (sum > maxSum) maxSum = sum;
	}
	for (int i=0;i<numDescriptors;i++) {
		values[i] /= maxSum;
		float_data[i * 4 + 3] = colormap(values[i]);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x7200(%rip), %rsi      # 0xa81c
movq %r15, %rdi
callq 0x2240
testq %rax, %rax
je 0x379e
movq %rax, %r14
leaq 0x8(%rsp), %r12
andl $0x0, (%r12)
leaq 0xc(%rsp), %r13
andl $0x0, (%r13)
leaq 0x20(%rsp), %r15
leaq 0x6e3c(%rip), %rbp      # 0xa48c
movq %r15, %rdi
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdx
callq 0x2340
testq %rax, %rax
je 0x36b7
movq %r15, %rdi
movq %rbp, %rsi
movq %r12, %rdx
xorl %eax, %eax
callq 0x21e0
cmpl $0x1, %eax
jne 0x3688
movl 0x8(%rsp), %eax
cmpl 0x60(%rbx), %eax
je 0x3650
jmp 0x37c0
movq %r15, %rdi
leaq 0x6e66(%rip), %rsi      # 0xa4f8
movq %r13, %rdx
xorl %eax, %eax
callq 0x21e0
cmpl $0x1, %eax
je 0x3650
movq %r15, %rdi
leaq 0x6e0a(%rip), %rsi      # 0xa4b5
pushq $0xa
popq %rdx
callq 0x2220
testl %eax, %eax
jne 0x3650
movq %rbx, 0x18(%rsp)
movslq 0x8(%rsp), %rbp
leaq (,%rbp,4), %rax
testq %rbp, %rbp
pushq $-0x1
popq %rdi
cmovnsq %rax, %rdi
callq 0x2040
movq %rax, %r12
xorps %xmm0, %xmm0
movss %xmm0, (%rsp)
xorl %ebx, %ebx
leaq 0x10(%rsp), %r13
movslq %ebp, %rax
cmpq %rax, %rbx
jge 0x3760
movq %r15, %rdi
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdx
callq 0x2340
movq %r15, 0x10(%rsp)
xorl %ebp, %ebp
xorps %xmm0, %xmm0
cmpl 0xc(%rsp), %ebp
jge 0x3747
movq 0x10(%rsp), %rdi
movq %r13, %rsi
movss %xmm0, 0x4(%rsp)
callq 0x2150
cvtsd2ss %xmm0, %xmm0
mulss %xmm0, %xmm0
movss 0x4(%rsp), %xmm1
addss %xmm0, %xmm1
movss %xmm1, 0x4(%rsp)
movss 0x4(%rsp), %xmm0
incl %ebp
jmp 0x370c
movss %xmm0, (%r12,%rbx,4)
maxss (%rsp), %xmm0
incq %rbx
movl 0x8(%rsp), %ebp
movss %xmm0, (%rsp)
jmp 0x36ea
movq 0x18(%rsp), %rax
movq 0x58(%rax), %rbx
xorl %r14d, %r14d
testl %ebp, %ebp
cmovlel %r14d, %ebp
shlq $0x2, %rbp
cmpq %r14, %rbp
je 0x37cc
movss (%r12,%r14), %xmm0
divss (%rsp), %xmm0
movss %xmm0, (%r12,%r14)
callq 0x37de
movss %xmm0, 0xc(%rbx,%r14,4)
addq $0x4, %r14
jmp 0x3776
leaq 0x6cd3(%rip), %rdi      # 0xa478
movq %r15, %rsi
xorl %eax, %eax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2050
leaq 0x7161(%rip), %rdi      # 0xa928
callq 0x2320
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq