// File: /workspace/github_c_makefile_star2_O0/yhg926[P]public_kssd/command_set.c
// Function: sketch_operate
int sketch_operate()
{
 int ret = 1;
 co_dstat_t co_dstat_pan, co_dstat_origin ;
 const char* co_dstat_fpath = NULL;
  co_dstat_fpath = test_get_fullpath(set_opt.pansketchpath,co_dstat);
 if(co_dstat_fpath == NULL ) err(errno,"cannot find %s under %s ",co_dstat,set_opt.pansketchpath);
 FILE *co_stat_fp;
  if( ( co_stat_fp = fopen(co_dstat_fpath,"rb")) == NULL ) err(errno,"sketch_operate():%s",co_dstat_fpath);
  fread( &co_dstat_pan, sizeof(co_dstat_t),1,co_stat_fp );
 fclose(co_stat_fp);
 co_dstat_fpath = test_get_fullpath(set_opt.insketchpath,co_dstat);
 if(co_dstat_fpath == NULL ) err(errno,"cannot find %s under %s ",co_dstat,set_opt.insketchpath);
 struct stat s;
 if(stat(co_dstat_fpath, &s) != 0) err(errno,"sketch_operate():%s",co_dstat_fpath);
 size_t codstat_fz = s.st_size;
 co_dstat_t *tmpmem = malloc(codstat_fz);
 if( ( co_stat_fp = fopen(co_dstat_fpath,"rb")) == NULL ) err(errno,"sketch_operate():%s",co_dstat_fpath);
 fread(tmpmem,codstat_fz, 1, co_stat_fp);
 co_dstat_origin = *tmpmem;
 if (co_dstat_pan.shuf_id != co_dstat_origin.shuf_id) err(errno,"sketcing id not match(%d Vs. %d)",co_dstat_origin.shuf_id,co_dstat_pan.shuf_id);
 fclose(co_stat_fp);
 unsigned int *tmp_ctx_ct = (void *) tmpmem + sizeof(co_dstat_t);
 memset(tmp_ctx_ct,0,co_dstat_origin.infile_num*sizeof(unsigned int)) ;
 mkdir(set_opt.outdir,0777);
 char tmppath[PATHLEN];
 size_t *fco_pos = malloc(sizeof(size_t) * (co_dstat_origin.infile_num + 1) );
 size_t *post_fco_pos = malloc(sizeof(size_t) * (co_dstat_origin.infile_num + 1) );
 post_fco_pos[0] = 0;
 size_t comp_sz = (1LLU << 4*COMPONENT_SZ);
  llong* dict = (llong*)malloc(comp_sz/8);
  unsigned int tmppanco;
 for(int c=0; c< co_dstat_pan.comp_num; c++ ){
  memset(dict,0,comp_sz/8);
  sprintf(tmppath,"%s/%s.%d",set_opt.pansketchpath, pan_prefix, c);
    if(stat(tmppath, &s) != 0){
   sprintf(tmppath,"%s/%s.%d",set_opt.pansketchpath, uniq_pan_prefix, c);
   if(stat(tmppath, &s) != 0) err(errno,"sketch_operate():%s",tmppath);
  }
    size_t size = s.st_size / sizeof(unsigned int);
  if( ( co_stat_fp = fopen(tmppath,"rb")) == NULL ) err(errno,"sketch_operate():%s",tmppath);
  for(size_t n=0; n< size ; n++){
      fread(&tmppanco,sizeof(unsigned int),1,co_stat_fp);
      dict[tmppanco/64] |= ( 0x8000000000000000LLU >> (tmppanco % 64) ) ;
    }
  fclose(co_stat_fp);
  sprintf(tmppath,"%s/%s.index.%d",set_opt.insketchpath,skch_prefix, c);
  if( ( co_stat_fp = fopen(tmppath,"rb")) == NULL ) err(errno,"sketch_operate():%s",tmppath);
  fread(fco_pos,sizeof(size_t),co_dstat_origin.infile_num + 1 ,co_stat_fp);
  fclose(co_stat_fp);
  sprintf(tmppath,"%s/%s.%d",set_opt.insketchpath,skch_prefix, c);
    if( ( co_stat_fp = fopen(tmppath,"rb")) == NULL ) err(errno,"sketch_operate():%s",tmppath);
    unsigned int *cbd_fcode_mem = malloc(fco_pos[co_dstat_origin.infile_num] * sizeof(unsigned int));
    fread(cbd_fcode_mem,sizeof(unsigned int),fco_pos[co_dstat_origin.infile_num],co_stat_fp);
    fclose(co_stat_fp);
  sprintf(tmppath,"%s/%s.%d",set_opt.outdir,skch_prefix, c);
  if( ( co_stat_fp = fopen(tmppath,"wb")) == NULL) err(errno,"sketch_operate():%s",tmppath);
  for(int i = 0 ; i < co_dstat_origin.infile_num; i++){
   post_fco_pos[i+1] = post_fco_pos[i];
   for(int n = 0; n < fco_pos[i+1] - fco_pos[i]; n++){
    if( set_opt.operation == ( (dict[ cbd_fcode_mem[ fco_pos[i] + n ]/64 ] & (0x8000000000000000LLU >> (cbd_fcode_mem[ fco_pos[i] + n ] % 64)) ) > 0 ) ){
     fwrite(cbd_fcode_mem + fco_pos[i] + n, sizeof(unsigned int), 1, co_stat_fp);
     post_fco_pos[i+1]++;
     tmp_ctx_ct[i]++;
    }
   }
  }
  fclose(co_stat_fp);
  sprintf(tmppath,"%s/%s.index.%d",set_opt.outdir,skch_prefix, c);
    if( ( co_stat_fp = fopen(tmppath,"wb")) == NULL) err(errno,"sketch_operate():%s",tmppath);
  fwrite(post_fco_pos,sizeof(size_t),co_dstat_origin.infile_num + 1,co_stat_fp);
  fclose(co_stat_fp);
 }
 sprintf(tmppath,"%s/%s",set_opt.outdir,co_dstat);
  if( ( co_stat_fp = fopen(tmppath,"wb")) == NULL) err(errno,"sketch_operate():%s",tmppath);
  fwrite(tmpmem,codstat_fz,1,co_stat_fp);
  free(tmpmem);
  fclose(co_stat_fp);
 ret = 0;
 return ret ;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x250, %rsp            # imm = 0x250
movl $0x1, -0x4(%rbp)
movq $0x0, -0x50(%rbp)
leaq 0x102ff(%rip), %rdi     # 0x23660
addq $0x118, %rdi            # imm = 0x118
leaq 0x9381(%rip), %rsi      # 0x1c6f0
callq 0x8250
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x133a9
callq 0x3050
movl (%rax), %edi
leaq 0x8ff2(%rip), %rsi      # 0x1c37f
leaq 0x935c(%rip), %rdx      # 0x1c6f0
leaq 0x102c5(%rip), %rcx     # 0x23660
addq $0x118, %rcx            # imm = 0x118
movb $0x0, %al
callq 0x3300
movq -0x50(%rbp), %rdi
leaq 0x8ca3(%rip), %rsi      # 0x1c057
callq 0x3370
movq %rax, -0x58(%rbp)
cmpq $0x0, %rax
jne 0x133dc
callq 0x3050
movl (%rax), %edi
movq -0x50(%rbp), %rdx
leaq 0xaafd(%rip), %rsi      # 0x1ded2
movb $0x0, %al
callq 0x3300
movq -0x58(%rbp), %rcx
leaq -0x28(%rbp), %rdi
movl $0x20, %esi
movl $0x1, %edx
callq 0x30a0
movq -0x58(%rbp), %rdi
callq 0x30e0
leaq 0x1025d(%rip), %rdi     # 0x23660
addq $0x18, %rdi
leaq 0x92e2(%rip), %rsi      # 0x1c6f0
callq 0x8250
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x13445
callq 0x3050
movl (%rax), %edi
leaq 0x8f53(%rip), %rsi      # 0x1c37f
leaq 0x92bd(%rip), %rdx      # 0x1c6f0
leaq 0x10226(%rip), %rcx     # 0x23660
addq $0x18, %rcx
movb $0x0, %al
callq 0x3300
movq -0x50(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x32b0
cmpl $0x0, %eax
je 0x13473
callq 0x3050
movl (%rax), %edi
movq -0x50(%rbp), %rdx
leaq 0xaa66(%rip), %rsi      # 0x1ded2
movb $0x0, %al
callq 0x3300
movq -0xb8(%rbp), %rax
movq %rax, -0xf0(%rbp)
movq -0xf0(%rbp), %rdi
callq 0x3310
movq %rax, -0xf8(%rbp)
movq -0x50(%rbp), %rdi
leaq 0x8bb8(%rip), %rsi      # 0x1c057
callq 0x3370
movq %rax, -0x58(%rbp)
cmpq $0x0, %rax
jne 0x134c7
callq 0x3050
movl (%rax), %edi
movq -0x50(%rbp), %rdx
leaq 0xaa12(%rip), %rsi      # 0x1ded2
movb $0x0, %al
callq 0x3300
movq -0xf8(%rbp), %rdi
movq -0xf0(%rbp), %rsi
movq -0x58(%rbp), %rcx
movl $0x1, %edx
callq 0x30a0
movq -0xf8(%rbp), %rax
movq (%rax), %rcx
movq %rcx, -0x48(%rbp)
movq 0x8(%rax), %rcx
movq %rcx, -0x40(%rbp)
movq 0x10(%rax), %rcx
movq %rcx, -0x38(%rbp)
movq 0x18(%rax), %rax
movq %rax, -0x30(%rbp)
movl -0x28(%rbp), %eax
cmpl -0x48(%rbp), %eax
je 0x1352c
callq 0x3050
movl (%rax), %edi
movl -0x48(%rbp), %edx
movl -0x28(%rbp), %ecx
leaq 0xa9c1(%rip), %rsi      # 0x1dee6
movb $0x0, %al
callq 0x3300
movq -0x58(%rbp), %rdi
callq 0x30e0
movq -0xf8(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x100(%rbp)
movq -0x100(%rbp), %rdi
movslq -0x34(%rbp), %rdx
shlq $0x2, %rdx
xorl %esi, %esi
callq 0x31f0
leaq 0x100fc(%rip), %rdi     # 0x23660
addq $0x318, %rdi            # imm = 0x318
movl $0x1ff, %esi            # imm = 0x1FF
callq 0x3080
movl -0x34(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x3310
movq %rax, -0x208(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
shlq $0x3, %rdi
callq 0x3310
movq %rax, -0x210(%rbp)
movq -0x210(%rbp), %rax
movq $0x0, (%rax)
movq $0x10000000, -0x218(%rbp) # imm = 0x10000000
movq -0x218(%rbp), %rdi
shrq $0x3, %rdi
callq 0x3310
movq %rax, -0x220(%rbp)
movl $0x0, -0x228(%rbp)
movl -0x228(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x13ba1
movq -0x220(%rbp), %rdi
movq -0x218(%rbp), %rdx
shrq $0x3, %rdx
xorl %esi, %esi
callq 0x31f0
leaq -0x200(%rbp), %rdi
movl -0x228(%rbp), %r8d
leaq 0x8a30(%rip), %rsi      # 0x1c04e
leaq 0x1003b(%rip), %rdx     # 0x23660
addq $0x118, %rdx            # imm = 0x118
leaq 0xae3a(%rip), %rcx      # 0x1e46d
movb $0x0, %al
callq 0x3400
leaq -0x200(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x32b0
cmpl $0x0, %eax
je 0x136b9
leaq -0x200(%rbp), %rdi
movl -0x228(%rbp), %r8d
leaq 0x89e7(%rip), %rsi      # 0x1c04e
leaq 0xfff2(%rip), %rdx      # 0x23660
addq $0x118, %rdx            # imm = 0x118
leaq 0xadf5(%rip), %rcx      # 0x1e471
movb $0x0, %al
callq 0x3400
leaq -0x200(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x32b0
cmpl $0x0, %eax
je 0x136b7
callq 0x3050
movl (%rax), %edi
leaq -0x200(%rbp), %rdx
leaq 0xa822(%rip), %rsi      # 0x1ded2
movb $0x0, %al
callq 0x3300
jmp 0x136b9
movq -0xb8(%rbp), %rax
shrq $0x2, %rax
movq %rax, -0x230(%rbp)
leaq -0x200(%rbp), %rdi
leaq 0x897e(%rip), %rsi      # 0x1c057
callq 0x3370
movq %rax, -0x58(%rbp)
cmpq $0x0, %rax
jne 0x13704
callq 0x3050
movl (%rax), %edi
leaq -0x200(%rbp), %rdx
leaq 0xa7d5(%rip), %rsi      # 0x1ded2
movb $0x0, %al
callq 0x3300
movq $0x0, -0x238(%rbp)
movq -0x238(%rbp), %rax
cmpq -0x230(%rbp), %rax
jae 0x13781
movq -0x58(%rbp), %rcx
leaq -0x224(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x30a0
movl -0x224(%rbp), %eax
andl $0x3f, %eax
movl %eax, %eax
movl %eax, %ecx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
shrq %cl, %rdx
movq -0x220(%rbp), %rax
movl -0x224(%rbp), %ecx
shrl $0x6, %ecx
movl %ecx, %ecx
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movq -0x238(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x238(%rbp)
jmp 0x1370f
movq -0x58(%rbp), %rdi
callq 0x30e0
leaq -0x200(%rbp), %rdi
movl -0x228(%rbp), %r8d
leaq 0xa768(%rip), %rsi      # 0x1df07
leaq 0xfeba(%rip), %rdx      # 0x23660
addq $0x18, %rdx
leaq 0xaca8(%rip), %rcx      # 0x1e459
movb $0x0, %al
callq 0x3400
leaq -0x200(%rbp), %rdi
leaq 0x8891(%rip), %rsi      # 0x1c057
callq 0x3370
movq %rax, -0x58(%rbp)
cmpq $0x0, %rax
jne 0x137f1
callq 0x3050
movl (%rax), %edi
leaq -0x200(%rbp), %rdx
leaq 0xa6e8(%rip), %rsi      # 0x1ded2
movb $0x0, %al
callq 0x3300
movq -0x208(%rbp), %rdi
movl -0x34(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdx
movq -0x58(%rbp), %rcx
movl $0x8, %esi
callq 0x30a0
movq -0x58(%rbp), %rdi
callq 0x30e0
leaq -0x200(%rbp), %rdi
movl -0x228(%rbp), %r8d
leaq 0x8821(%rip), %rsi      # 0x1c04e
leaq 0xfe2c(%rip), %rdx      # 0x23660
addq $0x18, %rdx
leaq 0xac1a(%rip), %rcx      # 0x1e459
movb $0x0, %al
callq 0x3400
leaq -0x200(%rbp), %rdi
leaq 0x8803(%rip), %rsi      # 0x1c057
callq 0x3370
movq %rax, -0x58(%rbp)
cmpq $0x0, %rax
jne 0x1387f
callq 0x3050
movl (%rax), %edi
leaq -0x200(%rbp), %rdx
leaq 0xa65a(%rip), %rsi      # 0x1ded2
movb $0x0, %al
callq 0x3300
movq -0x208(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
shlq $0x2, %rdi
callq 0x3310
movq %rax, -0x240(%rbp)
movq -0x240(%rbp), %rdi
movq -0x208(%rbp), %rax
movslq -0x34(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movq -0x58(%rbp), %rcx
movl $0x4, %esi
callq 0x30a0
movq -0x58(%rbp), %rdi
callq 0x30e0
leaq -0x200(%rbp), %rdi
movl -0x228(%rbp), %r8d
leaq 0x876e(%rip), %rsi      # 0x1c04e
leaq 0xfd79(%rip), %rdx      # 0x23660
addq $0x318, %rdx            # imm = 0x318
leaq 0xab64(%rip), %rcx      # 0x1e459
movb $0x0, %al
callq 0x3400
leaq -0x200(%rbp), %rdi
leaq 0x8750(%rip), %rsi      # 0x1c05a
callq 0x3370
movq %rax, -0x58(%rbp)
cmpq $0x0, %rax
jne 0x13935
callq 0x3050
movl (%rax), %edi
leaq -0x200(%rbp), %rdx
leaq 0xa5a4(%rip), %rsi      # 0x1ded2
movb $0x0, %al
callq 0x3300
movl $0x0, -0x244(%rbp)
movl -0x244(%rbp), %eax
cmpl -0x34(%rbp), %eax
jge 0x13af3
movq -0x210(%rbp), %rax
movslq -0x244(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movq -0x210(%rbp), %rax
movl -0x244(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq %rdx, (%rax,%rcx,8)
movl $0x0, -0x248(%rbp)
movslq -0x248(%rbp), %rax
movq -0x208(%rbp), %rcx
movl -0x244(%rbp), %edx
addl $0x1, %edx
movslq %edx, %rdx
movq (%rcx,%rdx,8), %rcx
movq -0x208(%rbp), %rdx
movslq -0x244(%rbp), %rsi
subq (%rdx,%rsi,8), %rcx
cmpq %rcx, %rax
jae 0x13add
movl 0xfca0(%rip), %eax      # 0x23660
movq -0x220(%rbp), %rcx
movq -0x240(%rbp), %rdx
movq -0x208(%rbp), %rsi
movslq -0x244(%rbp), %rdi
movq (%rsi,%rdi,8), %rsi
movslq -0x248(%rbp), %rdi
addq %rdi, %rsi
movl (%rdx,%rsi,4), %edx
shrl $0x6, %edx
movl %edx, %edx
movq (%rcx,%rdx,8), %rcx
movq %rcx, -0x250(%rbp)
movq -0x240(%rbp), %rcx
movq -0x208(%rbp), %rdx
movslq -0x244(%rbp), %rsi
movq (%rdx,%rsi,8), %rdx
movslq -0x248(%rbp), %rsi
addq %rsi, %rdx
movl (%rcx,%rdx,4), %ecx
andl $0x3f, %ecx
movl %ecx, %ecx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
shrq %cl, %rdx
movq -0x250(%rbp), %rcx
andq %rdx, %rcx
cmpq $0x0, %rcx
seta %cl
andb $0x1, %cl
movzbl %cl, %ecx
cmpl %ecx, %eax
jne 0x13ac7
movq -0x240(%rbp), %rdi
movq -0x208(%rbp), %rax
movslq -0x244(%rbp), %rcx
movq (%rax,%rcx,8), %rax
shlq $0x2, %rax
addq %rax, %rdi
movslq -0x248(%rbp), %rax
shlq $0x2, %rax
addq %rax, %rdi
movq -0x58(%rbp), %rcx
movl $0x4, %esi
movl $0x1, %edx
callq 0x3420
movq -0x210(%rbp), %rax
movl -0x244(%rbp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdx
addq $0x1, %rdx
movq %rdx, (%rax,%rcx,8)
movq -0x100(%rbp), %rax
movslq -0x244(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,4)
jmp 0x13ac9
movl -0x248(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x248(%rbp)
jmp 0x13981
jmp 0x13adf
movl -0x244(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x244(%rbp)
jmp 0x1393f
movq -0x58(%rbp), %rdi
callq 0x30e0
leaq -0x200(%rbp), %rdi
movl -0x228(%rbp), %r8d
leaq 0xa3f6(%rip), %rsi      # 0x1df07
leaq 0xfb48(%rip), %rdx      # 0x23660
addq $0x318, %rdx            # imm = 0x318
leaq 0xa933(%rip), %rcx      # 0x1e459
movb $0x0, %al
callq 0x3400
leaq -0x200(%rbp), %rdi
leaq 0x851f(%rip), %rsi      # 0x1c05a
callq 0x3370
movq %rax, -0x58(%rbp)
cmpq $0x0, %rax
jne 0x13b66
callq 0x3050
movl (%rax), %edi
leaq -0x200(%rbp), %rdx
leaq 0xa373(%rip), %rsi      # 0x1ded2
movb $0x0, %al
callq 0x3300
movq -0x210(%rbp), %rdi
movl -0x34(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdx
movq -0x58(%rbp), %rcx
movl $0x8, %esi
callq 0x3420
movq -0x58(%rbp), %rdi
callq 0x30e0
movl -0x228(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x228(%rbp)
jmp 0x135e1
leaq -0x200(%rbp), %rdi
leaq 0x877c(%rip), %rsi      # 0x1c32b
leaq 0xfaaa(%rip), %rdx      # 0x23660
addq $0x318, %rdx            # imm = 0x318
leaq 0x8b2c(%rip), %rcx      # 0x1c6f0
movb $0x0, %al
callq 0x3400
leaq -0x200(%rbp), %rdi
leaq 0x8481(%rip), %rsi      # 0x1c05a
callq 0x3370
movq %rax, -0x58(%rbp)
cmpq $0x0, %rax
jne 0x13c04
callq 0x3050
movl (%rax), %edi
leaq -0x200(%rbp), %rdx
leaq 0xa2d5(%rip), %rsi      # 0x1ded2
movb $0x0, %al
callq 0x3300
movq -0xf8(%rbp), %rdi
movq -0xf0(%rbp), %rsi
movq -0x58(%rbp), %rcx
movl $0x1, %edx
callq 0x3420
movq -0xf8(%rbp), %rdi
callq 0x3040
movq -0x58(%rbp), %rdi
callq 0x30e0
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x250, %rsp            # imm = 0x250
popq %rbp
retq
nopl (%rax,%rax)