// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x230, %rsp            # imm = 0x230
movq 0xf3ce(%rip), %rax      # 0x23670
movq (%rax), %rdi
leaq 0x8444(%rip), %rsi      # 0x1c6f0
callq 0x8250
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x7d97(%rip), %rsi      # 0x1c057
callq 0x3370
movq %rax, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x142e9
callq 0x3050
movl (%rax), %edi
movq -0x8(%rbp), %rdx
leaq 0x9c5f(%rip), %rsi      # 0x1df41
movb $0x0, %al
callq 0x3300
movq -0x10(%rbp), %rcx
leaq -0x30(%rbp), %rdi
movl $0x20, %esi
movl $0x1, %edx
callq 0x30a0
movq -0x10(%rbp), %rdi
callq 0x30e0
movslq 0xf35c(%rip), %rdi      # 0x2366c
movl $0x4, %esi
callq 0x3270
movq %rax, -0x58(%rbp)
movq $0x0, -0x60(%rbp)
movslq -0x20(%rbp), %rdi
shlq $0x3, %rdi
callq 0x3310
movq %rax, -0x168(%rbp)
movslq -0x20(%rbp), %rdi
shlq $0x3, %rdi
callq 0x3310
movq %rax, -0x170(%rbp)
movslq -0x20(%rbp), %rdi
movl $0x8, %esi
callq 0x3270
movq %rax, -0x178(%rbp)
leaq 0xf2f6(%rip), %rdi      # 0x23660
addq $0x318, %rdi            # imm = 0x318
movl $0x1ff, %esi            # imm = 0x1FF
callq 0x3080
movl $0x0, -0x17c(%rbp)
movl -0x17c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x144f2
leaq -0x160(%rbp), %rdi
movl -0x17c(%rbp), %r8d
leaq 0x7ca5(%rip), %rsi      # 0x1c04e
leaq 0xf2b0(%rip), %rdx      # 0x23660
addq $0x318, %rdx            # imm = 0x318
leaq 0xa09b(%rip), %rcx      # 0x1e459
movb $0x0, %al
callq 0x3400
leaq -0x160(%rbp), %rdi
leaq 0x7c87(%rip), %rsi      # 0x1c05a
callq 0x3370
movq %rax, %rdx
movq -0x168(%rbp), %rax
movslq -0x17c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x168(%rbp), %rax
movslq -0x17c(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0x1441e
callq 0x3050
movl (%rax), %edi
leaq -0x160(%rbp), %rdx
leaq 0x8f2f(%rip), %rsi      # 0x1d346
movb $0x0, %al
callq 0x3300
leaq -0x160(%rbp), %rdi
movl -0x17c(%rbp), %r8d
leaq 0x7c1b(%rip), %rsi      # 0x1c04e
leaq 0xf226(%rip), %rdx      # 0x23660
addq $0x318, %rdx            # imm = 0x318
leaq 0xa018(%rip), %rcx      # 0x1e460
movb $0x0, %al
callq 0x3400
leaq -0x160(%rbp), %rdi
leaq 0x7bfd(%rip), %rsi      # 0x1c05a
callq 0x3370
movq %rax, %rdx
movq -0x170(%rbp), %rax
movslq -0x17c(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
movq -0x170(%rbp), %rax
movslq -0x17c(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0x144a8
callq 0x3050
movl (%rax), %edi
leaq -0x160(%rbp), %rdx
leaq 0x8ea5(%rip), %rsi      # 0x1d346
movb $0x0, %al
callq 0x3300
movq -0x178(%rbp), %rdi
movslq -0x17c(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x170(%rbp), %rax
movslq -0x17c(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
movl $0x8, %esi
movl $0x1, %edx
callq 0x3420
movl -0x17c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x17c(%rbp)
jmp 0x14385
movl $0x0, -0x214(%rbp)
movl -0x214(%rbp), %eax
cmpl 0xf164(%rip), %eax      # 0x2366c
jge 0x147e0
movq 0xf15b(%rip), %rax      # 0x23670
movslq -0x214(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0x81c9(%rip), %rsi      # 0x1c6f0
callq 0x8250
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rdi
leaq 0x7b1c(%rip), %rsi      # 0x1c057
callq 0x3370
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
jne 0x14563
callq 0x3050
movl (%rax), %edi
movq -0x8(%rbp), %rdx
leaq 0x99e5(%rip), %rsi      # 0x1df41
movb $0x0, %al
callq 0x3300
movq -0x10(%rbp), %rcx
leaq -0x50(%rbp), %rdi
movl $0x20, %esi
movl $0x1, %edx
callq 0x30a0
movq -0x10(%rbp), %rdi
callq 0x30e0
movl -0x30(%rbp), %eax
cmpl -0x50(%rbp), %eax
je 0x145ad
callq 0x3050
movl (%rax), %edi
movl -0x214(%rbp), %edx
movl -0x50(%rbp), %ecx
movl -0x30(%rbp), %r8d
leaq 0x99ac(%rip), %rsi      # 0x1df52
movb $0x0, %al
callq 0x3300
movl -0x20(%rbp), %eax
cmpl -0x40(%rbp), %eax
je 0x145d7
callq 0x3050
movl (%rax), %edi
movl -0x214(%rbp), %edx
movl -0x40(%rbp), %ecx
movl -0x20(%rbp), %r8d
leaq 0x99bd(%rip), %rsi      # 0x1df8d
movb $0x0, %al
callq 0x3300
jmp 0x145d9
movl $0x0, -0x218(%rbp)
movl -0x218(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x147b6
leaq -0x160(%rbp), %rdi
movq 0xf070(%rip), %rax      # 0x23670
movslq -0x214(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movl -0x218(%rbp), %r8d
leaq 0x7a35(%rip), %rsi      # 0x1c04e
leaq 0x9e4d(%rip), %rcx      # 0x1e46d
movb $0x0, %al
callq 0x3400
leaq -0x160(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0x32b0
cmpl $-0x1, %eax
jne 0x146aa
leaq -0x160(%rbp), %rdi
movq 0xf023(%rip), %rax      # 0x23670
movslq -0x214(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
movl -0x218(%rbp), %r8d
leaq 0x79e8(%rip), %rsi      # 0x1c04e
leaq 0x9e04(%rip), %rcx      # 0x1e471
movb $0x0, %al
callq 0x3400
leaq -0x160(%rbp), %rdi
leaq -0x210(%rbp), %rsi
callq 0x32b0
cmpl $-0x1, %eax
jne 0x146a8
callq 0x3050
movl (%rax), %edi
leaq -0x160(%rbp), %rdx
leaq 0x8ca5(%rip), %rsi      # 0x1d346
movb $0x0, %al
callq 0x3300
jmp 0x146aa
movq -0x1e0(%rbp), %rdi
callq 0x3310
movq %rax, -0x220(%rbp)
leaq -0x160(%rbp), %rdi
leaq 0x798c(%rip), %rsi      # 0x1c057
callq 0x3370
movq %rax, -0x228(%rbp)
movq -0x220(%rbp), %rdi
movq -0x1e0(%rbp), %rsi
movq -0x228(%rbp), %rcx
movl $0x1, %edx
callq 0x30a0
movq -0x220(%rbp), %rdi
movq -0x1e0(%rbp), %rsi
movq -0x168(%rbp), %rax
movslq -0x218(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
movl $0x1, %edx
callq 0x3420
movq -0x228(%rbp), %rdi
callq 0x30e0
movq -0x1e0(%rbp), %rdx
shrq $0x2, %rdx
movq -0x178(%rbp), %rax
movslq -0x218(%rbp), %rcx
addq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
movq -0x178(%rbp), %rdi
movslq -0x218(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rdi
movq -0x170(%rbp), %rax
movslq -0x218(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
movl $0x8, %esi
movl $0x1, %edx
callq 0x3420
movq -0x1e0(%rbp), %rsi
shrq $0x2, %rsi
movq -0x58(%rbp), %rax
movslq -0x214(%rbp), %rcx
movl (%rax,%rcx,4), %edx
addq %rsi, %rdx
movl %edx, (%rax,%rcx,4)
movl -0x218(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x218(%rbp)
jmp 0x145e3
movq -0x58(%rbp), %rax
movslq -0x214(%rbp), %rcx
movl (%rax,%rcx,4), %eax
addq -0x60(%rbp), %rax
movq %rax, -0x60(%rbp)
movl -0x214(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x214(%rbp)
jmp 0x144fc
movl $0x0, -0x22c(%rbp)
movl -0x22c(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x14834
movq -0x168(%rbp), %rax
movslq -0x22c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x30e0
movq -0x170(%rbp), %rax
movslq -0x22c(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x30e0
movl -0x22c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x22c(%rbp)
jmp 0x147ea
movq -0x168(%rbp), %rdi
callq 0x3040
movq -0x170(%rbp), %rdi
callq 0x3040
movq -0x178(%rbp), %rdi
callq 0x3040
movl 0xee0e(%rip), %eax      # 0x2366c
movl %eax, -0x1c(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0x18(%rbp)
leaq -0x160(%rbp), %rdi
leaq 0x7ab4(%rip), %rsi      # 0x1c32b
leaq 0xede2(%rip), %rdx      # 0x23660
addq $0x318, %rdx            # imm = 0x318
leaq 0x7e64(%rip), %rcx      # 0x1c6f0
movb $0x0, %al
callq 0x3400
leaq -0x160(%rbp), %rdi
leaq 0x77b9(%rip), %rsi      # 0x1c05a
callq 0x3370
movq %rax, -0x10(%rbp)
cmpq $0x0, %rax
jne 0x148cc
callq 0x3050
movl (%rax), %edi
leaq -0x160(%rbp), %rdx
leaq 0x8a81(%rip), %rsi      # 0x1d346
movb $0x0, %al
callq 0x3300
movq -0x10(%rbp), %rcx
leaq -0x30(%rbp), %rdi
movl $0x20, %esi
movl $0x1, %edx
callq 0x3420
movq -0x58(%rbp), %rdi
movslq 0xed7e(%rip), %rdx      # 0x2366c
movq -0x10(%rbp), %rcx
movl $0x4, %esi
callq 0x3420
movl $0x0, -0x230(%rbp)
movl -0x230(%rbp), %eax
cmpl 0xed5a(%rip), %eax      # 0x2366c
jge 0x1494a
movq 0xed55(%rip), %rax      # 0x23670
movslq -0x230(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x10(%rbp), %rcx
movl $0x1, %esi
movl $0x100, %edx            # imm = 0x100
callq 0x3420
movl -0x230(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x230(%rbp)
jmp 0x14906
movq -0x10(%rbp), %rdi
callq 0x30e0
movq -0x58(%rbp), %rdi
callq 0x3040
movl $0x1, %eax
addq $0x230, %rsp            # imm = 0x230
popq %rbp
retq
nopw (%rax,%rax)