// File: /workspace/github_c_makefile_star2_O3/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), %r15d
movl 0x8(%rdi), %ebp
cmpl %ebp, %r15d
jl 0x110fa
cmpl $0x8, %ebp
jge 0x11114
movq %rsi, %r14
movq %rdi, %rbx
movl 0xc(%rdi), %eax
subl %eax, %ebp
shll $0x2, %ebp
cmpl $0xb, %ebp
ja 0x10fee
movl $0x1, %esi
movl %ebp, %ecx
shll %cl, %esi
addl $0x3, %eax
leaq 0x66fc(%rip), %rdi      # 0x176dc
movl $0x1000, %edx           # imm = 0x1000
movl %eax, %ecx
xorl %eax, %eax
callq 0x3180
movq %r14, %rdi
callq 0x3130
addq $-0xfc, %rax
cmpq $-0x102, %rax           # imm = 0xFEFE
jbe 0x11129
leaq 0x4be7(%rip), %rsi      # 0x15bf6
movq %rsp, %r15
movq %r15, %rdi
movq %r14, %rdx
xorl %eax, %eax
callq 0x3430
leaq 0x4044(%rip), %rsi      # 0x1506a
movq %r15, %rdi
callq 0x33a0
testq %rax, %rax
je 0x11146
movq %rax, %r14
xorl %edi, %edi
callq 0x3310
movl %eax, %edi
callq 0x3270
callq 0x34c0
movl %eax, (%rbx)
movb 0x8(%rbx), %cl
shlb $0x2, %cl
movl $0x1, %r12d
movl $0x1, %edi
shll %cl, %edi
xorl %esi, %esi
callq 0x111b7
movq %rax, %r15
movb 0x8(%rbx), %cl
shlb $0x2, %cl
movl $0x1, %esi
shll %cl, %esi
movq %rax, %rdi
callq 0x1115e
movl $0x10, %esi
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rcx
callq 0x3450
movq %rax, %r13
movb 0x8(%rbx), %cl
shlb $0x2, %cl
shll %cl, %r12d
movl $0x4, %esi
movq %r15, %rdi
movq %r12, %rdx
movq %r14, %rcx
callq 0x3450
movq %rax, %r12
addl %r13d, %r12d
movq %r14, %rdi
callq 0x3100
movq %r15, %rdi
callq 0x3040
movl (%rbx), %esi
movl 0x4(%rbx), %edx
movl 0x8(%rbx), %ecx
movl 0xc(%rbx), %r8d
leaq 0x66f4(%rip), %rdi      # 0x177d2
xorl %eax, %eax
callq 0x3170
movl %r12d, %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 0x6528(%rip), %rsi      # 0x17630
movl %r15d, %edx
movl %ebp, %ecx
xorl %eax, %eax
callq 0x3330
callq 0x3060
movl (%rax), %edi
leaq 0x6586(%rip), %rsi      # 0x176a8
xorl %eax, %eax
callq 0x3330
callq 0x3060
movl (%rax), %edi
leaq 0x663a(%rip), %rsi      # 0x17771
movq %r14, %rdx
movl $0x100, %ecx            # imm = 0x100
xorl %eax, %eax
callq 0x3330
callq 0x3060
movl (%rax), %edi
leaq 0x6650(%rip), %rsi      # 0x177a4
movq %rsp, %rdx
xorl %eax, %eax
callq 0x3330