// File: /workspace/github_c_makefile_star2_O2/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
leaq 0x4(%rdi), %r15
leaq 0xc(%rdi), %rax
movq %rax, 0x10(%rsp)
leaq 0x18(%rdi), %r12
leaq 0x8(%rsp), %r13
movq %r14, %rdi
callq 0x1130
testq %rax, %rax
je 0x16fc
movq %rax, %rbp
cmpb $0x0, (%rax)
je 0x15a5
movq %rbp, %rdi
callq 0x11a0
movq %rbp, 0x8(%rsp)
movq %r13, %rdi
callq 0x3664
callq 0x10c0
movq %rax, %rbp
movq (%rax), %rcx
movq 0x8(%rsp), %rax
movsbq (%rax), %rsi
movl (%rcx,%rsi,4), %ecx
cmpl $0x44, %ecx
je 0x15af
cmpl $0x54, %ecx
jne 0x1693
xorl %ecx, %ecx
jmp 0x15b1
movq %rbp, %rdi
callq 0x10e0
jmp 0x154e
movb $0x1, %cl
movb %cl, (%rbx)
incq %rax
movq %rax, 0x8(%rsp)
movq %r13, %rdi
callq 0x3664
movq %r13, %rdi
movq %r15, %rsi
callq 0x36b5
testb %al, %al
je 0x1682
movq %r13, %rdi
callq 0x3664
movq 0x8(%rsp), %rax
leaq 0x1(%rax), %rcx
movq %rcx, 0x8(%rsp)
cmpb $0x2d, (%rax)
jne 0x16a6
movq %r13, %rdi
callq 0x3664
movq %r13, %rdi
movq 0x10(%rsp), %rsi
callq 0x36b5
testb %al, %al
je 0x16b7
andl $0x0, 0x14(%rbx)
xorl %eax, %eax
cmpl $0x8, %eax
jg 0x16ea
movq %r13, %rdi
callq 0x3664
movq 0x8(%rsp), %rax
cmpb $0x0, (%rax)
je 0x16ea
movq %r13, %rdi
callq 0x3664
movq (%rbp), %rax
movq 0x8(%rsp), %rcx
leaq 0x1(%rcx), %rdx
movq %rdx, 0x8(%rsp)
movsbq (%rcx), %rcx
cmpl $0x58, (%rax,%rcx,4)
jne 0x16c8
movq %r13, %rdi
callq 0x3664
movslq 0x14(%rbx), %rax
leal 0x1(%rax), %ecx
movl %ecx, 0x14(%rbx)
leaq (%r12,%rax,8), %rsi
movq %r13, %rdi
callq 0x36b5
testb %al, %al
je 0x16d9
movl 0x14(%rbx), %eax
jmp 0x1618
leaq 0x3a29(%rip), %rdi      # 0x50b2
callq 0x1040
jmp 0x154e
leaq 0x39fe(%rip), %rdi      # 0x5098
xorl %eax, %eax
callq 0x1030
jmp 0x154e
leaq 0x3a28(%rip), %rdi      # 0x50d5
callq 0x1040
jmp 0x154e
leaq 0x39fd(%rip), %rdi      # 0x50bb
callq 0x1040
jmp 0x154e
leaq 0x39fc(%rip), %rdi      # 0x50cb
callq 0x1040
jmp 0x154e
leaq 0x39e2(%rip), %rdi      # 0x50c2
callq 0x1040
jmp 0x154e
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