// File: /workspace/github_c_makefile_star2_O3/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 0x71de
movl %ebx, %r14d
cmpl $0x43, %ebx
je 0x7274
movl %ebx, %r14d
cmpl $0x52, %ebx
je 0x7274
movl %ebx, %r14d
orl $0x20, %r14d
jmp 0x7274
testl %ebx, %ebx
je 0x7209
movl %ebx, %r14d
cmpl $0x14, %ebx
jne 0x7274
movl 0x132d4(%rip), %eax     # 0x1a4c8
testb $0x2, %al
jne 0x73f2
testb $0x4, %al
jne 0x7357
jmp 0x73c9
movl 0x132b9(%rip), %eax     # 0x1a4c8
testb $0x8, %al
jne 0x7227
xorl %r14d, %r14d
testb $0x10, %al
je 0x723a
movl $0x64, %r14d
movl $0xffffffe7, %ecx       # imm = 0xFFFFFFE7
jmp 0x7232
movl $0x61, %r14d
movl $0xfffffff7, %ecx       # imm = 0xFFFFFFF7
andl %ecx, %eax
movl %eax, 0x1328e(%rip)     # 0x1a4c8
btl $0xa, %eax
leaq 0x7c18(%rip), %rcx      # 0xee5d
leaq 0x7be7(%rip), %rdx      # 0xee33
cmovaeq %rcx, %rdx
movq %rdx, 0x13289(%rip)     # 0x1a4e0
btl $0xb, %eax
leaq 0x7e8d(%rip), %rax      # 0xf0ef
leaq 0x7d48(%rip), %rcx      # 0xefb1
cmovaeq %rax, %rcx
movq %rcx, 0x13274(%rip)     # 0x1a4e8
xorl %eax, %eax
leal -0x61(%r14), %ecx
cmpl $0x4, %ecx
jbe 0x72d8
addl $-0x72, %r14d
cmpl $0x4, %r14d
ja 0x7492
leaq 0xdeb4(%rip), %rcx      # 0x15148
movslq (%rcx,%r14,4), %rdx
addq %rcx, %rdx
jmpq *%rdx
movl 0x13225(%rip), %eax     # 0x1a4c8
movl %eax, %ecx
xorl $0x400, %ecx            # imm = 0x400
movl %ecx, 0x13217(%rip)     # 0x1a4c8
btl $0xa, %eax
leaq 0x7b77(%rip), %rax      # 0xee33
leaq 0x7b9a(%rip), %rcx      # 0xee5d
cmovaeq %rax, %rcx
movq %rcx, 0x13212(%rip)     # 0x1a4e0
movl $0x72, %eax
jmp 0x7458
leaq 0xde55(%rip), %rdx      # 0x15134
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movl 0x131da(%rip), %eax     # 0x1a4c8
testb $0x8, %al
jne 0x7415
orl $0x18, %eax
movb $0x1, 0x1cdc4(%rip)     # 0x240c4
jmp 0x7418
movl $0xfffffbe1, %eax       # imm = 0xFFFFFBE1
andl 0x131b8(%rip), %eax     # 0x1a4c8
xorl $0x20, %eax
movl %eax, 0x131af(%rip)     # 0x1a4c8
leaq 0x7b3d(%rip), %rax      # 0xee5d
movq %rax, 0x131b9(%rip)     # 0x1a4e0
movl $0x65, %eax
jmp 0x7458
movl 0x13191(%rip), %eax     # 0x1a4c8
leal (%rax,%rax), %ecx
andl $0x10, %ecx
andl $-0x9, %eax
xorl %ecx, %eax
xorl $0x10, %eax
movb $0x0, 0x1cd78(%rip)     # 0x240c4
jmp 0x7418
movl 0x13171(%rip), %eax     # 0x1a4c8
andl $0xfffff3c1, %eax       # imm = 0xFFFFF3C1
movl %eax, 0x13166(%rip)     # 0x1a4c8
leaq 0x7af4(%rip), %rax      # 0xee5d
movq %rax, 0x13170(%rip)     # 0x1a4e0
leaq 0x7d78(%rip), %rax      # 0xf0ef
movq %rax, 0x1316a(%rip)     # 0x1a4e8
movl $0x63, %eax
jmp 0x7458
movl 0x1313a(%rip), %eax     # 0x1a4c8
btl $0xb, %eax
leaq 0x7c18(%rip), %rcx      # 0xefb1
leaq 0x7d4f(%rip), %rdx      # 0xf0ef
cmovaeq %rcx, %rdx
movq %rdx, 0x1313d(%rip)     # 0x1a4e8
andl $-0x3f, %eax
xorl $0x800, %eax            # imm = 0x800
movl %eax, 0x1310f(%rip)     # 0x1a4c8
movl $0x76, %eax
jmp 0x7458
movl 0x130ff(%rip), %eax     # 0x1a4c8
andl $0xfffffbc3, %eax       # imm = 0xFFFFFBC3
xorl $0x2, %eax
movl %eax, 0x130f1(%rip)     # 0x1a4c8
leaq 0x7a7f(%rip), %rax      # 0xee5d
movq %rax, 0x130fb(%rip)     # 0x1a4e0
movl $0x74, %eax
jmp 0x7458
movl 0x130d6(%rip), %eax     # 0x1a4c8
andl $0xfffffbc5, %eax       # imm = 0xFFFFFBC5
xorl $0x4, %eax
movl %eax, 0x130c8(%rip)     # 0x1a4c8
leaq 0x7a56(%rip), %rax      # 0xee5d
movq %rax, 0x130d2(%rip)     # 0x1a4e0
movl $0x73, %eax
jmp 0x7458
andl $-0x19, %eax
movl %eax, %ecx
andl $0x10, %ecx
shll $0x4, %ecx
orl %eax, %ecx
movl %ecx, %eax
andl $-0x27, %eax
movl %eax, 0x1309b(%rip)     # 0x1a4c8
testl %ebx, %ebx
je 0x744b
andl $0xfffffbd9, %ecx       # imm = 0xFFFFFBD9
movl %ecx, 0x1308b(%rip)     # 0x1a4c8
leaq 0x7a19(%rip), %rax      # 0xee5d
movq %rax, 0x13095(%rip)     # 0x1a4e0
movl $0x1, %edi
callq 0xf19f
movl %r14d, %eax
cmpl $0x19, %ebp
ja 0x747c
cmpl $0x43, %ebx
je 0x747c
cmpl $0x52, %ebx
je 0x747c
orb $0x4, 0x1305b(%rip)     # 0x1a4c9
leaq 0x79be(%rip), %rcx      # 0xee33
movq %rcx, 0x13064(%rip)     # 0x1a4e0
movl 0x13046(%rip), %ecx     # 0x1a4c8
shrl $0xd, %ecx
andl $0x7, %ecx
leaq 0x1cc36(%rip), %rdx     # 0x240c5
movb %al, (%rcx,%rdx)
popq %rbx
popq %r14
popq %rbp
retq