// File: /workspace/github_c_makefile_star2_O2/cinemast[P]sudoku/sudoku.c
// Function: generate
static
void
generate (void)
{
    static int digits[9];

    int i;

    for (;;) {
        for (i = 0; i < 9; ++i) {
            digits[i] = i + 1;
        }

        rotate(digits, 9, 1 + rand() % 8);
        shuffle(digits, 9);
        select_template();

        rotate(tmplt, len_tmplt, 1 + rand() % (len_tmplt - 1));
        shuffle(tmplt, len_tmplt);

        reset();  /* construct a new board */

        for (i = 0; i < len_tmplt; ++i) {
            fill(tmplt[i], digits[i % 9]);
        }
        if (0 != solve() || idx_history < 81) {
            continue;
        }
        for (i = 0; i < len_tmplt; ++i) {
            board[tmplt[i]] |= FIXED;
        }
        /* Construct fixed squares */
        for (idx_history = i = 0; i < 81; ++i) {
            if (IS_FIXED(i)) {
                history[idx_history++] = SET_INDEX(i)
                                         | SET_DIGIT(DIGIT(i))
                                         | FIXED;
            }
        }
        clear_moves();

        if (0 != solve() || idx_history < 81) {
            continue;
        }
        if (-1 != backtrack() && 0 == solve()) {
            continue;
        }
        if (NULL != requested_class) {
            const char * generated_class = classify();
            sprintf(title, "randomly generated - %s", generated_class);
            write_title(title);
            wrefresh(stdscr);
            if (0 != strcmp(requested_class, generated_class)) {
                continue;
            }
        }

        break;
    }

    strcpy(title, "randomly generated - ");
    strcat(title, classify());

    clear_moves();
    time(&start_time);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
leaq 0xb40e(%rip), %r14      # 0xfcb0
pushq $0x1
popq %r15
leaq 0xb1a3(%rip), %r13      # 0xfa50
leaq 0xabec(%rip), %r12      # 0xf4a0
pushq $0x9
popq %rbx
xorl %ecx, %ecx
cmpq $0x9, %rcx
jne 0x48fc
callq 0x2380
cltd
pushq $0x8
popq %rcx
idivl %ecx
incl %edx
movq %r14, %rdi
pushq $0x9
popq %rbp
movl %ebp, %esi
callq 0x5ee0
movq %r14, %rdi
movl %ebp, %esi
callq 0x5fbd
cmpl $0x0, 0xab16(%rip)      # 0xf400
jle 0x4909
callq 0x2380
cltd
idivl 0xab08(%rip)            # 0xf400
movl %edx, %ebp
jmp 0x490b
leaq 0x1(%rcx), %rax
movl %eax, (%r14,%rcx,4)
movq %rax, %rcx
jmp 0x48b9
xorl %ebp, %ebp
movq 0xaad6(%rip), %rdi      # 0xf3e8
leaq 0xb27f(%rip), %rax      # 0xfb98
cmpq %rax, %rdi
je 0x4929
xorl %esi, %esi
xorl %edx, %edx
callq 0x2270
jmp 0x4939
cmpb $0x1, 0xb340(%rip)      # 0xfc70
jne 0x4939
andl $0x0, 0xb33b(%rip)      # 0xfc74
incl %ebp
decl %ebp
js 0x4952
movq 0xaaa2(%rip), %rdi      # 0xf3e8
movl %r15d, %esi
callq 0x54b2
testl %eax, %eax
je 0x493b
movl 0xb0a0(%rip), %ebp      # 0xf9f8
callq 0x2380
movl 0xb095(%rip), %ecx      # 0xf9f8
decl %ecx
cltd
idivl %ecx
incl %edx
movq %r13, %rdi
movl %ebp, %esi
callq 0x5ee0
movl 0xb07e(%rip), %esi      # 0xf9f8
movq %r13, %rdi
callq 0x5fbd
movl $0x144, %edx            # imm = 0x144
movq %r12, %rdi
xorl %esi, %esi
callq 0x2190
movl $0x3cc, %edx            # imm = 0x3CC
leaq 0xac83(%rip), %rdi      # 0xf620
xorl %esi, %esi
callq 0x2190
andl $0x0, 0xac69(%rip)      # 0xf614
andl $0x0, 0xb1e2(%rip)      # 0xfb94
movq %r13, %r15
movq %r14, %r13
xorl %ebp, %ebp
movq %rbp, %rax
xorl %edx, %edx
divq %rbx
movslq 0xb02f(%rip), %rcx      # 0xf9f8
cmpq %rcx, %rbp
jge 0x49eb
imulq $-0x24, %rax, %rax
movl (%r15), %edi
movl (%r14,%rax), %esi
callq 0x5894
incq %rbp
addq $0x4, %r14
addq $0x4, %r15
jmp 0x49ba
callq 0x5a11
movl $0x0, %ecx
testl %eax, %eax
movq %r13, %r14
pushq $0x1
popq %r15
leaq 0xb04b(%rip), %r13      # 0xfa50
leaq 0xac14(%rip), %r8       # 0xf620
jne 0x48b9
cmpl $0x51, 0xabfb(%rip)     # 0xf614
movl $0x0, %ecx
jl 0x48b9
movl 0xafce(%rip), %eax      # 0xf9f8
testl %eax, %eax
movl $0x0, %ecx
cmovlel %ecx, %eax
shlq $0x2, %rax
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0x4a4f
movslq (%rcx,%r13), %rdx
orb $0x10, 0x2(%r12,%rdx,4)
addq $0x4, %rcx
jmp 0x4a3a
andl $0x0, 0xabbe(%rip)      # 0xf614
xorl %eax, %eax
movl $0x100000, %ecx         # imm = 0x100000
xorl %edx, %edx
cmpq $0x144, %rax            # imm = 0x144
je 0x4a90
movl (%rax,%r12), %esi
btl $0x14, %esi
jae 0x4a88
andl $0xf0000, %esi          # imm = 0xF0000
addl %ecx, %esi
movslq %edx, %rdi
incl %edx
movl %edx, 0xab90(%rip)      # 0xf614
movl %esi, (%r8,%rdi,4)
addq $0x4, %rax
incl %ecx
jmp 0x4a5f
callq 0x5e53
callq 0x5a11
movl $0x0, %ecx
testl %eax, %eax
jne 0x48b9
cmpl $0x51, 0xab66(%rip)     # 0xf614
movl $0x0, %ecx
jl 0x48b9
callq 0x5d0a
cmpl $-0x1, %eax
je 0x4ad5
callq 0x5a11
movl $0x0, %ecx
testl %eax, %eax
je 0x48b9
cmpq $0x0, 0xa8eb(%rip)      # 0xf3c8
je 0x4b36
callq 0x5d76
movq %rax, %rbp
leaq 0xa922(%rip), %rdi      # 0xf410
leaq 0x56d5(%rip), %rsi      # 0xa1ca
movq %rax, %rdx
xorl %eax, %eax
callq 0x2320
leaq 0xa90a(%rip), %rdi      # 0xf410
callq 0x5ff5
movq 0x94c6(%rip), %rax      # 0xdfd8
movq (%rax), %rdi
callq 0x2180
movq 0xa8a7(%rip), %rdi      # 0xf3c8
movq %rbp, %rsi
callq 0x2210
movl $0x0, %ecx
testl %eax, %eax
jne 0x48b9
movups 0x56a5(%rip), %xmm0     # 0xa1e2
movaps %xmm0, 0xa8cc(%rip)     # 0xf410
movabsq $0x202d2064657461, %rax # imm = 0x202D2064657461
movq %rax, 0xa8c9(%rip)      # 0xf41e
leaq 0xa8b4(%rip), %rbx      # 0xf410
callq 0x5d76
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2310
callq 0x5e53
leaq 0xb160(%rip), %rdi      # 0xfcd8
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2250