// File: /workspace/github_c_makefile_star2_O0/jarun[P]nnn/src/nnn.c
// Function: addcmdtohist
static void addcmdtohist(char *cmd)
{
	bool new = FALSE;

	if (lastcmdpos == INVALID_POS)
		new = TRUE;
	else if ((selcmdpos == INVALID_POS) || (xstrcmp(cmd_hist[selcmdpos], cmd) != 0)) { /* New or not matching */
		if (lastcmdpos == (MAX_HISTORY - 1)) {
			free(cmd_hist[0]);

			for (uchar_t pos = 0; pos < lastcmdpos; ++pos)
				cmd_hist[pos] = cmd_hist[pos + 1];
			--lastcmdpos;
		}

		new = TRUE;
	} else if (selcmdpos != lastcmdpos) { /* Command matches, make it the latest if not already */
		cmd = cmd_hist[selcmdpos];

		for (uchar_t pos = selcmdpos; pos < lastcmdpos; ++pos)
			cmd_hist[pos] = cmd_hist[pos + 1];
		cmd_hist[lastcmdpos] = cmd;
	}

	if (new)
		cmd_hist[++lastcmdpos] = xstrdup(cmd);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x10, %rsp
movq %rdi, -0x8(%rbp)
movb $0x0, -0x9(%rbp)
movzbl 0x6449(%rip), %eax      # 0x207a0
cmpl $0xff, %eax
jne 0x1a367
movb $0x1, -0x9(%rbp)
jmp 0x1a4c9
movzbl 0x648a(%rip), %eax      # 0x207f8
cmpl $0xff, %eax
je 0x1a3c9
movzbl 0x647c(%rip), %eax      # 0x207f8
movl %eax, %ecx
leaq 0x7a3b(%rip), %rax      # 0x21dc0
movq (%rax,%rcx,8), %rax
movsbl (%rax), %eax
movq -0x8(%rbp), %rcx
movsbl (%rcx), %ecx
cmpl %ecx, %eax
je 0x1a3a1
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movl %eax, -0x10(%rbp)
jmp 0x1a3c1
movzbl 0x6450(%rip), %eax      # 0x207f8
movl %eax, %ecx
leaq 0x7a0f(%rip), %rax      # 0x21dc0
movq (%rax,%rcx,8), %rdi
movq -0x8(%rbp), %rsi
callq 0x44e0
movl %eax, -0x10(%rbp)
movl -0x10(%rbp), %eax
cmpl $0x0, %eax
je 0x1a43b
movzbl 0x63d0(%rip), %eax      # 0x207a0
cmpl $0xf, %eax
jne 0x1a432
movq 0x79e4(%rip), %rdi      # 0x21dc0
callq 0x4090
movb $0x0, -0xa(%rbp)
movzbl -0xa(%rbp), %eax
movzbl 0x63b0(%rip), %ecx      # 0x207a0
cmpl %ecx, %eax
jge 0x1a424
movzbl -0xa(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rcx
leaq 0x79bb(%rip), %rax      # 0x21dc0
movq (%rax,%rcx,8), %rdx
movzbl -0xa(%rbp), %eax
movl %eax, %ecx
leaq 0x79aa(%rip), %rax      # 0x21dc0
movq %rdx, (%rax,%rcx,8)
movb -0xa(%rbp), %al
addb $0x1, %al
movb %al, -0xa(%rbp)
jmp 0x1a3e5
movb 0x6376(%rip), %al       # 0x207a0
addb $-0x1, %al
movb %al, 0x636e(%rip)       # 0x207a0
movb $0x1, -0x9(%rbp)
jmp 0x1a4c7
movzbl 0x63b6(%rip), %eax      # 0x207f8
movzbl 0x6357(%rip), %ecx      # 0x207a0
cmpl %ecx, %eax
je 0x1a4c5
movzbl 0x63a4(%rip), %eax      # 0x207f8
movl %eax, %ecx
leaq 0x7963(%rip), %rax      # 0x21dc0
movq (%rax,%rcx,8), %rax
movq %rax, -0x8(%rbp)
movb 0x638d(%rip), %al       # 0x207f8
movb %al, -0xb(%rbp)
movzbl -0xb(%rbp), %eax
movzbl 0x6327(%rip), %ecx      # 0x207a0
cmpl %ecx, %eax
jge 0x1a4ad
movzbl -0xb(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rcx
leaq 0x7932(%rip), %rax      # 0x21dc0
movq (%rax,%rcx,8), %rdx
movzbl -0xb(%rbp), %eax
movl %eax, %ecx
leaq 0x7921(%rip), %rax      # 0x21dc0
movq %rdx, (%rax,%rcx,8)
movb -0xb(%rbp), %al
addb $0x1, %al
movb %al, -0xb(%rbp)
jmp 0x1a46e
movq -0x8(%rbp), %rdx
movzbl 0x62e8(%rip), %eax      # 0x207a0
movl %eax, %ecx
leaq 0x78ff(%rip), %rax      # 0x21dc0
movq %rdx, (%rax,%rcx,8)
jmp 0x1a4c7
jmp 0x1a4c9
testb $0x1, -0x9(%rbp)
je 0x1a4f9
movq -0x8(%rbp), %rdi
callq 0x7190
movq %rax, %rdx
movb 0x62bf(%rip), %al       # 0x207a0
addb $0x1, %al
movb %al, 0x62b7(%rip)       # 0x207a0
movzbl %al, %eax
movl %eax, %ecx
leaq 0x78cb(%rip), %rax      # 0x21dc0
movq %rdx, (%rax,%rcx,8)
addq $0x10, %rsp
popq %rbp
retq
nop