// File: /workspace/github_c_makefile_star2_O0/mmayer[P]pcal/src/pcal.c
// Function: main
int main (int argc GCC_UNUSED, char **argv)
{
   FILE *dfp = NULL;   /* date file pointer */
   char *p, *pathlist[10];
   char tmp[STRSIZ];
   int n;
   
   /* get version from VERSION_STRING (for PostScript comments and version
    * symbol predefined in init_misc())
    */
   strcpy(tmp, VERSION_STRING + 4);
   p = strchr(tmp, ' ') + 1;   /* skip program name */
   *strchr(p, ' ') = '\0';   /* terminate after version */
   strcpy(version, p);
   
   init_misc();   /* handle initialization warts */
   
   /* extract root program name and program path - note that some systems
    * supply the full pathname and others just the root
    */

   strcpy(progname, **argv ? *argv : "pcal");
   
   if ((p = strrchr(progname, END_PATH)) != NULL) strcpy(progname, ++p);

#ifndef BUILD_ENV_UNIX
   if ((p = strchr(progname, '.')) != NULL) *p = '\0';   /* strip suffix if non-Un*x */
#endif

   mk_path(progpath, find_executable(*argv));

   /*
    * Get the arguments from a) the command line (pre-pass to pick up debug
    * and usage flags), b) the environment variable PCAL_OPTS, c) the first
    * command line pass, d) "opt" lines in the date file, and e) a final
    * command line pass, in that order
    */

   /* Make a preliminary pass to look for the debug flags (to ensure that -ZO
    * will print any flags set in PCAL_OPTS) and the usage flags (-h, -u, and
    * -v).  If none of the latter is specified, this pass will also validate
    * any numeric command-line arguments.
    */
   if (!get_args(argv, P_CMD0, NULL, TRUE)) {
      display_usage(stderr, FALSE);   /* invalid flag or param */
      exit(EXIT_FAILURE);
   }

   /* parse environment variable PCAL_OPTS as a command line */
   
   if ((p = getenv(PCAL_OPTS)) != NULL) {
      strcpy(lbuf, "pcal ");   /* dummy program name */
      strcat(lbuf, p);
      (void) loadwords(words, lbuf);   /* split string into words */
      if (! get_args(words, P_ENV, PCAL_OPTS, FALSE)) {
         display_usage(stderr, FALSE);
         exit(EXIT_FAILURE);
      }
   }
   
   /* parse command-line arguments once to find name of date file, etc. */
   
   (void) get_args(argv, P_CMD1, NULL, FALSE);
   
   /* if in whole-year mode, round number of months up to full year and set
    * default starting month to January of current year
    */
   if (do_whole_year) {
      nmonths = ((nmonths + 11) / 12) * 12;
      if (nargs == 0) init_month = JAN;
   }

   /* recalculate final month and year (latter needed for "year all") */
   final_month = (init_month + (nmonths - 1) - 1) % 12 + 1;
   final_year = init_year + ((nmonths - 1 + init_month - 1) / 12);
   
   /* Attempt to open the date file as specified by the [-e | -f] flags */

   switch (datefile_type) {
   case NO_DATEFILE:
      dfp = NULL;
      break;
      
   case USER_DATEFILE:
      /* Attempt to open user-specified calendar file: search first in the
       * current directory, then in PCAL_DIR (if defined), and finally in the
       * directory where the Pcal executable lives (if SEARCH_PCAL_DIR != 0).
       * It is a fatal error if the user-specified date file cannot be found.
       */
      n = 0;
      pathlist[n++] = "";
      if ((p = getenv(PCAL_DIR)) != NULL) pathlist[n++] = p;

#if (SEARCH_PCAL_DIR != 0)
      pathlist[n++] = progpath;
#endif

      pathlist[n] = NULL;
      
      strcpy(tmp, datefile);   /* save original name for error msg */
      
      if ((dfp = alt_fopen(datefile, tmp, pathlist, "r")) == NULL) {
         fprintf(stderr, E_FOPEN_ERR, progname, tmp);
         exit(EXIT_FAILURE);
      }
      break;

   case SYS_DATEFILE:
      /* Attempt to open system-specified calendar file: search first in
       * PCAL_DIR, then in HOME_DIR (current directory if neither is defined)
       * and finally in the directory where the Pcal executable lives (if
       * SEARCH_PCAL_DIR != 0).  It is not an error if the system-specified
       * date file cannot be opened; Pcal will simply generate an empty
       * calendar.
       */
      n = 0;
      if ((p = getenv(PCAL_DIR)) != NULL) pathlist[n++] = p;
      if ((p = getenv(HOME_DIR)) != NULL) pathlist[n++] = p;
      if (n == 0) pathlist[n++] = "";

#if (SEARCH_PCAL_DIR != 0)
      pathlist[n++] = progpath;
#endif

      pathlist[n] = NULL;
      
      dfp = alt_fopen(datefile, DATEFILE, pathlist, "r");
      
      /* if the date file has not been found and ALT_DATEFILE is defined,
       * search same paths for ALT_DATEFILE before giving up
       */
#ifdef ALT_DATEFILE
      if (!dfp) dfp = alt_fopen(datefile, ALT_DATEFILE, pathlist, "r");
#endif

      break;
   }

   /* read the date file (if any) and build internal data structure */
   
   if (dfp) {
      curr_year = init_year;
      read_datefile(dfp, datefile);
      fclose(dfp);
   } else datefile[0] = '\0';   /* for PostScript comment */

   /* reparse command line - flags there supersede those in date file */
   
   (void) get_args(argv, P_CMD2, NULL, FALSE);
   
   /* if the user has not explicitly selected a mapping, choose one based on
    * the chosen language
    */
   if (map_default == TRUE) mapfonts = lang_mapping[output_language];

   /* fprintf(stderr, "Font mapping is %d\n", mapfonts); */
   
   /* select an appropriate color for holidays if not set explicitly */
   if (holiday_color == HOLIDAY_DEFAULT) holiday_color = select_color();

   /* done with the arguments and flags - try to open the output file */
   
   /* use default output files (cf. pcaldefs.h) if -o flag not used */
   if (!oflag && output_type == OUTPUT_PS) strcpy(outfile, PS_OUTFILE);
   if (!oflag && output_type == OUTPUT_HTML) strcpy(outfile, HTML_OUTFILE);
   
   /* reopen stdout as alternate file if one was specified */
   if (*outfile && freopen(outfile, "w", stdout) == (FILE *) NULL) {
      fprintf(stderr, E_FOPEN_ERR, progname, outfile);
      exit(EXIT_FAILURE);
   }
   
   /* Set up the initial page-related values based on the default paper
    * size.
    */
   recalc_paper_parameters(paper_size);
   
   /* generate the "calendar", HTML, or PostScript code (cf. writefil.c) */
   
   if (output_type == OUTPUT_CAL) write_calfile();
   else if (output_type == OUTPUT_HTML) write_htmlfile();
   else write_psfile(generate_diagonals);
   
   cleanup();   /* free allocated data */
   
   exit(EXIT_SUCCESS);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
leaq -0x140(%rbp), %rdi
leaq 0x27fb5(%rip), %rsi     # 0x2fa74
callq 0x5080
leaq -0x140(%rbp), %rdi
movl $0x20, %esi
callq 0x5100
addq $0x1, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
movl $0x20, %esi
callq 0x5100
movb $0x0, (%rax)
movq -0x20(%rbp), %rsi
leaq 0x2ad97(%rip), %rdi     # 0x32890
callq 0x5080
callq 0x53f0
movq -0x10(%rbp), %rax
movq (%rax), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
je 0x7b22
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x150(%rbp)
jmp 0x7b32
leaq 0x145b6(%rip), %rax     # 0x1c0df
movq %rax, -0x150(%rbp)
jmp 0x7b32
movq -0x150(%rbp), %rsi
leaq 0x2ad70(%rip), %rdi     # 0x328b0
callq 0x5080
leaq 0x2ad64(%rip), %rdi     # 0x328b0
movl $0x2f, %esi
callq 0x5130
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0x7b78
movq -0x20(%rbp), %rsi
addq $0x1, %rsi
movq %rsi, -0x20(%rbp)
leaq 0x2ad3d(%rip), %rdi     # 0x328b0
callq 0x5080
movq -0x10(%rbp), %rax
movq (%rax), %rdi
callq 0xd7b0
movq %rax, %rsi
leaq 0x2ba02(%rip), %rdi     # 0x33590
callq 0xd4d0
movq -0x10(%rbp), %rdi
movl $0x2, %esi
xorl %eax, %eax
movl %eax, %edx
movl $0x1, %ecx
callq 0x62c0
cmpl $0x0, %eax
jne 0x7bca
movq 0x26442(%rip), %rax     # 0x2dff8
movq (%rax), %rdi
xorl %esi, %esi
callq 0x5970
movl $0x1, %edi
callq 0x52b0
leaq 0x14513(%rip), %rdi     # 0x1c0e4
callq 0x5030
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0x7c52
leaq 0x2adc9(%rip), %rdi     # 0x329b0
leaq 0x14500(%rip), %rsi     # 0x1c0ee
callq 0x5080
movq -0x20(%rbp), %rsi
leaq 0x2adb2(%rip), %rdi     # 0x329b0
callq 0x5290
leaq 0x2afa6(%rip), %rdi     # 0x32bb0
leaq 0x2ad9f(%rip), %rsi     # 0x329b0
callq 0xc660
leaq 0x2af93(%rip), %rdi     # 0x32bb0
movl $0x4, %esi
leaq 0x144bb(%rip), %rdx     # 0x1c0e4
xorl %ecx, %ecx
callq 0x62c0
cmpl $0x0, %eax
jne 0x7c50
movq 0x263bc(%rip), %rax     # 0x2dff8
movq (%rax), %rdi
xorl %esi, %esi
callq 0x5970
movl $0x1, %edi
callq 0x52b0
jmp 0x7c52
movq -0x10(%rbp), %rdi
movl $0x8, %esi
xorl %eax, %eax
movl %eax, %edx
xorl %ecx, %ecx
callq 0x62c0
cmpl $0x0, 0x2aad7(%rip)     # 0x32744
je 0x7c9e
movl 0x2b8a7(%rip), %eax     # 0x3351c
addl $0xb, %eax
movl $0xc, %ecx
cltd
idivl %ecx
imull $0xc, %eax, %eax
movl %eax, 0x2b893(%rip)     # 0x3351c
cmpl $0x0, 0x2ad10(%rip)     # 0x329a0
jne 0x7c9c
movl $0x1, 0x2b878(%rip)     # 0x33514
jmp 0x7c9e
movl 0x2b870(%rip), %eax     # 0x33514
movl 0x2b872(%rip), %edx     # 0x3351c
movl %eax, %ecx
movl %edx, %eax
leal -0x2(%rax,%rcx), %eax
movslq %eax, %rcx
imulq $0x2aaaaaab, %rcx, %rdx # imm = 0x2AAAAAAB
movq %rdx, %rcx
shrq $0x3f, %rcx
shrq $0x21, %rdx
addl %ecx, %edx
shll $0x2, %edx
movl %edx, %ecx
leal (%rcx,%rcx,2), %ecx
subl %ecx, %eax
incl %eax
movl %eax, 0x2b97d(%rip)     # 0x33658
movl 0x2b837(%rip), %eax     # 0x33518
movl 0x2b835(%rip), %esi     # 0x3351c
movl 0x2b827(%rip), %ecx     # 0x33514
movl %ecx, %edx
movl %esi, %ecx
leal -0x2(%rcx,%rdx), %ecx
movslq %ecx, %rcx
imulq $0x2aaaaaab, %rcx, %rcx # imm = 0x2AAAAAAB
movq %rcx, %rdx
shrq $0x3f, %rdx
sarq $0x21, %rcx
addl %edx, %ecx
addl %ecx, %eax
movl %eax, 0x2b948(%rip)     # 0x3365c
movl 0x26506(%rip), %eax     # 0x2e220
movl %eax, -0x154(%rbp)
testl %eax, %eax
je 0x7d47
jmp 0x7d26
movl -0x154(%rbp), %eax
subl $0x1, %eax
je 0x7d54
jmp 0x7d33
movl -0x154(%rbp), %eax
subl $0x2, %eax
je 0x7e2f
jmp 0x7f22
movq $0x0, -0x18(%rbp)
jmp 0x7f22
movl $0x0, -0x144(%rbp)
movl -0x144(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x144(%rbp)
cltq
leaq 0x1df13(%rip), %rcx     # 0x25c8b
movq %rcx, -0x70(%rbp,%rax,8)
leaq 0x14370(%rip), %rdi     # 0x1c0f4
callq 0x5030
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0x7daf
movq -0x20(%rbp), %rcx
movl -0x144(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x144(%rbp)
cltq
movq %rcx, -0x70(%rbp,%rax,8)
movslq -0x144(%rbp), %rax
movq $0x0, -0x70(%rbp,%rax,8)
leaq -0x140(%rbp), %rdi
leaq 0x2a563(%rip), %rsi     # 0x32330
callq 0x5080
leaq -0x140(%rbp), %rsi
leaq -0x70(%rbp), %rdx
leaq 0x2a54c(%rip), %rdi     # 0x32330
leaq 0x1c876(%rip), %rcx     # 0x24661
callq 0x7940
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
jne 0x7e2a
movq 0x261f7(%rip), %rax     # 0x2dff8
movq (%rax), %rdi
leaq -0x140(%rbp), %rcx
leaq 0x142eb(%rip), %rsi     # 0x1c0fd
leaq 0x2aa97(%rip), %rdx     # 0x328b0
movb $0x0, %al
callq 0x51b0
movl $0x1, %edi
callq 0x52b0
jmp 0x7f22
movl $0x0, -0x144(%rbp)
leaq 0x142b4(%rip), %rdi     # 0x1c0f4
callq 0x5030
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0x7e6b
movq -0x20(%rbp), %rcx
movl -0x144(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x144(%rbp)
cltq
movq %rcx, -0x70(%rbp,%rax,8)
leaq 0x142a3(%rip), %rdi     # 0x1c115
callq 0x5030
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0x7e9d
movq -0x20(%rbp), %rcx
movl -0x144(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x144(%rbp)
cltq
movq %rcx, -0x70(%rbp,%rax,8)
cmpl $0x0, -0x144(%rbp)
jne 0x7ec5
movl -0x144(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x144(%rbp)
cltq
leaq 0x1ddcb(%rip), %rcx     # 0x25c8b
movq %rcx, -0x70(%rbp,%rax,8)
movslq -0x144(%rbp), %rax
movq $0x0, -0x70(%rbp,%rax,8)
leaq -0x70(%rbp), %rdx
leaq 0x2a450(%rip), %rdi     # 0x32330
leaq 0x137e8(%rip), %rsi     # 0x1b6cf
leaq 0x1c773(%rip), %rcx     # 0x24661
callq 0x7940
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x7f20
leaq -0x70(%rbp), %rdx
leaq 0x2a427(%rip), %rdi     # 0x32330
leaq 0x13807(%rip), %rsi     # 0x1b717
leaq 0x1c74a(%rip), %rcx     # 0x24661
callq 0x7940
movq %rax, -0x18(%rbp)
jmp 0x7f22
cmpq $0x0, -0x18(%rbp)
je 0x7f50
movl 0x2b5e9(%rip), %eax     # 0x33518
movl %eax, 0x2b72b(%rip)     # 0x33660
movq -0x18(%rbp), %rdi
leaq 0x2a3f0(%rip), %rsi     # 0x32330
callq 0xd950
movq -0x18(%rbp), %rdi
callq 0x50c0
jmp 0x7f57
movb $0x0, 0x2a3d9(%rip)     # 0x32330
movq -0x10(%rbp), %rdi
movl $0x20, %esi
xorl %eax, %eax
movl %eax, %edx
xorl %ecx, %ecx
callq 0x62c0
cmpl $0x1, 0x27aee(%rip)     # 0x2fa60
jne 0x7f8e
leaq 0x2b909(%rip), %rax     # 0x33884
movslq (%rax), %rcx
leaq 0x2a1bb(%rip), %rax     # 0x32140
movl (%rax,%rcx,4), %eax
movl %eax, 0x2a46e(%rip)     # 0x323fc
cmpl $-0x1, 0x2a81f(%rip)    # 0x327b4
jne 0x7fa2
callq 0x18790
movl %eax, 0x2a812(%rip)     # 0x327b4
cmpl $0x0, 0x2b567(%rip)     # 0x33510
jne 0x7fc7
cmpl $0x0, 0x2a796(%rip)     # 0x32748
jne 0x7fc7
leaq 0x2a6b5(%rip), %rdi     # 0x32670
leaq 0x1dcc9(%rip), %rsi     # 0x25c8b
callq 0x5080
cmpl $0x0, 0x2b542(%rip)     # 0x33510
jne 0x7fec
cmpl $0x2, 0x2a771(%rip)     # 0x32748
jne 0x7fec
leaq 0x2a690(%rip), %rdi     # 0x32670
leaq 0x1dca4(%rip), %rsi     # 0x25c8b
callq 0x5080
movsbl 0x2a67d(%rip), %eax     # 0x32670
cmpl $0x0, %eax
je 0x804b
movq 0x25fd9(%rip), %rax     # 0x2dfd8
movq (%rax), %rdx
leaq 0x2a667(%rip), %rdi     # 0x32670
leaq 0x13fc8(%rip), %rsi     # 0x1bfd8
callq 0x5140
cmpq $0x0, %rax
jne 0x804b
movq 0x25fd6(%rip), %rax     # 0x2dff8
movq (%rax), %rdi
leaq 0x140d1(%rip), %rsi     # 0x1c0fd
leaq 0x2a87d(%rip), %rdx     # 0x328b0
leaq 0x2a636(%rip), %rcx     # 0x32670
movb $0x0, %al
callq 0x51b0
movl $0x1, %edi
callq 0x52b0
movl 0x2a757(%rip), %edi     # 0x327a8
callq 0x6130
cmpl $0x1, 0x2a6eb(%rip)     # 0x32748
jne 0x8066
callq 0x16c00
jmp 0x8083
cmpl $0x2, 0x2a6db(%rip)     # 0x32748
jne 0x8076
callq 0x18290
jmp 0x8081
movl 0x2a6dc(%rip), %edi     # 0x32758
callq 0x11ee0
jmp 0x8083
callq 0xeab0
xorl %edi, %edi
callq 0x52b0
nop