// File: /workspace/github_c_makefile_star2_O1/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 %r12
pushq %rbx
subq $0x30, %rsp
leaq 0xca17(%rip), %rax      # 0x175bc
movl (%rax), %eax
movl %eax, (%rsp)
leaq 0x5c9b(%rip), %rax      # 0x1084c
movq %rax, 0x8(%rsp)
leaq 0xca03(%rip), %rax      # 0x175c0
movl (%rax), %eax
movl %eax, 0x10(%rsp)
leaq 0x5c8d(%rip), %rax      # 0x10857
movq %rax, 0x18(%rsp)
leaq 0xc9ee(%rip), %rax      # 0x175c4
movl (%rax), %eax
movl %eax, 0x20(%rsp)
andb $-0x15, 0x11745(%rip)   # 0x1c328
leaq 0x5c78(%rip), %rax      # 0x10862
movq %rax, 0x28(%rsp)
movq 0x1377a(%rip), %rcx     # 0x1e370
movl $0x0, 0x13808(%rip)     # 0x1e408
movq 0x13779(%rip), %rax     # 0x1e380
movb $0x0, (%rcx,%rax)
cmpb $0x0, (%rcx)
je 0xac46
xorl %eax, %eax
leaq 0x1374f(%rip), %rdx     # 0x1e368
movq %rcx, 0x20(%rdx,%rax,8)
incq %rax
incq %rcx
movzbl -0x1(%rcx), %esi
testl %esi, %esi
je 0xac40
cmpl $0x3b, %esi
jne 0xac21
movb $0x0, -0x1(%rcx)
cmpq $0x10, %rax
jne 0xac19
movl $0x10, %eax
movl %eax, 0x137c2(%rip)     # 0x1e408
movl 0x137bb(%rip), %r15d    # 0x1e408
testl %r15d, %r15d
je 0xac62
movq 0x1372f(%rip), %rdi     # 0x1e388
callq 0x65e0
movl %eax, %ebx
jmp 0xac64
xorl %ebx, %ebx
movzbl 0x136fd(%rip), %eax     # 0x1e368
cmpl $0x5d, %eax
jle 0xac9d
leal -0x5e(%rax), %ecx
cmpl $0x2, %ecx
jb 0xaebc
cmpl $0x6b, %eax
jne 0xae37
movq 0x136fc(%rip), %rdi     # 0x1e388
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0xc615
cmpl $0x50, %eax
je 0xaebc
cmpl $0x5d, %eax
jne 0xae37
cmpl $0xc, %ebx
ja 0xad5c
movl %ebx, %eax
leaq 0x55c3(%rip), %rcx      # 0x10284
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpl $0x2, %r15d
jl 0xae37
leal -0xd(%rbx), %eax
cmpl $-0x3, %eax
jb 0xae37
movq 0x136a9(%rip), %r14     # 0x1e390
movslq %ebx, %r15
shlq $0x4, %r15
leaq 0x5b8c(%rip), %rsi      # 0x10881
movq %r14, %rdi
callq 0x6770
movq %rsp, %r12
movl -0xa0(%r15,%r12), %esi
testl %eax, %eax
je 0xae3e
movl %esi, %edi
movq %r14, %rsi
callq 0xbea9
testl %eax, %eax
jne 0xaee3
movl 0xd728(%rip), %edx      # 0x18450
decl %edx
movl %edx, %eax
sarl $0x1f, %eax
andl %edx, %eax
cltq
movl %edx, %ecx
negl %ecx
cmovsl %edx, %ecx
incl %ecx
shlq $0x2, %rax
addq 0x115a9(%rip), %rax     # 0x1c2f0
xorl %edx, %edx
movl $0x1, (%rax,%rdx,4)
incq %rdx
cmpl %edx, %ecx
jne 0xad49
jmp 0xaebc
cmpl $0x34, %ebx
je 0xae47
cmpl $0x68, %ebx
jne 0xae37
xorl %r14d, %r14d
jmp 0xadd0
cmpl $0x2, %r15d
jl 0xaebc
movq 0x1360c(%rip), %rdi     # 0x1e390
callq 0xc615
jmp 0xadab
cmpl $0x2, %r15d
jl 0xaebc
movq 0x135f4(%rip), %rdi     # 0x1e390
jmp 0xac8c
cmpl $0x2, %r15d
jl 0xaebc
movq 0x135de(%rip), %rdi     # 0x1e390
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0xc592
cmpl $0x3, %r15d
jl 0xae37
movq 0x135c8(%rip), %r14     # 0x1e398
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
cmpl $0x2, %r15d
jl 0xade9
movq 0x135ae(%rip), %rdi     # 0x1e390
callq 0x65e0
movl %eax, %ebp
testq %r14, %r14
je 0xae05
leaq 0x5a8c(%rip), %rsi      # 0x10881
movq %r14, %rdi
callq 0x6770
testl %eax, %eax
je 0xaec9
movl %ebp, %edi
movq %r14, %rsi
callq 0xbea9
testl %eax, %eax
je 0xae87
cmpl $0x1, %r15d
jg 0xaf18
cmpl $0x68, %ebx
jne 0xaf18
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0xbc62
callq 0x6d39
jmp 0xaebc
movl %ebx, %edi
xorl %edx, %edx
jmp 0xaed2
cmpl $0x3, %r15d
jl 0xaebc
leaq 0x13864(%rip), %rax     # 0x1e6b8
cmpl $0x0, (%rax)
je 0xaebc
movq 0x13538(%rip), %rdi     # 0x1e398
callq 0xafdf
testq %rax, %rax
je 0xaf4c
movq %rax, %rdi
callq 0xbbfa
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0xbb98
movl 0xd5c3(%rip), %edx      # 0x18450
decl %edx
movl %edx, %eax
sarl $0x1f, %eax
andl %edx, %eax
cltq
movl %edx, %ecx
negl %ecx
cmovsl %edx, %ecx
incl %ecx
shlq $0x2, %rax
addq 0x11444(%rip), %rax     # 0x1c2f0
xorl %edx, %edx
movl $0x1, (%rax,%rdx,4)
incq %rdx
cmpl %edx, %ecx
jne 0xaeae
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl %ebp, %edi
xorl %esi, %esi
movl $0x1, %edx
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0xb0e7
leaq (%r15,%r12), %rax
addq $-0xa0, %rax
movq 0xc0fc(%rip), %rcx      # 0x16ff0
movq (%rcx), %rdi
movq 0x8(%rax), %rdx
leaq 0x5981(%rip), %rsi      # 0x10883
movq %r14, %rcx
xorl %eax, %eax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x69e0
testq %r14, %r14
movq 0xc0ce(%rip), %rax      # 0x16ff0
movq (%rax), %rdi
leaq 0x5997(%rip), %rcx      # 0x108c3
cmovneq %r14, %rcx
leaq 0x596a(%rip), %rsi      # 0x108a1
movl %ebp, %edx
xorl %eax, %eax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x69e0
callq 0x6d1d
jmp 0xaebc