// File: /workspace/github_cpp_makefile_star2_O3/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 0xabd17
leaq 0x16cc57(%rip), %r14    # 0x218924
movl (%r14), %eax
cmpl $0x7, %eax
jle 0xabd29
cmpl $0x8, %eax
je 0xabd56
cmpl $0x8000, %eax           # imm = 0x8000
je 0xabe11
cmpl $0x10, %eax
jne 0xabdec
movb $0x0, 0x2c076d(%rip)    # 0x36c462
leaq 0x2c0754(%rip), %rsi    # 0x36c450
leaq 0x261c71(%rip), %rax    # 0x30d974
orb $0x8, (%rax)
leaq 0x291573(%rip), %rdi    # 0x33d280
callq 0x9340
jmp 0xabe11
leaq 0x16cc06(%rip), %rax    # 0x218924
movl $0x0, (%rax)
jmp 0xabe11
cmpl $0x1, %eax
je 0xabd94
cmpl $0x4, %eax
jne 0xabdec
callq 0xab5d1
leaq 0x260e55(%rip), %rax    # 0x30cb98
movsd (%rax), %xmm0
ucomisd 0x72ab1(%rip), %xmm0    # 0x11e800
ja 0xabd84
jmp 0xabe11
callq 0xab614
leaq 0x260e3e(%rip), %rax    # 0x30cba0
movsd (%rax), %xmm0
divsd 0x5d2f2(%rip), %xmm0    # 0x109060
movsd %xmm0, (%rax)
movsd 0x5fd66(%rip), %xmm1    # 0x10bae0
ucomisd %xmm0, %xmm1
jbe 0xabe11
movl $0x0, (%r14)
movl %ebx, %edi
callq 0x5802f
jmp 0xabe11
callq 0xab69a
leaq 0x260e10(%rip), %r15    # 0x30cbb0
movsd (%r15), %xmm0
ucomisd 0x5d2b3(%rip), %xmm0    # 0x109060
jbe 0xabdbd
movl $0x0, (%r14)
movl %ebx, %edi
callq 0x5802f
leaq 0x16cb0c(%rip), %rax    # 0x2188d0
cmpq $0x80000, (%rax)        # imm = 0x80000
jne 0xabdf5
movsd (%r15), %xmm0
leaq 0x260c3f(%rip), %rax    # 0x30ca18
movsd %xmm0, (%rax)
leaq 0x261468(%rip), %rax    # 0x30d24c
movl $0x384, (%rax)          # imm = 0x384
jmp 0xabe11
movl $0x0, (%r14)
jmp 0xabe11
leaq 0x261450(%rip), %rax    # 0x30d24c
cmpl $0x0, (%rax)
jne 0xabe11
movsd (%r15), %xmm0
leaq 0x260c0b(%rip), %rax    # 0x30ca18
movsd %xmm0, (%rax)
callq 0xaba1b
leaq 0x16cb0b(%rip), %rax    # 0x218928
movl (%rax), %eax
testb $0x4, %al
jne 0xabe50
testb $0x8, %al
jne 0xabe5f
testb $0x1, %al
jne 0xabe6e
testb $0x10, %al
leaq 0x7a4f3(%rip), %rax     # 0x126327
leaq 0x7a4f0(%rip), %rdi     # 0x12632b
cmoveq %rax, %rdi
movl $0x1, %eax
movl $0x10, %r14d
cmovel %eax, %r14d
jmp 0xabe7b
movl $0x4, %r14d
leaq 0x7a4c2(%rip), %rdi     # 0x12631f
jmp 0xabe7b
movl $0x8, %r14d
leaq 0x7a4b7(%rip), %rdi     # 0x126323
jmp 0xabe7b
movl $0x1, %r14d
leaq 0x7a4ac(%rip), %rdi     # 0x126327
movl %ebx, %esi
callq 0x60f7b
leaq 0x16ca9b(%rip), %rax    # 0x218924
movl %r14d, (%rax)
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq