// File: /workspace/github_cpp_makefile_star2_O3/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %r8d, %r12d
movq %rcx, 0x8(%rsp)
movq %rdx, (%rsp)
movq %rsi, 0x20(%rsp)
movq %rdi, %r15
movslq (%rdi), %r14
leaq (,%r14,4), %rdi
callq 0x2030
movq %rax, %rbx
testq %r14, %r14
jle 0x2ddc
leal 0x1(%r14), %eax
andl $-0x2, %eax
decq %r14
movq %r14, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movdqa 0x2304(%rip), %xmm1     # 0x5070
xorl %ecx, %ecx
movdqa 0x230a(%rip), %xmm2     # 0x5080
pxor %xmm2, %xmm0
pcmpeqd %xmm3, %xmm3
movdqa 0x230a(%rip), %xmm4     # 0x5090
movdqa %xmm1, %xmm5
pxor %xmm2, %xmm5
movdqa %xmm5, %xmm6
pcmpgtd %xmm0, %xmm6
pcmpeqd %xmm0, %xmm5
pshufd $0xf5, %xmm5, %xmm7     # xmm7 = xmm5[1,1,3,3]
pand %xmm6, %xmm7
pshufd $0xf5, %xmm6, %xmm5     # xmm5 = xmm6[1,1,3,3]
por %xmm7, %xmm5
movd %xmm5, %edx
notl %edx
testb $0x1, %dl
je 0x2dba
movl %ecx, (%rbx,%rcx,4)
pxor %xmm3, %xmm5
pextrw $0x4, %xmm5, %edx
testb $0x1, %dl
je 0x2dcf
leal 0x1(%rcx), %edx
movl %edx, 0x4(%rbx,%rcx,4)
addq $0x2, %rcx
paddq %xmm4, %xmm1
cmpq %rcx, %rax
jne 0x2d86
movl $0x10, %edi
callq 0x21d0
movq %rax, %rbp
movl 0x4(%r15), %eax
movl %r12d, (%rbp)
movl %eax, 0x4(%rbp)
imull %r12d, %eax
movslq %eax, %rdi
shlq $0x2, %rdi
callq 0x2030
movq %rax, 0x8(%rbp)
movq (%rsp), %rax
movq %rbp, (%rax)
movl $0x10, %edi
callq 0x21d0
movq %rax, %rbp
movl %r12d, (%rax)
movslq %r12d, %rdi
shlq $0x2, %rdi
callq 0x2030
movq %rax, 0x8(%rbp)
movq 0x8(%rsp), %rax
movq %rbp, (%rax)
movq (%rsp), %rax
movq (%rax), %rax
cmpl $0x0, (%rax)
jle 0x2f4d
movq %r15, 0x18(%rsp)
xorl %r15d, %r15d
movq 0x535a(%rip), %r14      # 0x81b0
movabsq $0x5851f42d4c957f2d, %r9 # imm = 0x5851F42D4C957F2D
movabsq $0x100000000, %r10      # imm = 0x100000000
xorl %r12d, %r12d
xorl %r13d, %r13d
movq %rbx, 0x10(%rsp)
movq %r14, %rdx
shrq $0x16, %rdx
xorq %r14, %rdx
movq %r14, %rcx
shrq $0x3d, %rcx
addb $0x16, %cl
shrq %cl, %rdx
movl %edx, %ecx
movq 0x18(%rsp), %r8
movl (%r8), %edx
addl %r15d, %edx
imulq %rcx, %rdx
addq %r12, %rdx
sarq $0x20, %rdx
movl (%rbx,%r13,4), %ecx
movl (%rbx,%rdx,4), %esi
movl %esi, (%rbx,%r13,4)
movl %ecx, (%rbx,%rdx,4)
movl (%rbx,%r13,4), %ecx
movl 0x4(%r8), %edx
leal 0x1(%rcx), %edi
imull %edx, %edi
imull %ecx, %edx
movslq %edx, %rsi
shlq $0x2, %rsi
movslq %edi, %rdx
shlq $0x2, %rdx
subq %rsi, %rdx
je 0x2f16
addq 0x8(%r8), %rsi
movslq 0x4(%rax), %rcx
movslq %r13d, %rdi
imulq %rcx, %rdi
shlq $0x2, %rdi
addq 0x8(%rax), %rdi
movq %r9, %rbp
movq %r10, %rbx
callq 0x22c0
movq %rbx, %r10
movq 0x10(%rsp), %rbx
movq %rbp, %r9
movl (%rbx,%r13,4), %ecx
movq 0x8(%rsp), %rax
movq (%rax), %rbp
movq (%rsp), %rax
movq (%rax), %rax
imulq %r9, %r14
movq 0x20(%rsp), %rdx
movq 0x8(%rdx), %rdx
movslq %ecx, %rcx
movl (%rdx,%rcx,4), %ecx
movq 0x8(%rbp), %rdx
movl %ecx, (%rdx,%r13,4)
incq %r13
movslq (%rax), %rcx
addq %r10, %r12
decl %r15d
cmpq %rcx, %r13
jl 0x2e75
movq %r14, 0x5263(%rip)      # 0x81b0
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2230
jmp 0x2f65
movq %rax, %r14
movq %rbp, %rdi
callq 0x21b0
jmp 0x2f75
movq %rax, %r14
movq %rbx, %rdi
callq 0x2230
movq %r14, %rdi
callq 0x22e0