// File: /workspace/github_c_makefile_star2_O2/jarun[P]nnn/src/nnn.c
// Function: set_sort_flags
static int set_sort_flags(int r)
{
	bool session = (r == '\0');
	bool reverse = FALSE;

	if (ISUPPER_(r) && (r != 'R') && (r != 'C')) {
		reverse = TRUE;
		r = TOLOWER(r);
	}

	/* Set the correct input in case of a session load */
	if (session) {
		if (cfg.apparentsz) {
			cfg.apparentsz = 0;
			r = 'a';
		} else if (cfg.blkorder) {
			cfg.blkorder = 0;
			r = 'd';
		}

		/* Ensure function pointers are in sync with cfg. */
		entrycmpfn = cfg.reverse ? &reventrycmp : &entrycmp;
		namecmpfn = cfg.version ? &xstrverscasecmp : &xstricmp;
	} else if (r == CONTROL('T')) {
		/* Cycling order: clear -> size -> time -> clear */
		if (cfg.timeorder)
			r = 's';
		else if (cfg.sizeorder)
			r = 'c';
		else
			r = 't';
	}

	switch (r) {
	case 'a': /* Apparent du */
		cfg.apparentsz ^= 1;
		if (cfg.apparentsz) {
			cfg.blkorder = 1;
			blk_shift = 0;
		} else
			cfg.blkorder = 0;
		// fallthrough
	case 'd': /* Disk usage */
		if (r == 'd') {
			if (!cfg.apparentsz)
				cfg.blkorder ^= 1;
			cfg.apparentsz = 0;
			blk_shift = ffs(S_BLKSIZE) - 1;
		}

		if (cfg.blkorder)
			cfg.showdetail = 1;
		cfg.timeorder = 0;
		cfg.sizeorder = 0;
		cfg.extnorder = 0;
		if (!session) {
			cfg.reverse = 0;
			entrycmpfn = &entrycmp;
		}
		endselection(TRUE); /* We are going to reload dir */
		break;
	case 'c':
		cfg.timeorder = 0;
		cfg.sizeorder = 0;
		cfg.apparentsz = 0;
		cfg.blkorder = 0;
		cfg.extnorder = 0;
		cfg.reverse = 0;
		cfg.version = 0;
		entrycmpfn = &entrycmp;
		namecmpfn = &xstricmp;
		break;
	case 'e': /* File extension */
		cfg.extnorder ^= 1;
		cfg.sizeorder = 0;
		cfg.timeorder = 0;
		cfg.apparentsz = 0;
		cfg.blkorder = 0;
		cfg.reverse = 0;
		entrycmpfn = &entrycmp;
		break;
	case 'r': /* Reverse sort */
		cfg.reverse ^= 1;
		entrycmpfn = cfg.reverse ? &reventrycmp : &entrycmp;
		break;
	case 's': /* File size */
		cfg.sizeorder ^= 1;
		cfg.timeorder = 0;
		cfg.apparentsz = 0;
		cfg.blkorder = 0;
		cfg.extnorder = 0;
		cfg.reverse = 0;
		entrycmpfn = &entrycmp;
		break;
	case 't': /* Time */
		cfg.timeorder ^= 1;
		cfg.sizeorder = 0;
		cfg.apparentsz = 0;
		cfg.blkorder = 0;
		cfg.extnorder = 0;
		cfg.reverse = 0;
		entrycmpfn = &entrycmp;
		break;
	case 'v': /* Version */
		cfg.version ^= 1;
		namecmpfn = cfg.version ? &xstrverscasecmp : &xstricmp;
		cfg.timeorder = 0;
		cfg.sizeorder = 0;
		cfg.apparentsz = 0;
		cfg.blkorder = 0;
		cfg.extnorder = 0;
		break;
	default:
		return 0;
	}

	if (reverse) {
		cfg.reverse = 1;
		entrycmpfn = &reventrycmp;
	}

	cfgsort[cfg.curctx] = (uchar_t)r;

	return r;
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
movl %edi, %ebx
leal -0x41(%rbx), %ebp
cmpl $0x19, %ebp
ja 0x6b72
movl %ebx, %r14d
cmpl $0x43, %ebx
je 0x6bfb
movl %ebx, %r14d
cmpl $0x52, %ebx
je 0x6bfb
movl %ebx, %r14d
orl $0x20, %r14d
jmp 0x6bfb
testl %ebx, %ebx
je 0x6b99
movl %ebx, %r14d
cmpl $0x14, %ebx
jne 0x6bfb
movl 0x12944(%rip), %eax     # 0x194c8
testb $0x2, %al
jne 0x6d64
testb $0x4, %al
jne 0x6cd8
jmp 0x6d3e
movl 0x12929(%rip), %eax     # 0x194c8
testb $0x8, %al
jne 0x6bb2
xorl %r14d, %r14d
testb $0x10, %al
je 0x6bc1
pushq $0x64
popq %r14
pushq $-0x19
jmp 0x6bb8
pushq $0x61
popq %r14
pushq $-0x9
popq %rcx
andl %ecx, %eax
movl %eax, 0x12907(%rip)     # 0x194c8
btl $0xa, %eax
leaq 0x6bd5(%rip), %rcx      # 0xd7a1
leaq 0x6ba4(%rip), %rdx      # 0xd777
cmovaeq %rcx, %rdx
movq %rdx, 0x12902(%rip)     # 0x194e0
btl $0xb, %eax
leaq 0x6e11(%rip), %rax      # 0xd9fa
leaq 0x6cdc(%rip), %rcx      # 0xd8cc
cmovaeq %rax, %rcx
movq %rcx, 0x128ed(%rip)     # 0x194e8
xorl %eax, %eax
leal -0x61(%r14), %ecx
cmpl $0x4, %ecx
jbe 0x6c5c
addl $-0x72, %r14d
cmpl $0x4, %r14d
ja 0x6e00
leaq 0xc52d(%rip), %rcx      # 0x13148
movslq (%rcx,%r14,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
movl 0x1289e(%rip), %eax     # 0x194c8
movl %eax, %ecx
xorl $0x400, %ecx            # imm = 0x400
movl %ecx, 0x12890(%rip)     # 0x194c8
btl $0xa, %eax
leaq 0x6b34(%rip), %rax      # 0xd777
leaq 0x6b57(%rip), %rcx      # 0xd7a1
cmovaeq %rax, %rcx
movq %rcx, 0x1288b(%rip)     # 0x194e0
pushq $0x72
jmp 0x6d82
leaq 0xc4d1(%rip), %rdx      # 0x13134
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movl 0x12856(%rip), %eax     # 0x194c8
testb $0x8, %al
jne 0x6d85
orl $0x18, %eax
movb $0x1, 0x1c440(%rip)     # 0x230c4
jmp 0x6d88
movl $0xfffffbe1, %eax       # imm = 0xFFFFFBE1
andl 0x12834(%rip), %eax     # 0x194c8
xorl $0x20, %eax
movl %eax, 0x1282b(%rip)     # 0x194c8
leaq 0x6afd(%rip), %rax      # 0xd7a1
movq %rax, 0x12835(%rip)     # 0x194e0
pushq $0x65
jmp 0x6d82
movl 0x12810(%rip), %eax     # 0x194c8
leal (%rax,%rax), %ecx
andl $0x10, %ecx
andl $-0x9, %eax
xorl %ecx, %eax
xorl $0x10, %eax
movb $0x0, 0x1c3f7(%rip)     # 0x230c4
jmp 0x6d88
movl 0x127f0(%rip), %eax     # 0x194c8
andl $0xfffff3c1, %eax       # imm = 0xFFFFF3C1
movl %eax, 0x127e5(%rip)     # 0x194c8
leaq 0x6ab7(%rip), %rax      # 0xd7a1
movq %rax, 0x127ef(%rip)     # 0x194e0
leaq 0x6d02(%rip), %rax      # 0xd9fa
movq %rax, 0x127e9(%rip)     # 0x194e8
pushq $0x63
jmp 0x6d82
movl 0x127bf(%rip), %eax     # 0x194c8
btl $0xb, %eax
leaq 0x6bb8(%rip), %rcx      # 0xd8cc
leaq 0x6cdf(%rip), %rdx      # 0xd9fa
cmovaeq %rcx, %rdx
movq %rdx, 0x127c2(%rip)     # 0x194e8
andl $-0x3f, %eax
xorl $0x800, %eax            # imm = 0x800
movl %eax, 0x12794(%rip)     # 0x194c8
pushq $0x76
jmp 0x6d82
movl 0x1278a(%rip), %eax     # 0x194c8
andl $0xfffffbc3, %eax       # imm = 0xFFFFFBC3
xorl $0x2, %eax
movl %eax, 0x1277c(%rip)     # 0x194c8
leaq 0x6a4e(%rip), %rax      # 0xd7a1
movq %rax, 0x12786(%rip)     # 0x194e0
pushq $0x74
jmp 0x6d82
movl 0x12764(%rip), %eax     # 0x194c8
andl $0xfffffbc5, %eax       # imm = 0xFFFFFBC5
xorl $0x4, %eax
movl %eax, 0x12756(%rip)     # 0x194c8
leaq 0x6a28(%rip), %rax      # 0xd7a1
movq %rax, 0x12760(%rip)     # 0x194e0
pushq $0x73
popq %rax
jmp 0x6dc6
andl $-0x19, %eax
movl %eax, %ecx
andl $0x10, %ecx
shll $0x4, %ecx
orl %eax, %ecx
movl %ecx, %eax
andl $-0x27, %eax
movl %eax, 0x1272b(%rip)     # 0x194c8
testl %ebx, %ebx
je 0x6dbb
andl $0xfffffbd9, %ecx       # imm = 0xFFFFFBD9
movl %ecx, 0x1271b(%rip)     # 0x194c8
leaq 0x69ed(%rip), %rax      # 0xd7a1
movq %rax, 0x12725(%rip)     # 0x194e0
pushq $0x1
popq %rdi
callq 0xdaa7
movl %r14d, %eax
cmpl $0x19, %ebp
ja 0x6dea
cmpl $0x43, %ebx
je 0x6dea
cmpl $0x52, %ebx
je 0x6dea
orb $0x4, 0x126ed(%rip)     # 0x194c9
leaq 0x6994(%rip), %rcx      # 0xd777
movq %rcx, 0x126f6(%rip)     # 0x194e0
movl 0x126d8(%rip), %ecx     # 0x194c8
shrl $0xd, %ecx
andl $0x7, %ecx
leaq 0x1c2c8(%rip), %rdx     # 0x230c5
movb %al, (%rcx,%rdx)
popq %rbx
popq %r14
popq %rbp
retq