// File: /workspace/github_cpp_makefile_star2_O1/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, %r15d
movq %rcx, 0x8(%rsp)
movq %rdx, (%rsp)
movq %rsi, 0x20(%rsp)
movq %rdi, %r13
movslq (%rdi), %r14
leaq (,%r14,4), %rdi
callq 0x2030
movq %rax, %rbx
testq %r14, %r14
jle 0x2e22
leal 0x1(%r14), %eax
andl $-0x2, %eax
decq %r14
movq %r14, %xmm0
pshufd $0x44, %xmm0, %xmm0     # xmm0 = xmm0[0,1,0,1]
movdqa 0x22be(%rip), %xmm1     # 0x5070
xorl %ecx, %ecx
movdqa 0x22c4(%rip), %xmm2     # 0x5080
pxor %xmm2, %xmm0
pcmpeqd %xmm3, %xmm3
movdqa 0x22c4(%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 0x2e00
movl %ecx, (%rbx,%rcx,4)
pxor %xmm3, %xmm5
pextrw $0x4, %xmm5, %edx
testb $0x1, %dl
je 0x2e15
leal 0x1(%rcx), %edx
movl %edx, 0x4(%rbx,%rcx,4)
addq $0x2, %rcx
paddq %xmm4, %xmm1
cmpq %rcx, %rax
jne 0x2dcc
movl $0x10, %edi
callq 0x21d0
movq %rax, %rbp
movl 0x4(%r13), %eax
movl %r15d, (%rbp)
movl %eax, 0x4(%rbp)
imull %r15d, %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 %r15d, (%rax)
movslq %r15d, %rdi
shlq $0x2, %rdi
callq 0x2030
movq %rax, 0x8(%rbp)
movq 0x8(%rsp), %rdi
movq %rbp, (%rdi)
movq (%rsp), %rax
movq (%rax), %rax
cmpl $0x0, (%rax)
jle 0x2f92
xorl %r12d, %r12d
movq 0x5321(%rip), %rbp      # 0x81b8
movabsq $0x5851f42d4c957f2d, %r8 # imm = 0x5851F42D4C957F2D
movabsq $0x100000000, %r9       # imm = 0x100000000
xorl %r14d, %r14d
xorl %r15d, %r15d
movq %rbx, 0x18(%rsp)
movq %r13, 0x10(%rsp)
movq %rbp, %rdx
shrq $0x16, %rdx
xorq %rbp, %rdx
movq %rbp, %rcx
shrq $0x3d, %rcx
addb $0x16, %cl
shrq %cl, %rdx
movl %edx, %ecx
movl (%r13), %edx
addl %r12d, %edx
imulq %rcx, %rdx
addq %r14, %rdx
sarq $0x20, %rdx
movl (%rbx,%r15,4), %ecx
movl (%rbx,%rdx,4), %esi
movl %esi, (%rbx,%r15,4)
movl %ecx, (%rbx,%rdx,4)
movl (%rbx,%r15,4), %ecx
movl 0x4(%r13), %edx
movl %edx, %esi
imull %ecx, %esi
movslq %esi, %rsi
shlq $0x2, %rsi
incl %ecx
imull %edx, %ecx
movslq %ecx, %rdx
shlq $0x2, %rdx
subq %rsi, %rdx
je 0x2f50
addq 0x8(%r13), %rsi
movslq 0x4(%rax), %rcx
movslq %r15d, %rdi
imulq %rcx, %rdi
shlq $0x2, %rdi
addq 0x8(%rax), %rdi
movq %r8, %r13
movq %r9, %rbx
callq 0x22d0
movq %rbx, %r9
movq %r13, %r8
movq 0x10(%rsp), %r13
movq 0x18(%rsp), %rbx
movq 0x8(%rsp), %rdi
imulq %r8, %rbp
movslq (%rbx,%r15,4), %rax
movq 0x20(%rsp), %rcx
movq 0x8(%rcx), %rcx
movl (%rcx,%rax,4), %eax
movq (%rdi), %rcx
movq 0x8(%rcx), %rcx
movl %eax, (%rcx,%r15,4)
incq %r15
movq (%rsp), %rax
movq (%rax), %rax
movslq (%rax), %rcx
addq %r9, %r14
decl %r12d
cmpq %rcx, %r15
jl 0x2ebb
movq %rbp, 0x5226(%rip)      # 0x81b8
movq %rbx, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2230
jmp 0x2faa
movq %rax, %r14
movq %rbp, %rdi
callq 0x21b0
jmp 0x2fba
movq %rax, %r14
movq %rbx, %rdi
callq 0x2230
movq %r14, %rdi
callq 0x22f0