// File: /workspace/github_c_makefile_star2_O3/jarun[P]nnn/src/nnn.c
// Function: coolsize
static char *coolsize(off_t size)
{
	const char * const U = "BKMGTPEZY";
	static char size_buf[12]; /* Buffer to hold human readable size */
	off_t rem = 0;
	size_t ret;
	int i = 0;

	while (size >= 1024) {
		rem = size & (0x3FF); /* 1024 - 1 = 0x3FF */
		size >>= 10;
		++i;
	}

	if (i == 1) {
		rem = (rem * 1000) >> 10;
		rem /= 10;
		size = get_size(size, &rem, 10);
	} else if (i == 2) {
		rem = (rem * 1000) >> 10;
		size = get_size(size, &rem, 100);
	} else if (i > 2) {
		rem = (rem * 10000) >> 10;
		size = get_size(size, &rem, 1000);
	}

	if (i > 0 && i < 6 && rem) {
		ret = xstrsncpy(size_buf, xitoa(size), 12);
		size_buf[ret - 1] = '.';

		char *frac = xitoa(rem);
		size_t toprint = i > 3 ? 3 : i;
		size_t len = xstrlen(frac);

		if (len < toprint) {
			size_buf[ret] = size_buf[ret + 1] = size_buf[ret + 2] = '0';
			xstrsncpy(size_buf + ret + (toprint - len), frac, len + 1);
		} else
			xstrsncpy(size_buf + ret, frac, toprint + 1);

		ret += toprint;
	} else {
		ret = xstrsncpy(size_buf, size ? xitoa(size) : "0", 12);
		--ret;
	}

	size_buf[ret] = U[i];
	size_buf[ret + 1] = '\0';

	return size_buf;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
xorl %ebp, %ebp
cmpq $0x400, %rdi            # imm = 0x400
jl 0x134bc
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq %rdi, %rax
shrq $0xa, %rdi
incl %ebp
cmpq $0xfffff, %rax          # imm = 0xFFFFF
ja 0x1332b
andl $0x3ff, %eax            # imm = 0x3FF
cmpl $0x1, %ebp
je 0x1338d
testl %ebp, %ebp
jne 0x133c3
imull $0x3e8, %eax, %eax      # imm = 0x3E8
shrl $0xa, %eax
imull $0x199a, %eax, %eax     # imm = 0x199A
shrl $0x10, %eax
imull $0x67, %eax, %ecx
movzwl %cx, %ebx
shrl $0xa, %ebx
movl %ebx, %ecx
addl %ecx, %ecx
leaq (%rcx,%rcx,4), %rcx
subq %rcx, %rax
movl $0x1, %ebp
cmpq $0x5, %rax
jl 0x13400
leaq 0x1(%rbx), %rax
xorl %ebx, %ebx
xorl %ecx, %ecx
cmpq $0xa, %rax
jmp 0x133f6
imull $0x3e8, %eax, %eax      # imm = 0x3E8
shrl $0xa, %eax
imull $0x199a, %eax, %ebx     # imm = 0x199A
shrl $0x10, %ebx
movl %ebx, %ecx
addl %ecx, %ecx
leaq (%rcx,%rcx,4), %rcx
subq %rcx, %rax
movl $0x2, %ebp
cmpq $0x5, %rax
jl 0x13400
leaq 0x1(%rbx), %rax
xorl %ebx, %ebx
xorl %ecx, %ecx
cmpq $0x64, %rax
jmp 0x133f6
incl %ebp
imull $0x2710, %eax, %eax     # imm = 0x2710
shrl $0xa, %eax
imull $0x199a, %eax, %ebx     # imm = 0x199A
shrl $0x10, %ebx
movl %ebx, %ecx
addl %ecx, %ecx
leaq (%rcx,%rcx,4), %rcx
subq %rcx, %rax
cmpq $0x5, %rax
jl 0x13400
leaq 0x1(%rbx), %rax
xorl %ebx, %ebx
xorl %ecx, %ecx
cmpq $0x3e8, %rax            # imm = 0x3E8
sete %cl
cmovneq %rax, %rbx
addq %rcx, %rdi
cmpl $0x5, %ebp
ja 0x134bc
testq %rbx, %rbx
je 0x134bc
callq 0x5f73
leaq 0x11f46(%rip), %r15     # 0x25364
movl $0xc, %ecx
movq %r15, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x4860
movq %rax, %r14
testq %rax, %rax
jne 0x13446
movb $0x0, 0x11f30(%rip)     # 0x2536f
leaq 0x11f2a(%rip), %r14     # 0x25370
movb $0x2e, -0x1(%r14)
subq %r15, %r14
movl %ebx, %edi
callq 0x5f73
movq %rax, %rbx
cmpl $0x3, %ebp
movl $0x3, %r12d
cmovbl %ebp, %r12d
movq %rax, %rdi
xorl %esi, %esi
callq 0x4490
movq %rax, %r13
movq %r12, %rax
subq %rbx, %r13
subq %r13, %r12
jbe 0x1352d
movb $0x30, 0x2(%r14,%r15)
movq %rax, (%rsp)
addq %r15, %r12
addq %r14, %r12
movw $0x3030, (%r14,%r15)    # imm = 0x3030
incq %r13
movq %r12, %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %r13, %rcx
callq 0x4860
testq %rax, %rax
movq (%rsp), %rax
jne 0x134fe
addq %r13, %r12
jmp 0x13555
testq %rdi, %rdi
je 0x134cb
callq 0x5f73
movq %rax, %rsi
jmp 0x134d2
leaq 0x2eb8(%rip), %rsi      # 0x1638a
leaq 0x11e8b(%rip), %r14     # 0x25364
movl $0xc, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x4860
testq %rax, %rax
jne 0x134fb
movb $0x0, 0x11e7b(%rip)     # 0x2536f
leaq 0x11e75(%rip), %rax     # 0x25370
notq %r14
addq %rax, %r14
movl %ebp, %eax
leaq 0x2e74(%rip), %rcx      # 0x1637e
movb (%rax,%rcx), %al
leaq 0x11e50(%rip), %rcx     # 0x25364
movb %al, (%r14,%rcx)
movb $0x0, 0x1(%r14,%rcx)
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addq %r14, %r15
leaq 0x1(%rax), %r12
movq %r15, %rdi
movq %rbx, %rsi
xorl %edx, %edx
movq %r12, %rcx
movq %rax, %rbx
callq 0x4860
testq %rax, %rax
movq %rbx, %rax
jne 0x134fe
addq %r12, %r15
movq %r15, %r12
movb $0x0, -0x1(%r12)
jmp 0x134fe