// File: /workspace/github_cpp_makefile_star2_O1/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 0x1d5f0
leaq -0x430(%rbp), %r15
movb $0x0, (%r15)
movq (%rbx), %rsi
movq %r15, %rdi
callq 0x9340
movq %r15, %rdi
callq 0x96a0
leaq 0x31e62a(%rip), %rdi    # 0x33e740
movq %rax, %rsi
callq 0x9340
leaq 0xeb3bb(%rip), %rdi     # 0x10b4e0
movl $0x401, %edx            # imm = 0x401
movq %r15, %rsi
callq 0x93a0
movq %rax, %r15
testl %r15d, %r15d
jns 0x20169
leaq 0xeb3ae(%rip), %rdi     # 0x10b4ef
leaq -0x430(%rbp), %r12
movl $0x401, %edx            # imm = 0x401
movq %r12, %rsi
callq 0x93a0
leaq 0xeb3a6(%rip), %rdi     # 0x10b502
movl $0x401, %edx            # imm = 0x401
movq %r12, %rsi
callq 0x93a0
testl %r15d, %r15d
js 0x2019b
leaq -0x430(%rbp), %rdi
callq 0x9110
leaq 0x150b0f(%rip), %r15    # 0x170c90
movq %r15, %rdi
movq %rax, %rsi
callq 0x9340
movq %r15, %rdi
callq 0x9120
movw $0x2f, (%rax,%r15)
movl %r14d, %edi
movq %rbx, %rsi
callq 0x20019
leaq 0xeb36b(%rip), %rdi     # 0x10b518
leaq 0x150adc(%rip), %rsi    # 0x170c90
xorl %r15d, %r15d
xorl %eax, %eax
callq 0x9030
leaq 0xeb368(%rip), %rdi     # 0x10b52d
leaq 0x31e574(%rip), %r12    # 0x33e740
movq %r12, %rsi
xorl %eax, %eax
callq 0x9030
callq 0x9ab6
movq %r12, %rdi
movl $0x1, %esi
movl $0x1, %edx
callq 0x1d19a
movq %r12, %rdi
movl $0x2, %esi
movl $0x1, %edx
callq 0x1d19a
cmpl $0x2, %r14d
jl 0x2025b
movl %r14d, %r14d
movl $0x1, %r12d
movabsq $0x2000a01000000000, %r13 # imm = 0x2000A01000000000
movq (%rbx,%r12,8), %rdi
movzbl (%rdi), %eax
cmpq $0x3d, %rax
ja 0x2023e
btq %rax, %r13
jae 0x2023e
callq 0x3251d
testl %eax, %eax
jne 0x2023e
incq %r12
cmpq %r12, %r14
jne 0x20218
jmp 0x2025b
movq (%rbx,%r12,8), %rsi
leaq 0xeb2f0(%rip), %rdi     # 0x10b539
leaq 0x31e4f0(%rip), %rdx    # 0x33e740
callq 0x1d4ed
movl $0x1, %r15d
movl %r15d, %eax
addq $0x408, %rsp            # imm = 0x408
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq