// File: /workspace/github_c_makefile_star2_O0/mcaimi[P]st/st.c
// Function: strhandle
void
strhandle(void)
{
  char *p = NULL;
  int j, narg, par;

  const struct { int idx; char *str; } osc_table[] = {
    { defaultfg, "foreground" },
    { defaultbg, "background" },
    { defaultcs, "cursor" }
  };

  term.esc &= ~(ESC_STR_END|ESC_STR);
  strparse();
  par = (narg = strescseq.narg) ? atoi(strescseq.args[0]) : 0;

  switch (strescseq.type) {
  case ']': /* OSC -- Operating System Command */
    switch (par) {
    case 0:
      if (narg > 1) {
        xsettitle(strescseq.args[1], 0);
        xseticontitle(strescseq.args[1]);
      }
      return;
    case 1:
      if (narg > 1)
        xseticontitle(strescseq.args[1]);
      return;
    case 2:
      if (narg > 1)
        xsettitle(strescseq.args[1], 0);
      return;
    case 52:
      if (narg > 2 && allowwindowops) {
        char *dec;

        dec = base64dec(strescseq.args[2]);
        if (dec) {
          xsetsel(dec);
          xclipcopy();
        } else {
          fprintf(stderr, "erresc: invalid base64\n");
        }
      }
      return;
   case 10:
   case 11:
   case 12:
     if (narg < 2)
       break;

     p = strescseq.args[1];

     if ((j = par - 10) < 0 || j >= LEN(osc_table))
       break; // should not be possible

     if (!strcmp(p, "?")) {
       osc_color_response(par, osc_table[j].idx, 0);
     } else if (xsetcolorname(osc_table[j].idx, p)) {
       fprintf(stderr, "erresc: invalid %s color: %s\n", osc_table[j].str, p);
     } else {
       tfulldirt();
     }
     return;
    case 4: /* color set */
      if (narg < 3)
        break;
      p = strescseq.args[2];
      /* FALLTHROUGH */
    case 104: /* color reset */
      j = (narg > 1) ? atoi(strescseq.args[1]) : -1;

     if ( p && !strcmp(p, "?")) {
       osc_color_response(j, 0, 1);
     } else if (xsetcolorname(j, p)) {
        if (par == 104 && narg <= 1) {
          xloadcols();
          return; /* color reset without parameter */
        }
        fprintf(stderr, "erresc: invalid color j=%d, p=%s\n",
                j, p ? p : "(null)");
      } else {
        /*
         * TODO if defaultbg color is changed, borders
         * are dirty
         */
        tfulldirt();
      }
      return;
    }
    break;
  case 'k': /* old title set compatibility */
    xsettitle(strescseq.args[0], 0);
    return;
  case 'P': /* DCS -- Device Control String */
    /* https://gitlab.com/gnachman/iterm2/-/wikis/synchronized-updates-spec */
    if (strstr(strescseq.buf, "=1s") == strescseq.buf)
      tsync_begin(), term.mode &= ~ESC_STR;  /* BSU */
    else if (strstr(strescseq.buf, "=2s") == strescseq.buf)
      tsync_end(), term.mode &= ~ESC_STR;  /* ESU */
    return;
  case '_': /* APC -- Application Program Command */
  case '^': /* PM -- Privacy Message */
    return;
  }

  if (debug) { 
    fprintf(stderr, "erresc: unknown str "); 
    strdump();
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq $0x0, -0x8(%rbp)
leaq 0x13436(%rip), %rax     # 0x1f7e0
movl (%rax), %eax
movl %eax, -0x50(%rbp)
leaq 0xa6ec(%rip), %rax      # 0x16aa2
movq %rax, -0x48(%rbp)
leaq 0x1341b(%rip), %rax     # 0x1f7dc
movl (%rax), %eax
movl %eax, -0x40(%rbp)
leaq 0xa6e0(%rip), %rax      # 0x16aad
movq %rax, -0x38(%rbp)
leaq 0x1340c(%rip), %rax     # 0x1f7e4
movl (%rax), %eax
movl %eax, -0x30(%rbp)
leaq 0xa6d4(%rip), %rax      # 0x16ab8
movq %rax, -0x28(%rbp)
movl 0x160ca(%rip), %eax     # 0x224b8
andl $-0x15, %eax
movl %eax, 0x160c1(%rip)     # 0x224b8
callq 0xc870
movl 0x18196(%rip), %eax     # 0x24598
movl %eax, -0x10(%rbp)
cmpl $0x0, %eax
je 0xc41b
movq 0x18107(%rip), %rdi     # 0x24518
callq 0x6530
movl %eax, -0x5c(%rbp)
jmp 0xc422
xorl %eax, %eax
movl %eax, -0x5c(%rbp)
jmp 0xc422
movl -0x5c(%rbp), %eax
movl %eax, -0x14(%rbp)
movsbl 0x180c9(%rip), %eax     # 0x244f8
addl $-0x50, %eax
movl %eax, %ecx
movq %rcx, -0x68(%rbp)
subl $0x1b, %eax
ja 0xc790
movq -0x68(%rbp), %rax
leaq 0xa0e8(%rip), %rcx      # 0x16534
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl -0x14(%rbp), %eax
movl %eax, -0x6c(%rbp)
testl %eax, %eax
je 0xc4af
jmp 0xc461
movl -0x6c(%rbp), %eax
subl $0x1, %eax
je 0xc4d4
jmp 0xc46b
movl -0x6c(%rbp), %eax
subl $0x2, %eax
je 0xc4eb
jmp 0xc475
movl -0x6c(%rbp), %eax
subl $0x4, %eax
je 0xc61d
jmp 0xc483
movl -0x6c(%rbp), %eax
addl $-0xa, %eax
subl $0x3, %eax
jb 0xc55c
jmp 0xc494
movl -0x6c(%rbp), %eax
subl $0x34, %eax
je 0xc504
jmp 0xc49e
movl -0x6c(%rbp), %eax
subl $0x68, %eax
je 0xc633
jmp 0xc713
cmpl $0x1, -0x10(%rbp)
jle 0xc4cf
movq 0x18064(%rip), %rdi     # 0x24520
xorl %esi, %esi
callq 0xeee0
movq 0x18056(%rip), %rdi     # 0x24520
callq 0xedd0
jmp 0xc7b9
cmpl $0x1, -0x10(%rbp)
jle 0xc4e6
movq 0x1803f(%rip), %rdi     # 0x24520
callq 0xedd0
jmp 0xc7b9
cmpl $0x1, -0x10(%rbp)
jle 0xc4ff
movq 0x18028(%rip), %rdi     # 0x24520
xorl %esi, %esi
callq 0xeee0
jmp 0xc7b9
cmpl $0x2, -0x10(%rbp)
jle 0xc557
leaq 0x1836b(%rip), %rax     # 0x2487c
cmpl $0x0, (%rax)
je 0xc557
movq 0x1800b(%rip), %rdi     # 0x24528
callq 0xc930
movq %rax, -0x58(%rbp)
cmpq $0x0, -0x58(%rbp)
je 0xc53d
movq -0x58(%rbp), %rdi
callq 0xe0f0
callq 0xe060
jmp 0xc555
movq 0x12aac(%rip), %rax     # 0x1eff0
movq (%rax), %rdi
leaq 0xa571(%rip), %rsi      # 0x16abf
movb $0x0, %al
callq 0x6970
jmp 0xc557
jmp 0xc7b9
cmpl $0x2, -0x10(%rbp)
jge 0xc567
jmp 0xc713
movq 0x17fb2(%rip), %rax     # 0x24520
movq %rax, -0x8(%rbp)
movl -0x14(%rbp), %eax
subl $0xa, %eax
movl %eax, -0xc(%rbp)
cmpl $0x0, %eax
jl 0xc58a
movslq -0xc(%rbp), %rax
cmpq $0x3, %rax
jb 0xc58f
jmp 0xc713
movq -0x8(%rbp), %rdi
leaq 0xa53d(%rip), %rsi      # 0x16ad7
callq 0x66f0
cmpl $0x0, %eax
jne 0xc5c1
movl -0x14(%rbp), %edi
movslq -0xc(%rbp), %rcx
leaq -0x50(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movl (%rax), %esi
xorl %edx, %edx
callq 0xcab0
jmp 0xc618
movslq -0xc(%rbp), %rcx
leaq -0x50(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movl (%rax), %edi
movq -0x8(%rbp), %rsi
callq 0xe560
cmpl $0x0, %eax
je 0xc611
movq 0x12a09(%rip), %rax     # 0x1eff0
movq (%rax), %rdi
movslq -0xc(%rbp), %rcx
leaq -0x50(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rdx
movq -0x8(%rbp), %rcx
leaq 0xa4d1(%rip), %rsi      # 0x16ad9
movb $0x0, %al
callq 0x6970
jmp 0xc616
callq 0x92e0
jmp 0xc618
jmp 0xc7b9
cmpl $0x3, -0x10(%rbp)
jge 0xc628
jmp 0xc713
movq 0x17ef9(%rip), %rax     # 0x24528
movq %rax, -0x8(%rbp)
cmpl $0x1, -0x10(%rbp)
jle 0xc64a
movq 0x17ee0(%rip), %rdi     # 0x24520
callq 0x6530
movl %eax, -0x70(%rbp)
jmp 0xc654
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x70(%rbp)
jmp 0xc654
movl -0x70(%rbp), %eax
movl %eax, -0xc(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0xc68a
movq -0x8(%rbp), %rdi
leaq 0xa46b(%rip), %rsi      # 0x16ad7
callq 0x66f0
cmpl $0x0, %eax
jne 0xc68a
movl -0xc(%rbp), %edi
xorl %esi, %esi
movl $0x1, %edx
callq 0xcab0
jmp 0xc70e
movl -0xc(%rbp), %edi
movq -0x8(%rbp), %rsi
callq 0xe560
cmpl $0x0, %eax
je 0xc707
cmpl $0x68, -0x14(%rbp)
jne 0xc6b1
cmpl $0x1, -0x10(%rbp)
jg 0xc6b1
callq 0xe190
jmp 0xc7b9
movq 0x12938(%rip), %rax     # 0x1eff0
movq (%rax), %rax
movq %rax, -0x80(%rbp)
movl -0xc(%rbp), %eax
movl %eax, -0x74(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0xc6d9
movq -0x8(%rbp), %rax
movq %rax, -0x88(%rbp)
jmp 0xc6e9
leaq 0xa439(%rip), %rax      # 0x16b19
movq %rax, -0x88(%rbp)
jmp 0xc6e9
movl -0x74(%rbp), %edx
movq -0x80(%rbp), %rdi
movq -0x88(%rbp), %rcx
leaq 0xa3f9(%rip), %rsi      # 0x16af7
movb $0x0, %al
callq 0x6970
jmp 0xc70c
callq 0x92e0
jmp 0xc70e
jmp 0xc7b9
jmp 0xc790
movq 0x17dfc(%rip), %rdi     # 0x24518
xorl %esi, %esi
callq 0xeee0
jmp 0xc7b9
movq 0x17dd1(%rip), %rdi     # 0x24500
leaq 0xa3ea(%rip), %rsi      # 0x16b20
callq 0x64c0
cmpq 0x17dbe(%rip), %rax     # 0x24500
jne 0xc75a
callq 0xce30
movl 0x15d65(%rip), %eax     # 0x224b4
andl $-0x5, %eax
movl %eax, 0x15d5c(%rip)     # 0x224b4
jmp 0xc78c
movq 0x17d9f(%rip), %rdi     # 0x24500
leaq 0xa3bc(%rip), %rsi      # 0x16b24
callq 0x64c0
cmpq 0x17d8c(%rip), %rax     # 0x24500
jne 0xc78a
callq 0xa600
movl 0x15d33(%rip), %eax     # 0x224b4
andl $-0x5, %eax
movl %eax, 0x15d2a(%rip)     # 0x224b4
jmp 0xc78c
jmp 0xc7b9
jmp 0xc7b9
leaq 0x180b5(%rip), %rax     # 0x2484c
cmpl $0x0, (%rax)
je 0xc7b9
movq 0x1284d(%rip), %rax     # 0x1eff0
movq (%rax), %rdi
leaq 0xa37b(%rip), %rsi      # 0x16b28
movb $0x0, %al
callq 0x6970
callq 0xcc30
addq $0x90, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)