// File: adrianphoulady[P]weighted-tsetlin-machine-cpp/./utils.h
// Function: sample_data(array2d<unsigned int>*, array1d<int>*, array2d<unsigned int>*&, array1d<int>*&, int)
void sample_data(array2d<word> *x, array1d<int> *y, array2d<word> *&xs, array1d<int> *&ys, int size) {
    array1d<int> idx{x->rows};
    for (int i = 0; i < idx.columns; ++i)
        idx(i) = i;
    xs = new array2d<word>{size, x->columns};
    ys = new array1d<int>{size};
    for (int i = 0; i < xs->rows; ++i) {
        std::swap(idx(i), idx(i + fastrandrange(x->rows - i)));
        std::copy((*x)(idx(i)), (*x)(idx(i) + 1), (*xs)(i));
        (*ys)(i) = (*y)(idx(i));
    }
}

// Assembly:
subq $0xe8, %rsp
movq %rdi, 0xe0(%rsp)
movq %rsi, 0xd8(%rsp)
movq %rdx, 0xd0(%rsp)
movq %rcx, 0xc8(%rsp)
movl %r8d, 0xc4(%rsp)
movq 0xe0(%rsp), %rax
movl (%rax), %esi
leaq 0xb0(%rsp), %rdi
callq 0x40f0
movl $0x0, 0xac(%rsp)
movl 0xac(%rsp), %eax
cmpl 0xb0(%rsp), %eax
jge 0x3163
movl 0xac(%rsp), %esi
movl %esi, 0x8c(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0x4220
movq %rax, 0x90(%rsp)
jmp 0x3126
movq 0x90(%rsp), %rax
movl 0x8c(%rsp), %ecx
movl %ecx, (%rax)
movl 0xac(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xac(%rsp)
jmp 0x30f1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
jmp 0x3406
movl $0x10, %edi
callq 0x2210
movq %rax, 0x80(%rsp)
jmp 0x3177
movq 0x80(%rsp), %rdi
movl 0xc4(%rsp), %esi
movq 0xe0(%rsp), %rax
movl 0x4(%rax), %edx
callq 0x40a0
jmp 0x3198
movq 0x80(%rsp), %rcx
movq 0xd0(%rsp), %rax
movq %rcx, (%rax)
movl $0x10, %edi
callq 0x2210
movq %rax, 0x78(%rsp)
jmp 0x31bc
movq 0x78(%rsp), %rdi
movl 0xc4(%rsp), %esi
callq 0x40f0
jmp 0x31cf
movq 0x78(%rsp), %rcx
movq 0xc8(%rsp), %rax
movq %rcx, (%rax)
movl $0x0, 0x98(%rsp)
movl 0x98(%rsp), %eax
movq 0xd0(%rsp), %rcx
movq (%rcx), %rcx
cmpl (%rcx), %eax
jge 0x33f1
movl 0x98(%rsp), %esi
leaq 0xb0(%rsp), %rdi
callq 0x4220
movq %rax, 0x70(%rsp)
jmp 0x321f
movl 0x98(%rsp), %eax
movl %eax, 0x68(%rsp)
movq 0xe0(%rsp), %rcx
movl (%rcx), %edi
subl %eax, %edi
callq 0x3420
movl %eax, 0x6c(%rsp)
jmp 0x3241
movl 0x6c(%rsp), %eax
movl 0x68(%rsp), %esi
addl %eax, %esi
leaq 0xb0(%rsp), %rdi
callq 0x4220
movq %rax, 0x60(%rsp)
jmp 0x325f
movq 0x60(%rsp), %rsi
movq 0x70(%rsp), %rdi
callq 0x44a0
movq 0xe0(%rsp), %rax
movq %rax, 0x50(%rsp)
movl 0x98(%rsp), %esi
leaq 0xb0(%rsp), %rdi
callq 0x4220
movq %rax, 0x58(%rsp)
jmp 0x3296
movq 0x50(%rsp), %rdi
movq 0x58(%rsp), %rax
movl (%rax), %esi
callq 0x4160
movq %rax, 0x48(%rsp)
jmp 0x32ae
movq 0xe0(%rsp), %rax
movq %rax, 0x38(%rsp)
movl 0x98(%rsp), %esi
leaq 0xb0(%rsp), %rdi
callq 0x4220
movq %rax, 0x40(%rsp)
jmp 0x32d6
movq 0x38(%rsp), %rdi
movq 0x40(%rsp), %rax
movl (%rax), %esi
incl %esi
callq 0x4160
movq %rax, 0x30(%rsp)
jmp 0x32f0
movq 0xd0(%rsp), %rax
movq (%rax), %rdi
movl 0x98(%rsp), %esi
callq 0x4160
movq %rax, 0x28(%rsp)
jmp 0x330e
movq 0x28(%rsp), %rdx
movq 0x30(%rsp), %rsi
movq 0x48(%rsp), %rdi
callq 0x44d0
jmp 0x3324
movq 0xd8(%rsp), %rax
movq %rax, 0x18(%rsp)
movl 0x98(%rsp), %esi
leaq 0xb0(%rsp), %rdi
callq 0x4220
movq %rax, 0x20(%rsp)
jmp 0x334c
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rax
movl (%rax), %esi
callq 0x4220
movq %rax, 0x10(%rsp)
jmp 0x3364
movq 0x10(%rsp), %rax
movl (%rax), %eax
movl %eax, 0x4(%rsp)
movq 0xc8(%rsp), %rax
movq (%rax), %rdi
movl 0x98(%rsp), %esi
callq 0x4220
movq %rax, 0x8(%rsp)
jmp 0x338d
movq 0x8(%rsp), %rax
movl 0x4(%rsp), %ecx
movl %ecx, (%rax)
movl 0x98(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x98(%rsp)
jmp 0x31ea
movq 0x80(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
callq 0x2200
jmp 0x3406
movq 0x78(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xa0(%rsp)
movl %eax, 0x9c(%rsp)
callq 0x2200
jmp 0x3406
leaq 0xb0(%rsp), %rdi
callq 0x4520
addq $0xe8, %rsp
retq
leaq 0xb0(%rsp), %rdi
callq 0x4520
movq 0xa0(%rsp), %rdi
callq 0x2360