// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x20, %rsp
movl $0x0, -0xc(%rbp)
leaq 0x10f7a(%rip), %rax     # 0x19960
movq (%rax), %rax
cmpl $0x0, 0x13c(%rax)
jne 0x89fb
cmpl $0x1, 0x110db(%rip)     # 0x19ad4
jne 0x8a05
callq 0x8060
jmp 0x8c42
movq 0x1108c(%rip), %rax     # 0x19a98
movq 0xe8(%rax), %rax
movslq 0x110be(%rip), %rcx     # 0x19ad8
shlq $0x7, %rcx
addq %rcx, %rax
movq 0x40(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x83e0
leaq 0x10f27(%rip), %rax     # 0x19960
movq (%rax), %rax
cmpl $0x2, 0x14c(%rax)
jge 0x8a6f
cmpl $0x8, 0x11088(%rip)     # 0x19ad4
jge 0x8a63
movl 0x11080(%rip), %ecx     # 0x19ad4
movl $0x1, %eax
shll %cl, %eax
movl %eax, 0x1105f(%rip)     # 0x19ac0
jmp 0x8a6d
movl $0x100, 0x11053(%rip)   # imm = 0x100
jmp 0x8a85
leaq 0x10eea(%rip), %rax     # 0x19960
movq (%rax), %rax
movl 0x14c(%rax), %eax
movl %eax, 0x1103b(%rip)     # 0x19ac0
leaq 0x10ed4(%rip), %rax     # 0x19960
movq (%rax), %rax
cmpl $0x1, 0x148(%rax)
jge 0x8aae
movl 0x11022(%rip), %ecx     # 0x19ac0
leaq 0x10ebb(%rip), %rax     # 0x19960
movq (%rax), %rax
movl %ecx, 0x148(%rax)
jmp 0x8ab0
callq 0x8730
callq 0x8890
leaq 0x10e9f(%rip), %rax     # 0x19960
movq (%rax), %rax
cmpl $0x0, 0x13c(%rax)
je 0x8ad7
callq 0x8060
jmp 0x8c42
leaq 0x10e82(%rip), %rax     # 0x19960
movq (%rax), %rax
cmpl $0x1, 0x148(%rax)
jle 0x8aef
callq 0x8140
movq 0x10fa2(%rip), %rax     # 0x19a98
movq 0xe8(%rax), %rax
movslq 0x10fd4(%rip), %rcx     # 0x19ad8
shlq $0x7, %rcx
addq %rcx, %rax
movq 0x40(%rax), %rax
movl 0x34(%rax), %eax
cmpl 0x10fac(%rip), %eax     # 0x19ac4
jl 0x8b36
movq 0x10f87(%rip), %rax     # 0x19aa8
movq %rax, 0x10f88(%rip)     # 0x19ab0
leaq -0xc(%rbp), %rdi
callq 0x8520
movl %eax, -0x4(%rbp)
jmp 0x8b5c
movq 0x10f5b(%rip), %rax     # 0x19a98
movq 0xe8(%rax), %rax
movslq 0x10f8d(%rip), %rcx     # 0x19ad8
shlq $0x7, %rcx
addq %rcx, %rax
movq 0x40(%rax), %rax
movl 0x34(%rax), %eax
movl %eax, -0x4(%rbp)
movl $0x0, -0x8(%rbp)
cmpl $0x0, -0xc(%rbp)
jne 0x8c0d
movq 0x10f24(%rip), %rdi     # 0x19a98
movq 0x10f35(%rip), %rsi     # 0x19ab0
movq 0x10efe(%rip), %rdx     # 0x19a80
movl -0x4(%rbp), %ecx
xorl %eax, %eax
movl %eax, %r8d
callq 0x51c0
leaq 0x10dca(%rip), %rax     # 0x19960
movq (%rax), %rax
cmpl $0x0, 0x144(%rax)
jne 0x8c0b
movq 0x10eef(%rip), %rdi     # 0x19a98
movq 0x10f30(%rip), %rsi     # 0x19ae0
movq -0x18(%rbp), %rdx
xorl %ecx, %ecx
callq 0x5200
movq %rax, 0x10eee(%rip)     # 0x19ab0
leaq -0xc(%rbp), %rdi
callq 0x8520
movl %eax, -0x8(%rbp)
cmpl $0x0, -0xc(%rbp)
jne 0x8c09
movq 0x10ebd(%rip), %rdi     # 0x19a98
movq 0x10ece(%rip), %rsi     # 0x19ab0
movq 0x10e97(%rip), %rdx     # 0x19a80
movl -0x8(%rbp), %ecx
xorl %eax, %eax
movl %eax, %r8d
callq 0x51c0
movq 0x10e9b(%rip), %rdi     # 0x19a98
movq 0x10eac(%rip), %rsi     # 0x19ab0
callq 0x50c0
jmp 0x8c0b
jmp 0x8c0d
movl -0x4(%rbp), %eax
cmpl -0x8(%rbp), %eax
jle 0x8c1d
movl -0x4(%rbp), %eax
movl %eax, -0x1c(%rbp)
jmp 0x8c23
movl -0x8(%rbp), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, 0x10e94(%rip)     # 0x19ac0
cmpl $0x0, -0xc(%rbp)
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x8ab0
callq 0x8310
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax,%rax)