// File: /workspace/github_cpp_makefile_star2_O1/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 0x8056(%rip), %rsi      # 0xb7a4
movq %rbx, %rdi
callq 0x2230
testq %rax, %rax
je 0x38bb
movq %rax, %r14
xorl %eax, %eax
movl %eax, (%rsp)
movl %eax, 0x8(%rsp)
leaq 0x20(%rsp), %r15
movq %r15, %rdi
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdx
callq 0x2330
testq %rax, %rax
je 0x3815
leaq 0x7c84(%rip), %r12      # 0xb414
leaq 0x20(%rsp), %r13
movq %rsp, %rbp
leaq 0x8(%rsp), %rbx
movq %r13, %rdi
movq %r12, %rsi
movq %rbp, %rdx
xorl %eax, %eax
callq 0x21e0
cmpl $0x1, %eax
jne 0x37c4
movl (%rsp), %eax
movq 0x10(%rsp), %rcx
cmpl 0x60(%rcx), %eax
je 0x3800
jmp 0x392a
movq %r13, %rdi
leaq 0x7cb2(%rip), %rsi      # 0xb480
movq %rbx, %rdx
xorl %eax, %eax
callq 0x21e0
cmpl $0x1, %eax
je 0x3800
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 0x3815
movq %r13, %rdi
movl $0x100, %esi            # imm = 0x100
movq %r14, %rdx
callq 0x2330
testq %rax, %rax
jne 0x379d
movslq (%rsp), %rbp
leaq (,%rbp,4), %rax
testq %rbp, %rbp
movq $-0x1, %rdi
cmovnsq %rax, %rdi
callq 0x2040
movq %rax, %r12
testq %rbp, %rbp
jle 0x38dd
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 0x389e
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 0x3871
movss %xmm1, (%r12,%rbx,4)
maxss 0xc(%rsp), %xmm1
incq %rbx
movslq (%rsp), %rbp
movaps %xmm1, %xmm0
cmpq %rbp, %rbx
jl 0x384a
jmp 0x38e0
leaq 0x7b3e(%rip), %rdi      # 0xb400
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
xorps %xmm1, %xmm1
testl %ebp, %ebp
jle 0x3936
movq 0x10(%rsp), %rax
movq 0x58(%rax), %rbx
movl %ebp, %r14d
shlq $0x2, %r14
xorl %r15d, %r15d
movss %xmm1, 0x4(%rsp)
movss (%r12,%r15), %xmm0
divss %xmm1, %xmm0
movss %xmm0, (%r12,%r15)
callq 0x3948
movss 0x4(%rsp), %xmm1
movss %xmm0, 0xc(%rbx,%r15,4)
addq $0x4, %r15
cmpq %r15, %r14
jne 0x38fd
jmp 0x3936
leaq 0x7f7f(%rip), %rdi      # 0xb8b0
callq 0x2310
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq