// File: jkingan[P]ladyheather/heathui.cpp
// Function: config_tcpip_device(unsigned int, char*)
int config_tcpip_device(unsigned port, char *arg)
{
int i;

   // setup to use a com device using a com device name.
   // Returns 0 if successful,  non-zero if error.

   if(arg == 0) return 1;
   if(port >= NUM_COM_PORTS) return 2;

   if(arg[0]) {  // TCP/IP addr given
      com[port].com_port = com[port].usb_port = 0;
      com[port].user_disabled_com = 0;
      com[port].process_com = 1;
      strncpy(com[port].IP_addr, &arg[0], sizeof(com[port].IP_addr)-1);
      com[port].IP_addr[sizeof(com[port].IP_addr)-1] = 0;

      for(i=strlen(com[port].IP_addr)-1; i>=0; i++) {  // trim trailing scuzz
         if     (com[port].IP_addr[i] == 0x0A) com[port].IP_addr[i] = 0;
         else if(com[port].IP_addr[i] == 0x0D) com[port].IP_addr[i] = 0;
         else if(com[port].IP_addr[i] == ' ')  com[port].IP_addr[i] = 0;
         else if(com[port].IP_addr[i] == '\t') com[port].IP_addr[i] = 0;
         else if(com[port].IP_addr[i]) break;
      }
   }
   else if(com[port].IP_addr[0]) {  // use old IP address
   }
   else {  // !!!!!! use a default IP addr
   }

   com[port].IP_addr[sizeof(com[port].IP_addr)-1] = 0;
   if(com[port].IP_addr[0] == 0) return 3;
   com[port].user_set_ip = 2;

   if(com[port].com_running && com[port].IP_addr[0]) {  // use TCPIP port
      com[port].com_port = com[port].usb_port = 0;
      com[port].user_disabled_com = 0;
      com[port].process_com = 1;
      init_com(port, 15);
   }

   com[port].last_com_time = this_msec - com[port].com_timeout;

   return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x6d682
movl $0x1, -0x4(%rbp)
jmp 0x6daad
cmpl $0x13, -0x8(%rbp)
jb 0x6d694
movl $0x2, -0x4(%rbp)
jmp 0x6daad
movq -0x10(%rbp), %rax
cmpb $0x0, (%rax)
je 0x6d903
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x2ffe13(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
movl $0x0, 0x4(%rax)
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x2ffdf6(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
movl $0x0, (%rax)
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x2ffdda(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
movl $0x0, 0x2228(%rax)
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x2ffdba(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
movl $0x1, 0x2234(%rax)
movl -0x8(%rbp), %eax
leaq 0x2ffd9c(%rip), %rdi    # 0x36d4c0
imulq $0x2260, %rax, %rax     # imm = 0x2260
addq %rax, %rdi
addq $0x10d, %rdi            # imm = 0x10D
movq -0x10(%rbp), %rsi
movl $0x100, %edx            # imm = 0x100
callq 0x9170
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x2ffd71(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
movb $0x0, 0x20d(%rax)
movl -0x8(%rbp), %eax
leaq 0x2ffd56(%rip), %rdi    # 0x36d4c0
imulq $0x2260, %rax, %rax     # imm = 0x2260
addq %rax, %rdi
addq $0x10d, %rdi            # imm = 0x10D
callq 0x9120
subq $0x1, %rax
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
jl 0x6d901
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x2ffd23(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
movslq -0x14(%rbp), %rcx
movsbl 0x10d(%rax,%rcx), %eax
cmpl $0xa, %eax
jne 0x6d7df
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x2ffcfc(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
movslq -0x14(%rbp), %rcx
movb $0x0, 0x10d(%rax,%rcx)
jmp 0x6d8f1
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x2ffcd5(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
movslq -0x14(%rbp), %rcx
movsbl 0x10d(%rax,%rcx), %eax
cmpl $0xd, %eax
jne 0x6d82d
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x2ffcae(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
movslq -0x14(%rbp), %rcx
movb $0x0, 0x10d(%rax,%rcx)
jmp 0x6d8ef
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x2ffc87(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
movslq -0x14(%rbp), %rcx
movsbl 0x10d(%rax,%rcx), %eax
cmpl $0x20, %eax
jne 0x6d878
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x2ffc60(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
movslq -0x14(%rbp), %rcx
movb $0x0, 0x10d(%rax,%rcx)
jmp 0x6d8ed
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x2ffc3c(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
movslq -0x14(%rbp), %rcx
movsbl 0x10d(%rax,%rcx), %eax
cmpl $0x9, %eax
jne 0x6d8c3
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x2ffc15(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
movslq -0x14(%rbp), %rcx
movb $0x0, 0x10d(%rax,%rcx)
jmp 0x6d8eb
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x2ffbf1(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
movslq -0x14(%rbp), %rcx
cmpb $0x0, 0x10d(%rax,%rcx)
je 0x6d8e9
jmp 0x6d901
jmp 0x6d8eb
jmp 0x6d8ed
jmp 0x6d8ef
jmp 0x6d8f1
jmp 0x6d8f3
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x6d787
jmp 0x6d928
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x2ffbb1(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
cmpb $0x0, 0x10d(%rax)
je 0x6d924
jmp 0x6d926
jmp 0x6d926
jmp 0x6d928
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x2ffb8c(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
movb $0x0, 0x20d(%rax)
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x2ffb6f(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
movsbl 0x10d(%rax), %eax
cmpl $0x0, %eax
jne 0x6d973
movl $0x3, -0x4(%rbp)
jmp 0x6daad
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x2ffb41(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
movl $0x2, 0x225c(%rax)
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x2ffb21(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
cmpl $0x0, 0x2230(%rax)
je 0x6da5f
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x2ffafe(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
cmpb $0x0, 0x10d(%rax)
je 0x6da5f
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x2ffadb(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
movl $0x0, 0x4(%rax)
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x2ffabe(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
movl $0x0, (%rax)
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x2ffaa2(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
movl $0x0, 0x2228(%rax)
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x2ffa82(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
movl $0x1, 0x2234(%rax)
movl -0x8(%rbp), %edi
movl $0xf, %esi
callq 0xc0e0
leaq 0x2feee2(%rip), %rax    # 0x36c948
movsd (%rax), %xmm0
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x2ffa4a(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
subsd 0x2238(%rax), %xmm0
movl -0x8(%rbp), %eax
movl %eax, %ecx
leaq 0x2ffa2c(%rip), %rax    # 0x36d4c0
imulq $0x2260, %rcx, %rcx     # imm = 0x2260
addq %rcx, %rax
movsd %xmm0, 0x2248(%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)