// File: /workspace/github_c_makefile_star2_O1/icarroll[P]clunk/clunk.c
// Function: getmove
struct move getmove(char * prompt)
{
    struct move move;

    char * line = NULL;
retry:
    line = readline(prompt);

    if (line)
    {
        if (* line) add_history(line);
        else
        {
            free(line);
            goto retry;
        }
    }
    else exit(EXIT_SUCCESS);

    char * cur = line;

    skipspace(& cur);
    if (toupper(* cur) == 'D') move.isdwarfmove = true;
    else if (toupper(* cur) == 'T') move.isdwarfmove = false;
    else
    {
        printf("bad side %c\n", * cur);
        goto retry;
    }
    cur += 1;

    bool valid;

    skipspace(& cur);
    valid = getpos(& cur, & move.from);
    if (! valid)
    {
        printf("bad from\n");
        goto retry;
    }

    skipspace(& cur);
    if (* cur++ != '-')
    {
        printf("missing -\n");
        goto retry;
    }

    skipspace(& cur);
    valid = getpos(& cur, & move.to);
    if (! valid)
    {
        printf("bad to\n");
        goto retry;
    }

    move.numcapts = 0;
    while (move.numcapts <= NUMDIRS)
    {
        skipspace(& cur);
        if (* cur == '\0') break;

        skipspace(& cur);
        if (toupper(* cur++) != 'X')
        {
            printf("missing x\n");
            goto retry;
        }

        skipspace(& cur);
        valid = getpos(& cur, & move.capts[move.numcapts++]);
        if (! valid)
        {
            printf("bad capt\n");
            goto retry;
        }
    }

    return move;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r14
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x1130
testq %rax, %rax
je 0x174b
movq %rax, %rbp
leaq 0x4(%rbx), %r15
leaq 0xc(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x18(%rbx), %r12
leaq 0x8(%rsp), %r13
cmpb $0x0, (%rbp)
je 0x1606
movq %rbp, %rdi
callq 0x11a0
movq %rbp, 0x8(%rsp)
movq %r13, %rdi
callq 0x3991
callq 0x10c0
movq %rax, %rbp
movq (%rax), %rcx
movq 0x8(%rsp), %rax
movsbq (%rax), %rsi
movl (%rcx,%rsi,4), %ecx
cmpl $0x44, %ecx
je 0x1613
cmpl $0x54, %ecx
jne 0x16f5
xorl %ecx, %ecx
jmp 0x1615
movq %rbp, %rdi
callq 0x10e0
jmp 0x171a
movb $0x1, %cl
movb %cl, (%rbx)
incq %rax
movq %rax, 0x8(%rsp)
movq %r13, %rdi
callq 0x3991
movq %r13, %rdi
movq %r15, %rsi
callq 0x39ea
testb %al, %al
je 0x16ec
movq %r13, %rdi
callq 0x3991
movq 0x8(%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rsp)
cmpb $0x2d, (%rax)
jne 0x1705
movq %r13, %rdi
callq 0x3991
movq %r13, %rdi
movq 0x10(%rsp), %rsi
callq 0x39ea
testb %al, %al
je 0x170e
movl $0x0, 0x14(%rbx)
cmpl $0x8, 0x14(%rbx)
jg 0x1739
movq %r13, %rdi
callq 0x3991
movq 0x8(%rsp), %rax
cmpb $0x0, (%rax)
je 0x1739
movq %r13, %rdi
callq 0x3991
movq (%rbp), %rax
movq 0x8(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rsp)
movsbq (%rcx), %rcx
cmpl $0x58, (%rax,%rcx,4)
jne 0x1730
movq %r13, %rdi
callq 0x3991
movslq 0x14(%rbx), %rax
leal 0x1(%rax), %ecx
movl %ecx, 0x14(%rbx)
leaq (%r12,%rax,8), %rsi
movq %r13, %rdi
callq 0x39ea
testb %al, %al
jne 0x167d
leaq 0x39d8(%rip), %rdi      # 0x50c2
jmp 0x1715
leaq 0x39bf(%rip), %rdi      # 0x50b2
jmp 0x1715
leaq 0x399c(%rip), %rdi      # 0x5098
xorl %eax, %eax
callq 0x1030
jmp 0x171a
leaq 0x39c9(%rip), %rdi      # 0x50d5
jmp 0x1715
leaq 0x39a6(%rip), %rdi      # 0x50bb
callq 0x1040
movq %r14, %rdi
callq 0x1130
movq %rax, %rbp
testq %rax, %rax
jne 0x15c2
jmp 0x174b
leaq 0x3994(%rip), %rdi      # 0x50cb
jmp 0x1715
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %edi, %edi
callq 0x1070
nop