// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/ansiart.c
// Function: do_control_sequence
static void do_control_sequence(deark *c, lctx *d, u8 code,
	i64 param_start, i64 param_len)
{
	if(code>=128) return;

	if(c->debug_level>=2) {
		de_dbg2(c, "[(%2d,%d) %c at %"I64_FMT" %d]", (int)(d->xpos+1), (int)(d->ypos+1),
			(char)code, param_start, (int)param_len);
	}

	if(param_len > (i64)(sizeof(d->param_string_buf)-1)) {
		de_warn(c, "Ignoring long control sequence (len %d at %"I64_FMT")",
			(int)param_len, param_start);
		goto done;
	}

	de_read(d->param_string_buf, param_start, param_len);
	d->param_string_buf[param_len] = '\0';

	switch(code) {
	case 'A': do_code_A(c, d); break;
	case 'B': do_code_B(c, d); break;
	case 'C': do_code_C(c, d); break;
	case 'D': do_code_D(c, d); break;
	case 'H': do_code_H(c, d); break;
	case 'h': do_code_h(c, d, param_start); break;
	case 'J': do_code_J(c, d); break;
	case 'K': do_code_K(c, d); break;
	case 'f': do_code_H(c, d); break; // f is the same as H
	case 'l': do_code_l(c, d, param_start); break;
	case 'm': do_code_m(c, d); break;
	case 'q': break; // Programmable LED command. Ignore.
	case 's':
		d->saved_xpos = d->xpos;
		d->saved_ypos = d->ypos;
		break;
	case 't': do_code_t(c, d, param_start); break;
	case 'u':
		d->xpos = d->saved_xpos;
		d->ypos = d->saved_ypos;
		break;
	default:
		if(!d->control_seq_seen[(UI)code]) {
			const char *name = NULL;
			switch(code) {
			case 'r': name = "Define scrolling region"; break;
			}

			if(name) {
				de_warn(c, "Unsupported control sequence '%c' (%s) at %"I64_FMT,
					(char)code, name, param_start);
			}
			else if(code>=0x70 && code<=0x7e) {
				// "Bit combinations 07/00 to 07/14 are available as final bytes
				// of control sequences for private use" -- ECMA 48
				de_warn(c, "Unsupported private-use control sequence '%c' at %"I64_FMT,
					(char)code, param_start);
			}
			else {
				de_warn(c, "Unsupported control sequence '%c' at %"I64_FMT,
					(char)code, param_start);
			}
		}
	}

done:
	d->control_seq_seen[(UI)code] = 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movb %dl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movzbl -0x11(%rbp), %eax
cmpl $0x80, %eax
jl 0x2097d
jmp 0x20c36
movq -0x8(%rbp), %rax
cmpl $0x2, (%rax)
jl 0x209c4
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
addq $0x1, %rax
movl %eax, %edx
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
addq $0x1, %rax
movl %eax, %ecx
movsbl -0x11(%rbp), %r8d
movq -0x20(%rbp), %r9
movq -0x28(%rbp), %rax
leaq 0x17d344(%rip), %rsi    # 0x19dcfe
movl %eax, (%rsp)
movb $0x0, %al
callq 0x15b350
cmpq $0x63, -0x28(%rbp)
jle 0x209ec
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rax
movl %eax, %edx
movq -0x20(%rbp), %rcx
leaq 0x17d336(%rip), %rsi    # 0x19dd16
movb $0x0, %al
callq 0x15bc10
jmp 0x20c24
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x10(%rbp), %rsi
addq $0xb8, %rsi
movq -0x20(%rbp), %rdx
movq -0x28(%rbp), %rcx
callq 0x164d10
movq -0x10(%rbp), %rax
movq -0x28(%rbp), %rcx
movb $0x0, 0xb8(%rax,%rcx)
movzbl -0x11(%rbp), %eax
addl $-0x41, %eax
movl %eax, %ecx
movq %rcx, -0x38(%rbp)
subl $0x34, %eax
ja 0x20b79
movq -0x38(%rbp), %rax
leaq 0x17cfe3(%rip), %rcx    # 0x19da20
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x21160
jmp 0x20c22
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x211b0
jmp 0x20c22
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x21200
jmp 0x20c22
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x21250
jmp 0x20c22
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x212c0
jmp 0x20c22
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x21360
jmp 0x20c22
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x214e0
jmp 0x20c22
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x21640
jmp 0x20c22
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x212c0
jmp 0x20c22
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x21710
jmp 0x20c22
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x218b0
jmp 0x20c22
jmp 0x20c22
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x40(%rax)
jmp 0x20c22
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0x21bc0
jmp 0x20c22
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x30(%rax)
jmp 0x20c22
movq -0x10(%rbp), %rax
movzbl -0x11(%rbp), %ecx
movl %ecx, %ecx
cmpb $0x0, 0x208(%rax,%rcx)
jne 0x20c20
movq $0x0, -0x30(%rbp)
movb -0x11(%rbp), %al
subb $0x72, %al
jne 0x20bad
jmp 0x20ba2
leaq 0x17d19c(%rip), %rax    # 0x19dd45
movq %rax, -0x30(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x20bd4
movq -0x8(%rbp), %rdi
movsbl -0x11(%rbp), %edx
movq -0x30(%rbp), %rcx
movq -0x20(%rbp), %r8
leaq 0x17d192(%rip), %rsi    # 0x19dd5d
movb $0x0, %al
callq 0x15bc10
jmp 0x20c1e
movzbl -0x11(%rbp), %eax
cmpl $0x70, %eax
jl 0x20c02
movzbl -0x11(%rbp), %eax
cmpl $0x7e, %eax
jg 0x20c02
movq -0x8(%rbp), %rdi
movsbl -0x11(%rbp), %edx
movq -0x20(%rbp), %rcx
leaq 0x17d192(%rip), %rsi    # 0x19dd8b
movb $0x0, %al
callq 0x15bc10
jmp 0x20c1c
movq -0x8(%rbp), %rdi
movsbl -0x11(%rbp), %edx
movq -0x20(%rbp), %rcx
leaq 0x17d1ab(%rip), %rsi    # 0x19ddc0
movb $0x0, %al
callq 0x15bc10
jmp 0x20c1e
jmp 0x20c20
jmp 0x20c22
jmp 0x20c24
movq -0x10(%rbp), %rax
movzbl -0x11(%rbp), %ecx
movl %ecx, %ecx
movb $0x1, 0x208(%rax,%rcx)
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)