// File: /workspace/github_c_makefile_star2_O0/7402[P]randwords/main.c
// Function: print_words
bool print_words(int from_index, int to_index, int words_per_row, int word_count)
{
    bool error = false;
    
    int key_index_size = to_index - from_index + 1;;
    KeyIndex *key_index = (KeyIndex *)calloc(key_index_size, sizeof(KeyIndex));
    
    if (key_index != NULL) {
        bool needs_shuffle = true;
        int next_key_index = 0;
        
        srand((unsigned int)time(NULL));
        for (int k = 0; k < key_index_size; k++) key_index[k].words_index = (short)(from_index + k);
        
        for (int word_num = 1; word_num <= word_count; word_num++) {
            if (needs_shuffle) {
                for (int k = 0; k < key_index_size; k++) key_index[k].rand_key = (short)rand();
                qsort(key_index, key_index_size, sizeof(KeyIndex), compare);
                next_key_index = 0;
                needs_shuffle = false;
            }
            
            printf("%s", word(key_index[next_key_index++].words_index));

            if (word_num % words_per_row == 0 || word_num == word_count) {
                printf("\n");
                
            } else {
                printf(" ");
            }

            if (next_key_index >= key_index_size) needs_shuffle = true;
        }

        free(key_index);
        key_index = NULL;
    }
    
    return error;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl %edi, -0x4(%rbp)
movl %esi, -0x8(%rbp)
movl %edx, -0xc(%rbp)
movl %ecx, -0x10(%rbp)
movb $0x0, -0x11(%rbp)
movl -0x8(%rbp), %eax
subl -0x4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
movslq -0x18(%rbp), %rdi
movl $0x4, %esi
callq 0x1e070
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x1e743
movb $0x1, -0x21(%rbp)
movl $0x0, -0x28(%rbp)
xorl %eax, %eax
movl %eax, %edi
callq 0x1e0a0
movl %eax, %edi
callq 0x1e060
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x1e64c
movl -0x4(%rbp), %eax
addl -0x2c(%rbp), %eax
movw %ax, %dx
movq -0x20(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movw %dx, 0x2(%rax,%rcx,4)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x1e623
movl $0x1, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x10(%rbp), %eax
jg 0x1e732
testb $0x1, -0x21(%rbp)
je 0x1e6b7
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x1e693
callq 0x1e0c0
movw %ax, %dx
movq -0x20(%rbp), %rax
movslq -0x34(%rbp), %rcx
movw %dx, (%rax,%rcx,4)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1e66c
movq -0x20(%rbp), %rdi
movslq -0x18(%rbp), %rsi
movl $0x4, %edx
leaq 0xa9(%rip), %rcx        # 0x1e750
callq 0x1e040
movl $0x0, -0x28(%rbp)
movb $0x0, -0x21(%rbp)
movq -0x20(%rbp), %rax
movl -0x28(%rbp), %ecx
movl %ecx, %edx
addl $0x1, %edx
movl %edx, -0x28(%rbp)
movslq %ecx, %rcx
movswl 0x2(%rax,%rcx,4), %edi
callq 0x1e780
movq %rax, %rsi
leaq 0xc6c(%rip), %rdi       # 0x1f349
movb $0x0, %al
callq 0x1e050
movl -0x30(%rbp), %eax
cltd
idivl -0xc(%rbp)
cmpl $0x0, %edx
je 0x1e6f8
movl -0x30(%rbp), %eax
cmpl -0x10(%rbp), %eax
jne 0x1e708
leaq 0x1272(%rip), %rdi      # 0x1f971
movb $0x0, %al
callq 0x1e050
jmp 0x1e716
leaq 0xc3d(%rip), %rdi       # 0x1f34c
movb $0x0, %al
callq 0x1e050
movl -0x28(%rbp), %eax
cmpl -0x18(%rbp), %eax
jl 0x1e722
movb $0x1, -0x21(%rbp)
jmp 0x1e724
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x1e653
movq -0x20(%rbp), %rdi
callq 0x1e030
movq $0x0, -0x20(%rbp)
movb -0x11(%rbp), %al
andb $0x1, %al
addq $0x40, %rsp
popq %rbp
retq
nop