// File: /workspace/github_c_makefile_star2_O2/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 0x3392(%rip), %rdi      # 0xe359
callq 0x5550
testq %rax, %rax
je 0xb1dd
leaq 0x3395(%rip), %rdx      # 0xe371
leaq 0x3a2a(%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 0xb1dd
leaq 0x3510(%rip), %rsi      # 0xe51c
leaq 0x160(%rsp), %rdi
callq 0x5200
testq %rax, %rax
je 0xb1dd
movq %rax, %r14
leaq 0x10(%rsp), %rbp
andq $0x0, (%rbp)
xorl %r13d, %r13d
leaq 0x8(%rsp), %r15
leaq 0x20(%rsp), %r12
movq %rbp, 0x18(%rsp)
movq %r14, %rdi
movq %r15, %rsi
callq 0xcdfd
testq %rax, %rax
je 0xb124
movq %rax, %rbp
movq 0x8(%rsp), %rdi
cmpb $0xa, -0x1(%rax,%rdi)
jne 0xb06d
leaq (%rdi,%rbp), %rax
decq %rax
jmp 0xb093
incq %rdi
callq 0x6014
movq %rax, %r13
movq 0x8(%rsp), %rdx
movq %rax, %rdi
movq %rbp, %rsi
callq 0x5860
movq %r13, %rax
addq 0x8(%rsp), %rax
movq %r13, %rbp
movb $0x0, (%rax)
movb (%rbp), %al
cmpb $0x7c, %al
jne 0xb0a9
cmpb $0x31, 0x1(%rbp)
jne 0xb0a9
cmpb $0x7c, 0x2(%rbp)
je 0xb041
movq 0x8(%rsp), %rsi
leaq (%rsi,%rbp), %rdx
xorl %ecx, %ecx
cmpb $0x20, %al
je 0xb0ce
movzbl %al, %eax
cmpl $0x2c, %eax
je 0xb0ce
cmpq %rcx, %rsi
je 0xb0d4
movb 0x1(%rbp,%rcx), %al
incq %rcx
jmp 0xb0b4
addq %rbp, %rcx
movq %rcx, %rdx
subq %rbp, %rdx
incq %rdx
cmpq $0x40, %rdx
ja 0xb041
movq %r12, %rdi
movq %rbp, %rsi
callq 0xcd50
movl $0x98, %esi
pushq $0x1
popq %rdi
callq 0x6032
movq %rax, %rbp
leaq 0x20(%rax), %rdi
movq %r12, %rsi
pushq $0x33
popq %rdx
callq 0xcd50
andq $0x0, (%rbp)
movq 0x18(%rsp), %rax
movq %rax, 0x8(%rbp)
movq %rbp, (%rax)
jmp 0xb03c
movq %r13, %rdi
callq 0x6050
movq %r14, %rdi
callq 0x56b0
andq $0x0, (%rsp)
leaq 0x32ef(%rip), %rdx      # 0xe42f
leaq -0x2e7a(%rip), %r9      # 0x82cd
leaq 0x10(%rsp), %r14
pushq $0x1
popq %r8
movq %rbx, %rdi
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x7294
testq %rax, %rax
je 0xb1b9
movq %rax, %rbx
cmpb $0x0, 0x20(%rax)
je 0xb1a7
movq %rbx, %r8
addq $0x20, %r8
movl $0xe0, %ecx
addq 0x8e32(%rip), %rcx      # 0x13fb0
leaq 0x3899(%rip), %rdx      # 0xea1e
leaq 0x60(%rsp), %rdi
movl $0x100, %esi            # imm = 0x100
xorl %eax, %eax
callq 0x50b0
cmpl $0xff, %eax
ja 0xb1a7
leaq 0x60(%rsp), %rdi
callq 0x8384
cmpw $0x0, 0x90(%rbx)
je 0xb1b9
movq %rbx, %rdi
callq 0x6050
movq 0x10(%rsp), %rbx
testq %rbx, %rbx
je 0xb1dd
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
testq %rax, %rax
movq %rax, %rdx
cmoveq %r14, %rdx
movq %rcx, 0x8(%rdx)
movq %rax, (%rcx)
jmp 0xb1b1
addq $0x1168, %rsp           # imm = 0x1168
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq