// File: /workspace/github_cpp_makefile_star2_O3/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 0x1d644
leaq -0x430(%rbp), %r15
movb $0x0, (%r15)
movq (%rbx), %rsi
movq %r15, %rdi
callq 0x9340
movq %r15, %rdi
callq 0x96a0
leaq 0x31e660(%rip), %rdi    # 0x33e740
movq %rax, %rsi
callq 0x9340
leaq 0xeb3fe(%rip), %rdi     # 0x10b4ed
movl $0x401, %edx            # imm = 0x401
movq %r15, %rsi
callq 0x93a0
testl %eax, %eax
js 0x2012f
leaq -0x430(%rbp), %rdi
callq 0x9110
leaq 0x150b7d(%rip), %r15    # 0x170c90
movq %r15, %rdi
movq %rax, %rsi
callq 0x9340
movq %r15, %rdi
callq 0x9120
movw $0x2f, (%rax,%r15)
jmp 0x20157
leaq 0xeb3c6(%rip), %rdi     # 0x10b4fc
movl $0x401, %edx            # imm = 0x401
movq %r15, %rsi
callq 0x93a0
leaq 0xeb3c5(%rip), %rdi     # 0x10b50f
movl $0x401, %edx            # imm = 0x401
movq %r15, %rsi
callq 0x93a0
movl %r14d, %edi
movq %rbx, %rsi
callq 0x1fff3
leaq 0xeb3bc(%rip), %rdi     # 0x10b525
leaq 0x150b20(%rip), %rsi    # 0x170c90
xorl %r15d, %r15d
xorl %eax, %eax
callq 0x9030
leaq 0xeb3b9(%rip), %rdi     # 0x10b53a
leaq 0x31e5b8(%rip), %r12    # 0x33e740
movq %r12, %rsi
xorl %eax, %eax
callq 0x9030
callq 0x9aae
movq %r12, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0x1d1d8
movq %r12, %rdi
movl $0x2, %esi
movl $0x1, %edx
callq 0x1d1d8
cmpl $0x2, %r14d
jl 0x2021a
movl %r14d, %r14d
movl $0x1, %r12d
movabsq $0x2000a01000000000, %r13 # imm = 0x2000A01000000000
movq (%rbx,%r12,8), %rsi
movzbl (%rsi), %eax
cmpq $0x3d, %rax
ja 0x20201
btq %rax, %r13
jae 0x20201
movq %rsi, %rdi
callq 0x326cf
testl %eax, %eax
jne 0x201fd
incq %r12
cmpq %r12, %r14
jne 0x201d4
jmp 0x2021a
movq (%rbx,%r12,8), %rsi
leaq 0xeb33e(%rip), %rdi     # 0x10b546
leaq 0x31e531(%rip), %rdx    # 0x33e740
callq 0x1d541
movl $0x1, %r15d
movl %r15d, %eax
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq