// File: /workspace/github_c_makefile_star2_O0/cinemast[P]sudoku/sudoku.c
// Function: read_board
static
int
read_board (FILE * f, int is_tmplt)
{
    char * p, * q;
    int i, row, col, type = COMPACT;

    reset();
    len_tmplt = 0;

    /* Skip lines until a '%' is found */
    line[0] = ' ';
    while ('%' != line[0]) {
        if (0 == tgets(line, sizeof(line), f)) {
            return -1;
        }
    }
    /* Read optional title, and removing trailing whitespace */
    for (p = line + 1; *p && isspace(*p); ++p) {
       ;
    }
    if (*p) {
        for (q = title; '\0' != (*q++ = *p++);) {
           ;
        }
        --q;
        while (isspace(*--q)) {
           ;
        }
        *++q = '\0';
    } else {
        strcpy(title, "(untitled)");
    }
    /* Consume comment lines - no leading spaces allowed */
    line[0] = '#';
    while ('#' == line[0]) {
        if (0 == tgets(line, sizeof(line), f)) {
            return -1;
        }
    }
    /* Analyse first line to determine the 'type' - default is COMPACT */
    if (0 == is_tmplt) {
        for (p = line; *p && COMPACT == type; ++p) {
            if ('|' == *p) {
                type = VERBOSE;
            }
        }
    }
    /* Consume grid - allow leading spaces and comments at end */
    for (row = 0; row < 9; ++row) {
        /* Assume line already loaded into buffer; skip leading spaces */
        for (p = line; *p && isspace(*p); ++p) {
           ;
        }
        for (col = 0; *p && col < 9; ++col, ++p) {
            if (is_tmplt) {
                if ('*' == *p) {
                    tmplt[len_tmplt++] = INDEX(row, col);
                }
            } else {
                if (VERBOSE == type) {
                    while (*p && (isspace(*p) || '|' == *p)) {
                        ++p;
                    }
                }
                if (isdigit(*p)) {
                    if (0 != fill(INDEX(row, col), *p - '0')) {
                        return -1;
                    }
                    board[INDEX(row, col)] |= FIXED;
                }
                /* else assume blank square */
            }
        }
        /* Don't complain about any trailing characters - ignored silently */

        /* Load next line (if needed) */
        if (row < 8) {
            if (0 == tgets(line, sizeof(line), f)) {
                return -1;
            }
            if (VERBOSE == type
                && 2 == row % 3
                && 0 == tgets(line, sizeof(line), f)) {
                return -1; /* Skip separators */
            }
        }
    }

    /* Construct move history for a template */
    if (is_tmplt) {
        idx_history = 0;
        for (i = 0; i < 81; ++i) {
            if (0 != DIGIT(i)) {
                history[idx_history++] = i | (DIGIT(i) << 8);
            }
        }
    }
    /* Finally, markup all of these moves as 'fixed' */
    for (i = 0; i < idx_history; ++i) {
        history[i] |= FIXED;
    }
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movl $0x0, -0x38(%rbp)
callq 0x62e0
movl $0x0, 0xcc53(%rip)      # 0x12a08
movb $0x20, 0xcc54(%rip)     # 0x12a10
movsbl 0xcc4d(%rip), %ecx      # 0x12a10
movl $0x25, %eax
cmpl %ecx, %eax
je 0x5df9
movq -0x10(%rbp), %rdx
leaq 0xcc39(%rip), %rdi      # 0x12a10
movl $0x50, %esi
callq 0x6320
movq %rax, %rcx
xorl %eax, %eax
cmpq %rcx, %rax
jne 0x5df7
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x62ce
jmp 0x5dbc
leaq 0xcc10(%rip), %rax      # 0x12a10
addq $0x1, %rax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x39(%rbp)
je 0x5e3d
callq 0x2360
movq (%rax), %rax
movq -0x20(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
setne %al
movb %al, -0x39(%rbp)
movb -0x39(%rbp), %al
testb $0x1, %al
jne 0x5e46
jmp 0x5e56
jmp 0x5e48
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x5e08
movq -0x20(%rbp), %rax
cmpb $0x0, (%rax)
je 0x5eea
leaq 0xc5b6(%rip), %rax      # 0x12420
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x20(%rbp)
movb (%rax), %al
movq -0x28(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x28(%rbp)
movb %al, (%rcx)
movsbl %al, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
je 0x5e9b
jmp 0x5e6e
movq -0x28(%rbp), %rax
addq $-0x1, %rax
movq %rax, -0x28(%rbp)
callq 0x2360
movq (%rax), %rax
movq -0x28(%rbp), %rcx
movq %rcx, %rdx
addq $-0x1, %rdx
movq %rdx, -0x28(%rbp)
movsbl -0x1(%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0x5ed5
jmp 0x5ea7
movq -0x28(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x28(%rbp)
movb $0x0, 0x1(%rax)
jmp 0x5efd
leaq 0xc52f(%rip), %rdi      # 0x12420
leaq 0x7112(%rip), %rsi      # 0xd00a
callq 0x2050
movb $0x23, 0xcb0c(%rip)     # 0x12a10
movsbl 0xcb05(%rip), %ecx      # 0x12a10
movl $0x23, %eax
cmpl %ecx, %eax
jne 0x5f41
movq -0x10(%rbp), %rdx
leaq 0xcaf1(%rip), %rdi      # 0x12a10
movl $0x50, %esi
callq 0x6320
movq %rax, %rcx
xorl %eax, %eax
cmpq %rcx, %rax
jne 0x5f3f
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x62ce
jmp 0x5f04
xorl %eax, %eax
cmpl -0x14(%rbp), %eax
jne 0x5fa1
leaq 0xcac1(%rip), %rax      # 0x12a10
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x3a(%rbp)
je 0x5f6f
xorl %eax, %eax
cmpl -0x38(%rbp), %eax
sete %al
movb %al, -0x3a(%rbp)
movb -0x3a(%rbp), %al
testb $0x1, %al
jne 0x5f78
jmp 0x5f9f
movq -0x20(%rbp), %rax
movsbl (%rax), %ecx
movl $0x7c, %eax
cmpl %ecx, %eax
jne 0x5f8f
movl $0x1, -0x38(%rbp)
jmp 0x5f91
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x5f53
jmp 0x5fa1
movl $0x0, -0x30(%rbp)
cmpl $0x9, -0x30(%rbp)
jge 0x6207
leaq 0xca57(%rip), %rax      # 0x12a10
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x3b(%rbp)
je 0x5ff2
callq 0x2360
movq (%rax), %rax
movq -0x20(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
setne %al
movb %al, -0x3b(%rbp)
movb -0x3b(%rbp), %al
testb $0x1, %al
jne 0x5ffb
jmp 0x600b
jmp 0x5ffd
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x5fbd
movl $0x0, -0x34(%rbp)
movq -0x20(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x3c(%rbp)
je 0x602d
cmpl $0x9, -0x34(%rbp)
setl %al
movb %al, -0x3c(%rbp)
movb -0x3c(%rbp), %al
testb $0x1, %al
jne 0x6039
jmp 0x617b
cmpl $0x0, -0x14(%rbp)
je 0x6079
movq -0x20(%rbp), %rax
movsbl (%rax), %ecx
movl $0x2a, %eax
cmpl %ecx, %eax
jne 0x6074
imull $0x9, -0x30(%rbp), %edx
addl -0x34(%rbp), %edx
movl 0xc9ac(%rip), %eax      # 0x12a08
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, 0xc9a1(%rip)      # 0x12a08
movslq %eax, %rcx
leaq 0xc9ef(%rip), %rax      # 0x12a60
movl %edx, (%rax,%rcx,4)
jmp 0x615f
movl $0x1, %eax
cmpl -0x38(%rbp), %eax
jne 0x60ef
jmp 0x6085
movq -0x20(%rbp), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x3d(%rbp)
je 0x60d6
callq 0x2360
movq (%rax), %rax
movq -0x20(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %ecx
andl $0x2000, %ecx           # imm = 0x2000
movb $0x1, %al
cmpl $0x0, %ecx
movb %al, -0x3e(%rbp)
jne 0x60d0
movq -0x20(%rbp), %rax
movsbl (%rax), %ecx
movl $0x7c, %eax
cmpl %ecx, %eax
sete %al
movb %al, -0x3e(%rbp)
movb -0x3e(%rbp), %al
movb %al, -0x3d(%rbp)
movb -0x3d(%rbp), %al
testb $0x1, %al
jne 0x60df
jmp 0x60ed
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x6085
jmp 0x60ef
callq 0x2360
movq (%rax), %rax
movq -0x20(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x800, %eax            # imm = 0x800
cmpl $0x0, %eax
je 0x615d
imull $0x9, -0x30(%rbp), %edi
addl -0x34(%rbp), %edi
movq -0x20(%rbp), %rax
movsbl (%rax), %esi
subl $0x30, %esi
callq 0x64b0
movl %eax, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
je 0x6139
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x62ce
imull $0x9, -0x30(%rbp), %eax
addl -0x34(%rbp), %eax
movslq %eax, %rcx
leaq 0xc366(%rip), %rax      # 0x124b0
movl (%rax,%rcx,4), %edx
orl $0x100000, %edx         # imm = 0x100000
leaq 0xc356(%rip), %rax      # 0x124b0
movl %edx, (%rax,%rcx,4)
jmp 0x615f
jmp 0x6161
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x6012
cmpl $0x8, -0x30(%rbp)
jge 0x61f7
movq -0x10(%rbp), %rdx
leaq 0xc884(%rip), %rdi      # 0x12a10
movl $0x50, %esi
callq 0x6320
movq %rax, %rcx
xorl %eax, %eax
cmpq %rcx, %rax
jne 0x61ac
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x62ce
movl $0x1, %eax
cmpl -0x38(%rbp), %eax
jne 0x61f5
movl -0x30(%rbp), %eax
movl $0x3, %ecx
cltd
idivl %ecx
movl $0x2, %eax
cmpl %edx, %eax
jne 0x61f5
movq -0x10(%rbp), %rdx
leaq 0xc83b(%rip), %rdi      # 0x12a10
movl $0x50, %esi
callq 0x6320
movq %rax, %rcx
xorl %eax, %eax
cmpq %rcx, %rax
jne 0x61f5
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x62ce
jmp 0x61f7
jmp 0x61f9
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x5fa8
cmpl $0x0, -0x14(%rbp)
je 0x628c
movl $0x0, 0xc40d(%rip)      # 0x12624
movl $0x0, -0x2c(%rbp)
cmpl $0x51, -0x2c(%rbp)
jge 0x628a
movslq -0x2c(%rbp), %rcx
leaq 0xc281(%rip), %rax      # 0x124b0
movl (%rax,%rcx,4), %ecx
andl $0xf0000, %ecx          # imm = 0xF0000
sarl $0x10, %ecx
xorl %eax, %eax
cmpl %ecx, %eax
je 0x627d
movl -0x2c(%rbp), %edx
movslq -0x2c(%rbp), %rcx
leaq 0xc261(%rip), %rax      # 0x124b0
movl (%rax,%rcx,4), %eax
andl $0xf0000, %eax          # imm = 0xF0000
sarl $0x10, %eax
shll $0x8, %eax
orl %eax, %edx
movl 0xc3bf(%rip), %eax      # 0x12624
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, 0xc3b4(%rip)      # 0x12624
movslq %eax, %rcx
leaq 0xc3b6(%rip), %rax      # 0x12630
movl %edx, (%rax,%rcx,4)
jmp 0x627f
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x621e
jmp 0x628c
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl 0xc388(%rip), %eax      # 0x12624
jge 0x62c7
movslq -0x2c(%rbp), %rcx
leaq 0xc387(%rip), %rax      # 0x12630
movl (%rax,%rcx,4), %edx
orl $0x100000, %edx         # imm = 0x100000
leaq 0xc377(%rip), %rax      # 0x12630
movl %edx, (%rax,%rcx,4)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x6293
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)