// File: /workspace/github_cpp_makefile_star2_O2/jkingan[P]ladyheather/heather.cpp
// Function: config_program(int, char**)
int config_program(int argc, char *argv[])
{
int i;
int j;
int add_path;
int error;
char path[1024+1];

   set_defaults();     // initialize global variables

   add_path = 0;
   j = 0;
   path[j] = 0;

#ifdef WINDOWS
      strcpy(help_path, &argv[0][0]);
#else  // __linux__  __MACH__  __FreeBSD__
   strcpy(path, argv[0]);
   strcpy(help_path, basename(path));
   if(strstr(help_path,"luxor")) {
//    luxor = 2;
   }

   // get program name (help path) and executable path (heather_path)
   #ifdef __MACH__
      char temp[1024+1];
      j = sizeof(temp);
      i = _NSGetExecutablePath(temp, (unsigned int *) &j);
      if(i == 0) {
         realpath(path, temp);
      }
   #else
      i = readlink("/proc/self/exe", path, sizeof(path));
   #endif

   if(i < 0) readlink("/proc/curproc/file", path, sizeof(path));
   if(i < 0) readlink("/proc/self/path/a.out", path, sizeof(path));
   if(i >= 0) {
      strcpy(heather_path, dirname(path));
      strcat(heather_path, "/");
   }
   add_path = 1;
#endif

   // Look for /hd option for setting the home directory
   // We need to do this before looking for all the other files
   // and so we have to do it before other option parsing. We'll
   // call a special routine to do this one thing for us.

    option_handle_hd(argc, argv);

	printf("excecutable path:%s\n", heather_path);  // zork - show_debug_info
	printf("program:%s\n", help_path);

   find_sound_files();

   read_config_file(help_path, 1, add_path);  // process options from default config file
   read_config_file(help_path, 2, add_path);  // process calendar file

   for(i=1; i<argc; i++) {          // process the command line
      if((argv[i][0] == '/') || (argv[i][0] == '-') || (argv[i][0] == '=') || (argv[i][0] == '$')) {
         error = option_switch(argv[i]);
      }
      else error = 1;

      if(error) {
         command_help("on command line: ", argv[i], help_path);
         return 1;
//qqq    exit(10);
      }
   }

   return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x408, %rsp            # imm = 0x408
movq %rsi, %rbx
movl %edi, %r14d
callq 0x1c670
leaq -0x430(%rbp), %r15
movb $0x0, (%r15)
movq (%rbx), %rsi
movq %r15, %rdi
callq 0x9330
movq %r15, %rdi
callq 0x96a0
leaq 0x309a15(%rip), %rdi    # 0x328740
movq %rax, %rsi
callq 0x9330
leaq 0xd682e(%rip), %rdi     # 0xf5568
movl $0x401, %edx            # imm = 0x401
movq %r15, %rsi
callq 0x93a0
testl %eax, %eax
js 0x1ed7a
leaq -0x430(%rbp), %rdi
callq 0x9110
leaq 0x13bf32(%rip), %r15    # 0x15ac90
movq %r15, %rdi
movq %rax, %rsi
callq 0x9330
movq %r15, %rdi
callq 0x9120
movw $0x2f, (%rax,%r15)
jmp 0x1eda2
leaq 0xd67f6(%rip), %rdi     # 0xf5577
movl $0x401, %edx            # imm = 0x401
movq %r15, %rsi
callq 0x93a0
leaq 0xd67f5(%rip), %rdi     # 0xf558a
movl $0x401, %edx            # imm = 0x401
movq %r15, %rsi
callq 0x93a0
movl %r14d, %edi
movq %rbx, %rsi
callq 0x1ec47
leaq 0xd67ec(%rip), %rdi     # 0xf55a0
leaq 0x13bed5(%rip), %rsi    # 0x15ac90
xorl %eax, %eax
callq 0x9030
leaq 0xd67ec(%rip), %rdi     # 0xf55b5
leaq 0x309970(%rip), %r12    # 0x328740
movq %r12, %rsi
xorl %eax, %eax
callq 0x9030
callq 0x9a71
pushq $0x1
popq %r15
movq %r12, %rdi
movl %r15d, %esi
movl %r15d, %edx
callq 0x1c21b
pushq $0x2
popq %rsi
movq %r12, %rdi
movl %r15d, %edx
callq 0x1c21b
movslq %r14d, %r12
pushq $0x1
popq %r14
movabsq $0x2000a01000000000, %r13 # imm = 0x2000A01000000000
cmpq %r12, %r14
jge 0x1ee51
movq (%rbx,%r14,8), %rsi
movzbl (%rsi), %eax
cmpq $0x3d, %rax
ja 0x1ee3c
btq %rax, %r13
jae 0x1ee3c
movq %rsi, %rdi
callq 0x2f9d5
incq %r14
testl %eax, %eax
je 0x1ee10
movq -0x8(%rbx,%r14,8), %rsi
leaq 0xd677e(%rip), %rdi     # 0xf55c1
leaq 0x3098f6(%rip), %rdx    # 0x328740
callq 0x1c571
jmp 0x1ee54
xorl %r15d, %r15d
movl %r15d, %eax
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq