// File: /workspace/github_c_makefile_star2_O1/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
cmpq $0x400, %rdi            # imm = 0x400
jl 0x1368a
xorl %ebp, %ebp
movq %rdi, %rbx
shrq $0xa, %rdi
incl %ebp
cmpq $0xfffff, %rbx          # imm = 0xFFFFF
ja 0x13670
andl $0x3ff, %ebx            # imm = 0x3FF
jmp 0x1368e
xorl %ebx, %ebx
xorl %ebp, %ebp
cmpl $0x2, %ebp
je 0x136ea
cmpl $0x1, %ebp
jne 0x13723
imulq $0x3e8, %rbx, %rcx      # imm = 0x3E8
movabsq $0x6666666666667, %rdx  # imm = 0x6666666666667
movq %rcx, %rax
mulq %rdx
movq %rdx, %rsi
movabsq $0xa3d70a3d70a4, %rdx   # imm = 0xA3D70A3D70A4
movq %rcx, %rax
mulq %rdx
movq %rdx, %rbx
leal (%rdx,%rdx), %eax
leaq (%rax,%rax,4), %rax
subq %rax, %rsi
cmpq $0x5, %rsi
jl 0x1376c
incq %rbx
xorl %eax, %eax
xorl %ecx, %ecx
cmpq $0xa, %rbx
jmp 0x13762
imulq $0x3e8, %rbx, %rax      # imm = 0x3E8
movl %eax, %ecx
shrl $0xa, %ecx
movabsq $0x6666666666667, %rdx  # imm = 0x6666666666667
mulq %rdx
movq %rdx, %rbx
leal (%rdx,%rdx), %eax
leaq (%rax,%rax,4), %rax
subq %rax, %rcx
cmpq $0x5, %rcx
jl 0x1376c
incq %rbx
xorl %eax, %eax
xorl %ecx, %ecx
cmpq $0x64, %rbx
jmp 0x13762
cmpl $0x3, %ebp
jb 0x1376c
imulq $0x2710, %rbx, %rax     # imm = 0x2710
movl %eax, %ecx
shrl $0xa, %ecx
movabsq $0x6666666666667, %rdx  # imm = 0x6666666666667
mulq %rdx
movq %rdx, %rbx
leal (%rdx,%rdx), %eax
leaq (%rax,%rax,4), %rax
subq %rax, %rcx
cmpq $0x5, %rcx
jl 0x1376c
incq %rbx
xorl %eax, %eax
xorl %ecx, %ecx
cmpq $0x3e8, %rbx            # imm = 0x3E8
sete %cl
cmoveq %rax, %rbx
addq %rcx, %rdi
leal -0x1(%rbp), %eax
cmpl $0x4, %eax
ja 0x13824
testq %rbx, %rbx
je 0x13824
callq 0x5fa8
leaq 0x11bd7(%rip), %r15     # 0x25364
movl $0xc, %ecx
movq %r15, %rdi
movq %rax, %rsi
xorl %edx, %edx
callq 0x4860
movq %rax, %r14
testq %rax, %rax
jne 0x137b5
movb $0x0, 0x11bc1(%rip)     # 0x2536f
leaq 0x11bbb(%rip), %r14     # 0x25370
movb $0x2e, -0x1(%r14)
subq %r15, %r14
movl %ebx, %edi
callq 0x5fa8
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 0x13833
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 0x13896
addq %r13, %r12
jmp 0x1385b
testq %rdi, %rdi
je 0x13863
callq 0x5fa8
movq %rax, %rsi
jmp 0x1386a
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 0x13896
addq %r12, %r15
movq %r15, %r12
movb $0x0, -0x1(%r12)
jmp 0x13896
leaq 0x2b06(%rip), %rsi      # 0x16370
leaq 0x11af3(%rip), %r14     # 0x25364
movl $0xc, %ecx
movq %r14, %rdi
xorl %edx, %edx
callq 0x4860
testq %rax, %rax
jne 0x13893
movb $0x0, 0x11ae3(%rip)     # 0x2536f
leaq 0x11add(%rip), %rax     # 0x25370
notq %r14
addq %rax, %r14
movl %ebp, %eax
leaq 0x2ac2(%rip), %rcx      # 0x16364
movb (%rax,%rcx), %al
leaq 0x11ab8(%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