// File: /workspace/github_c_makefile_star2_O0/mmayer[P]pcal/src/pcal.c
// Function: set_color
void set_color (char *day, int col)
{
   int i, j, max, count[NUM_COLORS];
   char tmp[STRSIZ], *p;
   
   if (ci_strncmp(day, ALL, strlen(ALL)) == 0) {   /* set all days */
      for (i = 0; i < 7; i++) day_color[i] = col;
   }
   
   else if (ci_strncmp(day, HOLIDAY, MIN_DAY_LEN) == 0) { /* set holidays */
      holiday_color = col;
   }
   
   else {   /* set range of days */
      strcpy(tmp, day);
      if ((p = strchr(tmp, '-')) != NULL) *p++ = '\0';
      
      /* parse single day or range of days - return if error */
      if ((i = get_weekday(tmp, FALSE)) == NOT_WEEKDAY ||
          (j = p ? get_weekday(p, FALSE) : i) == NOT_WEEKDAY) {
         return;
      }

      /* set day colors, wrapping around end of week */
      for (j = (i > j) ? j + 7 : j; i <= j; i++) day_color[i % 7] = col;
   }
   
   /* reset weekday_color to most prevalent color */
   
   for (i = 0; i < NUM_COLORS; i++) {   /* clear counts */
      count[i] = 0;
   }
   
   for (i = SUN; i <= SAT; i++) { /* count colors */
      count[(int)day_color[i]]++;
   }
   
   for (i = max = 0; i < NUM_COLORS; i++) { /* get most prevalent */
      if (count[i] > max) max = count[weekday_color = i];
   }
   return;   
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x1fe9a(%rip), %rsi     # 0x25487
movl $0x3, %edx
callq 0xb3b0
cmpl $0x0, %eax
jne 0x562c
movl $0x0, -0x10(%rbp)
cmpl $0x7, -0x10(%rbp)
jge 0x5627
movl -0xc(%rbp), %eax
movb %al, %dl
movslq -0x10(%rbp), %rcx
leaq 0x2d193(%rip), %rax     # 0x327ac
movb %dl, (%rax,%rcx)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x5603
jmp 0x5754
movq -0x8(%rbp), %rdi
leaq 0x15c1d(%rip), %rsi     # 0x1b254
movl $0x3, %edx
callq 0xb3b0
cmpl $0x0, %eax
jne 0x5654
movl -0xc(%rbp), %eax
movl %eax, 0x2d165(%rip)     # 0x327b4
jmp 0x5752
leaq -0x100(%rbp), %rdi
movq -0x8(%rbp), %rsi
callq 0x5080
leaq -0x100(%rbp), %rdi
movl $0x2d, %esi
callq 0x5100
movq %rax, -0x108(%rbp)
cmpq $0x0, %rax
je 0x569a
movq -0x108(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x108(%rbp)
movb $0x0, (%rax)
leaq -0x100(%rbp), %rdi
xorl %esi, %esi
callq 0xfb80
movl %eax, -0x10(%rbp)
cmpl $-0x1, %eax
je 0x56e7
cmpq $0x0, -0x108(%rbp)
je 0x56d0
movq -0x108(%rbp), %rdi
xorl %esi, %esi
callq 0xfb80
movl %eax, -0x10c(%rbp)
jmp 0x56d9
movl -0x10(%rbp), %eax
movl %eax, -0x10c(%rbp)
movl -0x10c(%rbp), %eax
movl %eax, -0x14(%rbp)
cmpl $-0x1, %eax
jne 0x56ec
jmp 0x57ee
movl -0x10(%rbp), %eax
cmpl -0x14(%rbp), %eax
jle 0x5702
movl -0x14(%rbp), %eax
addl $0x7, %eax
movl %eax, -0x110(%rbp)
jmp 0x570b
movl -0x14(%rbp), %eax
movl %eax, -0x110(%rbp)
movl -0x110(%rbp), %eax
movl %eax, -0x14(%rbp)
movl -0x10(%rbp), %eax
cmpl -0x14(%rbp), %eax
jg 0x5750
movl -0xc(%rbp), %eax
movb %al, -0x111(%rbp)
movl -0x10(%rbp), %eax
movl $0x7, %ecx
cltd
idivl %ecx
movl %edx, %eax
movb -0x111(%rbp), %dl
movslq %eax, %rcx
leaq 0x2d06a(%rip), %rax     # 0x327ac
movb %dl, (%rax,%rcx)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x5714
jmp 0x5752
jmp 0x5754
movl $0x0, -0x10(%rbp)
cmpl $0x4, -0x10(%rbp)
jge 0x5778
movslq -0x10(%rbp), %rax
movl $0x0, -0x30(%rbp,%rax,4)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x575b
movl $0x0, -0x10(%rbp)
cmpl $0x6, -0x10(%rbp)
jg 0x57ac
movslq -0x10(%rbp), %rcx
leaq 0x2d01c(%rip), %rax     # 0x327ac
movsbl (%rax,%rcx), %eax
cltq
movl -0x30(%rbp,%rax,4), %ecx
addl $0x1, %ecx
movl %ecx, -0x30(%rbp,%rax,4)
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x577f
movl $0x0, -0x18(%rbp)
movl $0x0, -0x10(%rbp)
cmpl $0x4, -0x10(%rbp)
jge 0x57ec
movslq -0x10(%rbp), %rax
movl -0x30(%rbp,%rax,4), %eax
cmpl -0x18(%rbp), %eax
jle 0x57df
movl -0x10(%rbp), %eax
movl %eax, 0x2cb52(%rip)     # 0x32328
cltq
movl -0x30(%rbp,%rax,4), %eax
movl %eax, -0x18(%rbp)
jmp 0x57e1
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x57ba
jmp 0x57ee
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
nopw (%rax,%rax)