// File: /workspace/github_c_makefile_star2_O0/yhg926[P]public_kssd/command_set.c
// Function: uniq_sketch_union
int uniq_sketch_union()
{
  const char* co_dstat_fpath = NULL;
  char combco[20];
  char unionco[20];
  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);
  FILE *co_stat_fp;
  if( ( co_stat_fp = fopen(co_dstat_fpath,"rb")) == NULL ) err(errno,"uniq_sketch_union():%s",co_dstat_fpath);
  co_dstat_t co_dstat_readin;
  fread( &co_dstat_readin, sizeof(co_dstat_t),1,co_stat_fp );
  if(co_dstat_readin.infile_num == 1){
    char inpbuff;
    printf("only 1 sketch, use %s as pan-sketch?(Y/N)\n",set_opt.insketchpath);
    scanf(" %c", &inpbuff);
    if ( (inpbuff == 'Y') || (inpbuff == 'y') ) {
      chdir(set_opt.insketchpath);
      for(int i=0 ; i < co_dstat_readin.comp_num;i++){
        sprintf(combco,"%s.%d",skch_prefix,i);
        sprintf(unionco,"%s.%d",uniq_pan_prefix,i);
        if(rename(combco,unionco) !=0) err(errno,"uniq_sketch_union()");
      }
      printf("the union directory: %s created successfully\n", set_opt.insketchpath) ;
      return 1;
    }
  }
  mkdir(set_opt.outdir,0777);
  char outpath[PATHLEN];
  sprintf(outpath,"%s/%s",set_opt.outdir,co_dstat);
  FILE *co_stat_fp2;
  if( ( co_stat_fp2 = fopen(outpath,"wb")) == NULL ) err(errno,"uniq_sketch_union():%s",outpath);
  fwrite( &co_dstat_readin,sizeof(co_dstat_t),1, co_stat_fp2 );
  fclose(co_stat_fp);
  fclose(co_stat_fp2);
  size_t comp_sz = (1LLU << 4*COMPONENT_SZ);
  llong* dict = (llong*)malloc(comp_sz/8);
 llong* dict2 = (llong*)malloc(comp_sz/8);
  unsigned int tmpcbdco;
  for(int i=0; i < co_dstat_readin.comp_num; i++){
    memset(dict,0,comp_sz/8);
  memset(dict2,~0,comp_sz/8);
    sprintf(outpath,"%s/%s.%d",set_opt.insketchpath,skch_prefix,i);
    struct stat s;
    if(stat(outpath, &s) != 0) err(errno,"uniq_sketch_union():%s",outpath);
    size_t size = s.st_size / sizeof(unsigned int);
    if( ( co_stat_fp = fopen(outpath,"rb")) == NULL ) err(errno,"uniq_sketch_union():%s",outpath);
    for(size_t n=0; n< size ; n++){
      fread(&tmpcbdco,sizeof(unsigned int),1,co_stat_fp);
   if ( dict[tmpcbdco/64] & ( 0x8000000000000000LLU >> (tmpcbdco % 64) ))
    dict2[tmpcbdco/64] &= ~( 0x8000000000000000LLU >> (tmpcbdco % 64) );
      dict[tmpcbdco/64] |= ( 0x8000000000000000LLU >> (tmpcbdco % 64) ) ;
    }
    fclose(co_stat_fp);
    sprintf(outpath,"%s/%s.%d",set_opt.outdir,uniq_pan_prefix,i);
    if( ( co_stat_fp = fopen(outpath,"wb")) == NULL ) err(errno,"uniq_sketch_union():%s",outpath);
    for(unsigned int n=0;n< comp_sz/64; n++){
      if(dict[n] & dict2[n]){
        for(int b=0; b< 64; b++){
          if ( (0x8000000000000000LLU >> b) & dict[n] & dict2[n] ){
            unsigned int var = 64*n + b ;
            fwrite(&var,sizeof(unsigned int),1,co_stat_fp);
          }
        }
      }
    }
    fclose(co_stat_fp);
  }
  free(dict);
 free(dict2);
  return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x260, %rsp            # imm = 0x260
movq $0x0, -0x10(%rbp)
leaq 0xf9f6(%rip), %rdi      # 0x23660
addq $0x18, %rdi
leaq 0x8a7b(%rip), %rsi      # 0x1c6f0
callq 0x8250
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x13cac
callq 0x3050
movl (%rax), %edi
leaq 0x86ec(%rip), %rsi      # 0x1c37f
leaq 0x8a56(%rip), %rdx      # 0x1c6f0
leaq 0xf9bf(%rip), %rcx      # 0x23660
addq $0x18, %rcx
movb $0x0, %al
callq 0x3300
movq -0x10(%rbp), %rdi
leaq 0x83a0(%rip), %rsi      # 0x1c057
callq 0x3370
movq %rax, -0x58(%rbp)
cmpq $0x0, %rax
jne 0x13cdf
callq 0x3050
movl (%rax), %edi
movq -0x10(%rbp), %rdx
leaq 0xa23e(%rip), %rsi      # 0x1df16
movb $0x0, %al
callq 0x3300
movq -0x58(%rbp), %rcx
leaq -0x78(%rbp), %rdi
movl $0x20, %esi
movl $0x1, %edx
callq 0x30a0
cmpl $0x1, -0x64(%rbp)
jne 0x13df3
leaq 0xa16e(%rip), %rdi      # 0x1de75
leaq 0xf952(%rip), %rsi      # 0x23660
addq $0x18, %rsi
movb $0x0, %al
callq 0x3150
leaq 0xa180(%rip), %rdi      # 0x1dea0
leaq -0x79(%rbp), %rsi
movb $0x0, %al
callq 0x33d0
movsbl -0x79(%rbp), %eax
cmpl $0x59, %eax
je 0x13d41
movsbl -0x79(%rbp), %eax
cmpl $0x79, %eax
jne 0x13df1
leaq 0xf918(%rip), %rdi      # 0x23660
addq $0x18, %rdi
callq 0x3120
movl $0x0, -0x80(%rbp)
movl -0x80(%rbp), %eax
cmpl -0x68(%rbp), %eax
jge 0x13dcc
leaq -0x30(%rbp), %rdi
movl -0x80(%rbp), %ecx
leaq 0x82e3(%rip), %rsi      # 0x1c051
leaq 0xa6e4(%rip), %rdx      # 0x1e459
movb $0x0, %al
callq 0x3400
leaq -0x50(%rbp), %rdi
movl -0x80(%rbp), %ecx
leaq 0x82c7(%rip), %rsi      # 0x1c051
leaq 0xa6e0(%rip), %rdx      # 0x1e471
movb $0x0, %al
callq 0x3400
leaq -0x30(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x33b0
cmpl $0x0, %eax
je 0x13dbf
callq 0x3050
movl (%rax), %edi
leaq 0xa175(%rip), %rsi      # 0x1df2d
movb $0x0, %al
callq 0x3300
jmp 0x13dc1
movl -0x80(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x80(%rbp)
jmp 0x13d58
leaq 0xa0d1(%rip), %rdi      # 0x1dea4
leaq 0xf886(%rip), %rsi      # 0x23660
addq $0x18, %rsi
movb $0x0, %al
callq 0x3150
movl $0x1, -0x4(%rbp)
jmp 0x1427a
jmp 0x13df3
leaq 0xf866(%rip), %rdi      # 0x23660
addq $0x318, %rdi            # imm = 0x318
movl $0x1ff, %esi            # imm = 0x1FF
callq 0x3080
leaq -0x180(%rbp), %rdi
leaq 0x8512(%rip), %rsi      # 0x1c32b
leaq 0xf840(%rip), %rdx      # 0x23660
addq $0x318, %rdx            # imm = 0x318
leaq 0x88c2(%rip), %rcx      # 0x1c6f0
movb $0x0, %al
callq 0x3400
leaq -0x180(%rbp), %rdi
leaq 0x8217(%rip), %rsi      # 0x1c05a
callq 0x3370
movq %rax, -0x188(%rbp)
cmpq $0x0, %rax
jne 0x13e71
callq 0x3050
movl (%rax), %edi
leaq -0x180(%rbp), %rdx
leaq 0xa0ac(%rip), %rsi      # 0x1df16
movb $0x0, %al
callq 0x3300
movq -0x188(%rbp), %rcx
leaq -0x78(%rbp), %rdi
movl $0x20, %esi
movl $0x1, %edx
callq 0x3420
movq -0x58(%rbp), %rdi
callq 0x30e0
movq -0x188(%rbp), %rdi
callq 0x30e0
movq $0x10000000, -0x190(%rbp) # imm = 0x10000000
movq -0x190(%rbp), %rdi
shrq $0x3, %rdi
callq 0x3310
movq %rax, -0x198(%rbp)
movq -0x190(%rbp), %rdi
shrq $0x3, %rdi
callq 0x3310
movq %rax, -0x1a0(%rbp)
movl $0x0, -0x1a8(%rbp)
movl -0x1a8(%rbp), %eax
cmpl -0x68(%rbp), %eax
jge 0x1425b
movq -0x198(%rbp), %rdi
movq -0x190(%rbp), %rdx
shrq $0x3, %rdx
xorl %esi, %esi
callq 0x31f0
movq -0x1a0(%rbp), %rdi
movq -0x190(%rbp), %rdx
shrq $0x3, %rdx
movl $0xff, %esi
callq 0x31f0
leaq -0x180(%rbp), %rdi
movl -0x1a8(%rbp), %r8d
leaq 0x8112(%rip), %rsi      # 0x1c04e
leaq 0xf71d(%rip), %rdx      # 0x23660
addq $0x18, %rdx
leaq 0xa50b(%rip), %rcx      # 0x1e459
movb $0x0, %al
callq 0x3400
leaq -0x180(%rbp), %rdi
leaq -0x238(%rbp), %rsi
callq 0x32b0
cmpl $0x0, %eax
je 0x13f89
callq 0x3050
movl (%rax), %edi
leaq -0x180(%rbp), %rdx
leaq 0x9f94(%rip), %rsi      # 0x1df16
movb $0x0, %al
callq 0x3300
movq -0x208(%rbp), %rax
shrq $0x2, %rax
movq %rax, -0x240(%rbp)
leaq -0x180(%rbp), %rdi
leaq 0x80ae(%rip), %rsi      # 0x1c057
callq 0x3370
movq %rax, -0x58(%rbp)
cmpq $0x0, %rax
jne 0x13fd4
callq 0x3050
movl (%rax), %edi
leaq -0x180(%rbp), %rdx
leaq 0x9f49(%rip), %rsi      # 0x1df16
movb $0x0, %al
callq 0x3300
movq $0x0, -0x248(%rbp)
movq -0x248(%rbp), %rax
cmpq -0x240(%rbp), %rax
jae 0x140ca
movq -0x58(%rbp), %rcx
leaq -0x1a4(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x30a0
movq -0x198(%rbp), %rax
movl -0x1a4(%rbp), %ecx
shrl $0x6, %ecx
movl %ecx, %ecx
movq (%rax,%rcx,8), %rax
movl -0x1a4(%rbp), %ecx
andl $0x3f, %ecx
movl %ecx, %ecx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
shrq %cl, %rdx
movq %rdx, %rcx
andq %rcx, %rax
cmpq $0x0, %rax
je 0x1407f
movl -0x1a4(%rbp), %eax
andl $0x3f, %eax
movl %eax, %eax
movl %eax, %ecx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
shrq %cl, %rdx
xorq $-0x1, %rdx
movq -0x1a0(%rbp), %rax
movl -0x1a4(%rbp), %ecx
shrl $0x6, %ecx
movl %ecx, %ecx
andq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movl -0x1a4(%rbp), %eax
andl $0x3f, %eax
movl %eax, %eax
movl %eax, %ecx
movabsq $-0x8000000000000000, %rdx # imm = 0x8000000000000000
shrq %cl, %rdx
movq -0x198(%rbp), %rax
movl -0x1a4(%rbp), %ecx
shrl $0x6, %ecx
movl %ecx, %ecx
orq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movq -0x248(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x248(%rbp)
jmp 0x13fdf
movq -0x58(%rbp), %rdi
callq 0x30e0
leaq -0x180(%rbp), %rdi
movl -0x1a8(%rbp), %r8d
leaq 0x7f66(%rip), %rsi      # 0x1c04e
leaq 0xf571(%rip), %rdx      # 0x23660
addq $0x318, %rdx            # imm = 0x318
leaq 0xa374(%rip), %rcx      # 0x1e471
movb $0x0, %al
callq 0x3400
leaq -0x180(%rbp), %rdi
leaq 0x7f48(%rip), %rsi      # 0x1c05a
callq 0x3370
movq %rax, -0x58(%rbp)
cmpq $0x0, %rax
jne 0x1413d
callq 0x3050
movl (%rax), %edi
leaq -0x180(%rbp), %rdx
leaq 0x9de0(%rip), %rsi      # 0x1df16
movb $0x0, %al
callq 0x3300
movl $0x0, -0x24c(%rbp)
movl -0x24c(%rbp), %eax
movq -0x190(%rbp), %rcx
shrq $0x6, %rcx
cmpq %rcx, %rax
jae 0x1423e
movq -0x198(%rbp), %rax
movl -0x24c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq -0x1a0(%rbp), %rcx
movl -0x24c(%rbp), %edx
andq (%rcx,%rdx,8), %rax
cmpq $0x0, %rax
je 0x14228
movl $0x0, -0x250(%rbp)
cmpl $0x40, -0x250(%rbp)
jge 0x14226
movl -0x250(%rbp), %eax
movl %eax, %ecx
movabsq $-0x8000000000000000, %rax # imm = 0x8000000000000000
shrq %cl, %rax
movq -0x198(%rbp), %rcx
movl -0x24c(%rbp), %edx
andq (%rcx,%rdx,8), %rax
movq -0x1a0(%rbp), %rcx
movl -0x24c(%rbp), %edx
andq (%rcx,%rdx,8), %rax
cmpq $0x0, %rax
je 0x14210
movl -0x24c(%rbp), %eax
shll $0x6, %eax
addl -0x250(%rbp), %eax
movl %eax, -0x254(%rbp)
movq -0x58(%rbp), %rcx
leaq -0x254(%rbp), %rdi
movl $0x4, %esi
movl $0x1, %edx
callq 0x3420
jmp 0x14212
movl -0x250(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x250(%rbp)
jmp 0x14197
jmp 0x14228
jmp 0x1422a
movl -0x24c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24c(%rbp)
jmp 0x14147
movq -0x58(%rbp), %rdi
callq 0x30e0
movl -0x1a8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1a8(%rbp)
jmp 0x13ee3
movq -0x198(%rbp), %rdi
callq 0x3040
movq -0x1a0(%rbp), %rdi
callq 0x3040
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x260, %rsp            # imm = 0x260
popq %rbp
retq
nopw %cs:(%rax,%rax)