// File: /workspace/github_c_makefile_star2_O1/zenlinux[P]cwm/kbfunc.c
// Function: kbfunc_ssh
void
kbfunc_ssh(struct client_ctx *cc, union arg *arg)
{
	struct screen_ctx	*sc = cc->sc;
	struct menu		*mi;
	struct menu_q		 menuq;
	FILE			*fp;
	char			*buf, *lbuf, *p, *home;
	char			 hostbuf[MAXHOSTNAMELEN], filename[MAXPATHLEN];
	char			 cmd[256];
	int			 l;
	size_t			 len;

	if ((home = getenv("HOME")) == NULL)
		return;

	l = snprintf(filename, sizeof(filename), "%s/%s", home, KNOWN_HOSTS);
	if (l == -1 || l >= sizeof(filename))
		return;

	if ((fp = fopen(filename, "r")) == NULL)
		return;

	TAILQ_INIT(&menuq);
	lbuf = NULL;
	while ((buf = fgetln(fp, &len))) {
		if (buf[len - 1] == '\n')
			buf[len - 1] = '\0';
		else {
			/* EOF without EOL, copy and add the NUL */
			lbuf = xmalloc(len + 1);
			(void)memcpy(lbuf, buf, len);
			lbuf[len] = '\0';
			buf = lbuf;
		}
		/* skip hashed hosts */
		if (strncmp(buf, HASH_MARKER, strlen(HASH_MARKER)) == 0)
			continue;
		for (p = buf; *p != ',' && *p != ' ' && p != buf + len; p++) {
			/* do nothing */
		}
		/* ignore badness */
		if (p - buf + 1 > sizeof(hostbuf))
			continue;
		(void)strlcpy(hostbuf, buf, p - buf + 1);
		mi = xcalloc(1, sizeof(*mi));
		(void)strlcpy(mi->text, hostbuf, sizeof(mi->text));
		TAILQ_INSERT_TAIL(&menuq, mi, entry);
	}
	xfree(lbuf);
	(void)fclose(fp);

	if ((mi = menu_filter(sc, &menuq, "ssh", NULL, 1,
	    search_match_exec, NULL)) != NULL) {
		if (mi->text[0] == '\0')
			goto out;
		l = snprintf(cmd, sizeof(cmd), "%s -e ssh %s", Conf.termpath,
		    mi->text);
		if (l != -1 && l < sizeof(cmd))
			u_spawn(cmd);
	}
out:
	if (mi != NULL && mi->dummy)
		xfree(mi);
	while ((mi = TAILQ_FIRST(&menuq)) != NULL) {
		TAILQ_REMOVE(&menuq, mi, entry);
		xfree(mi);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1178, %rsp           # imm = 0x1178
movq 0x30(%rdi), %rbx
leaq 0x2d1a(%rip), %rdi      # 0xe369
callq 0x5560
testq %rax, %rax
je 0xb89d
leaq 0x2d1d(%rip), %rdx      # 0xe381
leaq 0x33b2(%rip), %r8       # 0xea1d
leaq 0x170(%rsp), %rdi
movl $0x1000, %esi           # imm = 0x1000
movq %rax, %rcx
xorl %eax, %eax
callq 0x50b0
cmpl $0xfff, %eax            # imm = 0xFFF
ja 0xb89d
leaq 0x2e98(%rip), %rsi      # 0xe52c
leaq 0x170(%rsp), %rdi
callq 0x5210
testq %rax, %rax
je 0xb89d
movq %rax, %r14
movq %rbx, 0x28(%rsp)
leaq 0x18(%rsp), %rax
movq $0x0, (%rax)
movq %rax, 0x8(%rax)
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0xd5d3
testq %rax, %rax
je 0xb7d6
movq %rax, %r15
xorl %ebx, %ebx
leaq 0x334a(%rip), %r12      # 0xea2e
leaq 0x10(%rsp), %r13
leaq 0x30(%rsp), %rbp
movq 0x10(%rsp), %rdi
cmpb $0xa, -0x1(%r15,%rdi)
jne 0xb704
leaq (%r15,%rdi), %rax
decq %rax
jmp 0xb72a
incq %rdi
callq 0x6188
movq %rax, %rbx
movq 0x10(%rsp), %rdx
movq %rax, %rdi
movq %r15, %rsi
callq 0x5870
movq %rbx, %rax
addq 0x10(%rsp), %rax
movq %rbx, %r15
movb $0x0, (%rax)
movl $0x3, %edx
movq %r15, %rdi
movq %r12, %rsi
callq 0x51f0
testl %eax, %eax
je 0xb7bd
movq 0x10(%rsp), %rcx
leaq (%r15,%rcx), %rdx
xorl %eax, %eax
movzbl (%r15,%rax), %esi
cmpl $0x20, %esi
je 0xb765
cmpl $0x2c, %esi
je 0xb765
cmpq %rax, %rcx
je 0xb76b
incq %rax
jmp 0xb74c
addq %r15, %rax
movq %rax, %rdx
subq %r15, %rdx
incq %rdx
cmpq $0x40, %rdx
ja 0xb7bd
movq %rbp, %rdi
movq %r15, %rsi
callq 0xd500
movl $0x1, %edi
movl $0x98, %esi
callq 0x61a8
movq %rax, %r15
leaq 0x20(%rax), %rdi
movl $0x33, %edx
movq %rbp, %rsi
callq 0xd500
movq $0x0, (%r15)
movq 0x20(%rsp), %rax
movq %rax, 0x8(%r15)
movq %r15, (%rax)
movq %r15, 0x20(%rsp)
movq %r14, %rdi
movq %r13, %rsi
callq 0xd5d3
movq %rax, %r15
testq %rax, %rax
jne 0xb6ee
jmp 0xb7d8
xorl %ebx, %ebx
movq %rbx, %rdi
callq 0x61c8
movq %r14, %rdi
callq 0x56c0
movq $0x0, (%rsp)
leaq 0x2c48(%rip), %rdx      # 0xe43f
leaq -0x3120(%rip), %r9      # 0x86de
leaq 0x18(%rsp), %rbx
movq 0x28(%rsp), %rdi
movq %rbx, %rsi
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0x74d7
testq %rax, %rax
je 0xb893
movq %rax, %r14
cmpb $0x0, 0x20(%rax)
je 0xb862
movq %r14, %r8
addq $0x20, %r8
movl $0xe0, %ecx
addq 0x8777(%rip), %rcx      # 0x13fb0
leaq 0x31f2(%rip), %rdx      # 0xea32
leaq 0x70(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
xorl %eax, %eax
callq 0x50b0
cmpl $0xff, %eax
ja 0xb862
leaq 0x70(%rsp), %rdi
callq 0x87a4
cmpw $0x0, 0x90(%r14)
je 0xb893
movq %r14, %rdi
jmp 0xb88e
movq (%rdi), %rax
testq %rax, %rax
movq %rax, %rcx
cmoveq %rbx, %rcx
movq 0x8(%rdi), %rdx
movq %rdx, 0x8(%rcx)
movq 0x8(%rdi), %rcx
movq %rax, (%rcx)
callq 0x61c8
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
jne 0xb872
addq $0x1178, %rsp           # imm = 0x1178
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq