// File: /workspace/github_c_makefile_star2_O2/Openvario[P]sensord/configfile_parser.c
// Function: cfgfile_parser
int cfgfile_parser(FILE *fp, t_ms5611 *static_sensor, t_ms5611 *tek_sensor, t_ams5915 *dynamic_sensor, t_ads1110 *voltage_sensor, t_ds2482 *temp_sensor, t_config *config)
{
	char line[70];
	char tmp[20],tmp2[20];
	float data;

	// is config file used ??
	if (fp)
	{
		// read whole config file
		while (! feof(fp))
		{
			// get line from config file
			if (fgets(line, 70, fp)!=NULL) {
				//fprintf(stderr, "getting line: '%69s'\n", line);

				// check if line is comment
				if((!(line[0] == '#')) && (!(line[0] == '\n')))
				{

					// get first config tag
					sscanf(line, "%19s", tmp);

					// check for output of POV_E sentence
					if (strcmp(tmp,"output_POV_E") == 0)
					{
						config->output_POV_E = 1;
						//fprintf(stderr, "OUTput POV_E enabled !! \n");
					}

					// check for output of POV_P_Q sentence
					if (strcmp(tmp,"output_POV_P_Q") == 0)
					{
						config->output_POV_P_Q = 1;
						//fprintf(stderr, "OUTput POV_P_Q enabled !! \n");
					}

					// check for output of POV_V sentence
					if (strcmp(tmp,"output_POV_V") == 0)
					{
						config->output_POV_V= 1;
						//fprintf(stderr, "OUTput POV_V enabled !! \n");
					}

					// check for output of POV_T sentence
					if (strcmp(tmp,"output_POV_T") == 0)
					{
						config->output_POV_T = 1;
						//fprintf(stderr, "OUTput POV_T enabled !! \n");
					}

				       // check for output of POV_H sentence
					if (strcmp(tmp,"output_POV_H") == 0)
					{
						config->output_POV_H = 1;
						//fprintf(stderr, "OUTput POV_H enabled !! \n");
					}

					// check for static_sensor
					if (strcmp(tmp,"static_sensor") == 0)
					{
						// get config data for static sensor
						sscanf(line, "%19s %f %f %hhx %hhu", tmp, &static_sensor->offset, &static_sensor->linearity, &static_sensor->address, &static_sensor->bus);
						static_sensor->offset*=16;
					}

					// check for temp_sensor_type
					if (strcmp(tmp,"temp_sensor_type") == 0)
					{
						// get config data for temp sensor type
						sscanf(line, "%19s %19s", tmp, tmp2);
						char *s = tmp2;
						while (*s) {
							*s = toupper((unsigned char) *s);
							s++;
						}
						if (!strcmp(tmp2,"AUTO")) temp_sensor->sensor_type=AUTO;
						else if (!strcmp(tmp2,"HTU21D")) temp_sensor->sensor_type=HTU21D;
							else if (!strcmp(tmp2,"HTU31D")) temp_sensor->sensor_type=HTU31D;
								else if (!strcmp(tmp2,"SHT85")) temp_sensor->sensor_type=SHT85;
									else if (!strcmp(tmp2,"SHT4X")) temp_sensor->sensor_type=SHT4X;
										else if (!strcmp(tmp2,"SI7021")) temp_sensor->sensor_type=SI7021;
											else if (!strcmp(tmp2,"DS18B20")) temp_sensor->sensor_type=DS18B20;
												else if (!strcmp(tmp2,"AM2321")) temp_sensor->sensor_type=AM2321;
													else fprintf(stderr, "Invalid sensor type.  Supported types are: auto, htu21d, htu31d, sht4x, sht85, si7021, ds18b20, and am2321 !!\n");
					}

					if (strcmp(tmp,"static_comp") == 0)
					{
						// get compensation data for static sensor
						sscanf(line, "%19s %lf %lf %lf",tmp, &static_sensor->comp2, &static_sensor->comp1, &static_sensor->comp0);
					}

					if (strcmp(tmp,"static_Pcomp") == 0)
					{
						// get pressure compensation data for static sensor
						sscanf(line, "%19s %lf %lf %lf",tmp, &static_sensor->Pcomp2, &static_sensor->Pcomp1, &static_sensor->Pcomp0);
					}

					// check for tek_sensor
					if (strcmp(tmp,"tek_sensor") == 0)
					{
						// get config data for tek sensor
						sscanf(line, "%19s %f %f %hhx %hhu", tmp, &tek_sensor->offset, &tek_sensor->linearity, &tek_sensor->address, &tek_sensor->bus);
						tek_sensor->offset*=16;
					}

					if (strcmp(tmp,"tek_comp") == 0)
					{
						// get compensation data for tek sensor
						sscanf (line, "%19s %lf %lf %lf",tmp, &tek_sensor->comp2, &tek_sensor->comp1, &tek_sensor->comp0);
					}

					if (strcmp(tmp,"tek_Pcomp") == 0)
					{
						// get pressure compensation data for tek sensor
						sscanf(line, "%19s %lf %lf %lf",tmp, &tek_sensor->Pcomp2, &tek_sensor->Pcomp1, &tek_sensor->Pcomp0);
					}

					// check for glitch watchdog_timing
					if (strcmp(tmp,"glitch_timing") == 0)
					{
						// get config data for glitch watchdog timer
						sscanf(line, "%19s %lf %lf %lf", tmp, &config->timing_log, &config->timing_mult, &config->timing_off);
					}

					// check for dynamic_sensor
					if (strcmp(tmp,"dynamic_sensor") == 0)
					{
						// get config data for dynamic sensor
						sscanf(line, "%19s %f %f", tmp, &dynamic_sensor->offset, &dynamic_sensor->linearity);
					}

					// check for vario config
					if (strcmp(tmp,"vario_config") == 0)
					{
						// get config data for dynamic sensor
						sscanf(line, "%19s %f", tmp, &config->vario_x_accel);
					}

					// check for voltage sensor config
					if (strcmp(tmp,"voltage_config") == 0)
					{
						// get config data for dynamic sensor
						sscanf(line, "%19s %f %f", tmp, &voltage_sensor->scale,&voltage_sensor->offset);
						voltage_sensor->scale=1.0/voltage_sensor->scale;
					}

					// check for temperature sensor config
					if (strcmp(tmp,"temp_databits") == 0) {
						// get config data for temperature sensor
						sscanf(line,"%19s %d",tmp, &temp_sensor->databits);
					}

					// check for temperature sensor sample rate
					if (strcmp(tmp,"temp_rate") == 0) {
						// get config data for temperature sensor sample rate
						sscanf (line,"%19s %f",tmp, &data);
						temp_sensor->rollover=((int)(round(80.0/data)));
						temp_sensor->maxrollover=temp_sensor->rollover+40;
						if (temp_sensor->maxrollover<100) temp_sensor->maxrollover=100;
					}

				}
			}

		}
		return(1);
	}
	else
	{
		// no config file used
		return (0);
	}
}

