// File: /workspace/github_c_makefile_star2_O2/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 %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
andb $-0x15, 0xf6af(%rip)    # 0x1a500
movq 0x11848(%rip), %r14     # 0x1c6a0
andl $0x0, 0x118d9(%rip)     # 0x1c738
movq 0x1184a(%rip), %rax     # 0x1c6b0
movb $0x0, (%r14,%rax)
cmpb $0x0, (%r14)
je 0xaec7
xorl %r12d, %r12d
leaq 0x1181d(%rip), %rax     # 0x1c698
movq %r14, %rcx
cmpq $0x10, %r12
je 0xaebb
movq %rcx, 0x20(%rax,%r12,8)
incq %r12
incq %rcx
movzbl -0x1(%rcx), %edx
cmpl $0x3b, %edx
je 0xae9e
testl %edx, %edx
jne 0xae8c
jmp 0xaea4
movb $0x0, -0x1(%rcx)
jmp 0xae7e
movl %r12d, 0x1188d(%rip)    # 0x1c738
movq 0x11806(%rip), %rdi     # 0x1c6b8
callq 0x64d0
movl %eax, %ebx
jmp 0xaecc
movl %r12d, 0x11876(%rip)    # 0x1c738
testl %r12d, %r12d
jne 0xaeab
xorl %r12d, %r12d
xorl %ebx, %ebx
movzbl 0x117c5(%rip), %eax     # 0x1c698
leal -0x5e(%rax), %ecx
cmpl $0x2, %ecx
jb 0xb249
cmpl $0x50, %eax
je 0xaf28
cmpl $0x6b, %eax
je 0xaf5b
cmpl $0x5d, %eax
jne 0xb258
cmpl $0xc, %ebx
ja 0xaf97
movl %ebx, %eax
leaq 0x6458(%rip), %rcx      # 0x1135c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
cmpl $0x2, %r12d
jl 0xb249
movq 0x117a2(%rip), %rdi     # 0x1c6c0
callq 0xc3e6
jmp 0xb0e2
cmpb $0x3d, (%r14)
jne 0xb249
cmpb $0x31, 0x1(%r14)
jne 0xaf75
cmpb $0x73, 0x2(%r14)
jne 0xaf75
leaq 0xe581(%rip), %rsi      # 0x194c8
pushq $0x1
popq %rdi
callq 0x6130
movb $0x1, 0xe56a(%rip)      # 0x194c0
jmp 0xb249
movq 0x11756(%rip), %rdi     # 0x1c6b8
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xc3e6
cmpb $0x32, 0x1(%r14)
jne 0xb249
cmpb $0x73, 0x2(%r14)
jne 0xb249
movb $0x0, 0xe52e(%rip)      # 0x194c0
jmp 0xb249
cmpl $0x34, %ebx
je 0xb13d
cmpl $0x68, %ebx
jne 0xb258
xorl %r14d, %r14d
cmpl $0x2, %r12d
jge 0xb10d
pushq $-0x1
popq %rbp
leaq 0x69c4(%rip), %r15      # 0x11984
jmp 0xb34f
cmpl $0x2, %r12d
jl 0xb258
movq 0x116ea(%rip), %rbx     # 0x1c6c0
cmpb $0x3f, (%rbx)
jne 0xafe5
cmpb $0x0, 0x1(%rbx)
je 0xb396
leaq 0xd5ac(%rip), %rax      # 0x18598
movl (%rax), %edi
movq %rbx, %rsi
callq 0xbfd6
testl %eax, %eax
je 0xb383
movq 0xcfeb(%rip), %rax      # 0x17ff0
movq (%rax), %rdi
leaq 0x6931(%rip), %rsi      # 0x11940
jmp 0xb0aa
cmpl $0x2, %r12d
jl 0xb258
movq 0x1169b(%rip), %rbx     # 0x1c6c0
cmpb $0x3f, (%rbx)
jne 0xb034
cmpb $0x0, 0x1(%rbx)
je 0xb3a3
leaq 0xd555(%rip), %rax      # 0x18590
movl (%rax), %edi
movq %rbx, %rsi
callq 0xbfd6
testl %eax, %eax
je 0xb383
movq 0xcf9c(%rip), %rax      # 0x17ff0
movq (%rax), %rdi
leaq 0x6896(%rip), %rsi      # 0x118f4
jmp 0xb0aa
cmpl $0x2, %r12d
jl 0xb258
movq 0x1164f(%rip), %rbx     # 0x1c6c0
cmpb $0x3f, (%rbx)
jne 0xb080
cmpb $0x0, 0x1(%rbx)
je 0xb3b0
leaq 0xd50d(%rip), %rax      # 0x18594
movl (%rax), %edi
movq %rbx, %rsi
callq 0xbfd6
testl %eax, %eax
je 0xb383
movq 0xcf50(%rip), %rax      # 0x17ff0
movq (%rax), %rdi
leaq 0x6870(%rip), %rsi      # 0x1191a
movq %rbx, %rdx
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x68d0
cmpl $0x2, %r12d
jl 0xb249
movq 0x115ed(%rip), %rdi     # 0x1c6c0
jmp 0xaf62
cmpl $0x2, %r12d
jl 0xb249
movq 0x115d7(%rip), %rdi     # 0x1c6c0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xc363
cmpl $0x3, %r12d
jl 0xb258
movq 0x115bb(%rip), %r14     # 0x1c6c8
movq 0x115ac(%rip), %rdi     # 0x1c6c0
callq 0x64d0
movl %eax, %ebp
testq %r14, %r14
je 0xb345
cmpb $0x3f, (%r14)
jne 0xb135
cmpb $0x0, 0x1(%r14)
je 0xb3cf
movq %r14, %r15
jmp 0xb34f
cmpl $0x3, %r12d
jl 0xb249
leaq 0x1189a(%rip), %rax     # 0x1c9e8
cmpl $0x0, (%rax)
je 0xb249
movq 0x1156a(%rip), %r15     # 0x1c6c8
leaq 0x8(%rsp), %rax
movq %r15, (%rax)
movq %r15, %rdi
callq 0x6390
addq $0x3, %rax
shrq $0x2, %rax
leaq (%rax,%rax,2), %rdi
incq %rdi
callq 0x6b30
movq %rax, %r13
leaq 0x2(%rax), %rbp
movq %rax, 0x10(%rsp)
cmpb $0x0, (%r15)
je 0xb3e4
leaq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0xb4fa
movzbl %al, %eax
leaq 0x6311(%rip), %rbx      # 0x114c0
movb (%rax,%rbx), %r14b
movq %r12, %rdi
callq 0xb4fa
movzbl %al, %eax
movb (%rax,%rbx), %r15b
movq %r12, %rdi
callq 0xb4fa
movzbl %al, %eax
movb (%rax,%rbx), %bl
movq %r12, %rdi
callq 0xb4fa
cmpb $-0x1, %r14b
je 0xb3ea
cmpb $-0x1, %r15b
je 0xb3ea
movzbl %al, %eax
leaq 0x62ca(%rip), %rcx      # 0x114c0
movb (%rax,%rcx), %al
shlb $0x2, %r14b
movl %r15d, %ecx
shrb $0x4, %cl
andb $0x3, %cl
orb %r14b, %cl
movb %cl, -0x2(%rbp)
cmpb $-0x1, %bl
je 0xb3ef
shlb $0x4, %r15b
movl %ebx, %ecx
shrb $0x2, %cl
andb $0xf, %cl
orb %r15b, %cl
movb %cl, -0x1(%rbp)
cmpb $-0x1, %al
je 0xb3f2
shlb $0x6, %bl
orb %bl, %al
addq $0x3, %r13
movb %al, (%rbp)
movq 0x8(%rsp), %r15
addq $0x3, %rbp
jmp 0xb18e
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xcd91(%rip), %r12      # 0x17ff0
movq (%r12), %rcx
leaq 0x6721(%rip), %rdi      # 0x1198b
pushq $0x14
popq %rsi
pushq $0x1
popq %rbx
movq %rbx, %rdx
callq 0x6860
movq (%r12), %rdi
movsbl 0x11415(%rip), %edx     # 0x1c698
leaq 0x6716(%rip), %rsi      # 0x119a0
xorl %eax, %eax
callq 0x68d0
pushq $0x4
popq %r15
leaq 0x6719(%rip), %rbp      # 0x119b5
xorl %r13d, %r13d
cmpq 0x1140a(%rip), %r13     # 0x1c6b0
jae 0xb443
movq 0x113ed(%rip), %rax     # 0x1c6a0
movzbl (%rax,%r13), %r14d
testl %r14d, %r14d
je 0xb32b
callq 0x63b0
movq (%rax), %rax
testb $0x40, 0x1(%rax,%r14,2)
movq (%r12), %rcx
je 0xb2e1
movl %r14d, %edi
movq %rcx, %rsi
callq 0x6510
incq %r13
jmp 0xb29f
cmpl $0x1b, %r14d
je 0xb305
cmpl $0xd, %r14d
je 0xb2fc
cmpl $0xa, %r14d
jne 0xb319
leaq 0x66ac(%rip), %rdi      # 0x119a6
jmp 0xb30c
leaq 0x66a8(%rip), %rdi      # 0x119ab
jmp 0xb30c
leaq 0x66a4(%rip), %rdi      # 0x119b0
movq %r15, %rsi
movq %rbx, %rdx
callq 0x6860
jmp 0xb2dc
movq %rcx, %rdi
movq %rbp, %rsi
movl %r14d, %edx
xorl %eax, %eax
callq 0x68d0
jmp 0xb2dc
movq (%r12), %rsi
pushq $0xa
popq %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6510
leaq 0x6638(%rip), %r15      # 0x11984
xorl %r14d, %r14d
movl %ebp, %edi
movq %r14, %rsi
callq 0xbfd6
testl %eax, %eax
je 0xb383
cmpl $0x1, %r12d
jg 0xb418
cmpl $0x68, %ebx
jne 0xb418
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xbd47
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x83d9
leaq 0xd1fb(%rip), %rax      # 0x18598
movl (%rax), %edi
pushq $0xc
jmp 0xb3bb
leaq 0xd1e6(%rip), %rax      # 0x18590
movl (%rax), %edi
pushq $0xa
jmp 0xb3bb
leaq 0xd1dd(%rip), %rax      # 0x18594
movl (%rax), %edi
pushq $0xb
popq %rsi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x84b2
movl %ebp, %edi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x8423
addq $-0x2, %rbp
jmp 0xb3f2
movq %r13, %rbp
jmp 0xb3f2
decq %rbp
movb $0x0, (%rbp)
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0xb452
callq 0xbcdf
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0xbc80
movq 0xcbd1(%rip), %rax      # 0x17ff0
movq (%rax), %rdi
leaq 0x6539(%rip), %rsi      # 0x11962
movl %ebp, %edx
movq %r15, %rcx
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x68d0
movq (%r12), %rcx
leaq 0x656e(%rip), %rdi      # 0x119bc
pushq $0x5
jmp 0xb465
movq 0xcb97(%rip), %rax      # 0x17ff0
movq (%rax), %rcx
leaq 0x6479(%rip), %rdi      # 0x118dc
pushq $0x17
popq %rsi
pushq $0x1
popq %rdx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x6860