// File: /workspace/github_c_makefile_star2_O3/olcaytaner[P]Isell/dataset.c
// Function: convert_byte_format_to_dataset_format
void convert_byte_format_to_dataset_format(char* inputfile, char separator, char* featuretypes, char* lengths, char* useful, char* outputfile)
{
 /*!Last Changed 20.05.2005*/
 FILE *infile1, *infile2, *outfile;
 char myline[READLINELENGTH], feature[READLINELENGTH], pst[READLINELENGTH];
 int *ftypes, fcount, i, *fsizes, *available, *fstart, tmp;
 double tmpr;
 infile1 = fopen(featuretypes, "r");
 if (!infile1)
   return;
 infile2 = fopen(lengths, "r");
 if (!infile2)
   return;
 fcount = file_length(featuretypes);
 ftypes = safemalloc(fcount * sizeof(int), "convert_byte_format_to_dataset_format", 6);
 fsizes = safemalloc(fcount * sizeof(int), "convert_byte_format_to_dataset_format", 7);
 fstart = safemalloc(fcount * sizeof(int), "convert_byte_format_to_dataset_format", 8);
 available = safecalloc(fcount, sizeof(int), "convert_byte_format_to_dataset_format", 9);
 i = 0;
 fstart[0] = 0;
 while (fgets(myline, READLINELENGTH, infile1))
  {
   tmp = strlen(myline);
   myline[tmp - 1] = '\0';
   ftypes[i] = listindex(myline, ftype, 3);
   fgets(myline, READLINELENGTH, infile2);
   fsizes[i] = atoi(myline);
   if (i > 0)
     fstart[i] = fstart[i - 1] + fsizes[i - 1];
   i++;
  }
 fclose(infile1);
 fclose(infile2);
 infile1 = fopen(useful, "r");
 if (!infile1)
   return;
 while (fgets(myline, READLINELENGTH, infile1))
  {
   i = atoi(myline);
   available[i] = 1;
  }
 fclose(infile1);
 infile1 = fopen(inputfile, "r");
 if (!infile1)
   return;
 outfile = fopen(outputfile, "w");
 if (!outfile)
  {
   printf(m1248, outputfile);
   return;
  }
 while (fgets(myline, READLINELENGTH, infile1))
  {
   for (i = 0; i < fcount; i++)
     if (available[i])
      {
       memcpy(feature, &(myline[fstart[i]]), fsizes[i]);
       feature[fsizes[i]] = '\0';
       switch (ftypes[i])
        {
         case 0 :tmp = atoi(feature);
                 fprintf(outfile, "%d%c", tmp, separator);
                 break;
         case 1 :fprintf(outfile, "%s%c", feature, separator);
                 break;
         case 2 :tmpr = atof(feature);
                 set_precision(pst, NULL, "%c");
                 fprintf(outfile, pst, tmpr, separator);
                 break;
         default:printf(m1236, ftypes[i]);
                 break;
        }
      }
   fprintf(outfile, "\n");
  }
 fclose(infile1);
 fclose(outfile);
 safe_free(ftypes);
 safe_free(fsizes);
 safe_free(available);
 safe_free(fstart);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x16e3a8, %rsp         # imm = 0x16E3A8
movq %r9, 0x18(%rsp)
movq %r8, %r15
movq %rcx, %r14
movq %rdx, %rbx
movl %esi, 0x28(%rsp)
movq %rdi, 0x8(%rsp)
leaq 0x985f1(%rip), %rsi     # 0xab95b
movq %rdx, %rdi
callq 0x40f0
testq %rax, %rax
je 0x1371a
movq %rax, %r13
leaq 0x985d6(%rip), %rsi     # 0xab95b
movq %r14, %rdi
callq 0x40f0
testq %rax, %rax
je 0x1371a
movq %rax, %rbp
movq %r15, 0x10(%rsp)
movq %rbx, %rdi
callq 0x38a4a
movl %eax, 0x24(%rsp)
movslq %eax, %rbx
leaq (,%rbx,4), %r15
leaq 0x93204(%rip), %r12     # 0xa65c0
movq %r15, %rdi
movq %r12, %rsi
movl $0x6, %edx
callq 0x3a0e1
movq %rax, 0x38(%rsp)
movq %r15, %rdi
movq %r12, %rsi
movl $0x7, %edx
callq 0x3a0e1
movq %r15, %rdi
movq %rax, %r15
movq %r12, %rsi
movl $0x8, %edx
callq 0x3a0e1
movq %rax, %r14
movl $0x4, %esi
movq %rbx, %rdi
movq %r12, %rdx
movl $0x9, %ecx
callq 0x3a1fc
movq %rax, %r12
movq %r14, 0x30(%rsp)
movl $0x0, (%r14)
leaq 0x40(%rsp), %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq %r13, %rdx
callq 0x4120
testq %rax, %rax
je 0x134b8
xorl %r14d, %r14d
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
callq 0x4190
decl %eax
cltq
movb $0x0, 0x40(%rsp,%rax)
movq %rbx, %rdi
leaq 0xc1687(%rip), %rsi     # 0xd4ae0
movl $0x3, %edx
callq 0x3b355
movq 0x38(%rsp), %rcx
movl %eax, (%rcx,%r14,4)
movq %rbx, %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq %rbp, %rdx
callq 0x4120
movq %rbx, %rdi
callq 0x4200
movl %eax, (%r15,%r14,4)
testq %r14, %r14
je 0x134a0
movl -0x4(%r15,%r14,4), %eax
movq 0x30(%rsp), %rcx
addl -0x4(%rcx,%r14,4), %eax
movl %eax, (%rcx,%r14,4)
incq %r14
movq %rbx, %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq %r13, %rdx
callq 0x4120
testq %rax, %rax
jne 0x1343e
movq %r13, %rdi
callq 0x42a0
movq %rbp, %rdi
callq 0x42a0
leaq 0x9848c(%rip), %rsi     # 0xab95b
movq 0x10(%rsp), %rdi
callq 0x40f0
testq %rax, %rax
je 0x1371a
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq %rax, %rdx
callq 0x4120
testq %rax, %rax
je 0x13528
leaq 0x40(%rsp), %r13
movq %r13, %rdi
callq 0x4200
cltq
movl $0x1, (%r12,%rax,4)
movq %r13, %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq %rbx, %rdx
callq 0x4120
testq %rax, %rax
jne 0x13501
movq %rbx, %rdi
callq 0x42a0
leaq 0x98424(%rip), %rsi     # 0xab95b
movq 0x8(%rsp), %rdi
callq 0x40f0
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x1371a
leaq 0x98417(%rip), %rsi     # 0xab96d
movq 0x18(%rsp), %rbx
movq %rbx, %rdi
callq 0x40f0
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x13709
leaq 0x40(%rsp), %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq 0x10(%rsp), %rdx
callq 0x4120
testq %rax, %rax
je 0x136cf
movsbl 0x28(%rsp), %eax
movl %eax, 0x18(%rsp)
movl 0x24(%rsp), %r14d
leaq 0x7a160(%rsp), %rbx
cmpl $0x0, 0x24(%rsp)
jle 0x136a3
xorl %ebp, %ebp
cmpl $0x0, (%r12,%rbp,4)
je 0x13697
movq 0x30(%rsp), %rax
movslq (%rax,%rbp,4), %rax
leaq (%rsp,%rax), %rsi
addq $0x40, %rsi
movq %r15, %r13
movslq (%r15,%rbp,4), %r15
movq %rbx, %rdi
movq %r15, %rdx
callq 0x4310
movb $0x0, 0x7a160(%rsp,%r15)
movq 0x38(%rsp), %rax
movl (%rax,%rbp,4), %esi
cmpl $0x2, %esi
je 0x13644
cmpl $0x1, %esi
je 0x13628
testl %esi, %esi
movq %r13, %r15
jne 0x13689
movq %rbx, %rdi
callq 0x4200
movq 0x8(%rsp), %rdi
leaq 0x92ff2(%rip), %rsi     # 0xa660b
movl %eax, %edx
movl 0x18(%rsp), %ecx
xorl %eax, %eax
callq 0x42e0
jmp 0x13697
movq 0x8(%rsp), %rdi
leaq 0x92fdc(%rip), %rsi     # 0xa6610
movq %rbx, %rdx
movl 0x18(%rsp), %ecx
xorl %eax, %eax
callq 0x42e0
jmp 0x13684
movq %rbx, %rdi
callq 0x4130
movsd %xmm0, 0x28(%rsp)
leaq 0xf4280(%rsp), %r15
movq %r15, %rdi
xorl %esi, %esi
leaq 0x9676a(%rip), %rdx     # 0xa9dd0
callq 0x3a535
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movsd 0x28(%rsp), %xmm0
movl 0x18(%rsp), %edx
movb $0x1, %al
callq 0x42e0
movq %r13, %r15
jmp 0x13697
leaq 0x92f85(%rip), %rdi     # 0xa6615
xorl %eax, %eax
callq 0x4030
incq %rbp
cmpq %rbp, %r14
jne 0x135b1
movl $0xa, %edi
movq 0x8(%rsp), %rsi
callq 0x4150
leaq 0x40(%rsp), %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq 0x10(%rsp), %rdx
callq 0x4120
testq %rax, %rax
jne 0x135a4
movq 0x10(%rsp), %rdi
callq 0x42a0
movq 0x8(%rsp), %rdi
callq 0x42a0
movq 0x38(%rsp), %rdi
callq 0x3a180
movq %r15, %rdi
callq 0x3a180
movq %r12, %rdi
callq 0x3a180
movq 0x30(%rsp), %rdi
callq 0x3a180
jmp 0x1371a
leaq 0x92ed6(%rip), %rdi     # 0xa65e6
movq %rbx, %rsi
xorl %eax, %eax
callq 0x4030
addq $0x16e3a8, %rsp         # imm = 0x16E3A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq