// File: /workspace/github_c_makefile_star2_O2/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 0xd7d1(%rip), %rax      # 0x1c680
movq (%rax), %rdi
leaq 0x58a7(%rip), %rsi      # 0x14760
callq 0x68a5
movq %rax, %rbx
leaq 0x519f(%rip), %rsi      # 0x14067
movq %rax, %rdi
callq 0x33a0
testq %rax, %rax
je 0xf336
movq %rax, %r14
leaq 0x40(%rsp), %rbx
pushq $0x20
popq %rsi
pushq $0x1
popq %rdx
movq %rbx, %rdi
movq %rax, %rcx
callq 0x30c0
movq %r14, %rdi
callq 0x3100
movslq 0xd77b(%rip), %rdi      # 0x1c67c
pushq $0x4
popq %rsi
callq 0x32a0
movq %rax, 0x8(%rsp)
movl 0x10(%rbx), %ebp
movslq %ebp, %rbx
leaq (,%rbx,8), %r14
movq %r14, %rdi
callq 0x3340
movq %rax, 0x18(%rsp)
movq %r14, %rdi
callq 0x3340
movq %rax, 0x10(%rsp)
pushq $0x8
popq %rsi
movq %rbx, %rdi
callq 0x32a0
movq %rax, %r13
leaq 0xda3d(%rip), %r15      # 0x1c988
movq %r15, %rdi
movl $0x1ff, %esi            # imm = 0x1FF
callq 0x3090
testl %ebx, %ebx
movl $0x0, %eax
movl %ebp, 0x4(%rsp)
cmovgl %ebp, %eax
movq %rax, 0x20(%rsp)
leaq 0x50ec(%rip), %r12      # 0x1405e
leaq 0x80(%rsp), %rbp
leaq 0x50e9(%rip), %rbx      # 0x1406a
movq %r13, 0x28(%rsp)
xorl %r14d, %r14d
cmpq %r14, 0x20(%rsp)
je 0xf01f
movq %rbp, %rdi
movq %r12, %rsi
movq %r15, %rdx
leaq 0x6fd8(%rip), %rcx      # 0x15f7c
movl %r14d, %r8d
xorl %eax, %eax
callq 0x3430
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x33a0
movq 0x18(%rsp), %rcx
movq %rax, (%rcx,%r14,8)
testq %rax, %rax
je 0xf319
movq %rbp, %rdi
movq %r12, %rsi
movq %r15, %rdx
leaq 0x6fa8(%rip), %rcx      # 0x15f83
movl %r14d, %r8d
xorl %eax, %eax
callq 0x3430
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x33a0
movq 0x10(%rsp), %rcx
movq %rax, (%rcx,%r14,8)
testq %rax, %rax
je 0xf319
movq %r13, %rdi
pushq $0x8
popq %rsi
pushq $0x1
popq %rdx
movq %rax, %rcx
callq 0x3450
incq %r14
addq $0x8, %r13
jmp 0xef89
movl 0x40(%rsp), %eax
movl %eax, (%rsp)
leaq 0x80(%rsp), %rbp
xorl %r12d, %r12d
xorl %r15d, %r15d
movslq 0xd641(%rip), %rax      # 0x1c67c
cmpq %rax, %r12
jge 0xf1fc
movq 0xd635(%rip), %rax      # 0x1c680
movq (%rax,%r12,8), %rdi
leaq 0x570a(%rip), %rsi      # 0x14760
callq 0x68a5
movq %rax, %rbx
movq %rax, %rdi
leaq 0x4fff(%rip), %rsi      # 0x14067
callq 0x33a0
testq %rax, %rax
je 0xf336
movq %rax, %r14
leaq 0x60(%rsp), %rdi
pushq $0x20
popq %rsi
pushq $0x1
popq %rdx
movq %rax, %rcx
callq 0x30c0
movq %r14, %rdi
callq 0x3100
movl 0x60(%rsp), %ebx
cmpl %ebx, (%rsp)
jne 0xf349
movq %r15, 0x30(%rsp)
movl 0x70(%rsp), %ebx
cmpl %ebx, 0x4(%rsp)
jne 0xf362
movq 0x28(%rsp), %r15
xorl %ebx, %ebx
cmpq %rbx, 0x20(%rsp)
je 0xf1e3
movq 0xd5b3(%rip), %rax      # 0x1c680
movq (%rax,%r12,8), %rdx
movq %rbp, %rdi
leaq 0x4f83(%rip), %rsi      # 0x1405e
leaq 0x6eae(%rip), %rcx      # 0x15f90
movl %ebx, %r8d
xorl %eax, %eax
callq 0x3430
movq %rbp, %rdi
leaq 0x188(%rsp), %rsi
callq 0x32e0
cmpl $-0x1, %eax
jne 0xf140
movq 0xd578(%rip), %rax      # 0x1c680
movq (%rax,%r12,8), %rdx
movq %rbp, %rdi
leaq 0x4f48(%rip), %rsi      # 0x1405e
leaq 0x6e77(%rip), %rcx      # 0x15f94
movl %ebx, %r8d
xorl %eax, %eax
callq 0x3430
movq %rbp, %rdi
leaq 0x188(%rsp), %rsi
callq 0x32e0
cmpl $-0x1, %eax
je 0xf319
movq 0x1b8(%rsp), %r14
movq %r14, %rdi
callq 0x3340
movq %rax, %r13
movq %rbp, %rdi
leaq 0x4f0a(%rip), %rsi      # 0x14067
callq 0x33a0
movq %r15, 0x38(%rsp)
movq %r12, %r15
movq %rax, %r12
movq %r13, %rdi
movq %r14, %rsi
pushq $0x1
popq %rbp
movq %rbp, %rdx
movq %rax, %rcx
callq 0x30c0
movq 0x18(%rsp), %rax
movq (%rax,%rbx,8), %rcx
movq %r13, %rdi
movq %r14, %rsi
movq %rbp, %rdx
callq 0x3450
movq %r12, %rdi
movq %r15, %r12
movq 0x38(%rsp), %r15
callq 0x3100
shrq $0x2, %r14
addq %r14, (%r15)
movq 0x10(%rsp), %rax
movq (%rax,%rbx,8), %rcx
movq %r15, %rdi
pushq $0x8
popq %rsi
movq %rbp, %rdx
leaq 0x80(%rsp), %rbp
callq 0x3450
movq 0x8(%rsp), %rax
addl %r14d, (%rax,%r12,4)
incq %rbx
addq $0x8, %r15
jmp 0xf0bb
movq 0x8(%rsp), %rax
movl (%rax,%r12,4), %eax
movq 0x30(%rsp), %r15
addq %rax, %r15
incq %r12
jmp 0xf034
xorl %ebx, %ebx
cmpq %rbx, 0x20(%rsp)
je 0xf226
movq 0x18(%rsp), %rax
movq (%rax,%rbx,8), %rdi
callq 0x3100
movq 0x10(%rsp), %rax
movq (%rax,%rbx,8), %rdi
callq 0x3100
incq %rbx
jmp 0xf1fe
movq 0x18(%rsp), %rdi
callq 0x3040
movq 0x10(%rsp), %rdi
callq 0x3040
movq 0x28(%rsp), %rdi
callq 0x3040
movl 0xd432(%rip), %eax      # 0x1c67c
movl %eax, 0x54(%rsp)
movq %r15, 0x58(%rsp)
leaq 0x5139(%rip), %rsi      # 0x14393
leaq 0xd727(%rip), %rdx      # 0x1c988
leaq 0x54f8(%rip), %rcx      # 0x14760
leaq 0x80(%rsp), %rbx
movq %rbx, %rdi
xorl %eax, %eax
callq 0x3430
leaq 0x4de9(%rip), %rsi      # 0x1406a
movq %rbx, %rdi
callq 0x33a0
testq %rax, %rax
je 0xf319
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
pushq $0x20
popq %rsi
pushq $0x1
popq %r14
movq %r14, %rdx
movq %rax, %rcx
callq 0x3450
movslq 0xd3c9(%rip), %rdx      # 0x1c67c
pushq $0x4
popq %rsi
movq 0x8(%rsp), %rdi
movq %rbx, %rcx
callq 0x3450
xorl %r15d, %r15d
movslq 0xd3af(%rip), %rax      # 0x1c67c
cmpq %rax, %r15
jge 0xf2f2
movq 0xd3a7(%rip), %rax      # 0x1c680
movq (%rax,%r15,8), %rdi
movl $0x100, %edx            # imm = 0x100
movq %r14, %rsi
movq %rbx, %rcx
callq 0x3450
incq %r15
jmp 0xf2c6
movq %rbx, %rdi
callq 0x3100
movq 0x8(%rsp), %rdi
callq 0x3040
pushq $0x1
popq %rax
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x3060
movl (%rax), %edi
leaq 0x604f(%rip), %rsi      # 0x15376
leaq 0x80(%rsp), %rdx
xorl %eax, %eax
callq 0x3330
callq 0x3060
movl (%rax), %edi
leaq 0x6d2c(%rip), %rsi      # 0x16070
movq %rbx, %rdx
jmp 0xf32f
callq 0x3060
movl (%rax), %edi
leaq 0x6d2a(%rip), %rsi      # 0x16081
movl %r12d, %edx
movl %ebx, %ecx
movl (%rsp), %r8d
jmp 0xf37a
callq 0x3060
movl (%rax), %edi
leaq 0x6d4c(%rip), %rsi      # 0x160bc
movl %r12d, %edx
movl %ebx, %ecx
movl 0x4(%rsp), %r8d
xorl %eax, %eax
callq 0x3330