// File: /workspace/github_c_makefile_star2_O1/bhk[P]tooltree/monoglot/xpio_c_q.c
// Function: main
int main(int argc, char **argv)
{
   // test scanNum
   {
      const char *psz;
      unsigned n;

      psz = scanNum("123.", &n);
      eq_i(123, n);
      eq_i('.', *psz);

      psz = scanNum("123 ", &n);
      eq_i(123, n);
      eq_i(' ', *psz);

      psz = scanNum("2147483647", &n);
      eq_i(2147483647, n);
      eq_i('\0', *psz);
   }

   // test addrFromString
   {
      // Perversely, sockaddr_in keeps exposes integer values (sin_addr and
      // sin_port) as if they can be treated as numeric values, but stores
      // them in network byte order.
      struct sockaddr_in sin;
      struct sockaddr *psa = (struct sockaddr *) &sin;
      unsigned char *pby = (unsigned char *)&psa->sa_data;
      int e;

      e = addrFromString(&sin, "123.4.5.255:258");
      eq_i(0, e);
      eq_i(AF_INET, psa->sa_family);
      eq_i(1,   pby[0]);      // sin_port
      eq_i(2,   pby[1]);
      eq_i(123, pby[2]);      // sin_addr
      eq_i(4,   pby[3]);
      eq_i(5,   pby[4]);
      eq_i(255, pby[5]);

      e = addrFromString(&sin, ":123");
      eq_i(0, e);
      eq_i(AF_INET, psa->sa_family);
      eq_i(123, htons(sin.sin_port));
      eq_i(0, sin.sin_addr.s_addr);

      e = addrFromString(&sin, "1.2.3.4");
      eq_i(0, e);
      eq_i(AF_INET, psa->sa_family);
      eq_i(0, htons(sin.sin_port));
      eq_i(0x01020304, htonl(sin.sin_addr.s_addr));
   }

   return 0;
}

// Assembly:
subq $0x18, %rsp
leaq 0x1364b(%rip), %rsi     # 0x17083
leaq 0x8(%rsp), %rdi
callq 0x3d0e
testl %eax, %eax
jne 0x3b54
movzwl 0x8(%rsp), %r8d
cmpl $0x2, %r8d
jne 0x3b6c
movzbl 0xa(%rsp), %r8d
cmpl $0x1, %r8d
jne 0x3b84
movzbl 0xb(%rsp), %r8d
cmpl $0x2, %r8d
jne 0x3ba1
movzbl 0xc(%rsp), %r8d
cmpl $0x7b, %r8d
jne 0x3bb9
movzbl 0xd(%rsp), %r8d
cmpl $0x4, %r8d
jne 0x3bd1
movzbl 0xe(%rsp), %r8d
cmpl $0x5, %r8d
jne 0x3bee
movzbl 0xf(%rsp), %r8d
cmpl $0xff, %r8d
jne 0x3c0b
leaq 0x135cf(%rip), %rsi     # 0x17093
leaq 0x8(%rsp), %rdi
callq 0x3d0e
testl %eax, %eax
jne 0x3c28
movzwl 0x8(%rsp), %r8d
cmpl $0x2, %r8d
jne 0x3c3d
movzwl 0xa(%rsp), %eax
cmpl $0x7b00, %eax           # imm = 0x7B00
jne 0x3c52
movl 0xc(%rsp), %r8d
testl %r8d, %r8d
jne 0x3c77
leaq 0x1358d(%rip), %rsi     # 0x17098
leaq 0x8(%rsp), %rdi
callq 0x3d0e
testl %eax, %eax
jne 0x3c8c
movzwl 0x8(%rsp), %r8d
cmpl $0x2, %r8d
jne 0x3ca9
movzwl 0xa(%rsp), %eax
testw %ax, %ax
jne 0x3cc3
movl 0xc(%rsp), %r8d
cmpl $0x4030201, %r8d        # imm = 0x4030201
jne 0x3ce2
xorl %eax, %eax
addq $0x18, %rsp
retq
leaq 0x134f7(%rip), %rdi     # 0x17052
leaq 0x13516(%rip), %rsi     # 0x17078
movl $0x3b, %edx
jmp 0x3c9f
leaq 0x134df(%rip), %rdi     # 0x17052
leaq 0x134fe(%rip), %rsi     # 0x17078
movl $0x3c, %edx
jmp 0x3cbc
leaq 0x134c7(%rip), %rdi     # 0x17052
leaq 0x134e6(%rip), %rsi     # 0x17078
movl $0x3d, %edx
movl $0x1, %ecx
jmp 0x3cfd
leaq 0x134aa(%rip), %rdi     # 0x17052
leaq 0x134c9(%rip), %rsi     # 0x17078
movl $0x3e, %edx
jmp 0x3cbc
leaq 0x13492(%rip), %rdi     # 0x17052
leaq 0x134b1(%rip), %rsi     # 0x17078
movl $0x3f, %edx
jmp 0x3c6d
leaq 0x1347a(%rip), %rdi     # 0x17052
leaq 0x13499(%rip), %rsi     # 0x17078
movl $0x40, %edx
movl $0x4, %ecx
jmp 0x3cfd
leaq 0x1345d(%rip), %rdi     # 0x17052
leaq 0x1347c(%rip), %rsi     # 0x17078
movl $0x41, %edx
movl $0x5, %ecx
jmp 0x3cfd
leaq 0x13440(%rip), %rdi     # 0x17052
leaq 0x1345f(%rip), %rsi     # 0x17078
movl $0x42, %edx
movl $0xff, %ecx
jmp 0x3cfd
leaq 0x13423(%rip), %rdi     # 0x17052
leaq 0x13442(%rip), %rsi     # 0x17078
movl $0x45, %edx
jmp 0x3c9f
leaq 0x1340e(%rip), %rdi     # 0x17052
leaq 0x1342d(%rip), %rsi     # 0x17078
movl $0x46, %edx
jmp 0x3cbc
rolw $0x8, %ax
movzwl %ax, %r8d
leaq 0x133f1(%rip), %rdi     # 0x17052
leaq 0x13410(%rip), %rsi     # 0x17078
movl $0x47, %edx
movl $0x7b, %ecx
jmp 0x3cfd
leaq 0x133d4(%rip), %rdi     # 0x17052
leaq 0x133f3(%rip), %rsi     # 0x17078
movl $0x48, %edx
jmp 0x3cde
leaq 0x133bf(%rip), %rdi     # 0x17052
leaq 0x133de(%rip), %rsi     # 0x17078
movl $0x4b, %edx
xorl %ecx, %ecx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
jmp 0x3cfd
leaq 0x133a2(%rip), %rdi     # 0x17052
leaq 0x133c1(%rip), %rsi     # 0x17078
movl $0x4c, %edx
movl $0x2, %ecx
jmp 0x3cfd
rolw $0x8, %ax
movzwl %ax, %r8d
leaq 0x13380(%rip), %rdi     # 0x17052
leaq 0x1339f(%rip), %rsi     # 0x17078
movl $0x4d, %edx
xorl %ecx, %ecx
jmp 0x3cfd
bswapl %r8d
leaq 0x13366(%rip), %rdi     # 0x17052
leaq 0x13385(%rip), %rsi     # 0x17078
movl $0x4e, %edx
movl $0x1020304, %ecx        # imm = 0x1020304
xorl %eax, %eax
callq 0x3170
movl $0x1, %edi
callq 0x33c0