// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x11c0, %rsp           # imm = 0x11C0
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movq %rax, -0x18(%rbp)
leaq 0x4db8(%rip), %rdi      # 0x144be
callq 0x5550
movq %rax, -0x58(%rbp)
cmpq $0x0, %rax
jne 0xf71a
jmp 0xfa72
leaq -0x10a0(%rbp), %rdi
movq -0x58(%rbp), %rcx
movl $0x1000, %esi           # imm = 0x1000
leaq 0x4da5(%rip), %rdx      # 0x144d6
leaq 0x53c1(%rip), %r8       # 0x14af9
movb $0x0, %al
callq 0x50b0
movl %eax, -0x11a4(%rbp)
cmpl $-0x1, -0x11a4(%rbp)
je 0xf75d
movslq -0x11a4(%rbp), %rax
cmpq $0x1000, %rax           # imm = 0x1000
jb 0xf762
jmp 0xfa72
leaq -0x10a0(%rbp), %rdi
leaq 0x4f11(%rip), %rsi      # 0x14681
callq 0x5210
movq %rax, -0x38(%rbp)
cmpq $0x0, %rax
jne 0xf784
jmp 0xfa72
jmp 0xf786
movq $0x0, -0x30(%rbp)
leaq -0x30(%rbp), %rax
movq %rax, -0x28(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x38(%rbp), %rdi
leaq -0x11b0(%rbp), %rsi
callq 0x12ed0
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
je 0xf942
movq -0x40(%rbp), %rax
movq -0x11b0(%rbp), %rcx
subq $0x1, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
jne 0xf7e9
movq -0x40(%rbp), %rax
movq -0x11b0(%rbp), %rcx
subq $0x1, %rcx
movb $0x0, (%rax,%rcx)
jmp 0xf828
movq -0x11b0(%rbp), %rdi
addq $0x1, %rdi
callq 0x6420
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x11b0(%rbp), %rdx
callq 0x5860
movq -0x48(%rbp), %rax
movq -0x11b0(%rbp), %rcx
movb $0x0, (%rax,%rcx)
movq -0x48(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rdi
leaq 0x52d7(%rip), %rsi      # 0x14b0a
movl $0x3, %edx
callq 0x51f0
cmpl $0x0, %eax
jne 0xf847
jmp 0xf79e
movq -0x40(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x2c, %ecx
movb %al, -0x11b1(%rbp)
je 0xf892
movq -0x50(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x20, %ecx
movb %al, -0x11b1(%rbp)
je 0xf892
movq -0x50(%rbp), %rax
movq -0x40(%rbp), %rcx
addq -0x11b0(%rbp), %rcx
cmpq %rcx, %rax
setne %al
movb %al, -0x11b1(%rbp)
movb -0x11b1(%rbp), %al
testb $0x1, %al
jne 0xf89e
jmp 0xf8ae
jmp 0xf8a0
movq -0x50(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0xf84f
movq -0x50(%rbp), %rax
movq -0x40(%rbp), %rcx
subq %rcx, %rax
addq $0x1, %rax
cmpq $0x40, %rax
jbe 0xf8c8
jmp 0xf79e
leaq -0xa0(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq -0x40(%rbp), %rax
subq %rax, %rdx
addq $0x1, %rdx
callq 0x12ce0
movl $0x1, %edi
movl $0x98, %esi
callq 0x6460
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
addq $0x20, %rdi
leaq -0xa0(%rbp), %rsi
movl $0x33, %edx
callq 0x12ce0
movq -0x20(%rbp), %rax
movq $0x0, (%rax)
movq -0x28(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x20(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0xf79e
movq -0x48(%rbp), %rdi
callq 0x64b0
movq -0x38(%rbp), %rdi
callq 0x56b0
movq -0x18(%rbp), %rdi
leaq -0x30(%rbp), %rsi
leaq 0x4c31(%rip), %rdx      # 0x14594
xorl %eax, %eax
movl %eax, %ecx
movl $0x1, %r8d
leaq -0x5284(%rip), %r9      # 0xa6f0
movq $0x0, (%rsp)
callq 0x8a30
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0xf9f6
movq -0x20(%rbp), %rax
movsbl 0x20(%rax), %eax
cmpl $0x0, %eax
jne 0xf99a
jmp 0xf9f8
leaq -0x11a0(%rbp), %rdi
movq -0x20(%rbp), %r8
addq $0x20, %r8
movl $0x100, %esi            # imm = 0x100
leaq 0x5159(%rip), %rdx      # 0x14b0e
leaq 0xad04(%rip), %rcx      # 0x1a6c0
addq $0xe0, %rcx
movb $0x0, %al
callq 0x50b0
movl %eax, -0x11a4(%rbp)
cmpl $-0x1, -0x11a4(%rbp)
je 0xf9f4
movslq -0x11a4(%rbp), %rax
cmpq $0x100, %rax            # imm = 0x100
jae 0xf9f4
leaq -0x11a0(%rbp), %rdi
callq 0xa850
jmp 0xf9f6
jmp 0xf9f8
cmpq $0x0, -0x20(%rbp)
je 0xfa18
movq -0x20(%rbp), %rax
movswl 0x90(%rax), %eax
cmpl $0x0, %eax
je 0xfa18
movq -0x20(%rbp), %rdi
callq 0x64b0
jmp 0xfa1a
movq -0x30(%rbp), %rax
movq %rax, -0x20(%rbp)
cmpq $0x0, %rax
je 0xfa72
jmp 0xfa2a
movq -0x20(%rbp), %rax
cmpq $0x0, (%rax)
je 0xfa49
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rcx
movq -0x20(%rbp), %rax
movq (%rax), %rax
movq %rcx, 0x8(%rax)
jmp 0xfa55
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq (%rax), %rcx
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rdi
callq 0x64b0
jmp 0xfa1a
addq $0x11c0, %rsp           # imm = 0x11C0
popq %rbp
retq
nopl (%rax,%rax)