// File: /workspace/github_c_makefile_star2_O1/jrrk[P]cbzone/c_gpr.c
// Function: setcolormap
void setcolormap()
{
  int dallocated, pallocated;
  Bool success = False;
  Visual* visual;

  if (opt->mono || depth == 1) {        /* mono? */
    setmonomap();
    return;
  }

  visual = DefaultVisual(d, screen_num);
  standardizecolors(visual);

  if (opt->max_colors < 2)
    if (depth<8)
      cr = 1<<depth;
    else
      cr = 256;
  else
    cr = opt->max_colors;

  if (opt->fading_colors < 1)
    opt->fading_colors = cr;

  do {
    countcolors();
    reducecolors();

    if (opt->mono) {
      setmonomap();
      return;
    }

    if (opt->fading_colors > 1)
      createfadedcolors();

    if (DisplayCells(d, screen_num) >= cw) {
      cmap = dcmap;
      dallocated = writecolormap(&success);
    }
    else
      dallocated = DisplayCells(d, screen_num);

    pallocated = 0;
    if (!success) {
      XFreeColors(d, cmap, pixels, dallocated, 0);
      if (!opt->defaultcolormap) {
        cmap = XCreateColormap(d, root, visual, AllocNone);
        pallocated = writecolormap(&success);
        if (!success) {
          XFreeColors(d, cmap, pixels, pallocated, 0);
          XFreeColormap(d, cmap);
        }
      }
    }

    cr = dallocated>pallocated ? dallocated : pallocated;
  } while (!success);

  setcoloroptvalues();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movl $0x0, 0xc(%rsp)
leaq 0xe040(%rip), %r12      # 0x14590
movq (%r12), %rax
cmpl $0x0, 0x13c(%rax)
jne 0x6758
cmpl $0x1, 0xe10c(%rip)      # 0x14674
je 0x6758
movq 0xe0c3(%rip), %rax      # 0x14638
movq 0xe8(%rax), %rax
movslq 0xe0f5(%rip), %rcx      # 0x14678
shlq $0x7, %rcx
movq 0x40(%rax,%rcx), %rbx
movq %rbx, %rdi
callq 0x60a3
movq (%r12), %rax
movl 0xe0d6(%rip), %ecx      # 0x14674
movl $0x1, %edx
shll %cl, %edx
cmpl $0x8, %ecx
movl $0x100, %ecx            # imm = 0x100
cmovll %edx, %ecx
movl 0x14c(%rax), %edx
cmpl $0x2, %edx
cmovgel %edx, %ecx
movl %ecx, 0xe09e(%rip)      # 0x14660
cmpl $0x0, 0x148(%rax)
jg 0x65d7
movl 0xe08f(%rip), %ecx      # 0x14660
movl %ecx, 0x148(%rax)
leaq 0xc(%rsp), %r14
callq 0x633c
callq 0x6441
movq (%r12), %rax
cmpl $0x0, 0x13c(%rax)
jne 0x6758
cmpl $0x2, 0x148(%rax)
jl 0x6605
callq 0x5e95
movq 0xe02c(%rip), %rax      # 0x14638
movq 0xe8(%rax), %rax
movslq 0xe05e(%rip), %rcx      # 0x14678
shlq $0x7, %rcx
movq 0x40(%rax,%rcx), %rax
movl 0x34(%rax), %ebp
cmpl 0xe038(%rip), %ebp      # 0x14664
jl 0x6646
movq 0xe013(%rip), %rax      # 0x14648
movq %rax, 0xe014(%rip)      # 0x14650
movq %r14, %rdi
callq 0x617d
movl %eax, %ebp
xorl %r15d, %r15d
cmpl $0x0, 0xc(%rsp)
jne 0x66e7
movq 0xdfdd(%rip), %rdi      # 0x14638
movq 0xdfee(%rip), %rsi      # 0x14650
movq 0xdfb7(%rip), %rdx      # 0x14620
xorl %r15d, %r15d
movl %ebp, %ecx
xorl %r8d, %r8d
callq 0x41d0
movq (%r12), %rax
cmpl $0x0, 0x144(%rax)
jne 0x66e7
movq 0xdfae(%rip), %rdi      # 0x14638
movq 0xdfef(%rip), %rsi      # 0x14680
movq %rbx, %rdx
xorl %ecx, %ecx
callq 0x4210
movq %rax, 0xdfae(%rip)      # 0x14650
movq %r14, %rdi
callq 0x617d
movl %eax, %r15d
cmpl $0x0, 0xc(%rsp)
jne 0x66e7
movq 0xdf7d(%rip), %rdi      # 0x14638
movq 0xdf8e(%rip), %rsi      # 0x14650
movq 0xdf57(%rip), %rdx      # 0x14620
movl %r15d, %ecx
xorl %r8d, %r8d
callq 0x41d0
movq 0xdf5d(%rip), %rdi      # 0x14638
movq 0xdf6e(%rip), %rsi      # 0x14650
callq 0x40d0
cmpl %r15d, %ebp
cmovgl %ebp, %r15d
movl %r15d, 0xdf6b(%rip)     # 0x14660
cmpl $0x0, 0xc(%rsp)
je 0x65dc
movq (%r12), %rax
xorl %ecx, %ecx
xorl %edx, %edx
leaq 0x12(%rcx), %rsi
movl 0x138(%rax,%rcx,4), %edi
cmpq %rdi, %rsi
jne 0x672d
movl %edx, 0x138(%rax,%rcx,4)
cmpq $0xc, %rsi
jb 0x6740
addl 0x148(%rax), %edx
jmp 0x6742
movslq %edi, %rsi
movl 0xf0(%rax,%rsi,4), %esi
movl %esi, 0x138(%rax,%rcx,4)
jmp 0x6742
incl %edx
decq %rcx
cmpq $-0x13, %rcx
jne 0x6708
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x5e11