// File: st0ne[P]XReflectorPlus/dxrfd.cpp
// Function: open_users(char*)
static int open_users(char *filename)
{
   FILE *fp = NULL;
   char inbuf[512];
   char *p = NULL;
   
   char *gwy_ptr;
   char gwy[9];
   char *host_ptr;
   const char *delim = " \t";
   call_ip_type::iterator pos;

   fp = fopen(filename, "r");
   if (!fp)
   {
      traceit("Failed to open file %s\n", filename);
      return 1;
   }

   call_ip_map.clear();

   traceit("Reading from file: [%s]\n", filename);
   while (fgets(inbuf, 511, fp) != NULL)
   {
      inbuf[511] = '\0';
      p = strchr(inbuf, '\r');
      if (p)
         *p = '\0';
      p = strchr(inbuf, '\n');
      if (p)
         *p = '\0';

      gwy_ptr = strtok(inbuf, delim);
      host_ptr = strtok(NULL, delim);

      if (gwy_ptr && host_ptr)
      {
         if (strlen(gwy_ptr) <= 8)
         {
            memset(gwy, ' ', 9); gwy[8] = '\0';
            memcpy(gwy, gwy_ptr, strlen(gwy_ptr));
            call_ip_map[gwy] = host_ptr;
         }
      }
   }
   fclose(fp);

   for (pos = call_ip_map.begin(); pos != call_ip_map.end(); pos++)
      traceit("[%s],[%s]\n", pos->first.c_str(), pos->second.c_str());
   traceit("Loaded %d entries\n", call_ip_map.size());

   return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2e0, %rsp            # imm = 0x2E0
movq %rdi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq $0x0, -0x228(%rbp)
leaq 0x12e04(%rip), %rax     # 0x1743d
movq %rax, -0x250(%rbp)
leaq -0x258(%rbp), %rdi
callq 0x11de0
movq -0x10(%rbp), %rdi
leaq 0x12b89(%rip), %rsi     # 0x171e0
callq 0x3380
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x4685
movq -0x10(%rbp), %rsi
leaq 0x12b70(%rip), %rdi     # 0x171e2
movb $0x0, %al
callq 0x3820
movl $0x1, -0x4(%rbp)
jmp 0x4981
leaq 0x1ad24(%rip), %rdi     # 0x1f3b0
callq 0x11e00
movq -0x10(%rbp), %rsi
leaq 0x12da4(%rip), %rdi     # 0x17440
movb $0x0, %al
callq 0x3820
leaq -0x220(%rbp), %rdi
movq -0x18(%rbp), %rdx
movl $0x1ff, %esi            # imm = 0x1FF
callq 0x34b0
cmpq $0x0, %rax
je 0x48a2
movb $0x0, -0x21(%rbp)
leaq -0x220(%rbp), %rdi
movl $0xd, %esi
callq 0x3120
movq %rax, -0x228(%rbp)
cmpq $0x0, -0x228(%rbp)
je 0x46f2
movq -0x228(%rbp), %rax
movb $0x0, (%rax)
leaq -0x220(%rbp), %rdi
movl $0xa, %esi
callq 0x3120
movq %rax, -0x228(%rbp)
cmpq $0x0, -0x228(%rbp)
je 0x471e
movq -0x228(%rbp), %rax
movb $0x0, (%rax)
leaq -0x220(%rbp), %rdi
movq -0x250(%rbp), %rsi
callq 0x34a0
movq %rax, -0x230(%rbp)
movq -0x250(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edi
callq 0x34a0
movq %rax, -0x248(%rbp)
cmpq $0x0, -0x230(%rbp)
je 0x489d
cmpq $0x0, -0x248(%rbp)
je 0x489d
movq -0x230(%rbp), %rdi
callq 0x3150
cmpq $0x8, %rax
ja 0x489b
movabsq $0x2020202020202020, %rax # imm = 0x2020202020202020
movq %rax, -0x240(%rbp)
movb $0x20, -0x238(%rbp)
movb $0x0, -0x238(%rbp)
movq -0x230(%rbp), %rdi
movq %rdi, -0x2c8(%rbp)
callq 0x3150
movq -0x2c8(%rbp), %rsi
movq %rax, %rdx
leaq -0x240(%rbp), %rdi
movq %rdi, -0x2b8(%rbp)
callq 0x3260
movq -0x248(%rbp), %rax
movq %rax, -0x2c0(%rbp)
leaq -0x279(%rbp), %rdi
movq %rdi, -0x2b0(%rbp)
callq 0x3520
movq -0x2b8(%rbp), %rsi
movq -0x2b0(%rbp), %rdx
leaq -0x278(%rbp), %rdi
callq 0x11f00
jmp 0x480d
leaq 0x1ab9c(%rip), %rdi     # 0x1f3b0
leaq -0x278(%rbp), %rsi
callq 0x11e20
movq %rax, -0x2d0(%rbp)
jmp 0x4829
movq -0x2c0(%rbp), %rsi
movq -0x2d0(%rbp), %rdi
callq 0x3440
jmp 0x483e
leaq -0x278(%rbp), %rdi
callq 0x31e0
leaq -0x279(%rbp), %rdi
callq 0x3330
jmp 0x489b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x288(%rbp)
movl %eax, -0x28c(%rbp)
jmp 0x488a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x288(%rbp)
movl %eax, -0x28c(%rbp)
leaq -0x278(%rbp), %rdi
callq 0x31e0
leaq -0x279(%rbp), %rdi
callq 0x3330
jmp 0x498d
jmp 0x489d
jmp 0x46a3
movq -0x18(%rbp), %rdi
callq 0x32d0
leaq 0x1aafe(%rip), %rdi     # 0x1f3b0
callq 0x11fb0
movq %rax, -0x298(%rbp)
movq -0x298(%rbp), %rax
movq %rax, -0x258(%rbp)
leaq 0x1aadd(%rip), %rdi     # 0x1f3b0
callq 0x12010
movq %rax, -0x2a0(%rbp)
leaq -0x258(%rbp), %rdi
leaq -0x2a0(%rbp), %rsi
callq 0x11fe0
testb $0x1, %al
jne 0x48f8
jmp 0x495d
leaq -0x258(%rbp), %rdi
callq 0x12040
movq %rax, %rdi
callq 0x3140
movq %rax, -0x2d8(%rbp)
leaq -0x258(%rbp), %rdi
callq 0x12040
movq %rax, %rdi
addq $0x20, %rdi
callq 0x3140
movq -0x2d8(%rbp), %rsi
movq %rax, %rdx
leaq 0x12b1d(%rip), %rdi     # 0x17459
movb $0x0, %al
callq 0x3820
leaq -0x258(%rbp), %rdi
xorl %esi, %esi
callq 0x12060
movq %rax, -0x2a8(%rbp)
jmp 0x48cc
leaq 0x1aa4c(%rip), %rdi     # 0x1f3b0
callq 0x120a0
movq %rax, %rsi
leaq 0x12af1(%rip), %rdi     # 0x17464
movb $0x0, %al
callq 0x3820
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x2e0, %rsp            # imm = 0x2E0
popq %rbp
retq
movq -0x288(%rbp), %rdi
callq 0x3500
nopl (%rax)