// File: Eba-M[P]E3DC-Control/RscpExampleMain.cpp
// Function: MQTTWB(float&)
int MQTTWB(float &f)
{
    //           Test zur Abfrage einer openWB
    if (strcmp(e3dc_config.WB_ip,"0.0.0.0")!=0)
    {
        
        char buf[127];
        static int WP_status = -1;
        int status;
        char path[1024];
        char var [4] [20];
        memset(path, 0x00, sizeof(path));
        f=-1;

        if (WP_status < 2)
        {
            if (e3dc_config.debug) printf("W1");
            mfp = NULL;
            sprintf(buf,"mosquitto_sub -h %s -t %s -W 1 -C 1",e3dc_config.WB_ip,e3dc_config.WB_topic);
            mfp = popen(buf, "r");
            //            int fd = fileno(mfp);
            //            int flags = fcntl(fd, F_GETFL, 0);
            //            flags |= O_NONBLOCK;
            //            fcntl(fd, F_SETFL, flags);
            WP_status = 2;
        }
        if (mfp != NULL)
            while (fgets(path, 1024, mfp) != NULL)
            {
                status = sscanf(path, "%s", var[0]);
                for (int x1=0;x1<status;x1++)
                    f=atof(var[x1]);
            }
        //        if (WP_status < 2)
        if (mfp != NULL)
            pclose(mfp);
        if (e3dc_config.debug) printf("W2");
        WP_status = 0;
        return f;

    }
    return -1;
}

// Assembly:
subq $0x508, %rsp            # imm = 0x508
movq %rdi, 0x4f8(%rsp)
leaq 0x665a2(%rip), %rdi     # 0x6e9e8
leaq 0x57eca(%rip), %rsi     # 0x60317
callq 0x23c0
cmpl $0x0, %eax
je 0x85e4
leaq 0x60(%rsp), %rdi
xorl %esi, %esi
movl $0x400, %edx            # imm = 0x400
callq 0x2170
movq 0x4f8(%rsp), %rax
movss 0x57b8c(%rip), %xmm0    # 0x60008
movss %xmm0, (%rax)
cmpl $0x2, 0x65ed5(%rip)     # 0x6e35c
jge 0x84fe
testb $0x1, 0x669d1(%rip)     # 0x6ee61
je 0x84a0
leaq 0x586dc(%rip), %rdi     # 0x60b75
movb $0x0, %al
callq 0x2040
movq $0x0, 0x68a8d(%rip) # 0x70f38
leaq 0x470(%rsp), %rdi
leaq 0x58704(%rip), %rsi     # 0x60bbe
leaq 0x66473(%rip), %rcx     # 0x6e934
movq %rcx, %rdx
addq $0xb4, %rdx
addq $0xc8, %rcx
movb $0x0, %al
callq 0x2060
leaq 0x470(%rsp), %rdi
leaq 0x5831b(%rip), %rsi     # 0x60803
callq 0x20b0
movq %rax, 0x68a44(%rip)     # 0x70f38
movl $0x2, 0x65e5e(%rip)     # 0x6e35c
cmpq $0x0, 0x68a32(%rip)     # 0x70f38
je 0x8598
jmp 0x850e
leaq 0x60(%rsp), %rdi
movq 0x68a1e(%rip), %rdx     # 0x70f38
movl $0x400, %esi            # imm = 0x400
callq 0x2450
cmpq $0x0, %rax
je 0x8596
leaq 0x60(%rsp), %rdi
leaq 0x10(%rsp), %rdx
leaq 0x59ed8(%rip), %rsi     # 0x62413
movb $0x0, %al
callq 0x22b0
movl %eax, 0x46c(%rsp)
movl $0x0, 0xc(%rsp)
movl 0xc(%rsp), %eax
cmpl 0x46c(%rsp), %eax
jge 0x8591
movslq 0xc(%rsp), %rax
leaq 0x10(%rsp), %rdi
imulq $0x14, %rax, %rax
addq %rax, %rdi
callq 0x2330
cvtsd2ss %xmm0, %xmm0
movq 0x4f8(%rsp), %rax
movss %xmm0, (%rax)
movl 0xc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xc(%rsp)
jmp 0x8551
jmp 0x850e
jmp 0x8598
cmpq $0x0, 0x68998(%rip)     # 0x70f38
je 0x85ae
movq 0x6898f(%rip), %rdi     # 0x70f38
callq 0x23d0
testb $0x1, 0x668ac(%rip)     # 0x6ee61
je 0x85c5
leaq 0x585fd(%rip), %rdi     # 0x60bbb
movb $0x0, %al
callq 0x2040
movl $0x0, 0x65d8d(%rip)     # 0x6e35c
movq 0x4f8(%rsp), %rax
cvttss2si (%rax), %eax
movl %eax, 0x504(%rsp)
jmp 0x85ef
movl $0xffffffff, 0x504(%rsp) # imm = 0xFFFFFFFF
movl 0x504(%rsp), %eax
addq $0x508, %rsp            # imm = 0x508
retq
nop