// File: /workspace/github_cpp_makefile_star2_O1/jkingan[P]ladyheather/heathgps.cpp
// Function: decode_dog_enviro(unsigned int, int)
void decode_dog_enviro(unsigned port, int i)
{
   // decode dogtaian.com values then poll for the next reading

   if(i) {
      if(last_enviro == ENV_ID) {  // device ID
         goto poll_next_dog_enviro;
      }
      else if(last_enviro == ENV_SN) {
         enviro_field[UNIT_LEN] = 0;
         have_info |= MFG_INFO;
         strcpy(enviro_sn, enviro_field);
      }
      else if(last_enviro == ENV_HUMID) {
         parse_humidity();
if(humidity > 110.0) {
   last_enviro = 0;
   drain_port(port);
}
      }
      else if(last_enviro == ENV_PRESS) {
         parse_pressure();
         pressure /= 100.0;    // convert to millibars
if(pressure < 200.0) {
   last_enviro = 0;
   drain_port(port);
}
      }
      else if(last_enviro == ENV_TEMP1) {
         parse_temp1();
if(tc1 > 100.0) {
   last_enviro = 0;
   drain_port(port);
}
         save_temp1();
      }
      else {  // unknown reading type
         last_enviro = 0;
      }
   }
   else last_enviro = 0;

   poll_next_dog_enviro: // get the next reading
   next_enviro_poll();   // get what reading type to request

   if(next_enviro & ENV_HUMID) {
      send_enviro_cmd("GH\r", port);
      last_enviro = ENV_HUMID;
   }
   else if(next_enviro & ENV_PRESS) {
      send_enviro_cmd("GP\r", port);
      last_enviro = ENV_PRESS;
   }
   else if(next_enviro & ENV_TEMP1) {
      send_enviro_cmd("GT\r", port);
      last_enviro = ENV_TEMP1;
   }
   else if(next_enviro & ENV_SN) {
      send_enviro_cmd("GN\r", port);
      last_enviro = ENV_SN;
   }
   else {  // should never happen
      send_enviro_cmd("GT\r", port);
      last_enviro = ENV_TEMP1;
   }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %edi, %ebx
testl %esi, %esi
je 0xaba90
leaq 0x16cede(%rip), %r14    # 0x218924
movl (%r14), %eax
cmpl $0x7, %eax
jle 0xabaa2
cmpl $0x8, %eax
je 0xabacf
cmpl $0x8000, %eax           # imm = 0x8000
je 0xabb8a
cmpl $0x10, %eax
jne 0xabb65
movb $0x0, 0x2c09f4(%rip)    # 0x36c462
leaq 0x2c09db(%rip), %rsi    # 0x36c450
leaq 0x261ef8(%rip), %rax    # 0x30d974
orb $0x8, (%rax)
leaq 0x2917fa(%rip), %rdi    # 0x33d280
callq 0x9340
jmp 0xabb8a
leaq 0x16ce8d(%rip), %rax    # 0x218924
movl $0x0, (%rax)
jmp 0xabb8a
cmpl $0x1, %eax
je 0xabb0d
cmpl $0x4, %eax
jne 0xabb65
callq 0xab34e
leaq 0x2610dc(%rip), %rax    # 0x30cb98
movsd (%rax), %xmm0
ucomisd 0x72c88(%rip), %xmm0    # 0x11e750
ja 0xabafd
jmp 0xabb8a
callq 0xab391
leaq 0x2610c5(%rip), %rax    # 0x30cba0
movsd (%rax), %xmm0
divsd 0x5d579(%rip), %xmm0    # 0x109060
movsd %xmm0, (%rax)
movsd 0x6000d(%rip), %xmm1    # 0x10bb00
ucomisd %xmm0, %xmm1
jbe 0xabb8a
movl $0x0, (%r14)
movl %ebx, %edi
callq 0x5804f
jmp 0xabb8a
callq 0xab417
leaq 0x261097(%rip), %r15    # 0x30cbb0
movsd (%r15), %xmm0
ucomisd 0x5d53a(%rip), %xmm0    # 0x109060
jbe 0xabb36
movl $0x0, (%r14)
movl %ebx, %edi
callq 0x5804f
leaq 0x16cd93(%rip), %rax    # 0x2188d0
cmpq $0x80000, (%rax)        # imm = 0x80000
jne 0xabb6e
movsd (%r15), %xmm0
leaq 0x260ec6(%rip), %rax    # 0x30ca18
movsd %xmm0, (%rax)
leaq 0x2616ef(%rip), %rax    # 0x30d24c
movl $0x384, (%rax)          # imm = 0x384
jmp 0xabb8a
movl $0x0, (%r14)
jmp 0xabb8a
leaq 0x2616d7(%rip), %rax    # 0x30d24c
cmpl $0x0, (%rax)
jne 0xabb8a
movsd (%r15), %xmm0
leaq 0x260e92(%rip), %rax    # 0x30ca18
movsd %xmm0, (%rax)
callq 0xab798
leaq 0x16cd92(%rip), %rax    # 0x218928
movl (%rax), %eax
testb $0x4, %al
jne 0xabbc9
testb $0x8, %al
jne 0xabbd8
testb $0x1, %al
jne 0xabbe7
testb $0x10, %al
leaq 0x7a69a(%rip), %rax     # 0x126247
leaq 0x7a697(%rip), %rdi     # 0x12624b
cmoveq %rax, %rdi
movl $0x1, %eax
movl $0x10, %r14d
cmovel %eax, %r14d
jmp 0xabbf4
movl $0x4, %r14d
leaq 0x7a669(%rip), %rdi     # 0x12623f
jmp 0xabbf4
movl $0x8, %r14d
leaq 0x7a65e(%rip), %rdi     # 0x126243
jmp 0xabbf4
movl $0x1, %r14d
leaq 0x7a653(%rip), %rdi     # 0x126247
movl %ebx, %esi
callq 0x60ef6
leaq 0x16cd22(%rip), %rax    # 0x218924
movl %r14d, (%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq