// File: /workspace/github_c_makefile_star2_O1/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
movl %edi, %r14d
cmpl $0x19, %ebp
ja 0x725f
movl %ebx, %r14d
cmpl $0x43, %ebx
je 0x725f
movl %ebx, %r14d
cmpl $0x52, %ebx
je 0x725f
movl %ebx, %r14d
orl $0x20, %r14d
testl %ebx, %ebx
je 0x7294
cmpl $0x14, %r14d
jne 0x7302
movl 0x13255(%rip), %eax     # 0x1a4c8
movl $0x73, %r14d
testb $0x2, %al
jne 0x7302
testb $0x4, %al
movl $0x74, %eax
movl $0x63, %r14d
cmovel %eax, %r14d
jmp 0x7302
movl 0x1322e(%rip), %eax     # 0x1a4c8
testb $0x8, %al
jne 0x72af
testb $0x10, %al
je 0x72c2
movl $0x64, %r14d
movl $0xffffffe7, %ecx       # imm = 0xFFFFFFE7
jmp 0x72ba
movl $0x61, %r14d
movl $0xfffffff7, %ecx       # imm = 0xFFFFFFF7
andl %ecx, %eax
movl %eax, 0x13206(%rip)     # 0x1a4c8
movl 0x13200(%rip), %eax     # 0x1a4c8
btl $0xa, %eax
leaq 0x7d98(%rip), %rcx      # 0xf06b
leaq 0x7d67(%rip), %rdx      # 0xf041
cmovaeq %rcx, %rdx
movq %rdx, 0x131fb(%rip)     # 0x1a4e0
btl $0xb, %eax
leaq 0x8009(%rip), %rax      # 0xf2f9
leaq 0x7ec4(%rip), %rcx      # 0xf1bb
cmovaeq %rax, %rcx
movq %rcx, 0x131e6(%rip)     # 0x1a4e8
xorl %eax, %eax
leal -0x61(%r14), %ecx
cmpl $0x4, %ecx
jbe 0x7360
leal -0x72(%r14), %ecx
cmpl $0x4, %ecx
ja 0x7504
leaq 0xde27(%rip), %rdx      # 0x15148
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movl 0x13198(%rip), %eax     # 0x1a4c8
movl %eax, %ecx
xorl $0x400, %ecx            # imm = 0x400
movl %ecx, 0x1318a(%rip)     # 0x1a4c8
btl $0xa, %eax
leaq 0x7cf8(%rip), %rax      # 0xf041
leaq 0x7d1b(%rip), %rcx      # 0xf06b
cmovaeq %rax, %rcx
movq %rcx, 0x13185(%rip)     # 0x1a4e0
jmp 0x74c6
leaq 0xddcd(%rip), %rdx      # 0x15134
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movl 0x13152(%rip), %eax     # 0x1a4c8
movl %eax, %ecx
xorl $0x8, %ecx
movl %ecx, 0x13147(%rip)     # 0x1a4c8
testb $0x8, %al
jne 0x7449
orl $0x10, %ecx
movl %ecx, 0x13136(%rip)     # 0x1a4c8
movb $0x1, 0x1cd2b(%rip)     # 0x240c4
jmp 0x7452
movl $0xfffffbe1, %eax       # imm = 0xFFFFFBE1
andl 0x1311f(%rip), %eax     # 0x1a4c8
xorl $0x20, %eax
jmp 0x7433
andl $0xfffff3c1, 0x1310d(%rip) # imm = 0xFFFFF3C1
leaq 0x7ca9(%rip), %rax      # 0xf06b
movq %rax, 0x13117(%rip)     # 0x1a4e0
leaq 0x7f29(%rip), %rax      # 0xf2f9
movq %rax, 0x13111(%rip)     # 0x1a4e8
jmp 0x74c6
movl 0x130e6(%rip), %eax     # 0x1a4c8
movl %eax, %ecx
xorl $0x800, %ecx            # imm = 0x800
btl $0xb, %eax
leaq 0x7dc6(%rip), %rax      # 0xf1bb
leaq 0x7efd(%rip), %rdx      # 0xf2f9
cmovaeq %rax, %rdx
movq %rdx, 0x130e1(%rip)     # 0x1a4e8
andl $-0x3f, %ecx
movl %ecx, 0x130b8(%rip)     # 0x1a4c8
jmp 0x74c6
movl $0xfffffbc3, %eax       # imm = 0xFFFFFBC3
andl 0x130a8(%rip), %eax     # 0x1a4c8
xorl $0x2, %eax
jmp 0x7433
movl $0xfffffbc5, %eax       # imm = 0xFFFFFBC5
andl 0x13098(%rip), %eax     # 0x1a4c8
xorl $0x4, %eax
movl %eax, 0x1308f(%rip)     # 0x1a4c8
leaq 0x7c2b(%rip), %rax      # 0xf06b
movq %rax, 0x13099(%rip)     # 0x1a4e0
jmp 0x74c6
andl $-0x19, %eax
movl %eax, 0x13076(%rip)     # 0x1a4c8
cmpl $0x64, %r14d
jne 0x7479
movl 0x1306a(%rip), %eax     # 0x1a4c8
testb $0x8, %al
jne 0x746b
xorl $0x10, %eax
movl %eax, 0x1305d(%rip)     # 0x1a4c8
andb $-0x9, 0x13056(%rip)    # 0x1a4c8
movb $0x0, 0x1cc4b(%rip)     # 0x240c4
movl 0x13049(%rip), %eax     # 0x1a4c8
testb $0x10, %al
je 0x748e
orl $0x100, %eax            # imm = 0x100
movl %eax, 0x1303a(%rip)     # 0x1a4c8
movl 0x13034(%rip), %eax     # 0x1a4c8
movl %eax, %ecx
andl $-0x27, %ecx
movl %ecx, 0x13029(%rip)     # 0x1a4c8
testl %ebx, %ebx
je 0x74bc
andl $0xfffffbd9, %eax       # imm = 0xFFFFFBD9
movl %eax, 0x1301a(%rip)     # 0x1a4c8
leaq 0x7bb6(%rip), %rax      # 0xf06b
movq %rax, 0x13024(%rip)     # 0x1a4e0
movl $0x1, %edi
callq 0xf3ca
cmpl $0x19, %ebp
ja 0x74ea
cmpl $0x43, %ebx
je 0x74ea
cmpl $0x52, %ebx
je 0x74ea
orb $0x4, 0x12fed(%rip)     # 0x1a4c9
leaq 0x7b5e(%rip), %rax      # 0xf041
movq %rax, 0x12ff6(%rip)     # 0x1a4e0
movl 0x12fd8(%rip), %eax     # 0x1a4c8
shrl $0xd, %eax
andl $0x7, %eax
leaq 0x1cbc8(%rip), %rcx     # 0x240c5
movb %r14b, (%rax,%rcx)
movl %r14d, %eax
popq %rbx
popq %r14
popq %rbp
retq