// Assembly:
testq %rdi, %rdi
je 0x60ac
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %r9, %r14
movq %r8, %r12
movq %rcx, %r8
movq %rdx, %rbx
movq %rdi, %rbp
movl $0x90, %eax
leaq (%rsi,%rax), %rcx
movq %rcx, 0x108(%rsp)
movl $0x8c, %ecx
leaq (%rsi,%rcx), %rdx
movq %rdx, 0xf8(%rsp)
leaq 0x4(%rsi), %rdx
movq %rdx, 0xf0(%rsp)
leaq 0x5(%rsi), %rdx
movq %rdx, 0xe8(%rsp)
leaq 0x70(%rsi), %rdx
movq %rdx, 0xe0(%rsp)
leaq 0x78(%rsi), %rdx
movq %rdx, 0xd8(%rsp)
movl $0x80, %edx
leaq (%rsi,%rdx), %rdi
movq %rdi, 0xc8(%rsp)
leaq 0x58(%rsi), %rdi
movq %rdi, 0xc0(%rsp)
leaq 0x60(%rsi), %rdi
movq %rdi, 0xb8(%rsp)
addq $0x68, %rsi
movq %rsi, 0x118(%rsp)
addq %rbx, %rax
movq %rax, 0x110(%rsp)
addq %rbx, %rcx
movq %rcx, 0x100(%rsp)
leaq 0x4(%rbx), %rax
movq %rax, 0xb0(%rsp)
leaq 0x5(%rbx), %rax
movq %rax, 0xa8(%rsp)
leaq 0x70(%rbx), %rax
movq %rax, 0xa0(%rsp)
addq %rbx, %rdx
movq %rdx, 0xd0(%rsp)
leaq 0x78(%rbx), %rax
movq %rax, 0x98(%rsp)
leaq 0x58(%rbx), %rax
movq %rax, 0x90(%rsp)
leaq 0x60(%rbx), %rax
movq %rax, 0x88(%rsp)
addq $0x68, %rbx
leaq 0x20(%r8), %rax
movq %rax, 0x80(%rsp)
addq $0x1c, %r8
movq %r8, 0x48(%rsp)
movq 0x1c0(%rsp), %rax
leaq 0x10(%rax), %rcx
movq %rcx, 0x78(%rsp)
leaq 0x18(%rax), %rcx
movq %rcx, 0x70(%rsp)
leaq 0x20(%rax), %rcx
movq %rcx, 0x68(%rsp)
addq $0x8, %rax
movq %rax, 0x60(%rsp)
leaq 0x4(%r12), %rax
movq %rax, 0x58(%rsp)
leaq 0x3c(%r9), %rax
movq %rax, 0x50(%rsp)
leaq 0x170(%rsp), %r15
movq %rbp, 0x28(%rsp)
movq %r12, 0x18(%rsp)
movq %rbx, 0x10(%rsp)
movq %rbp, %rdi
callq 0x21e0
testl %eax, %eax
jne 0x6097
leaq 0x120(%rsp), %rdi
pushq $0x46
popq %rsi
movq %rbp, %rdx
callq 0x2190
testq %rax, %rax
je 0x5a4c
movzbl 0x120(%rsp), %eax
cmpl $0xa, %eax
je 0x5a4c
cmpl $0x23, %eax
je 0x5a4c
leaq 0x120(%rsp), %rdi
leaq 0x3b97(%rip), %rsi      # 0x962c
movq %r15, %rdx
xorl %eax, %eax
callq 0x2210
movq %r15, %rdi
leaq 0x3b07(%rip), %rsi      # 0x95b0
pushq $0xd
popq %rdx
callq 0x2230
testl %eax, %eax
jne 0x5ac0
movq 0x1c0(%rsp), %rax
movb $0x1, (%rax)
movq %r15, %rdi
leaq 0x3af3(%rip), %rsi      # 0x95bd
pushq $0xf
popq %rdx
callq 0x2230
testl %eax, %eax
jne 0x5ae2
movq 0x1c0(%rsp), %rax
movb $0x1, 0x1(%rax)
movq %r15, %rdi
leaq 0x3ae0(%rip), %rsi      # 0x95cc
pushq $0xd
popq %r13
movq %r13, %rdx
callq 0x2230
testl %eax, %eax
jne 0x5b08
movq 0x1c0(%rsp), %rax
movb $0x1, 0x2(%rax)
movq %r15, %rdi
leaq 0x3ac7(%rip), %rsi      # 0x95d9
movq %r13, %rdx
callq 0x2230
testl %eax, %eax
jne 0x5b2a
movq 0x1c0(%rsp), %rax
movb $0x1, 0x3(%rax)
movq %r15, %rdi
leaq 0x3ab2(%rip), %rsi      # 0x95e6
movq %r13, %rdx
callq 0x2230
testl %eax, %eax
jne 0x5b4c
movq 0x1c0(%rsp), %rax
movb $0x1, 0x4(%rax)
movq %r15, %rdi
leaq 0x3a9d(%rip), %rsi      # 0x95f3
pushq $0xe
popq %rdx
callq 0x2230
testl %eax, %eax
jne 0x5bbb
movq 0xe8(%rsp), %rax
movq %rax, (%rsp)
leaq 0x120(%rsp), %rdi
leaq 0x3a84(%rip), %rsi      # 0x9601
movq %r15, %rdx
movq 0x108(%rsp), %r13
movq %r13, %rcx
movq 0xf8(%rsp), %r8
movq 0xf0(%rsp), %r9
xorl %eax, %eax
callq 0x2210
movss (%r13), %xmm0
mulss 0x39f4(%rip), %xmm0     # 0x95a4
movss %xmm0, (%r13)
movq 0x28(%rsp), %rbp
movq %r15, %rdi
leaq 0x3a51(%rip), %rsi      # 0x9616
pushq $0x11
popq %rdx
callq 0x2230
testl %eax, %eax
jne 0x5d0d
movq %r14, %r12
leaq 0x120(%rsp), %rdi
leaq 0x3a40(%rip), %rsi      # 0x9627
movq %r15, %rdx
leaq 0x30(%rsp), %rbx
movq %rbx, %rcx
xorl %eax, %eax
callq 0x2210
movq %rbx, %r13
movzbl (%r13), %r14d
testq %r14, %r14
je 0x5c1b
callq 0x2030
movq (%rax), %rax
movb (%rax,%r14,4), %al
movb %al, (%r13)
incq %r13
jmp 0x5bfc
movq %rbx, %rdi
leaq 0x3a0c(%rip), %rsi      # 0x9631
pushq $0x5
popq %rdx
callq 0x2230
testl %eax, %eax
je 0x5cf3
movq %rbx, %rdi
leaq 0x39f7(%rip), %rsi      # 0x9636
pushq $0x7
popq %r13
movq %r13, %rdx
callq 0x2230
testl %eax, %eax
movq %r12, %r14
je 0x5cfe
movq %rbx, %rdi
leaq 0x39dd(%rip), %rsi      # 0x963d
movq %r13, %rdx
callq 0x2230
testl %eax, %eax
movq 0x18(%rsp), %r12
movq %rbx, %rax
movq 0x10(%rsp), %rbx
je 0x602c
movq %rax, %rdi
leaq 0x39bd(%rip), %rsi      # 0x9644
pushq $0x6
popq %r13
movq %r13, %rdx
callq 0x2230
testl %eax, %eax
je 0x6036
leaq 0x30(%rsp), %rdi
leaq 0x39a3(%rip), %rsi      # 0x964a
movq %r13, %rdx
callq 0x2230
testl %eax, %eax
je 0x6040
leaq 0x30(%rsp), %rdi
leaq 0x398d(%rip), %rsi      # 0x9650
pushq $0x7
popq %r13
movq %r13, %rdx
callq 0x2230
testl %eax, %eax
je 0x604a
movabsq $0x30324238315344, %rax # imm = 0x30324238315344
cmpq %rax, 0x30(%rsp)
jne 0x6054
movb $0x4, 0x30(%r14)
jmp 0x5d0d
movq %r12, %r14
movb $0x0, 0x30(%r12)
jmp 0x5d03
movb $0x1, 0x30(%r14)
movq 0x18(%rsp), %r12
movq 0x10(%rsp), %rbx
movq %r15, %rdi
leaq 0x39b6(%rip), %rsi      # 0x96cd
pushq $0xc
popq %rdx
callq 0x2230
testl %eax, %eax
jne 0x5d54
leaq 0x120(%rsp), %rdi
leaq 0x39a7(%rip), %rsi      # 0x96d9
movq %r15, %rdx
movq 0xe0(%rsp), %rcx
movq 0xd8(%rsp), %r8
movq 0xc8(%rsp), %r9
xorl %eax, %eax
callq 0x2210
movq %r15, %rdi
leaq 0x398c(%rip), %rsi      # 0x96ea
pushq $0xd
popq %rdx
callq 0x2230
testl %eax, %eax
jne 0x5d9b
leaq 0x120(%rsp), %rdi
leaq 0x3960(%rip), %rsi      # 0x96d9
movq %r15, %rdx
movq 0xc0(%rsp), %rcx
movq 0xb8(%rsp), %r8
movq 0x118(%rsp), %r9
xorl %eax, %eax
callq 0x2210
movq %r15, %rdi
leaq 0x3952(%rip), %rsi      # 0x96f7
pushq $0xb
popq %rdx
callq 0x2230
testl %eax, %eax
jne 0x5e0a
movq 0xa8(%rsp), %rax
movq %rax, (%rsp)
leaq 0x120(%rsp), %rdi
leaq 0x3835(%rip), %rsi      # 0x9601
movq %r15, %rdx
movq 0x110(%rsp), %r13
movq %r13, %rcx
movq 0x100(%rsp), %r8
movq 0xb0(%rsp), %r9
xorl %eax, %eax
callq 0x2210
movss (%r13), %xmm0
mulss 0x37a5(%rip), %xmm0     # 0x95a4
movss %xmm0, (%r13)
movq 0x28(%rsp), %rbp
movq %r15, %rdi
leaq 0x38ee(%rip), %rsi      # 0x9702
pushq $0x9
popq %rdx
callq 0x2230
testl %eax, %eax
jne 0x5e51
leaq 0x120(%rsp), %rdi
leaq 0x38aa(%rip), %rsi      # 0x96d9
movq %r15, %rdx
movq 0xa0(%rsp), %rcx
movq 0x98(%rsp), %r8
movq 0xd0(%rsp), %r9
xorl %eax, %eax
callq 0x2210
movq %r15, %rdi
leaq 0x38b0(%rip), %rsi      # 0x970b
pushq $0xa
popq %rdx
callq 0x2230
testl %eax, %eax
jne 0x5e93
leaq 0x120(%rsp), %rdi
leaq 0x3863(%rip), %rsi      # 0x96d9
movq %r15, %rdx
movq 0x90(%rsp), %rcx
movq 0x88(%rsp), %r8
movq %rbx, %r9
xorl %eax, %eax
callq 0x2210
movq %r15, %rdi
leaq 0x3878(%rip), %rsi      # 0x9715
pushq $0xe
popq %rdx
callq 0x2230
testl %eax, %eax
jne 0x5ed1
leaq 0x120(%rsp), %rdi
leaq 0x3821(%rip), %rsi      # 0x96d9
movq %r15, %rdx
movq 0x78(%rsp), %rcx
movq 0x70(%rsp), %r8
movq 0x68(%rsp), %r9
xorl %eax, %eax
callq 0x2210
movq %r15, %rdi
leaq 0x3848(%rip), %rsi      # 0x9723
pushq $0xf
popq %rdx
callq 0x2230
testl %eax, %eax
jne 0x5f0d
leaq 0x120(%rsp), %rdi
leaq 0x383c(%rip), %rsi      # 0x9732
movq %r15, %rdx
movq 0x80(%rsp), %rcx
movq 0x48(%rsp), %r8
xorl %eax, %eax
callq 0x2210
movq %r15, %rdi
leaq 0x3826(%rip), %rsi      # 0x973d
pushq $0xd
popq %rdx
callq 0x2230
testl %eax, %eax
jne 0x5f41
leaq 0x120(%rsp), %rdi
leaq 0x3818(%rip), %rsi      # 0x974a
movq %r15, %rdx
movq 0x60(%rsp), %rcx
xorl %eax, %eax
callq 0x2210
movq %r15, %rdi
leaq 0x3807(%rip), %rsi      # 0x9752
pushq $0xf
popq %rdx
callq 0x2230
testl %eax, %eax
jne 0x5f8c
leaq 0x120(%rsp), %rdi
leaq 0x37cc(%rip), %rsi      # 0x9732
movq %r15, %rdx
movq %r12, %rcx
movq 0x58(%rsp), %r8
xorl %eax, %eax
callq 0x2210
movss 0x2608(%rip), %xmm0     # 0x8588
divss (%r12), %xmm0
movss %xmm0, (%r12)
movq %r15, %rdi
leaq 0x37cb(%rip), %rsi      # 0x9761
pushq $0xe
popq %rdx
callq 0x2230
testl %eax, %eax
jne 0x5fc0
leaq 0x120(%rsp), %rdi
leaq 0x37be(%rip), %rsi      # 0x976f
movq %r15, %rdx
movq 0x50(%rsp), %rcx
xorl %eax, %eax
callq 0x2210
movq %r15, %rdi
leaq 0x37ad(%rip), %rsi      # 0x9777
pushq $0xa
popq %rdx
callq 0x2230
testl %eax, %eax
jne 0x5a4c
leaq 0x120(%rsp), %rdi
leaq 0x3761(%rip), %rsi      # 0x974a
movq %r15, %rdx
leaq 0x24(%rsp), %rcx
xorl %eax, %eax
callq 0x2210
cvtss2sd 0x24(%rsp), %xmm1
movsd 0x35a2(%rip), %xmm0     # 0x95a8
divsd %xmm1, %xmm0
callq 0x2050
cvttsd2si %xmm0, %eax
movl %eax, 0x48(%r14)
leal 0x28(%rax), %ecx
cmpl $0x3c, %eax
pushq $0x64
popq %rax
cmovll %eax, %ecx
movl %ecx, 0x4c(%r14)
jmp 0x5a4c
movb $0x2, 0x30(%r14)
jmp 0x5d0d
movb $0x7, 0x30(%r14)
jmp 0x5d0d
movb $0x6, 0x30(%r14)
jmp 0x5d0d
movb $0x3, 0x30(%r14)
jmp 0x5d0d
leaq 0x30(%rsp), %rdi
leaq 0x35f7(%rip), %rsi      # 0x9657
movq %r13, %rdx
callq 0x2230
testl %eax, %eax
jne 0x6076
movb $0x5, 0x30(%r14)
jmp 0x5d0d
movq 0x6f7b(%rip), %rax      # 0xcff8
movq (%rax), %rcx
leaq 0x35d7(%rip), %rdi      # 0x965e
pushq $0x6e
popq %rsi
pushq $0x1
popq %rdx
callq 0x22b0
jmp 0x5d0d
pushq $0x1
popq %rax
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
retq
nop