// File: /workspace/github_c_makefile_star2_O3/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 0xdfe8(%rip), %r12      # 0x14580
movq (%r12), %rax
cmpl $0x0, 0x13c(%rax)
jne 0x674f
cmpl $0x1, 0xe0b4(%rip)      # 0x14664
je 0x674f
movq 0xe06b(%rip), %rax      # 0x14628
movq 0xe8(%rax), %rax
movslq 0xe09d(%rip), %rcx      # 0x14668
shlq $0x7, %rcx
movq 0x40(%rax,%rcx), %rbx
movq %rbx, %rdi
callq 0x609a
movq (%r12), %rax
movl 0xe07e(%rip), %ecx      # 0x14664
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, 0xe046(%rip)      # 0x14650
cmpl $0x0, 0x148(%rax)
jg 0x6619
movl %ecx, 0x148(%rax)
callq 0x6381
callq 0x6486
movq (%r12), %rax
cmpl $0x0, 0x13c(%rax)
jne 0x674f
leaq 0xc(%rsp), %r14
cmpl $0x2, 0x148(%rax)
jl 0x6647
callq 0x5e8f
movq 0xdfda(%rip), %rax      # 0x14628
movq 0xe8(%rax), %rax
movslq 0xe00c(%rip), %rcx      # 0x14668
shlq $0x7, %rcx
movq 0x40(%rax,%rcx), %rax
movl 0x34(%rax), %ebp
cmpl 0xdfe6(%rip), %ebp      # 0x14654
jl 0x6693
movq 0xdfc1(%rip), %rax      # 0x14638
movq %rax, 0xdfc2(%rip)      # 0x14640
movq %r14, %rdi
callq 0x6174
movl %eax, %ebp
cmpl $0x0, 0xc(%rsp)
jne 0x6760
movq 0xdf8e(%rip), %rdi      # 0x14628
movq 0xdf9f(%rip), %rsi      # 0x14640
movq 0xdf68(%rip), %rdx      # 0x14610
xorl %r15d, %r15d
movl %ebp, %ecx
xorl %r8d, %r8d
callq 0x41d0
movq (%r12), %rax
cmpl $0x0, 0x144(%rax)
jne 0x6726
movq 0xdf5f(%rip), %rdi      # 0x14628
movq 0xdfa0(%rip), %rsi      # 0x14670
movq %rbx, %rdx
xorl %ecx, %ecx
callq 0x4210
movq %rax, 0xdf5f(%rip)      # 0x14640
movq %r14, %rdi
callq 0x6174
movl %eax, %r15d
cmpl $0x0, 0xc(%rsp)
jne 0x6763
movq 0xdf2e(%rip), %rdi      # 0x14628
movq 0xdf3f(%rip), %rsi      # 0x14640
movq 0xdf08(%rip), %rdx      # 0x14610
movl %r15d, %ecx
xorl %r8d, %r8d
callq 0x41d0
movq 0xdf0e(%rip), %rdi      # 0x14628
movq 0xdf1f(%rip), %rsi      # 0x14640
callq 0x40d0
cmpl %r15d, %ebp
cmovgl %ebp, %r15d
movl %r15d, 0xdf1c(%rip)     # 0x14650
callq 0x6381
callq 0x6486
movq (%r12), %rax
cmpl $0x0, 0x13c(%rax)
je 0x6639
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x5d51
xorl %r15d, %r15d
cmpl %r15d, %ebp
cmovgl %ebp, %r15d
movl %r15d, 0xdedf(%rip)     # 0x14650
movq (%r12), %rax
xorl %ecx, %ecx
xorl %edx, %edx
leaq 0x12(%rcx), %rsi
movl 0x138(%rax,%rcx,4), %edi
cmpq %rdi, %rsi
jne 0x679e
movl %edx, 0x138(%rax,%rcx,4)
cmpq $0xc, %rsi
jb 0x67b1
addl 0x148(%rax), %edx
jmp 0x67b3
movslq %edi, %rsi
movl 0xf0(%rax,%rsi,4), %esi
movl %esi, 0x138(%rax,%rcx,4)
jmp 0x67b3
incl %edx
decq %rcx
cmpq $-0x13, %rcx
jne 0x6779
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq