// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x30(%rbp)
movq %rdi, -0x28(%rbp)
movq %rsi, -0x8(%rbp)
movq $0x0, -0x10(%rbp)
movq -0x8(%rbp), %rdi
callq 0x1140
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x1641
movq -0x10(%rbp), %rax
cmpb $0x0, (%rax)
je 0x1634
movq -0x10(%rbp), %rdi
callq 0x11a0
jmp 0x163f
movq -0x10(%rbp), %rdi
callq 0x10f0
jmp 0x160c
jmp 0x1648
xorl %edi, %edi
callq 0x1090
movq -0x10(%rbp), %rax
movq %rax, -0x18(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x4660
movq -0x18(%rbp), %rax
movsbl (%rax), %edi
callq 0x1080
cmpl $0x44, %eax
jne 0x1673
movq -0x30(%rbp), %rax
movb $0x1, (%rax)
jmp 0x16a9
movq -0x18(%rbp), %rax
movsbl (%rax), %edi
callq 0x1080
cmpl $0x54, %eax
jne 0x168d
movq -0x30(%rbp), %rax
movb $0x0, (%rax)
jmp 0x16a7
movq -0x18(%rbp), %rax
movsbl (%rax), %esi
leaq 0x49e3(%rip), %rdi      # 0x607e
movb $0x0, %al
callq 0x1030
jmp 0x160c
jmp 0x16a9
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
leaq -0x18(%rbp), %rdi
callq 0x4660
movq -0x30(%rbp), %rsi
addq $0x4, %rsi
leaq -0x18(%rbp), %rdi
callq 0x4700
andb $0x1, %al
movb %al, -0x19(%rbp)
testb $0x1, -0x19(%rbp)
jne 0x16ed
leaq 0x49aa(%rip), %rdi      # 0x608b
movb $0x0, %al
callq 0x1030
jmp 0x160c
leaq -0x18(%rbp), %rdi
callq 0x4660
movq -0x18(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x18(%rbp)
movsbl (%rax), %eax
cmpl $0x2d, %eax
je 0x1720
leaq 0x4981(%rip), %rdi      # 0x6095
movb $0x0, %al
callq 0x1030
jmp 0x160c
leaq -0x18(%rbp), %rdi
callq 0x4660
movq -0x30(%rbp), %rsi
addq $0xc, %rsi
leaq -0x18(%rbp), %rdi
callq 0x4700
andb $0x1, %al
movb %al, -0x19(%rbp)
testb $0x1, -0x19(%rbp)
jne 0x1758
leaq 0x4954(%rip), %rdi      # 0x60a0
movb $0x0, %al
callq 0x1030
jmp 0x160c
movq -0x30(%rbp), %rax
movl $0x0, 0x14(%rax)
movq -0x30(%rbp), %rax
cmpl $0x8, 0x14(%rax)
jg 0x1817
leaq -0x18(%rbp), %rdi
callq 0x4660
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x0, %eax
jne 0x178b
jmp 0x1817
leaq -0x18(%rbp), %rdi
callq 0x4660
movq -0x18(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x18(%rbp)
movsbl (%rax), %edi
callq 0x1080
cmpl $0x58, %eax
je 0x17c3
leaq 0x48f1(%rip), %rdi      # 0x60a8
movb $0x0, %al
callq 0x1030
jmp 0x160c
leaq -0x18(%rbp), %rdi
callq 0x4660
movq -0x30(%rbp), %rcx
movq %rcx, %rsi
addq $0x18, %rsi
movl 0x14(%rcx), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, 0x14(%rcx)
cltq
shlq $0x3, %rax
addq %rax, %rsi
leaq -0x18(%rbp), %rdi
callq 0x4700
andb $0x1, %al
movb %al, -0x19(%rbp)
testb $0x1, -0x19(%rbp)
jne 0x1812
leaq 0x48ad(%rip), %rdi      # 0x60b3
movb $0x0, %al
callq 0x1030
jmp 0x160c
jmp 0x1763
movq -0x28(%rbp), %rax
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax,%rax)