// File: /workspace/github_c_makefile_star2_O3/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 0x1735
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 0x38be
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 0x16ea
xorl %ecx, %ecx
jmp 0x1615
movq %rbp, %rdi
callq 0x10e0
jmp 0x1721
movb $0x1, %cl
movb %cl, (%rbx)
incq %rax
movq %rax, 0x8(%rsp)
movq %r13, %rdi
callq 0x38be
movq %r13, %rdi
movq %r15, %rsi
callq 0x3917
testb %al, %al
je 0x16e1
movq %r13, %rdi
callq 0x38be
movq 0x8(%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rsp)
cmpb $0x2d, (%rax)
jne 0x16fa
movq %r13, %rdi
callq 0x38be
movq %r13, %rdi
movq 0x10(%rsp), %rsi
callq 0x3917
testb %al, %al
je 0x1703
movl $0x0, 0x14(%rbx)
movq %r13, %rdi
callq 0x38be
movq 0x8(%rsp), %rax
cmpb $0x0, (%rax)
je 0x173c
movq %r13, %rdi
callq 0x38be
movq (%rbp), %rax
movq 0x8(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rsp)
movsbq (%rcx), %rcx
cmpl $0x58, (%rax,%rcx,4)
jne 0x170c
movq %r13, %rdi
callq 0x38be
movslq 0x14(%rbx), %rax
leal 0x1(%rax), %ecx
movl %ecx, 0x14(%rbx)
leaq (%r12,%rax,8), %rsi
movq %r13, %rdi
callq 0x3917
testb %al, %al
je 0x1715
cmpl $0x8, 0x14(%rbx)
jle 0x167d
jmp 0x173c
leaq 0x39ca(%rip), %rdi      # 0x50b2
jmp 0x171c
leaq 0x39a7(%rip), %rdi      # 0x5098
xorl %eax, %eax
callq 0x1030
jmp 0x1721
leaq 0x39d4(%rip), %rdi      # 0x50d5
jmp 0x171c
leaq 0x39b1(%rip), %rdi      # 0x50bb
jmp 0x171c
leaq 0x39b8(%rip), %rdi      # 0x50cb
jmp 0x171c
leaq 0x39a6(%rip), %rdi      # 0x50c2
callq 0x1040
movq %r14, %rdi
callq 0x1130
movq %rax, %rbp
testq %rax, %rax
jne 0x15c2
xorl %edi, %edi
callq 0x1070
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop