// File: /workspace/github_c_makefile_star2_O2/yhg926[P]public_kssd/command_shuffle.c
// Function: write_dim_shuffle_file
int write_dim_shuffle_file(dim_shuffle_stat_t* dim_shuffle_stat, char *outfile_prefix)
{
 if( dim_shuffle_stat->k < dim_shuffle_stat->subk )
  err(errno,"write_dim_shuffle_file(): half-context len: %d"
   "should larger than half-subcontext len (or dimension reduce level + 2) %d",
   dim_shuffle_stat->k,dim_shuffle_stat->subk);
 if(dim_shuffle_stat->subk >= 8)
    err(errno,"write_dim_shuffle_file(): subk shoud smaller than 8");
 int dim_after_reduction = 1<< 4*(dim_shuffle_stat->subk - dim_shuffle_stat->drlevel);
 if( dim_after_reduction < MIN_SUBCTX_DIM_SMP_SZ )
  warnx("dimension after reduction %d is smaller than the suggested minimal"
  " dimension sample size %d, which might cause loss of robutness, -s %d is suggested",dim_after_reduction,MIN_SUBCTX_DIM_SMP_SZ, dim_shuffle_stat->drlevel+3);
 if(strlen(outfile_prefix) + strlen(".shuf") >PATHLEN)
  err(errno,"output path name %s should less than %d characters",outfile_prefix,PATHLEN);
 char outfile[PATHLEN];
 sprintf(outfile,"%s.shuf",outfile_prefix);
 FILE *shuf_out;
 if( (shuf_out = fopen(outfile,"wb")) == NULL)
  err(errno,"write_dim_shuffle_file(): open file %s failed",outfile);
 srand ( time(NULL) );
 dim_shuffle_stat->id = rand();
  int *shuffled_dim = shuffleN(1 << 4*dim_shuffle_stat->subk, 0);
 shuffled_dim = shuffle(shuffled_dim,1 << 4*dim_shuffle_stat->subk);
 int ret = fwrite(dim_shuffle_stat,sizeof(dim_shuffle_stat_t),1,shuf_out)
  + fwrite(shuffled_dim,sizeof(int),1 << 4*dim_shuffle_stat->subk,shuf_out);
 fclose(shuf_out);
 free(shuffled_dim);
 printf("kssd shuffle: shuf_id=%d, k = %d, halfCtxLen = %d, level= %d\n",
    dim_shuffle_stat->id, dim_shuffle_stat->k,dim_shuffle_stat->subk,dim_shuffle_stat->drlevel);
 return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x108, %rsp            # imm = 0x108
movl 0x4(%rdi), %r14d
movl 0x8(%rdi), %ebp
cmpl %ebp, %r14d
jl 0x10287
cmpl $0x8, %ebp
jge 0x102a1
movq %rsi, %r15
movq %rdi, %rbx
movl 0xc(%rdi), %eax
subl %eax, %ebp
shll $0x2, %ebp
pushq $0x1
popq %r14
cmpl $0xb, %ebp
ja 0x1018b
movl %r14d, %esi
movl %ebp, %ecx
shll %cl, %esi
addl $0x3, %eax
leaq 0x650f(%rip), %rdi      # 0x1668c
movl $0x1000, %edx           # imm = 0x1000
movl %eax, %ecx
xorl %eax, %eax
callq 0x3180
movq %r15, %rdi
callq 0x3130
addq $-0xfc, %rax
cmpq $-0x102, %rax           # imm = 0xFEFE
jbe 0x102b6
leaq 0x49fa(%rip), %rsi      # 0x14ba6
movq %rsp, %r12
movq %r12, %rdi
movq %r15, %rdx
xorl %eax, %eax
callq 0x3430
leaq 0x3ea7(%rip), %rsi      # 0x1406a
movq %r12, %rdi
callq 0x33a0
testq %rax, %rax
je 0x102d3
movq %rax, %r15
xorl %edi, %edi
callq 0x3310
movl %eax, %edi
callq 0x3270
callq 0x34c0
movl %eax, (%rbx)
movb 0x8(%rbx), %cl
shlb $0x2, %cl
movl %r14d, %edi
shll %cl, %edi
xorl %esi, %esi
callq 0x10341
movq %rax, %r12
movb 0x8(%rbx), %cl
shlb $0x2, %cl
movl %r14d, %esi
shll %cl, %esi
movq %rax, %rdi
callq 0x102eb
pushq $0x10
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %r15, %rcx
callq 0x3450
movq %rax, %r13
movb 0x8(%rbx), %cl
shlb $0x2, %cl
shll %cl, %r14d
pushq $0x4
popq %rsi
movq %r12, %rdi
movq %r14, %rdx
movq %r15, %rcx
callq 0x3450
movq %rax, %r14
addl %r13d, %r14d
movq %r15, %rdi
callq 0x3100
movq %r12, %rdi
callq 0x3040
movl (%rbx), %esi
movl 0x4(%rbx), %edx
movl 0x8(%rbx), %ecx
movl 0xc(%rbx), %r8d
leaq 0x6517(%rip), %rdi      # 0x16782
xorl %eax, %eax
callq 0x3170
movl %r14d, %eax
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x3060
movl (%rax), %edi
leaq 0x634b(%rip), %rsi      # 0x165e0
movl %r14d, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x3330
callq 0x3060
movl (%rax), %edi
leaq 0x63a9(%rip), %rsi      # 0x16658
xorl %eax, %eax
callq 0x3330
callq 0x3060
movl (%rax), %edi
leaq 0x645d(%rip), %rsi      # 0x16721
movq %r15, %rdx
movl $0x100, %ecx            # imm = 0x100
xorl %eax, %eax
callq 0x3330
callq 0x3060
movl (%rax), %edi
leaq 0x6473(%rip), %rsi      # 0x16754
movq %rsp, %rdx
xorl %eax, %eax
callq 0x3330