// File: /workspace/github_c_makefile_star2_O1/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 0xa932(%rip), %r12      # 0xfcb0
leaq 0xa6cb(%rip), %r15      # 0xfa50
leaq 0xa114(%rip), %r14      # 0xf4a0
movabsq $-0x1c71c71c71c71c71, %r13 # imm = 0xE38E38E38E38E38F
xorl %ecx, %ecx
leaq 0x1(%rcx), %rax
movl %eax, (%r12,%rcx,4)
movq %rax, %rcx
cmpq $0x9, %rax
jne 0x5398
callq 0x2380
leal 0x7(%rax), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
andl $-0x8, %ecx
negl %ecx
leal (%rax,%rcx), %edx
incl %edx
movq %r12, %rdi
movl $0x9, %esi
callq 0x7280
movl $0xa, %ebx
callq 0x2380
leaq -0x1(%rbx), %rcx
cltd
idivl %ecx
movl -0x8(%r12,%rbx,4), %eax
movslq %edx, %rdx
movl (%r12,%rdx,4), %esi
movl %esi, -0x8(%r12,%rbx,4)
movl %eax, (%r12,%rdx,4)
movq %rcx, %rbx
cmpq $0x1, %rcx
ja 0x53d2
cmpl $0x0, 0x9ffd(%rip)      # 0xf400
jle 0x5415
callq 0x2380
cltd
idivl 0x9fef(%rip)            # 0xf400
movl %edx, %ebp
jmp 0x5417
xorl %ebp, %ebp
movq 0x9fca(%rip), %rdi      # 0xf3e8
leaq 0xa773(%rip), %rax      # 0xfb98
cmpq %rax, %rdi
je 0x5435
xorl %esi, %esi
xorl %edx, %edx
callq 0x2270
jmp 0x5448
cmpb $0x1, 0xa834(%rip)      # 0xfc70
jne 0x5448
movl $0x0, 0xa82c(%rip)      # 0xfc74
testl %ebp, %ebp
js 0x546a
movq 0x9f95(%rip), %rdi      # 0xf3e8
movl $0x1, %esi
callq 0x6183
testl %eax, %eax
jne 0x546a
leal -0x1(%rbp), %eax
testl %ebp, %ebp
movl %eax, %ebp
jg 0x544c
movl 0xa588(%rip), %ebp      # 0xf9f8
callq 0x2380
movl 0xa57d(%rip), %ecx      # 0xf9f8
decl %ecx
cltd
idivl %ecx
incl %edx
movq %r15, %rdi
movl %ebp, %esi
callq 0x7280
movslq 0xa565(%rip), %rbx      # 0xf9f8
testq %rbx, %rbx
jle 0x54c2
callq 0x2380
cltd
idivl %ebx
movl -0x4(%r15,%rbx,4), %eax
movslq %edx, %rcx
movl (%r15,%rcx,4), %edx
movl %edx, -0x4(%r15,%rbx,4)
leaq -0x1(%rbx), %rdx
movl %eax, (%r15,%rcx,4)
cmpq $0x1, %rbx
movq %rdx, %rbx
jg 0x5498
movl $0x144, %edx            # imm = 0x144
movq %r14, %rdi
xorl %esi, %esi
callq 0x2190
movl $0x3cc, %edx            # imm = 0x3CC
leaq 0xa143(%rip), %rdi      # 0xf620
xorl %esi, %esi
callq 0x2190
xorl %eax, %eax
movl %eax, 0xa128(%rip)      # 0xf614
movl %eax, 0xa6a2(%rip)      # 0xfb94
cmpl %eax, 0xa500(%rip)      # 0xf9f8
jle 0x5538
movq %r12, %rbx
movq %r15, %r14
xorl %ebp, %ebp
movq %rbp, %rax
mulq %r13
shrq %rdx
andq $-0x4, %rdx
leaq (%rdx,%rdx,8), %rax
negq %rax
movl (%r14), %edi
movl (%rbx,%rax), %esi
callq 0x65cb
incq %rbp
movslq 0xa4cd(%rip), %rax      # 0xf9f8
addq $0x4, %r14
addq $0x4, %rbx
cmpq %rax, %rbp
jl 0x5502
callq 0x675c
movl $0x0, %ecx
testl %eax, %eax
leaq 0x9f55(%rip), %r14      # 0xf4a0
jne 0x5398
cmpl $0x51, 0xa0bc(%rip)     # 0xf614
movl $0x0, %ecx
jl 0x5398
movslq 0xa48e(%rip), %rax      # 0xf9f8
testq %rax, %rax
jle 0x5588
shlq $0x2, %rax
xorl %ecx, %ecx
movslq (%rcx,%r15), %rdx
orb $0x10, 0x2(%r14,%rdx,4)
addq $0x4, %rcx
cmpq %rcx, %rax
jne 0x5575
movl $0x0, 0xa082(%rip)      # 0xf614
xorl %eax, %eax
movq %r14, %rcx
xorl %edx, %edx
leaq 0xa080(%rip), %r8       # 0xf620
movl (%rcx), %esi
btl $0x14, %esi
jae 0x55c7
andl $0xf0000, %esi          # imm = 0xF0000
movl %eax, %edi
orl %esi, %edi
orl $0x100000, %edi         # imm = 0x100000
movslq %edx, %rsi
incl %edx
movl %edx, 0xa051(%rip)      # 0xf614
movl %edi, (%r8,%rsi,4)
incq %rax
addq $0x4, %rcx
cmpq $0x51, %rax
jne 0x55a0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
movq %r8, %rcx
incl %eax
testb $0x10, 0x2(%rcx)
leaq 0x4(%rcx), %rcx
jne 0x55dc
movl %eax, 0xa026(%rip)      # 0xf614
callq 0x32e2
callq 0x675c
movl $0x0, %ecx
testl %eax, %eax
jne 0x5398
cmpl $0x51, 0xa008(%rip)     # 0xf614
movl $0x0, %ecx
jl 0x5398
callq 0x68a1
cmpl $-0x1, %eax
je 0x5633
callq 0x675c
movl $0x0, %ecx
testl %eax, %eax
je 0x5398
cmpq $0x0, 0x9d8d(%rip)      # 0xf3c8
je 0x5693
callq 0x690c
movq %rax, %rbp
leaq 0x9dc4(%rip), %rbx      # 0xf410
movq %rbx, %rdi
leaq 0x5ba5(%rip), %rsi      # 0xb1fb
movq %rax, %rdx
xorl %eax, %eax
callq 0x2320
movq %rbx, %rdi
callq 0x7398
movq 0x8969(%rip), %rax      # 0xdfd8
movq (%rax), %rdi
callq 0x2180
movq 0x9d4a(%rip), %rdi      # 0xf3c8
movq %rbp, %rsi
callq 0x2210
movl $0x0, %ecx
testl %eax, %eax
jne 0x5398
movups 0x5b79(%rip), %xmm0     # 0xb213
movaps %xmm0, 0x9d6f(%rip)     # 0xf410
movabsq $0x202d2064657461, %rax # imm = 0x202D2064657461
movq %rax, 0x9d6c(%rip)      # 0xf41e
leaq 0x9d57(%rip), %rbx      # 0xf410
callq 0x690c
movq %rbx, %rdi
movq %rax, %rsi
callq 0x2310
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
leaq 0x9f4b(%rip), %rcx      # 0xf620
incl %eax
testb $0x10, 0x2(%rcx)
leaq 0x4(%rcx), %rcx
jne 0x56d5
movl %eax, 0x9f2d(%rip)      # 0xf614
callq 0x32e2
leaq 0xa5e5(%rip), %rdi      # 0xfcd8
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2250