// File: /workspace/github_c_makefile_star2_O0/simh[P]simtools/crossassemblers/macro11/rad50.c
// Function: rad50
unsigned rad50(
    char *cp,
    char **endp)
{
    unsigned long   acc = 0;
    char           *rp;

    if (endp)
        *endp = cp;

    if (!*cp)                          /* Got to check for end-of-string manually, because strchr will call it a hit.  :-/ */
        return acc;

    rp = strchr(radtbl, toupper((unsigned char)*cp));
    if (rp == NULL)                    /* Not a RAD50 character */
        return acc;
    acc = ((int) (rp - radtbl)) * 03100;        /* Convert */
    cp++;

    /* Now, do the same thing two more times... */

    if (endp)
        *endp = cp;
    if (!*cp)
        return acc;
    rp = strchr(radtbl, toupper((unsigned char)*cp));
    if (rp == NULL)
        return acc;
    acc += ((int) (rp - radtbl)) * 050;

    cp++;
    if (endp)
        *endp = cp;
    if (!*cp)
        return acc;
    rp = strchr(radtbl, toupper((unsigned char)*cp));
    if (rp == NULL)
        return acc;
    acc += (int) (rp - radtbl);

    cp++;
    if (endp)
        *endp = cp;

    return acc;                        /* Done. */
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x139ba
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
cmpb $0x0, (%rax)
jne 0x139cf
movq -0x20(%rbp), %rax
movl %eax, -0x4(%rbp)
jmp 0x13b34
movq -0x10(%rbp), %rax
movzbl (%rax), %edi
callq 0x2080
movl %eax, %esi
leaq 0x615c(%rip), %rdi      # 0x19b40
callq 0x20d0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x13a00
movq -0x20(%rbp), %rax
movl %eax, -0x4(%rbp)
jmp 0x13b34
movq -0x28(%rbp), %rax
leaq 0x6135(%rip), %rcx      # 0x19b40
subq %rcx, %rax
imull $0x640, %eax, %eax      # imm = 0x640
cltq
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x13a38
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
cmpb $0x0, (%rax)
jne 0x13a4d
movq -0x20(%rbp), %rax
movl %eax, -0x4(%rbp)
jmp 0x13b34
movq -0x10(%rbp), %rax
movzbl (%rax), %edi
callq 0x2080
movl %eax, %esi
leaq 0x60de(%rip), %rdi      # 0x19b40
callq 0x20d0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x13a7e
movq -0x20(%rbp), %rax
movl %eax, -0x4(%rbp)
jmp 0x13b34
movq -0x28(%rbp), %rax
leaq 0x60b7(%rip), %rcx      # 0x19b40
subq %rcx, %rax
imull $0x28, %eax, %eax
cltq
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x13ab7
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
cmpb $0x0, (%rax)
jne 0x13ac9
movq -0x20(%rbp), %rax
movl %eax, -0x4(%rbp)
jmp 0x13b34
movq -0x10(%rbp), %rax
movzbl (%rax), %edi
callq 0x2080
movl %eax, %esi
leaq 0x6062(%rip), %rdi      # 0x19b40
callq 0x20d0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x13af7
movq -0x20(%rbp), %rax
movl %eax, -0x4(%rbp)
jmp 0x13b34
movq -0x28(%rbp), %rax
leaq 0x603e(%rip), %rcx      # 0x19b40
subq %rcx, %rax
cltq
addq -0x20(%rbp), %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x13b2d
movq -0x10(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x20(%rbp), %rax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)