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

	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:
			if (narg < 2)
				break;

			p = strescseq.args[1];

			if (!strcmp(p, "?"))
				osc_color_response(defaultfg, 10);
			else if (xsetcolorname(defaultfg, p))
				fprintf(stderr, "erresc: invalid foreground color: %s\n", p);
			else
				tfulldirt();
			return;
		case 11:
			if (narg < 2)
				break;

			p = strescseq.args[1];

			if (!strcmp(p, "?"))
				osc_color_response(defaultbg, 11);
			else if (xsetcolorname(defaultbg, p))
				fprintf(stderr, "erresc: invalid background color: %s\n", p);
			else
				tfulldirt();
			return;
		case 12:
			if (narg < 2)
				break;

			p = strescseq.args[1];

			if (!strcmp(p, "?"))
				osc_color_response(defaultcs, 12);
			else if (xsetcolorname(defaultcs, p))
				fprintf(stderr, "erresc: invalid cursor color: %s\n", 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, "?"))
				osc4_color_response(j);
			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 */
		/* https://gitlab.com/gnachman/iterm2/-/wikis/synchronized-updates-spec */
		if (strstr(strescseq.buf, "=1s") == strescseq.buf)
			tsync_begin();  /* BSU */
		else if (strstr(strescseq.buf, "=2s") == strescseq.buf)
			tsync_end();  /* ESU */
		return;
	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
