// File: /workspace/github_c_makefile_star2_O0/Openvario[P]sensord/main.c
// Function: NMEA_message_handler
static int NMEA_message_handler(int sock)
{
	// some local variables
	float vario;
	int sock_err = 0;
	static int nmea_counter = 1;
	int result;
	char s[256];

	if (temp_sensor.temp_valid) {
		// Compose POV NMEA sentences
		result=Compose_Temperature_POV(&s[0], temp_sensor.temperature);
		// fprintf(stderr, "temp: %f\n",temp_sensor.temperature);
		// // NMEA sentence valid ?? Otherwise print some error !!
		if (result != 1) fprintf(stderr, "POV Temperature NMEA Result = %d\n",result);
		// Send NMEA string via socket to XCSoar send complete sentence including terminating '\0'
		if ((sock_err = write(sock, s, strlen(s))) < 0) fprintf(stderr, "send failed %s\n",s);
	}
	if (temp_sensor.humidity_valid) {
		// Compose POV NMEA sentences
		result=Compose_Humidity_POV(&s[0], temp_sensor.humidity);
		// fprintf(stderr, "humid: %f\n",temp_sensor.humidity);
		// NMEA sentence valid ?? Otherwise print some error !!
		if (result != 1) fprintf(stderr, "POV Humidity NMEA Result = %d\n",result);
		// Send NMEA string via socket to XCSoar send complete sentence including terminating '\0'
		if ((sock_err = write(sock, s, strlen(s))) < 0) fprintf(stderr, "send failed %s\n",s);
	}

	if ((nmea_counter++)%4==0)
	{
		// Compute Vario
		vario = ComputeVario(vkf.x_abs_, vkf.x_vel_);

		if (config.output_POV_P_Q == 1)
		{
			// Compose POV slow NMEA sentences
			result = Compose_Pressure_POV_slow(&s[0], p_static/100, p_dynamic*100);
			// NMEA sentence valid ?? Otherwise print some error !!
			if (result != 1)
			{
				fprintf(stderr, "POV slow NMEA Result = %d\n",result);
			}
			// Send NMEA string via socket to XCSoar
			if ((sock_err = write(sock, s, strlen(s))) < 0)
			{
			  fprintf(stderr, "send failed %s\n",s);
				return sock_err;
			}
		}

		if (config.output_POV_E == 1)
		{
			if (tep_sensor.valid != 1)
			{
				vario = 99;
			}
			// Compose POV slow NMEA sentences
			result = Compose_Pressure_POV_fast(&s[0], vario);
			// NMEA sentence valid ?? Otherwise print some error !!
			if (result != 1)
			{
				fprintf(stderr, "POV fast NMEA Result = %d\n",result);
			}
			// Send NMEA string via socket to XCSoar
			if ((sock_err = write(sock, s, strlen(s))) < 0)
			{
				fprintf(stderr, "send failed\n");
				return sock_err;
			}
		}

		if (config.output_POV_V == 1 && voltage_sensor.present)
		{

			// Compose POV slow NMEA sentences
			result = Compose_Voltage_POV(&s[0], voltage_sensor.voltage_converted);

			// NMEA sentence valid ?? Otherwise print some error !!
			if (result != 1)
			{
				fprintf(stderr, "POV voltage NMEA Result = %d\n",result);
			}
			// Send NMEA string via socket to XCSoar
			if ((sock_err = write(sock, s, strlen(s))) < 0)
			{
			  fprintf(stderr, "send failed %s\n",s);
				return sock_err;
			}
		}
	}

	return(sock_err);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x170, %rsp            # imm = 0x170
movl %edi, -0x8(%rbp)
movl $0x0, -0x10(%rbp)
cmpb $0x0, 0x9612(%rip)      # 0xf38e
je 0x5e1b
leaq -0x120(%rbp), %rdi
movss 0x95f3(%rip), %xmm0     # 0xf384
callq 0x6510
movl %eax, -0x14(%rbp)
cmpl $0x1, -0x14(%rbp)
je 0x5dba
movq 0x9252(%rip), %rax      # 0xeff8
movq (%rax), %rdi
movl -0x14(%rbp), %edx
leaq 0x6175(%rip), %rsi      # 0xbf28
movb $0x0, %al
callq 0x21d0
movl -0x8(%rbp), %eax
movl %eax, -0x12c(%rbp)
leaq -0x120(%rbp), %rax
movq %rax, -0x128(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x20d0
movl -0x12c(%rbp), %edi
movq -0x128(%rbp), %rsi
movq %rax, %rdx
callq 0x20a0
movl %eax, -0x10(%rbp)
cmpl $0x0, %eax
jge 0x5e19
movq 0x91f7(%rip), %rax      # 0xeff8
movq (%rax), %rdi
leaq -0x120(%rbp), %rdx
leaq 0x6138(%rip), %rsi      # 0xbf4a
movb $0x0, %al
callq 0x21d0
jmp 0x5e1b
cmpb $0x0, 0x956d(%rip)      # 0xf38f
je 0x5ec1
leaq -0x120(%rbp), %rdi
movss 0x9551(%rip), %xmm0     # 0xf388
callq 0x65e0
movl %eax, -0x14(%rbp)
cmpl $0x1, -0x14(%rbp)
je 0x5e60
movq 0x91ac(%rip), %rax      # 0xeff8
movq (%rax), %rdi
movl -0x14(%rbp), %edx
leaq 0x6101(%rip), %rsi      # 0xbf5a
movb $0x0, %al
callq 0x21d0
movl -0x8(%rbp), %eax
movl %eax, -0x13c(%rbp)
leaq -0x120(%rbp), %rax
movq %rax, -0x138(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x20d0
movl -0x13c(%rbp), %edi
movq -0x138(%rbp), %rsi
movq %rax, %rdx
callq 0x20a0
movl %eax, -0x10(%rbp)
cmpl $0x0, %eax
jge 0x5ebf
movq 0x9151(%rip), %rax      # 0xeff8
movq (%rax), %rdi
leaq -0x120(%rbp), %rdx
leaq 0x6092(%rip), %rsi      # 0xbf4a
movb $0x0, %al
callq 0x21d0
jmp 0x5ec1
movl 0x92dd(%rip), %eax      # 0xf1a4
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, 0x92d2(%rip)      # 0xf1a4
movl $0x4, %ecx
cltd
idivl %ecx
cmpl $0x0, %edx
jne 0x6150
movss 0x94ed(%rip), %xmm0     # 0xf3d8
movss 0x94e9(%rip), %xmm1     # 0xf3dc
callq 0x7540
movss %xmm0, -0xc(%rbp)
movsbl 0x9435(%rip), %eax      # 0xf339
cmpl $0x1, %eax
jne 0x5fcd
leaq -0x120(%rbp), %rdi
movss 0x94b4(%rip), %xmm0     # 0xf3d0
movss 0x56e8(%rip), %xmm1     # 0xb60c
divss %xmm1, %xmm0
movss 0x56dc(%rip), %xmm1     # 0xb60c
mulss 0x949c(%rip), %xmm1     # 0xf3d4
callq 0x61d0
movl %eax, -0x14(%rbp)
cmpl $0x1, -0x14(%rbp)
je 0x5f61
movq 0x90ab(%rip), %rax      # 0xeff8
movq (%rax), %rdi
movl -0x14(%rbp), %edx
leaq 0x601f(%rip), %rsi      # 0xbf79
movb $0x0, %al
callq 0x21d0
movl -0x8(%rbp), %eax
movl %eax, -0x14c(%rbp)
leaq -0x120(%rbp), %rax
movq %rax, -0x148(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x20d0
movl -0x14c(%rbp), %edi
movq -0x148(%rbp), %rsi
movq %rax, %rdx
callq 0x20a0
movl %eax, -0x10(%rbp)
cmpl $0x0, %eax
jge 0x5fcb
movq 0x9050(%rip), %rax      # 0xeff8
movq (%rax), %rdi
leaq -0x120(%rbp), %rdx
leaq 0x5f91(%rip), %rsi      # 0xbf4a
movb $0x0, %al
callq 0x21d0
movl -0x10(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x6156
jmp 0x5fcd
movsbl 0x9364(%rip), %eax      # 0xf338
cmpl $0x1, %eax
jne 0x608d
cmpl $0x1, 0x9348(%rip)      # 0xf32c
je 0x5ff3
movss 0x563e(%rip), %xmm0     # 0xb62c
movss %xmm0, -0xc(%rbp)
leaq -0x120(%rbp), %rdi
movss -0xc(%rbp), %xmm0
callq 0x6350
movl %eax, -0x14(%rbp)
cmpl $0x1, -0x14(%rbp)
je 0x6028
movq 0x8fe4(%rip), %rax      # 0xeff8
movq (%rax), %rdi
movl -0x14(%rbp), %edx
leaq 0x5f73(%rip), %rsi      # 0xbf94
movb $0x0, %al
callq 0x21d0
movl -0x8(%rbp), %eax
movl %eax, -0x15c(%rbp)
leaq -0x120(%rbp), %rax
movq %rax, -0x158(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x20d0
movl -0x15c(%rbp), %edi
movq -0x158(%rbp), %rsi
movq %rax, %rdx
callq 0x20a0
movl %eax, -0x10(%rbp)
cmpl $0x0, %eax
jge 0x608b
movq 0x8f89(%rip), %rax      # 0xeff8
movq (%rax), %rdi
leaq 0x5f36(%rip), %rsi      # 0xbfaf
movb $0x0, %al
callq 0x21d0
movl -0x10(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x6156
jmp 0x608d
movsbl 0x92a6(%rip), %eax      # 0xf33a
cmpl $0x1, %eax
jne 0x614e
movzbl 0x9329(%rip), %eax      # 0xf3cd
cmpl $0x0, %eax
je 0x614e
leaq -0x120(%rbp), %rdi
movss 0x9308(%rip), %xmm0     # 0xf3c4
callq 0x6420
movl %eax, -0x14(%rbp)
cmpl $0x1, -0x14(%rbp)
je 0x60e5
movq 0x8f27(%rip), %rax      # 0xeff8
movq (%rax), %rdi
movl -0x14(%rbp), %edx
leaq 0x5ede(%rip), %rsi      # 0xbfbc
movb $0x0, %al
callq 0x21d0
movl -0x8(%rbp), %eax
movl %eax, -0x16c(%rbp)
leaq -0x120(%rbp), %rax
movq %rax, -0x168(%rbp)
leaq -0x120(%rbp), %rdi
callq 0x20d0
movl -0x16c(%rbp), %edi
movq -0x168(%rbp), %rsi
movq %rax, %rdx
callq 0x20a0
movl %eax, -0x10(%rbp)
cmpl $0x0, %eax
jge 0x614c
movq 0x8ecc(%rip), %rax      # 0xeff8
movq (%rax), %rdi
leaq -0x120(%rbp), %rdx
leaq 0x5e0d(%rip), %rsi      # 0xbf4a
movb $0x0, %al
callq 0x21d0
movl -0x10(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x6156
jmp 0x614e
jmp 0x6150
movl -0x10(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x170, %rsp            # imm = 0x170
popq %rbp
retq
nopw %cs:(%rax,%rax)