// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x140, %rsp            # imm = 0x140
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x8(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jge 0x15f66
callq 0x3050
movl (%rax), %edi
movq -0x8(%rbp), %rax
movl 0x4(%rax), %edx
movq -0x8(%rbp), %rax
movl 0x8(%rax), %ecx
leaq 0x8562(%rip), %rsi      # 0x1e4c1
movb $0x0, %al
callq 0x3300
movq -0x8(%rbp), %rax
cmpl $0x8, 0x8(%rax)
jl 0x15f85
callq 0x3050
movl (%rax), %edi
leaq 0x85bb(%rip), %rsi      # 0x1e539
movb $0x0, %al
callq 0x3300
movq -0x8(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x8(%rbp), %rax
subl 0xc(%rax), %ecx
shll $0x2, %ecx
movl $0x1, %eax
shll %cl, %eax
movl %eax, -0x14(%rbp)
cmpl $0x1000, -0x14(%rbp)    # imm = 0x1000
jge 0x15fc9
movl -0x14(%rbp), %esi
movq -0x8(%rbp), %rax
movl 0xc(%rax), %ecx
addl $0x3, %ecx
leaq 0x85b0(%rip), %rdi      # 0x1e56d
movl $0x1000, %edx           # imm = 0x1000
movb $0x0, %al
callq 0x3160
movq -0x10(%rbp), %rdi
callq 0x3110
addq $0x5, %rax
cmpq $0x100, %rax            # imm = 0x100
jbe 0x15ffc
callq 0x3050
movl (%rax), %edi
movq -0x10(%rbp), %rdx
leaq 0x8612(%rip), %rsi      # 0x1e602
movl $0x100, %ecx            # imm = 0x100
movb $0x0, %al
callq 0x3300
leaq -0x120(%rbp), %rdi
movq -0x10(%rbp), %rdx
leaq 0x6b28(%rip), %rsi      # 0x1cb36
movb $0x0, %al
callq 0x3400
leaq -0x120(%rbp), %rdi
leaq 0x6037(%rip), %rsi      # 0x1c05a
callq 0x3370
movq %rax, -0x128(%rbp)
cmpq $0x0, %rax
jne 0x16051
callq 0x3050
movl (%rax), %edi
leaq -0x120(%rbp), %rdx
leaq 0x85eb(%rip), %rsi      # 0x1e635
movb $0x0, %al
callq 0x3300
xorl %eax, %eax
movl %eax, %edi
callq 0x32e0
movl %eax, %edi
callq 0x3240
callq 0x3490
movl %eax, %ecx
movq -0x8(%rbp), %rax
movl %ecx, (%rax)
movq -0x8(%rbp), %rax
movl 0x8(%rax), %ecx
shll $0x2, %ecx
movl $0x1, %edi
shll %cl, %edi
xorl %esi, %esi
callq 0x16220
movq %rax, -0x130(%rbp)
movq -0x130(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x8(%rax), %ecx
shll $0x2, %ecx
movl $0x1, %esi
shll %cl, %esi
callq 0x16170
movq %rax, -0x130(%rbp)
movq -0x8(%rbp), %rdi
movq -0x128(%rbp), %rcx
movl $0x10, %esi
movl $0x1, %edx
callq 0x3420
movq %rax, -0x140(%rbp)
movq -0x130(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x8(%rax), %ecx
shll $0x2, %ecx
movl $0x1, %eax
shll %cl, %eax
movslq %eax, %rdx
movq -0x128(%rbp), %rcx
movl $0x4, %esi
callq 0x3420
movq %rax, %rcx
movq -0x140(%rbp), %rax
addq %rcx, %rax
movl %eax, -0x134(%rbp)
movq -0x128(%rbp), %rdi
callq 0x30e0
movq -0x130(%rbp), %rdi
callq 0x3040
movq -0x8(%rbp), %rax
movl (%rax), %esi
movq -0x8(%rbp), %rax
movl 0x4(%rax), %edx
movq -0x8(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x8(%rbp), %rax
movl 0xc(%rax), %r8d
leaq 0x8517(%rip), %rdi      # 0x1e663
movb $0x0, %al
callq 0x3150
movl -0x134(%rbp), %eax
addq $0x140, %rsp            # imm = 0x140
popq %rbp
retq
nopw %cs:(%rax,%rax)