// File: /workspace/github_c_makefile_star2_O3/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 0x13646(%rip), %rsi     # 0x17083
leaq 0x8(%rsp), %rdi
callq 0x3d13
testl %eax, %eax
jne 0x3b59
movzwl 0x8(%rsp), %r8d
cmpl $0x2, %r8d
jne 0x3b71
movzbl 0xa(%rsp), %r8d
cmpl $0x1, %r8d
jne 0x3b89
movzbl 0xb(%rsp), %r8d
cmpl $0x2, %r8d
jne 0x3ba6
movzbl 0xc(%rsp), %r8d
cmpl $0x7b, %r8d
jne 0x3bbe
movzbl 0xd(%rsp), %r8d
cmpl $0x4, %r8d
jne 0x3bd6
movzbl 0xe(%rsp), %r8d
cmpl $0x5, %r8d
jne 0x3bf3
movzbl 0xf(%rsp), %r8d
cmpl $0xff, %r8d
jne 0x3c10
leaq 0x135ca(%rip), %rsi     # 0x17093
leaq 0x8(%rsp), %rdi
callq 0x3d13
testl %eax, %eax
jne 0x3c2d
movzwl 0x8(%rsp), %r8d
cmpl $0x2, %r8d
jne 0x3c42
movzwl 0xa(%rsp), %eax
cmpl $0x7b00, %eax           # imm = 0x7B00
jne 0x3c57
movl 0xc(%rsp), %r8d
testl %r8d, %r8d
jne 0x3c7c
leaq 0x13588(%rip), %rsi     # 0x17098
leaq 0x8(%rsp), %rdi
callq 0x3d13
testl %eax, %eax
jne 0x3c91
movzwl 0x8(%rsp), %r8d
cmpl $0x2, %r8d
jne 0x3cae
movzwl 0xa(%rsp), %eax
testw %ax, %ax
jne 0x3cc8
movl 0xc(%rsp), %r8d
cmpl $0x4030201, %r8d        # imm = 0x4030201
jne 0x3ce7
xorl %eax, %eax
addq $0x18, %rsp
retq
leaq 0x134f2(%rip), %rdi     # 0x17052
leaq 0x13511(%rip), %rsi     # 0x17078
movl $0x3b, %edx
jmp 0x3ca4
leaq 0x134da(%rip), %rdi     # 0x17052
leaq 0x134f9(%rip), %rsi     # 0x17078
movl $0x3c, %edx
jmp 0x3cc1
leaq 0x134c2(%rip), %rdi     # 0x17052
leaq 0x134e1(%rip), %rsi     # 0x17078
movl $0x3d, %edx
movl $0x1, %ecx
jmp 0x3d02
leaq 0x134a5(%rip), %rdi     # 0x17052
leaq 0x134c4(%rip), %rsi     # 0x17078
movl $0x3e, %edx
jmp 0x3cc1
leaq 0x1348d(%rip), %rdi     # 0x17052
leaq 0x134ac(%rip), %rsi     # 0x17078
movl $0x3f, %edx
jmp 0x3c72
leaq 0x13475(%rip), %rdi     # 0x17052
leaq 0x13494(%rip), %rsi     # 0x17078
movl $0x40, %edx
movl $0x4, %ecx
jmp 0x3d02
leaq 0x13458(%rip), %rdi     # 0x17052
leaq 0x13477(%rip), %rsi     # 0x17078
movl $0x41, %edx
movl $0x5, %ecx
jmp 0x3d02
leaq 0x1343b(%rip), %rdi     # 0x17052
leaq 0x1345a(%rip), %rsi     # 0x17078
movl $0x42, %edx
movl $0xff, %ecx
jmp 0x3d02
leaq 0x1341e(%rip), %rdi     # 0x17052
leaq 0x1343d(%rip), %rsi     # 0x17078
movl $0x45, %edx
jmp 0x3ca4
leaq 0x13409(%rip), %rdi     # 0x17052
leaq 0x13428(%rip), %rsi     # 0x17078
movl $0x46, %edx
jmp 0x3cc1
rolw $0x8, %ax
movzwl %ax, %r8d
leaq 0x133ec(%rip), %rdi     # 0x17052
leaq 0x1340b(%rip), %rsi     # 0x17078
movl $0x47, %edx
movl $0x7b, %ecx
jmp 0x3d02
leaq 0x133cf(%rip), %rdi     # 0x17052
leaq 0x133ee(%rip), %rsi     # 0x17078
movl $0x48, %edx
jmp 0x3ce3
leaq 0x133ba(%rip), %rdi     # 0x17052
leaq 0x133d9(%rip), %rsi     # 0x17078
movl $0x4b, %edx
xorl %ecx, %ecx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
jmp 0x3d02
leaq 0x1339d(%rip), %rdi     # 0x17052
leaq 0x133bc(%rip), %rsi     # 0x17078
movl $0x4c, %edx
movl $0x2, %ecx
jmp 0x3d02
rolw $0x8, %ax
movzwl %ax, %r8d
leaq 0x1337b(%rip), %rdi     # 0x17052
leaq 0x1339a(%rip), %rsi     # 0x17078
movl $0x4d, %edx
xorl %ecx, %ecx
jmp 0x3d02
bswapl %r8d
leaq 0x13361(%rip), %rdi     # 0x17052
leaq 0x13380(%rip), %rsi     # 0x17078
movl $0x4e, %edx
movl $0x1020304, %ecx        # imm = 0x1020304
xorl %eax, %eax
callq 0x3170
movl $0x1, %edi
callq 0x33c0