// File: /workspace/github_c_makefile_star2_O0/FirestonnneTFM[P]tfm_key_parser/src/main_sniffer.cpp
// Function: find_handshake()
static void find_handshake() {
	class_info *c = abc_file::get_class(0);
	c->do_static_init();
	uint8_t *target = nullptr;
	for (auto trait : c->traits) {
		if (trait.kind == Trait_Method) {
			method_info *method = abc_file::get_method(trait.vindex);
			if (method->param_type.length() == 1 && method->code.length() > 50
				&& streq(method->param_type[0]->str, "Event")) {
				executer exec(method);
				if (exec.step() != OP_getlocal_0)
					continue;
				if (exec.step() != OP_pushscope)
					continue;
				if (exec.step() != OP_pushnull)
					continue;
				if (exec.next() != OP_coerce)
					continue;
				uint32_t obj;
				exec >> obj;
				if (! streq(abc_file::get_multiname(obj)->str, "Font"))
					continue;
				if (target)
					fatal("Handshake method not unqiue");
				else
					target = method->code.begin();
			}
		}
	}
	if (target == nullptr)
		fatal("Could not find suitable handshake method");
	executer exec(target);
	exec.step_until(OP_inclocal_i);
	exec.step_until(OP_setlocal);
	exec.step_until(OP_getproperty);
	exec.step_until(OP_getproperty);
	exec.step_until(OP_getproperty);
	char *str = key.handshake;
	for (int count = 0; count < 2 || exec.step() == OP_add; ++count) {
		assert(exec.next() == OP_getlex);
		char *ret = exec.get_lex_str();
		size_t len = strlen(ret);
		for (unsigned i = 0; i < len; ++i, ++str) {
			*str = ret[i];
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
xorl %edi, %edi
callq 0x36b0
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0x4f90
movq $0x0, -0x10(%rbp)
movq -0x8(%rbp), %rax
addq $0x68, %rax
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0x5520
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
callq 0xade0
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
cmpq -0x28(%rbp), %rax
je 0xa2ea
movq -0x20(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x40(%rbp)
movq 0x8(%rax), %rcx
movq %rcx, -0x38(%rbp)
movq 0x10(%rax), %rax
movq %rax, -0x30(%rbp)
movzbl -0x38(%rbp), %eax
cmpl $0x1, %eax
jne 0xa2d7
movl -0x34(%rbp), %edi
callq 0x3680
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
callq 0xae00
cmpl $0x1, %eax
jne 0xa2d5
movq -0x48(%rbp), %rdi
addq $0x38, %rdi
callq 0xae10
cmpl $0x32, %eax
jbe 0xa2d5
movq -0x48(%rbp), %rdi
xorl %esi, %esi
callq 0x5430
movq (%rax), %rax
movq 0x10(%rax), %rdi
leaq 0x163a(%rip), %rsi      # 0xb7ea
callq 0x2230
cmpl $0x0, %eax
jne 0xa2d5
movq -0x48(%rbp), %rsi
leaq -0x58(%rbp), %rdi
callq 0xad00
leaq -0x58(%rbp), %rdi
callq 0x2b10
movzbl %al, %eax
cmpl $0xd0, %eax
je 0xa1e3
jmp 0xa2d9
leaq -0x58(%rbp), %rdi
callq 0x2b10
movzbl %al, %eax
cmpl $0x30, %eax
je 0xa1f9
jmp 0xa2d9
leaq -0x58(%rbp), %rdi
callq 0x2b10
movzbl %al, %eax
cmpl $0x20, %eax
je 0xa20f
jmp 0xa2d9
leaq -0x58(%rbp), %rdi
callq 0x42e0
movzbl %al, %eax
cmpl $0x80, %eax
je 0xa227
jmp 0xa2d9
leaq -0x58(%rbp), %rdi
leaq -0x5c(%rbp), %rsi
callq 0x43e0
movl -0x5c(%rbp), %edi
callq 0x35e0
movq 0x10(%rax), %rdi
leaq 0x15a9(%rip), %rsi      # 0xb7f0
callq 0x2230
cmpl $0x0, %eax
je 0xa256
jmp 0xa2d9
cmpq $0x0, -0x10(%rbp)
je 0xa2c2
movl $0x18, %edi
callq 0x20e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xb0(%rbp)
leaq 0x157a(%rip), %rsi      # 0xb7f5
leaq 0x1459(%rip), %rdx      # 0xb6db
movl $0xf5, %ecx
callq 0x2f40
jmp 0xa28e
movq -0xb0(%rbp), %rdi
leaq 0x6aec(%rip), %rsi      # 0x10d88
xorl %eax, %eax
movl %eax, %edx
callq 0x22a0
movq -0xb0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
callq 0x2110
jmp 0xa510
movq -0x48(%rbp), %rdi
addq $0x38, %rdi
callq 0x5570
movq %rax, -0x10(%rbp)
jmp 0xa2d5
jmp 0xa2d7
jmp 0xa2d9
movq -0x20(%rbp), %rax
addq $0x18, %rax
movq %rax, -0x20(%rbp)
jmp 0xa12d
cmpq $0x0, -0x10(%rbp)
jne 0xa356
movl $0x18, %edi
callq 0x20e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xb8(%rbp)
leaq 0x1502(%rip), %rsi      # 0xb811
leaq 0x13c5(%rip), %rdx      # 0xb6db
movl $0xfc, %ecx
callq 0x2f40
jmp 0xa322
movq -0xb8(%rbp), %rdi
leaq 0x6a58(%rip), %rsi      # 0x10d88
xorl %eax, %eax
movl %eax, %edx
callq 0x22a0
movq -0xb8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
callq 0x2110
jmp 0xa510
movq -0x10(%rbp), %rsi
leaq -0x80(%rbp), %rdi
callq 0xae20
leaq -0x80(%rbp), %rdi
movl $0xc2, %esi
callq 0x2d70
leaq -0x80(%rbp), %rdi
movl $0x63, %esi
callq 0x2d70
leaq -0x80(%rbp), %rdi
movl $0x66, %esi
callq 0x2d70
leaq -0x80(%rbp), %rdi
movl $0x66, %esi
callq 0x2d70
leaq -0x80(%rbp), %rdi
movl $0x66, %esi
callq 0x2d70
leaq 0x7634(%rip), %rax      # 0x119e4
addq $0x1c, %rax
movq %rax, -0x88(%rbp)
movl $0x0, -0x8c(%rbp)
movb $0x1, %al
cmpl $0x2, -0x8c(%rbp)
movb %al, -0xb9(%rbp)
jl 0xa3f0
leaq -0x80(%rbp), %rdi
callq 0x2b10
movzbl %al, %eax
cmpl $0xa0, %eax
sete %al
movb %al, -0xb9(%rbp)
movb -0xb9(%rbp), %al
testb $0x1, %al
jne 0xa3ff
jmp 0xa507
jmp 0xa401
leaq -0x80(%rbp), %rdi
callq 0x42e0
movzbl %al, %eax
cmpl $0x60, %eax
je 0xa477
movl $0x18, %edi
callq 0x20e0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xc8(%rbp)
leaq 0x12c0(%rip), %rsi      # 0xb6f0
leaq 0x12a4(%rip), %rdx      # 0xb6db
movl $0x105, %ecx            # imm = 0x105
callq 0x2f40
jmp 0xa443
movq -0xc8(%rbp), %rdi
leaq 0x6937(%rip), %rsi      # 0x10d88
xorl %eax, %eax
movl %eax, %edx
callq 0x22a0
movq -0xc8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x68(%rbp)
movl %eax, -0x6c(%rbp)
callq 0x2110
jmp 0xa510
jmp 0xa479
leaq -0x80(%rbp), %rdi
callq 0x94f0
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rdi
callq 0x20d0
movq %rax, -0xa0(%rbp)
movl $0x0, -0xa4(%rbp)
movl -0xa4(%rbp), %eax
cmpq -0xa0(%rbp), %rax
jae 0xa4f1
movq -0x98(%rbp), %rax
movl -0xa4(%rbp), %ecx
movb (%rax,%rcx), %cl
movq -0x88(%rbp), %rax
movb %cl, (%rax)
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
movq -0x88(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x88(%rbp)
jmp 0xa4a6
jmp 0xa4f3
movl -0x8c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x8c(%rbp)
jmp 0xa3c5
addq $0xd0, %rsp
popq %rbp
retq
movq -0x68(%rbp), %rdi
callq 0x22d0
nopl (%rax)