// File: /workspace/github_cpp_makefile_star2_O3/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, %rbx
movq %rdi, 0x10(%rsp)
leaq 0x814e(%rip), %rsi      # 0xb874
movq %rbx, %rdi
callq 0x2230
testq %rax, %rax
je 0x38d8
movq %rax, %r14
xorl %eax, %eax
movl %eax, (%rsp)
movl %eax, 0x8(%rsp)
leaq 0x20(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdx
callq 0x2330
testq %rax, %rax
je 0x3906
leaq 0x7d7f(%rip), %r12      # 0xb4e4
leaq 0x20(%rsp), %r15
movq %rsp, %r13
leaq 0x7ddc(%rip), %rbp      # 0xb550
leaq 0x8(%rsp), %rbx
movq %r15, %rdi
movq %r12, %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0x21e0
cmpl $0x1, %eax
jne 0x37a0
movl (%rsp), %eax
movq 0x10(%rsp), %rcx
cmpl 0x60(%rcx), %eax
je 0x37d8
jmp 0x38fa
movq %r15, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
xorl %eax, %eax
callq 0x21e0
cmpl $0x1, %eax
je 0x37d8
movq 0x20(%rsp), %rax
movabsq $0x6373612041544144, %rcx # imm = 0x6373612041544144
xorq %rcx, %rax
movzwl 0x28(%rsp), %ecx
xorq $0x6969, %rcx           # imm = 0x6969
orq %rax, %rcx
je 0x37ed
movq %r15, %rdi
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdx
callq 0x2330
testq %rax, %rax
jne 0x3779
movl (%rsp), %eax
movslq %eax, %rbx
leaq (,%rbx,4), %rax
testl %ebx, %ebx
movq $-0x1, %rdi
cmovnsq %rax, %rdi
callq 0x2040
testl %ebx, %ebx
jle 0x3906
movq %rax, %r12
xorps %xmm0, %xmm0
xorl %ebx, %ebx
leaq 0x18(%rsp), %r13
movss %xmm0, 0xc(%rsp)
movq %r15, %rdi
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdx
callq 0x2330
movq %r15, 0x18(%rsp)
cmpl $0x0, 0x8(%rsp)
xorps %xmm1, %xmm1
jle 0x3876
xorl %ebp, %ebp
movss %xmm1, 0x4(%rsp)
movq 0x18(%rsp), %rdi
movq %r13, %rsi
callq 0x2150
movss 0x4(%rsp), %xmm1
cvtsd2ss %xmm0, %xmm0
mulss %xmm0, %xmm0
addss %xmm0, %xmm1
incl %ebp
cmpl 0x8(%rsp), %ebp
jl 0x3849
movss %xmm1, (%r12,%rbx,4)
maxss 0xc(%rsp), %xmm1
incq %rbx
movslq (%rsp), %rbp
movaps %xmm1, %xmm0
cmpq %rbp, %rbx
jl 0x3822
testl %ebp, %ebp
jle 0x3906
movq 0x10(%rsp), %rax
movq 0x58(%rax), %rbx
shlq $0x2, %rbp
xorl %r14d, %r14d
movss %xmm1, 0x4(%rsp)
movss (%r12,%r14), %xmm0
divss %xmm1, %xmm0
movss %xmm0, (%r12,%r14)
callq 0x3918
movss 0x4(%rsp), %xmm1
movss %xmm0, 0xc(%rbx,%r14,4)
addq $0x4, %r14
cmpq %r14, %rbp
jne 0x38a5
jmp 0x3906
leaq 0x7bf1(%rip), %rdi      # 0xb4d0
movq %rbx, %rsi
xorl %eax, %eax
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2050
leaq 0x807f(%rip), %rdi      # 0xb980
callq 0x2310
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq