// File: /workspace/github_c_makefile_star2_O1/yhg926[P]public_kssd/command_set.c
// Function: combin_pans
int combin_pans()
{
  const char *pan_dstat_fpath = test_get_fullpath(set_opt.remaining_args[0], co_dstat);
 FILE * co_stat_fp = fopen(pan_dstat_fpath,"rb") ;
  if( co_stat_fp == NULL ) err(errno,"combin_pans():%s", pan_dstat_fpath);
 co_dstat_t co_dstat_one, co_dstat_it;
  fread(&co_dstat_one, sizeof(co_dstat_t), 1, co_stat_fp);
 fclose(co_stat_fp) ;
 ctx_obj_ct_t *ctx_ct = calloc( set_opt.num_remaining_args , sizeof(ctx_obj_ct_t) );
 llong all_ctx_ct = 0;
 char tmppath[PATHLEN];
 FILE** com_cofp = malloc( sizeof(FILE*) * co_dstat_one.comp_num);
 FILE** indexfp = malloc( sizeof(FILE*) * co_dstat_one.comp_num);
 size_t *index_offset = calloc(co_dstat_one.comp_num,sizeof(size_t));
 mkdir(set_opt.outdir,0777);
 for(int c = 0; c < co_dstat_one.comp_num; c++){
      sprintf(tmppath,"%s/%s.%d",set_opt.outdir,skch_prefix,c);
      com_cofp[c] = fopen(tmppath,"wb");
      if(com_cofp[c] == NULL) err(errno,"%s",tmppath);
   sprintf(tmppath,"%s/%s.%d",set_opt.outdir,idx_prefix,c);
      indexfp[c] = fopen(tmppath,"wb");
      if(indexfp[c] == NULL) err(errno,"%s",tmppath);
   fwrite(index_offset+c, sizeof(size_t),1,indexfp[c]);
  }
 struct stat file_stat;
 for(int i=0; i<set_opt.num_remaining_args;i++){
  pan_dstat_fpath = test_get_fullpath(set_opt.remaining_args[i], co_dstat);
  if( ( co_stat_fp = fopen(pan_dstat_fpath,"rb")) == NULL ) err(errno,"combin_pans():%s", pan_dstat_fpath);
  fread(&co_dstat_it, sizeof(co_dstat_t), 1, co_stat_fp);
  fclose(co_stat_fp) ;
  if( co_dstat_one.shuf_id != co_dstat_it.shuf_id )
   err(errno,"combin_pans(): %dth shuf_id: %u not match 0th shuf_id: %u\n",i, co_dstat_it.shuf_id, co_dstat_one.shuf_id);
  else if (co_dstat_one.comp_num != co_dstat_it.comp_num )
   err(errno,"combin_pans(): %dth comp_num: %u not match 0th comp_num: %u\n",i, co_dstat_it.comp_num, co_dstat_one.comp_num);
  for(int c = 0; c < co_dstat_one.comp_num; c++){
   sprintf(tmppath,"%s/%s.%d",set_opt.remaining_args[i],pan_prefix,c);
   if(stat(tmppath, &file_stat) == -1) {
    sprintf(tmppath,"%s/%s.%d",set_opt.remaining_args[i],uniq_pan_prefix,c);
    if(stat(tmppath, &file_stat) == -1)
     err(errno,"%s",tmppath);
   }
   unsigned int *tmpco = malloc(file_stat.st_size);
   FILE *pan_fp = fopen(tmppath,"rb");
   fread(tmpco,file_stat.st_size, 1, pan_fp);
   fwrite(tmpco,file_stat.st_size, 1, com_cofp[c]);
   fclose(pan_fp);
   index_offset[c] += file_stat.st_size/ sizeof(unsigned int);
   fwrite(index_offset+c, sizeof(size_t),1,indexfp[c]);
   ctx_ct[i] += file_stat.st_size/ sizeof(unsigned int);
  }
  all_ctx_ct+= ctx_ct[i];
 }
 for(int c = 0; c < co_dstat_one.comp_num; c++) {
  fclose(com_cofp[c]) ;
  fclose(indexfp[c]);
 }
 free(com_cofp);
 free(indexfp);
 free(index_offset);
 co_dstat_one.infile_num = set_opt.num_remaining_args;
 co_dstat_one.all_ctx_ct = all_ctx_ct ;
 sprintf(tmppath,"%s/%s",set_opt.outdir,co_dstat);
 if( (co_stat_fp = fopen(tmppath,"wb") ) == NULL) { err(errno,"%s",tmppath) ;} ;
 fwrite(&co_dstat_one,sizeof(co_dstat_t),1,co_stat_fp);
 fwrite(ctx_ct,sizeof(ctx_obj_ct_t), set_opt.num_remaining_args, co_stat_fp);
 for(int i=0; i<set_opt.num_remaining_args;i++)
   fwrite(set_opt.remaining_args[i],1, PATHLEN,co_stat_fp);
 fclose(co_stat_fp) ;
 free(ctx_ct);
 return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
movq 0xdd5d(%rip), %rax      # 0x1d680
movq (%rax), %rdi
leaq 0x5e33(%rip), %rsi      # 0x15760
callq 0x6bcc
movq %rax, %rbx
leaq 0x572b(%rip), %rsi      # 0x15067
movq %rax, %rdi
callq 0x33a0
testq %rax, %rax
je 0xfdee
movq %rax, %r14
leaq 0x40(%rsp), %rbx
movl $0x20, %esi
movl $0x1, %edx
movq %rbx, %rdi
movq %rax, %rcx
callq 0x30c0
movq %r14, %rdi
callq 0x3100
movslq 0xdd03(%rip), %rdi      # 0x1d67c
movl $0x4, %esi
callq 0x32a0
movq %rax, 0x10(%rsp)
movslq 0x10(%rbx), %rbx
leaq (,%rbx,8), %r14
movq %r14, %rdi
callq 0x3340
movq %rax, %r13
movq %r14, %rdi
callq 0x3340
movq %rax, 0x28(%rsp)
movl $0x8, %esi
movq %rbx, %rdi
callq 0x32a0
movq %rax, 0x20(%rsp)
leaq 0xdfc3(%rip), %rdi      # 0x1d988
movl $0x1ff, %esi            # imm = 0x1FF
callq 0x3090
movl %ebx, %eax
movq %rax, 0x8(%rsp)
testq %rbx, %rbx
jle 0xfaa6
leaq 0x5678(%rip), %rbp      # 0x1505e
leaq 0xdf9b(%rip), %r12      # 0x1d988
movq 0x20(%rsp), %r15
xorl %ebx, %ebx
leaq 0x80(%rsp), %rdi
movq %rbp, %r14
movq %rdi, %rbp
movq %r14, %rsi
movq %r12, %rdx
leaq 0x756d(%rip), %rcx      # 0x16f7c
movl %ebx, %r8d
xorl %eax, %eax
callq 0x3430
movq %rbp, %rdi
leaq 0x5647(%rip), %rsi      # 0x1506a
callq 0x33a0
movq %rax, (%r13,%rbx,8)
testq %rax, %rax
je 0xfdd1
movq %rbp, %rdi
movq %r14, %rbp
movq %r14, %rsi
movq %r12, %r14
movq %r12, %rdx
leaq 0x7537(%rip), %rcx      # 0x16f83
movl %ebx, %r8d
xorl %eax, %eax
callq 0x3430
leaq 0x80(%rsp), %rdi
leaq 0x5605(%rip), %rsi      # 0x1506a
callq 0x33a0
movq 0x28(%rsp), %rcx
movq %rax, (%rcx,%rbx,8)
testq %rax, %rax
je 0xfdd1
movl $0x8, %esi
movl $0x1, %edx
movq %r15, %rdi
movq %rax, %rcx
callq 0x3450
incq %rbx
addq $0x8, %r15
cmpq %rbx, 0x8(%rsp)
movq %r14, %r12
jne 0xf9f4
cmpl $0x0, 0xdbcf(%rip)      # 0x1d67c
jle 0xfca7
movl 0x40(%rsp), %eax
movl %eax, 0x4(%rsp)
xorl %r14d, %r14d
xorl %r15d, %r15d
movq 0x8(%rsp), %rbp
movq %r13, 0x30(%rsp)
movq 0xdbae(%rip), %rax      # 0x1d680
movq %r14, 0x18(%rsp)
movq (%rax,%r14,8), %rdi
leaq 0x5c7e(%rip), %rsi      # 0x15760
callq 0x6bcc
movq %rax, %rbx
movq %rax, %rdi
leaq 0x5573(%rip), %rsi      # 0x15067
callq 0x33a0
testq %rax, %rax
je 0xfdee
movq %rax, %r14
movq %r15, 0x38(%rsp)
movl $0x20, %esi
movl $0x1, %edx
leaq 0x60(%rsp), %rdi
movq %rax, %rcx
callq 0x30c0
movq %r14, %rdi
callq 0x3100
movl 0x60(%rsp), %ebx
cmpl %ebx, 0x4(%rsp)
jne 0xfe19
movl 0x70(%rsp), %ebx
cmpl %ebx, %ebp
movq 0x18(%rsp), %r14
jne 0xfe01
testl %ebp, %ebp
leaq 0x80(%rsp), %r12
jle 0xfc7c
movq 0x20(%rsp), %r15
xorl %ebx, %ebx
movq 0xdb1a(%rip), %rax      # 0x1d680
movq (%rax,%r14,8), %rdx
movq %r12, %rdi
leaq 0x54ea(%rip), %rsi      # 0x1505e
leaq 0x7415(%rip), %rcx      # 0x16f90
movl %ebx, %r8d
xorl %eax, %eax
callq 0x3430
movq %r12, %rdi
leaq 0x188(%rsp), %rsi
callq 0x32e0
cmpl $-0x1, %eax
jne 0xfbd9
movq 0xdadf(%rip), %rax      # 0x1d680
movq (%rax,%r14,8), %rdx
movq %r12, %rdi
leaq 0x54af(%rip), %rsi      # 0x1505e
leaq 0x73de(%rip), %rcx      # 0x16f94
movl %ebx, %r8d
xorl %eax, %eax
callq 0x3430
movq %r12, %rdi
leaq 0x188(%rsp), %rsi
callq 0x32e0
cmpl $-0x1, %eax
je 0xfdd1
movq 0x1b8(%rsp), %r14
movq %r14, %rdi
callq 0x3340
movq %rax, %r13
movq %r12, %rdi
leaq 0x5471(%rip), %rsi      # 0x15067
callq 0x33a0
movq %rax, %rbp
movl $0x1, %edx
movq %r13, %rdi
movq %r14, %rsi
movq %rax, %rcx
callq 0x30c0
movq 0x30(%rsp), %rax
movq (%rax,%rbx,8), %rcx
movl $0x1, %edx
movq %r13, %rdi
movq %r14, %rsi
callq 0x3450
movq %rbp, %rdi
movq 0x8(%rsp), %rbp
callq 0x3100
shrq $0x2, %r14
addq %r14, (%r15)
movq 0x28(%rsp), %rax
movq (%rax,%rbx,8), %rcx
movl $0x8, %esi
movl $0x1, %edx
movq %r15, %rdi
callq 0x3450
movq 0x10(%rsp), %rax
movq 0x18(%rsp), %rcx
addl %r14d, (%rax,%rcx,4)
movq 0x18(%rsp), %r14
incq %rbx
addq $0x8, %r15
cmpq %rbx, %rbp
jne 0xfb5f
movq 0x10(%rsp), %rax
movl (%rax,%r14,4), %eax
movq 0x38(%rsp), %r15
addq %rax, %r15
incq %r14
movslq 0xd9e5(%rip), %rax      # 0x1d67c
cmpq %rax, %r14
movq 0x30(%rsp), %r13
jl 0xfacb
jmp 0xfcaf
xorl %r15d, %r15d
movq 0x8(%rsp), %rbp
testl %ebp, %ebp
movq 0x28(%rsp), %r14
jle 0xfcd5
xorl %ebx, %ebx
movq (%r13,%rbx,8), %rdi
callq 0x3100
movq (%r14,%rbx,8), %rdi
callq 0x3100
incq %rbx
cmpq %rbx, %rbp
jne 0xfcba
movq %r13, %rdi
callq 0x3040
movq %r14, %rdi
callq 0x3040
movq 0x20(%rsp), %rdi
callq 0x3040
movl 0xd987(%rip), %eax      # 0x1d67c
movl %eax, 0x54(%rsp)
movq %r15, 0x58(%rsp)
leaq 0x568e(%rip), %rsi      # 0x15393
leaq 0xdc7c(%rip), %rdx      # 0x1d988
leaq 0x5a4d(%rip), %rcx      # 0x15760
leaq 0x80(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3430
leaq 0x533e(%rip), %rsi      # 0x1506a
movq %rbx, %rdi
callq 0x33a0
testq %rax, %rax
je 0xfdd1
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
movl $0x20, %esi
movl $0x1, %edx
movq %rax, %rcx
callq 0x3450
movslq 0xd91e(%rip), %rdx      # 0x1d67c
movl $0x4, %esi
movq 0x10(%rsp), %rdi
movq %rbx, %rcx
callq 0x3450
cmpl $0x0, 0xd905(%rip)      # 0x1d67c
jle 0xfda8
xorl %r14d, %r14d
movq 0xd8fd(%rip), %rax      # 0x1d680
movq (%rax,%r14,8), %rdi
movl $0x1, %esi
movl $0x100, %edx            # imm = 0x100
movq %rbx, %rcx
callq 0x3450
incq %r14
movslq 0xd8d9(%rip), %rax      # 0x1d67c
cmpq %rax, %r14
jl 0xfd7c
movq %rbx, %rdi
callq 0x3100
movq 0x10(%rsp), %rdi
callq 0x3040
movl $0x1, %eax
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x3060
movl (%rax), %edi
leaq 0x6597(%rip), %rsi      # 0x16376
leaq 0x80(%rsp), %rdx
xorl %eax, %eax
callq 0x3330
callq 0x3060
movl (%rax), %edi
leaq 0x7274(%rip), %rsi      # 0x17070
movq %rbx, %rdx
jmp 0xfde7
callq 0x3060
movl (%rax), %edi
leaq 0x72ad(%rip), %rsi      # 0x170bc
movl %r14d, %edx
movl %ebx, %ecx
movl %ebp, %r8d
jmp 0xfe33
callq 0x3060
movl (%rax), %edi
leaq 0x725a(%rip), %rsi      # 0x17081
movq 0x18(%rsp), %rdx
movl %ebx, %ecx
movl 0x4(%rsp), %r8d
xorl %eax, %eax
callq 0x3330