// File: /workspace/github_c_makefile_star2_O3/odknt[P]st/st.c
// Function: strhandle
void
strhandle(void)
{
	char *p = NULL, *dec;
	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]);
				xseticontitle(strescseq.args[1]);
			}
			return;
		case 1:
			if (narg > 1)
				xseticontitle(strescseq.args[1]);
			return;
		case 2:
			if (narg > 1)
				xsettitle(strescseq.args[1]);
			return;
		case 52:
			if (narg > 2 && allowwindowops) {
				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; /* shouldn't 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]);
		return;
	case 'P': /* DCS -- Device Control String */
	case '_': /* APC -- Application Program Command */
	case '^': /* PM -- Privacy Message */
		return;
	}

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x38, %rsp
leaq 0xd531(%rip), %rax      # 0x185ac
movl (%rax), %eax
movl %eax, (%rsp)
leaq 0x67f3(%rip), %rax      # 0x1187a
movq %rax, 0x8(%rsp)
leaq 0xd51d(%rip), %rax      # 0x185b0
movl (%rax), %eax
movl %eax, 0x10(%rsp)
leaq 0x67e5(%rip), %rax      # 0x11885
movq %rax, 0x18(%rsp)
leaq 0xd508(%rip), %rax      # 0x185b4
movl (%rax), %eax
movl %eax, 0x20(%rsp)
andb $-0x15, 0x1225f(%rip)   # 0x1d318
leaq 0x67d0(%rip), %rax      # 0x11890
movq %rax, 0x28(%rsp)
movq 0x14294(%rip), %rax     # 0x1f360
movl $0x0, 0x14322(%rip)     # 0x1f3f8
movq 0x14293(%rip), %rcx     # 0x1f370
movb $0x0, (%rax,%rcx)
cmpb $0x0, (%rax)
je 0xb12f
xorl %r15d, %r15d
leaq 0x14268(%rip), %rcx     # 0x1f358
movq %rax, 0x20(%rcx,%r15,8)
incq %r15
incq %rax
movzbl -0x1(%rax), %edx
testl %edx, %edx
je 0xb118
cmpl $0x3b, %edx
jne 0xb0f8
movb $0x0, -0x1(%rax)
cmpq $0x10, %r15
jne 0xb0f0
movl $0x10, %r15d
movl %r15d, 0x142d9(%rip)    # 0x1f3f8
movq 0x14252(%rip), %rdi     # 0x1f378
callq 0x65e0
movl %eax, %ebx
jmp 0xb134
xorl %r15d, %r15d
xorl %ebx, %ebx
movzbl 0x1421d(%rip), %eax     # 0x1f358
cmpl $0x5d, %eax
jle 0xb16b
leal -0x5e(%rax), %ecx
cmpl $0x2, %ecx
jb 0xb575
cmpl $0x6b, %eax
jne 0xb3f9
movq 0x1421c(%rip), %rdi     # 0x1f378
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xcc5b
cmpl $0x50, %eax
je 0xb575
cmpl $0x5d, %eax
jne 0xb3f9
cmpl $0xc, %ebx
ja 0xb2f5
movl %ebx, %eax
leaq 0x6125(%rip), %rcx      # 0x112b4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpl $0x2, %r15d
jl 0xb3f9
movq 0x141d7(%rip), %r14     # 0x1f380
leal -0xa(%rbx), %r15d
cmpb $0x3f, (%r14)
jne 0xb1be
cmpb $0x0, 0x1(%r14)
je 0xb403
shlq $0x4, %r15
movl (%rsp,%r15), %edi
movq %r14, %rsi
callq 0xc501
testl %eax, %eax
jne 0xb580
movl 0xe264(%rip), %eax      # 0x19440
decl %eax
movl %eax, %ecx
sarl $0x1f, %ecx
andl %eax, %ecx
movq 0x120f4(%rip), %rdx     # 0x1d2e0
movl %eax, %esi
negl %esi
cmovsl %eax, %esi
movslq %ecx, %rcx
leaq 0x4(%rsi), %rax
andq $-0x4, %rax
movq %rsi, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
leaq (%rdx,%rcx,4), %rcx
addq $0xc, %rcx
xorl %edx, %edx
movdqa 0x5df6(%rip), %xmm1     # 0x11010
movdqa 0x5dfe(%rip), %xmm2     # 0x11020
movdqa 0x5e06(%rip), %xmm3     # 0x11030
pxor %xmm3, %xmm0
pcmpeqd %xmm4, %xmm4
movq %rdx, %xmm5
pshufd $0x44, %xmm5, %xmm5     # xmm5 = xmm5[0,1,0,1]
movdqa %xmm5, %xmm6
por %xmm2, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
movd %xmm6, %esi
notl %esi
testb $0x1, %sil
je 0xb27d
movl $0x1, -0xc(%rcx,%rdx,4)
pxor %xmm4, %xmm6
pextrw $0x4, %xmm6, %esi
testb $0x1, %sil
je 0xb294
movl $0x1, -0x8(%rcx,%rdx,4)
por %xmm1, %xmm5
pxor %xmm3, %xmm5
movdqa %xmm5, %xmm6
pcmpgtd %xmm0, %xmm6
pcmpeqd %xmm0, %xmm5
pshufd $0xf5, %xmm5, %xmm7     # xmm7 = xmm5[1,1,3,3]
pand %xmm6, %xmm7
pshufd $0xf5, %xmm6, %xmm5     # xmm5 = xmm6[1,1,3,3]
por %xmm7, %xmm5
pxor %xmm4, %xmm5
pextrw $0x0, %xmm5, %esi
testb $0x1, %sil
je 0xb2d1
movl $0x1, -0x4(%rcx,%rdx,4)
pextrw $0x4, %xmm5, %esi
testb $0x1, %sil
je 0xb2e3
movl $0x1, (%rcx,%rdx,4)
addq $0x4, %rdx
cmpq %rdx, %rax
jne 0xb232
jmp 0xb575
cmpl $0x34, %ebx
je 0xb3b3
cmpl $0x68, %ebx
jne 0xb3f9
leaq 0x65e1(%rip), %r14      # 0x118ef
cmpl $0x2, %r15d
jl 0xb41e
movq 0x14061(%rip), %rdi     # 0x1f380
callq 0x65e0
movl %eax, %ebp
jmp 0xb42c
cmpl $0x2, %r15d
jl 0xb575
movq 0x14044(%rip), %rdi     # 0x1f380
callq 0xcc5b
jmp 0xb363
cmpl $0x2, %r15d
jl 0xb575
movq 0x1402c(%rip), %rdi     # 0x1f380
jmp 0xb15c
cmpl $0x2, %r15d
jl 0xb575
movq 0x14016(%rip), %rdi     # 0x1f380
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xcbdd
cmpl $0x3, %r15d
jl 0xb3f9
movq 0x14002(%rip), %r14     # 0x1f388
movq 0x13ff3(%rip), %rdi     # 0x1f380
callq 0x65e0
movl %eax, %ebp
testq %r14, %r14
je 0xb425
cmpb $0x3f, (%r14)
jne 0xb3ae
cmpb $0x0, 0x1(%r14)
je 0xb5ad
movq %r14, %rsi
jmp 0xb42e
cmpl $0x3, %r15d
jl 0xb575
leaq 0x142e4(%rip), %rax     # 0x1f6a8
cmpl $0x0, (%rax)
je 0xb575
movq 0x13fb4(%rip), %rdi     # 0x1f388
callq 0xb672
testq %rax, %rax
je 0xb5e2
movq %rax, %rdi
callq 0xc256
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xc1f4
callq 0x6d19
jmp 0xb575
shlq $0x4, %r15
movl (%rsp,%r15), %esi
movl %ebx, %edi
xorl %edx, %edx
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xb779
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0xb42c
leaq 0x64c3(%rip), %r14      # 0x118ef
xorl %esi, %esi
movl %ebp, %edi
callq 0xc501
testl %eax, %eax
je 0xb45b
cmpl $0x1, %r15d
jg 0xb5bb
cmpl $0x68, %ebx
jne 0xb5bb
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xc2be
movl 0xdfdf(%rip), %eax      # 0x19440
decl %eax
movl %eax, %ecx
sarl $0x1f, %ecx
andl %eax, %ecx
movq 0x11e6f(%rip), %rdx     # 0x1d2e0
movl %eax, %esi
negl %esi
cmovsl %eax, %esi
movslq %ecx, %rcx
leaq 0x4(%rsi), %rax
andq $-0x4, %rax
movq %rsi, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
leaq (%rdx,%rcx,4), %rcx
addq $0xc, %rcx
xorl %edx, %edx
movdqa 0x5b71(%rip), %xmm1     # 0x11010
movdqa 0x5b79(%rip), %xmm2     # 0x11020
movdqa 0x5b81(%rip), %xmm3     # 0x11030
pxor %xmm3, %xmm0
pcmpeqd %xmm4, %xmm4
movq %rdx, %xmm5
pshufd $0x44, %xmm5, %xmm5     # xmm5 = xmm5[0,1,0,1]
movdqa %xmm5, %xmm6
por %xmm2, %xmm6
pxor %xmm3, %xmm6
movdqa %xmm6, %xmm7
pcmpgtd %xmm0, %xmm7
pcmpeqd %xmm0, %xmm6
pshufd $0xf5, %xmm6, %xmm8     # xmm8 = xmm6[1,1,3,3]
pand %xmm7, %xmm8
pshufd $0xf5, %xmm7, %xmm6     # xmm6 = xmm7[1,1,3,3]
por %xmm8, %xmm6
movd %xmm6, %esi
notl %esi
testb $0x1, %sil
je 0xb502
movl $0x1, -0xc(%rcx,%rdx,4)
pxor %xmm4, %xmm6
pextrw $0x4, %xmm6, %esi
testb $0x1, %sil
je 0xb519
movl $0x1, -0x8(%rcx,%rdx,4)
por %xmm1, %xmm5
pxor %xmm3, %xmm5
movdqa %xmm5, %xmm6
pcmpgtd %xmm0, %xmm6
pcmpeqd %xmm0, %xmm5
pshufd $0xf5, %xmm5, %xmm7     # xmm7 = xmm5[1,1,3,3]
pand %xmm6, %xmm7
pshufd $0xf5, %xmm6, %xmm5     # xmm5 = xmm6[1,1,3,3]
por %xmm7, %xmm5
pxor %xmm4, %xmm5
pextrw $0x0, %xmm5, %esi
testb $0x1, %sil
je 0xb556
movl $0x1, -0x4(%rcx,%rdx,4)
pextrw $0x4, %xmm5, %esi
testb $0x1, %sil
je 0xb568
movl $0x1, (%rcx,%rdx,4)
addq $0x4, %rdx
cmpq %rdx, %rax
jne 0xb4b7
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
leaq (%rsp,%r15), %rax
movq 0xca65(%rip), %rcx      # 0x17ff0
movq (%rcx), %rdi
movq 0x8(%rax), %rdx
leaq 0x6316(%rip), %rsi      # 0x118af
movq %r14, %rcx
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x69c0
movl %ebp, %edi
xorl %esi, %esi
movl $0x1, %edx
jmp 0xb40f
movq 0xca2e(%rip), %rax      # 0x17ff0
movq (%rax), %rdi
leaq 0x6301(%rip), %rsi      # 0x118cd
movl %ebp, %edx
movq %r14, %rcx
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x69c0
callq 0x6cfd
jmp 0xb575