pushq %rax
andb $-0x15, 0xfeea(%rip)    # 0x1b510
movq 0x12083(%rip), %rbx     # 0x1d6b0
movl $0x0, 0x12111(%rip)     # 0x1d748
movq 0x12082(%rip), %rax     # 0x1d6c0
movb $0x0, (%rbx,%rax)
cmpb $0x0, (%rbx)
je 0xb680
xorl %eax, %eax
leaq 0x12058(%rip), %rcx     # 0x1d6a8
movq %rbx, %rdx
movq %rdx, 0x20(%rcx,%rax,8)
incq %rax
incq %rdx
movzbl -0x1(%rdx), %esi
testl %esi, %esi
je 0xb67a
cmpl $0x3b, %esi
jne 0xb65b
movb $0x0, -0x1(%rdx)
cmpq $0x10, %rax
jne 0xb653
movl $0x10, %eax
movl %eax, 0x120c8(%rip)     # 0x1d748
movl 0x120c1(%rip), %r15d    # 0x1d748
testl %r15d, %r15d
je 0xb69c
movq 0x12035(%rip), %rdi     # 0x1d6c8
callq 0x64d0
movl %eax, %ebp
jmp 0xb69e
xorl %ebp, %ebp
movzbl 0x12003(%rip), %eax     # 0x1d6a8
cmpl $0x5d, %eax
jle 0xb6bd
leal -0x5e(%rax), %ecx
cmpl $0x2, %ecx
jae 0xb6fd
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x50, %eax
je 0xb71c
cmpl $0x5d, %eax
jne 0xba0d
cmpl $0xc, %ebp
ja 0xb779
movl %ebp, %eax
leaq 0x6bb7(%rip), %rcx      # 0x12294
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpl $0x2, %r15d
jl 0xb6b2
movq 0x11fdd(%rip), %rdi     # 0x1d6d0
callq 0xce7d
jmp 0xb938
cmpl $0x6b, %eax
jne 0xba0d
movq 0x11fbb(%rip), %rdi     # 0x1d6c8
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xce7d
leaq 0x726c(%rip), %rsi      # 0x1298f
movl $0x3, %edx
movq %rbx, %rdi
callq 0x61f0
testl %eax, %eax
je 0xb75c
leaq 0x7258(%rip), %rsi      # 0x12993
movl $0x3, %edx
movq %rbx, %rdi
callq 0x61f0
testl %eax, %eax
jne 0xb6b2
movb $0x0, 0xed79(%rip)      # 0x1a4d0
jmp 0xb6b2
leaq 0xed75(%rip), %rsi      # 0x1a4d8
movl $0x1, %edi
callq 0x6130
movb $0x1, 0xed5c(%rip)      # 0x1a4d0
jmp 0xb6b2
cmpl $0x34, %ebp
je 0xb9c7
cmpl $0x68, %ebp
jne 0xba0d
xorl %ebx, %ebx
jmp 0xb95f
cmpl $0x2, %r15d
jl 0xba0d
movq 0x11f2d(%rip), %rbx     # 0x1d6d0
leaq 0x714c(%rip), %rsi      # 0x128f6
movq %rbx, %rdi
callq 0x6680
leaq 0xddef(%rip), %rcx      # 0x195a8
movl (%rcx), %edi
testl %eax, %eax
je 0xba6a
movq %rbx, %rsi
callq 0xca52
testl %eax, %eax
jne 0xbabf
movb $0x0, 0xecf6(%rip)      # 0x1a4d0
movl 0xed38(%rip), %edx      # 0x1a518
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 0xfcd9(%rip), %rax      # 0x1b4d8
xorl %edx, %edx
movl $0x1, (%rax,%rdx,4)
incq %rdx
cmpl %edx, %ecx
jne 0xb801
jmp 0xb6b2
cmpl $0x2, %r15d
jl 0xba0d
movq 0x11eab(%rip), %rbx     # 0x1d6d0
leaq 0x70ca(%rip), %rsi      # 0x128f6
movq %rbx, %rdi
callq 0x6680
leaq 0xdd65(%rip), %rcx      # 0x195a0
movl (%rcx), %edi
testl %eax, %eax
je 0xba71
movq %rbx, %rsi
callq 0xca52
testl %eax, %eax
jne 0xbad2
movb $0x0, 0xec74(%rip)      # 0x1a4d0
movl 0xecb6(%rip), %edx      # 0x1a518
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 0xfc57(%rip), %rax      # 0x1b4d8
xorl %edx, %edx
movl $0x1, (%rax,%rdx,4)
incq %rdx
cmpl %edx, %ecx
jne 0xb883
jmp 0xb6b2
cmpl $0x2, %r15d
jl 0xba0d
movq 0x11e29(%rip), %rbx     # 0x1d6d0
leaq 0x7048(%rip), %rsi      # 0x128f6
movq %rbx, %rdi
callq 0x6680
leaq 0xdce7(%rip), %rcx      # 0x195a4
movl (%rcx), %edi
testl %eax, %eax
je 0xba78
movq %rbx, %rsi
callq 0xca52
testl %eax, %eax
jne 0xbae5
movb $0x0, 0xebf2(%rip)      # 0x1a4d0
movl 0xec34(%rip), %edx      # 0x1a518
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 0xfbd5(%rip), %rax      # 0x1b4d8
xorl %edx, %edx
movl $0x1, (%rax,%rdx,4)
incq %rdx
cmpl %edx, %ecx
jne 0xb905
jmp 0xb6b2
cmpl $0x2, %r15d
jl 0xb6b2
movq 0x11da7(%rip), %rdi     # 0x1d6d0
jmp 0xb70d
cmpl $0x2, %r15d
jl 0xb6b2
movq 0x11d91(%rip), %rdi     # 0x1d6d0
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xcdf0
cmpl $0x3, %r15d
jl 0xba0d
movq 0x11d79(%rip), %rbx     # 0x1d6d8
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
cmpl $0x2, %r15d
jl 0xb97a
movq 0x11d5e(%rip), %rdi     # 0x1d6d0
callq 0x64d0
movl %eax, %r14d
testq %rbx, %rbx
je 0xb996
leaq 0x6f70(%rip), %rsi      # 0x128f6
movq %rbx, %rdi
callq 0x6680
testl %eax, %eax
je 0xba58
movl %r14d, %edi
movq %rbx, %rsi
callq 0xca52
testl %eax, %eax
je 0xba17
cmpl $0x1, %r15d
jg 0xba8c
cmpl $0x68, %ebp
jne 0xba8c
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xc786
cmpl $0x3, %r15d
jl 0xb6b2
leaq 0x12020(%rip), %rax     # 0x1d9f8
cmpl $0x0, (%rax)
je 0xb6b2
movq 0x11cf0(%rip), %rdi     # 0x1d6d8
callq 0xbb9d
testq %rax, %rax
je 0xbb0a
movq %rax, %rdi
callq 0xc71e
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0xc6bc
callq 0x6cd5
jmp 0xb6b2
movb $0x0, 0xeab2(%rip)      # 0x1a4d0
movl 0xeaf4(%rip), %edx      # 0x1a518
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 0xfa95(%rip), %rax      # 0x1b4d8
xorl %edx, %edx
movl $0x1, (%rax,%rdx,4)
incq %rdx
cmpl %edx, %ecx
jne 0xba45
jmp 0xb6b2
movl %r14d, %edi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x8ab4
movl $0xc, %esi
jmp 0xba7d
movl $0xa, %esi
jmp 0xba7d
movl $0xb, %esi
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x8b47
testq %rbx, %rbx
movq 0xd55a(%rip), %rax      # 0x18ff0
movq (%rax), %rdi
leaq 0x6ee8(%rip), %rcx      # 0x12988
cmovneq %rbx, %rcx
leaq 0x6ebb(%rip), %rsi      # 0x12966
movl %r14d, %edx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x68e0
movq 0xd52a(%rip), %rax      # 0x18ff0
movq (%rax), %rdi
leaq 0x6e74(%rip), %rsi      # 0x12944
jmp 0xbaf6
movq 0xd517(%rip), %rax      # 0x18ff0
movq (%rax), %rdi
leaq 0x6e15(%rip), %rsi      # 0x128f8
jmp 0xbaf6
movq 0xd504(%rip), %rax      # 0x18ff0
movq (%rax), %rdi
leaq 0x6e28(%rip), %rsi      # 0x1291e
movq %rbx, %rdx
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x68e0
callq 0x6cb9
jmp 0xb6b2