// File: /workspace/github_c_makefile_star2_O0/excess-c64[P]lib1541img/src/lib/1541img/lynx.c
// Function: parsePetsciiNum
static int parsePetsciiNum(uint16_t *num, size_t *pos,
	const uint8_t *content, size_t size)
{
    size_t p = *pos;
    while (p < size && content[p] == 0x20) ++p;
    if (content[p] < 0x31 || content[p] > 0x39) return -1;
    uint16_t n = content[p++] - 0x30;
    if (p == size) return -1;
    if (content[p] > 0x2f && content[p] < 0x3a)
    {
	n *= 10;
	n += (content[p++] - 0x30);
	if (p == size) return -1;
    }
    if (content[p] > 0x2f && content[p] < 0x3a)
    {
	n *= 10;
	n += (content[p++] - 0x30);
	if (p == size) return -1;
    }
    if (content[p] > 0x2f && content[p] < 0x3a) return -1;
    while (p < size && content[p] == 0x20) ++p;
    if (p == size) return -1;
    if (content[p] != 0x0d) return -1;
    if (++p == size) return -1;
    *pos = p;
    *num = n;
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rcx
xorl %eax, %eax
cmpq -0x28(%rbp), %rcx
movb %al, -0x33(%rbp)
jae 0x10683
movq -0x20(%rbp), %rax
movq -0x30(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x20, %eax
sete %al
movb %al, -0x33(%rbp)
movb -0x33(%rbp), %al
testb $0x1, %al
jne 0x1068c
jmp 0x1069a
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x1065f
movq -0x20(%rbp), %rax
movq -0x30(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x31, %eax
jl 0x106bc
movq -0x20(%rbp), %rax
movq -0x30(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x39, %eax
jle 0x106c8
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1089e
movq -0x20(%rbp), %rax
movq -0x30(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x30(%rbp)
movzbl (%rax,%rcx), %eax
subl $0x30, %eax
movw %ax, -0x32(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x28(%rbp), %rax
jne 0x106fc
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1089e
movq -0x20(%rbp), %rax
movq -0x30(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x2f, %eax
jle 0x10765
movq -0x20(%rbp), %rax
movq -0x30(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x3a, %eax
jge 0x10765
movzwl -0x32(%rbp), %eax
imull $0xa, %eax, %eax
movw %ax, -0x32(%rbp)
movq -0x20(%rbp), %rax
movq -0x30(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x30(%rbp)
movzbl (%rax,%rcx), %ecx
subl $0x30, %ecx
movzwl -0x32(%rbp), %eax
addl %ecx, %eax
movw %ax, -0x32(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x28(%rbp), %rax
jne 0x10763
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1089e
jmp 0x10765
movq -0x20(%rbp), %rax
movq -0x30(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x2f, %eax
jle 0x107ce
movq -0x20(%rbp), %rax
movq -0x30(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x3a, %eax
jge 0x107ce
movzwl -0x32(%rbp), %eax
imull $0xa, %eax, %eax
movw %ax, -0x32(%rbp)
movq -0x20(%rbp), %rax
movq -0x30(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x30(%rbp)
movzbl (%rax,%rcx), %ecx
subl $0x30, %ecx
movzwl -0x32(%rbp), %eax
addl %ecx, %eax
movw %ax, -0x32(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x28(%rbp), %rax
jne 0x107cc
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1089e
jmp 0x107ce
movq -0x20(%rbp), %rax
movq -0x30(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x2f, %eax
jle 0x107fc
movq -0x20(%rbp), %rax
movq -0x30(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x3a, %eax
jge 0x107fc
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1089e
jmp 0x107fe
movq -0x30(%rbp), %rcx
xorl %eax, %eax
cmpq -0x28(%rbp), %rcx
movb %al, -0x34(%rbp)
jae 0x10822
movq -0x20(%rbp), %rax
movq -0x30(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0x20, %eax
sete %al
movb %al, -0x34(%rbp)
movb -0x34(%rbp), %al
testb $0x1, %al
jne 0x1082b
jmp 0x10839
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
jmp 0x107fe
movq -0x30(%rbp), %rax
cmpq -0x28(%rbp), %rax
jne 0x1084c
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1089e
movq -0x20(%rbp), %rax
movq -0x30(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0xd, %eax
je 0x10866
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1089e
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
cmpq -0x28(%rbp), %rax
jne 0x10881
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1089e
movq -0x30(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movw -0x32(%rbp), %cx
movq -0x10(%rbp), %rax
movw %cx, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopw %cs:(%rax,%rax)