// File: /workspace/github_c_makefile_star2_O3/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 $0x1168, %rsp           # imm = 0x1168
movq 0x30(%rdi), %rbx
leaq 0x2ed5(%rip), %rdi      # 0xe359
callq 0x5550
testq %rax, %rax
je 0xb6c1
leaq 0x2ed8(%rip), %rdx      # 0xe371
leaq 0x356d(%rip), %r8       # 0xea0d
leaq 0x160(%rsp), %rdi
movl $0x1000, %esi           # imm = 0x1000
movq %rax, %rcx
xorl %eax, %eax
callq 0x50b0
cmpl $0xfff, %eax            # imm = 0xFFF
ja 0xb6c1
leaq 0x3053(%rip), %rsi      # 0xe51c
leaq 0x160(%rsp), %rdi
callq 0x5200
testq %rax, %rax
je 0xb6c1
movq %rax, %r14
leaq 0x10(%rsp), %rax
movq $0x0, (%rax)
movq %rax, 0x8(%rax)
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0xd2df
testq %rax, %rax
je 0xb600
movq %rax, %rbp
xorl %r15d, %r15d
leaq 0x8(%rsp), %r12
leaq 0x20(%rsp), %r13
movq 0x8(%rsp), %rdi
cmpb $0xa, -0x1(%rbp,%rdi)
jne 0xb52d
leaq (%rdi,%rbp), %rax
decq %rax
jmp 0xb553
incq %rdi
callq 0x6178
movq %rax, %r15
movq 0x8(%rsp), %rdx
movq %rax, %rdi
movq %rbp, %rsi
callq 0x5860
movq %r15, %rax
addq 0x8(%rsp), %rax
movq %r15, %rbp
movb $0x0, (%rax)
movb (%rbp), %al
cmpb $0x7c, %al
jne 0xb569
cmpb $0x31, 0x1(%rbp)
jne 0xb569
cmpb $0x7c, 0x2(%rbp)
je 0xb5e7
movq 0x8(%rsp), %rsi
leaq (%rsi,%rbp), %rdx
xorl %ecx, %ecx
cmpb $0x20, %al
je 0xb58e
movzbl %al, %eax
cmpl $0x2c, %eax
je 0xb58e
cmpq %rcx, %rsi
je 0xb594
movb 0x1(%rbp,%rcx), %al
incq %rcx
jmp 0xb574
addq %rbp, %rcx
movq %rcx, %rdx
subq %rbp, %rdx
incq %rdx
cmpq $0x40, %rdx
ja 0xb5e7
movq %r13, %rdi
movq %rbp, %rsi
callq 0xd220
movl $0x1, %edi
movl $0x98, %esi
callq 0x6198
movq %rax, %rbp
leaq 0x20(%rax), %rdi
movl $0x33, %edx
movq %r13, %rsi
callq 0xd220
movq $0x0, (%rbp)
movq 0x18(%rsp), %rax
movq %rax, 0x8(%rbp)
movq %rbp, (%rax)
movq %rbp, 0x18(%rsp)
movq %r14, %rdi
movq %r12, %rsi
callq 0xd2df
movq %rax, %rbp
testq %rax, %rax
jne 0xb518
jmp 0xb603
xorl %r15d, %r15d
movq %r15, %rdi
callq 0x61b8
movq %r14, %rdi
callq 0x56b0
movq $0x0, (%rsp)
leaq 0x2e0d(%rip), %rdx      # 0xe42f
leaq -0x30d4(%rip), %r9      # 0x8555
leaq 0x10(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
xorl %ecx, %ecx
movl $0x1, %r8d
callq 0x7473
testq %rax, %rax
je 0xb6b7
movq %rax, %rbx
cmpb $0x0, 0x20(%rax)
je 0xb68b
movq %rbx, %r8
addq $0x20, %r8
movl $0xe0, %ecx
addq 0x894e(%rip), %rcx      # 0x13fb0
leaq 0x33b5(%rip), %rdx      # 0xea1e
leaq 0x60(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
xorl %eax, %eax
callq 0x50b0
cmpl $0xff, %eax
ja 0xb68b
leaq 0x60(%rsp), %rdi
callq 0x8618
cmpw $0x0, 0x90(%rbx)
je 0xb6b7
movq %rbx, %rdi
jmp 0xb6b2
movq (%rdi), %rax
movq 0x8(%rdi), %rcx
testq %rax, %rax
movq %rax, %rdx
cmoveq %r14, %rdx
movq %rcx, 0x8(%rdx)
movq %rax, (%rcx)
callq 0x61b8
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
jne 0xb69a
addq $0x1168, %rsp           # imm = 0x1168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq