// File: /workspace/github_c_makefile_star2_O0/ksherlock[P]nroff_man/read3.c
// Function: get_unit
int get_unit(const unsigned char *arg, int dv, int base) {
	double d;
	char sign = 0;
	uint_fast8_t c;
	char *cp = NULL;
	int rv;
	unsigned i;
	
	if (!arg) return dv;

	i = 0;
	while (arg[i] == ' ') ++i;
	arg += i;
	c = arg[0];
	if (!c) return dv;

	if (c == '+' || c == '-') {
		sign = c;
		++arg;
	}
	c = arg[0];
	if (!isdigit(c) && c != '.') return dv;

	errno = 0;
	d = strtod(arg, &cp);
	if (errno) return dv;

	c = *cp;
	switch (c) {
		case 'c': /* centimeter */
			d *= 94.5 / 24.0;
			break;
		case 'i': /* inch */
			d *= 10.0; /* 240.0 / 24.0; */
			break;
		case 'P': /* pica - 1/6 inch */
			d *= 10.0 / 6.0;
			break;
		case 'p': /* point - 1/72 inch */
			d *= 10.0 / 72.0;
			break;
		case 'f':
			d *= 65536.0 / 24.0;
			break;
		case 'M': /* mini em - 1/100 em */
			d  /= 100.0;
			break;

		case 'm':
		case 'n':
		case 'u':
		case 'v':
			break;
		default:
			break;
	}

	rv = (int)d;
	if (sign && base >= 0) {
		if (sign == '+') base += rv;
		else base -= rv;
		if (base < 0) return 0;
		return base;
	}
	if (sign == '-') rv = 0;

	return rv;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl %edx, -0x18(%rbp)
movb $0x0, -0x21(%rbp)
movq $0x0, -0x30(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x7640
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x7832
movl $0x0, -0x38(%rbp)
movq -0x10(%rbp), %rax
movl -0x38(%rbp), %ecx
movzbl (%rax,%rcx), %eax
cmpl $0x20, %eax
jne 0x7662
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x7647
movl -0x38(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movb (%rax), %al
movb %al, -0x22(%rbp)
cmpb $0x0, -0x22(%rbp)
jne 0x768c
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x7832
movzbl -0x22(%rbp), %eax
cmpl $0x2b, %eax
je 0x769e
movzbl -0x22(%rbp), %eax
cmpl $0x2d, %eax
jne 0x76b0
movb -0x22(%rbp), %al
movb %al, -0x21(%rbp)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movb (%rax), %al
movb %al, -0x22(%rbp)
callq 0x41d0
movq (%rax), %rax
movzbl -0x22(%rbp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
jne 0x76ea
movzbl -0x22(%rbp), %eax
cmpl $0x2e, %eax
je 0x76ea
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x7832
callq 0x4060
movl $0x0, (%rax)
movq -0x10(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x4080
movsd %xmm0, -0x20(%rbp)
callq 0x4060
cmpl $0x0, (%rax)
je 0x771c
movl -0x14(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x7832
movq -0x30(%rbp), %rax
movb (%rax), %al
movb %al, -0x22(%rbp)
movzbl -0x22(%rbp), %eax
addl $-0x4d, %eax
movl %eax, %ecx
movq %rcx, -0x40(%rbp)
subl $0x29, %eax
ja 0x77cd
movq -0x40(%rbp), %rax
leaq 0x45c2(%rip), %rcx      # 0xbd08
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movsd 0x45a9(%rip), %xmm0     # 0xbd00
mulsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x20(%rbp)
jmp 0x77cf
movsd 0x458d(%rip), %xmm0     # 0xbcf8
mulsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x20(%rbp)
jmp 0x77cf
movsd 0x4571(%rip), %xmm0     # 0xbcf0
mulsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x20(%rbp)
jmp 0x77cf
movsd 0x4555(%rip), %xmm0     # 0xbce8
mulsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x20(%rbp)
jmp 0x77cf
movsd 0x4539(%rip), %xmm0     # 0xbce0
mulsd -0x20(%rbp), %xmm0
movsd %xmm0, -0x20(%rbp)
jmp 0x77cf
movsd -0x20(%rbp), %xmm0
movsd 0x4518(%rip), %xmm1     # 0xbcd8
divsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
jmp 0x77cf
jmp 0x77cf
jmp 0x77cf
cvttsd2si -0x20(%rbp), %eax
movl %eax, -0x34(%rbp)
movsbl -0x21(%rbp), %eax
cmpl $0x0, %eax
je 0x781c
cmpl $0x0, -0x18(%rbp)
jl 0x781c
movsbl -0x21(%rbp), %eax
cmpl $0x2b, %eax
jne 0x77fa
movl -0x34(%rbp), %eax
addl -0x18(%rbp), %eax
movl %eax, -0x18(%rbp)
jmp 0x7805
movl -0x34(%rbp), %ecx
movl -0x18(%rbp), %eax
subl %ecx, %eax
movl %eax, -0x18(%rbp)
cmpl $0x0, -0x18(%rbp)
jge 0x7814
movl $0x0, -0x4(%rbp)
jmp 0x7832
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x7832
movsbl -0x21(%rbp), %eax
cmpl $0x2d, %eax
jne 0x782c
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)