// File: /workspace/github_c_makefile_star2_O1/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, 0x28(%rsp)
movq %r8, %r12
movq %rcx, %r14
movq %rdx, %rbx
movl %esi, %r15d
movq %rdi, 0x8(%rsp)
leaq 0x95548(%rip), %rsi     # 0xa888f
movq %rdx, %rdi
callq 0x40f0
testq %rax, %rax
je 0x13714
movq %rax, %r13
leaq 0x9552d(%rip), %rsi     # 0xa888f
movq %r14, %rdi
callq 0x40f0
testq %rax, %rax
je 0x13714
movq %rax, %rbp
movq %r12, 0x10(%rsp)
movl %r15d, 0x20(%rsp)
movq %rbx, %rdi
callq 0x37e22
movl %eax, 0x1c(%rsp)
movslq %eax, %rbx
leaq (,%rbx,4), %r15
leaq 0x901de(%rip), %r12     # 0xa357c
movq %r15, %rdi
movq %r12, %rsi
movl $0x6, %edx
callq 0x390f5
movq %rax, 0x38(%rsp)
movq %r15, %rdi
movq %r12, %rsi
movl $0x7, %edx
callq 0x390f5
movq %rax, %r14
movq %r15, %rdi
movq %r12, %rsi
movl $0x8, %edx
callq 0x390f5
movq %rax, %r15
movl $0x4, %esi
movq %rbx, %rdi
movq %r12, %rdx
movl $0x9, %ecx
callq 0x39210
movq %rax, %r12
movq %r15, 0x30(%rsp)
movl $0x0, (%r15)
leaq 0x40(%rsp), %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq %r13, %rdx
callq 0x4120
testq %rax, %rax
je 0x1349a
xorl %r15d, %r15d
leaq 0x40(%rsp), %rbx
movq %rbx, %rdi
callq 0x4190
decl %eax
cltq
movb $0x0, 0x40(%rsp,%rax)
movq %rbx, %rdi
leaq 0xbe6a5(%rip), %rsi     # 0xd1ae0
movl $0x3, %edx
callq 0x3a2c5
movq 0x38(%rsp), %rcx
movl %eax, (%rcx,%r15,4)
movq %rbx, %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq %rbp, %rdx
callq 0x4120
movq %rbx, %rdi
callq 0x4200
movl %eax, (%r14,%r15,4)
testq %r15, %r15
je 0x13482
movl -0x4(%r14,%r15,4), %eax
movq 0x30(%rsp), %rcx
addl -0x4(%rcx,%r15,4), %eax
movl %eax, (%rcx,%r15,4)
incq %r15
movq %rbx, %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq %r13, %rdx
callq 0x4120
testq %rax, %rax
jne 0x13420
movq %r13, %rdi
callq 0x42a0
movq %rbp, %rdi
callq 0x42a0
leaq 0x953de(%rip), %rsi     # 0xa888f
movq 0x10(%rsp), %rdi
callq 0x40f0
testq %rax, %rax
movl 0x20(%rsp), %ebp
je 0x13714
movq %rax, %rbx
leaq 0x40(%rsp), %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq %rax, %rdx
callq 0x4120
testq %rax, %rax
je 0x1350e
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 0x134e7
movq %rbx, %rdi
callq 0x42a0
leaq 0x95372(%rip), %rsi     # 0xa888f
movq 0x8(%rsp), %rdi
callq 0x40f0
movq %rax, 0x10(%rsp)
testq %rax, %rax
je 0x13714
leaq 0x95365(%rip), %rsi     # 0xa88a1
movq 0x28(%rsp), %rbx
movq %rbx, %rdi
callq 0x40f0
movq %rax, 0x8(%rsp)
testq %rax, %rax
je 0x13703
leaq 0x40(%rsp), %rdi
movl $0x7a120, %esi          # imm = 0x7A120
movq 0x10(%rsp), %rdx
callq 0x4120
testq %rax, %rax
je 0x136c9
movsbl %bpl, %r13d
movl 0x1c(%rsp), %r15d
leaq 0x7a160(%rsp), %rbx
movq %r15, 0x20(%rsp)
cmpl $0x0, 0x1c(%rsp)
jle 0x1369d
xorl %ebp, %ebp
cmpl $0x0, (%r12,%rbp,4)
je 0x13691
movq 0x30(%rsp), %rax
movslq (%rax,%rbp,4), %rax
leaq (%rsp,%rax), %rsi
addq $0x40, %rsi
movslq (%r14,%rbp,4), %rdx
movq %rbx, %rdi
callq 0x4310
movslq (%r14,%rbp,4), %rax
movb $0x0, 0x7a160(%rsp,%rax)
movq 0x38(%rsp), %rax
movl (%rax,%rbp,4), %esi
cmpl $0x2, %esi
je 0x13625
cmpl $0x1, %esi
je 0x1360a
testl %esi, %esi
jne 0x13683
movq %rbx, %rdi
callq 0x4200
movq 0x8(%rsp), %rdi
leaq 0x8ffce(%rip), %rsi     # 0xa35c7
movl %eax, %edx
movl %r13d, %ecx
xorl %eax, %eax
callq 0x42e0
jmp 0x13691
movq 0x8(%rsp), %rdi
leaq 0x8ffb6(%rip), %rsi     # 0xa35cc
movq %rbx, %rdx
movl %r13d, %ecx
xorl %eax, %eax
callq 0x42e0
jmp 0x13691
movq %rbx, %rdi
callq 0x4130
movsd %xmm0, 0x28(%rsp)
movq %r14, %r15
movq %rbx, %r14
movq %r12, %rbx
movl %r13d, %r12d
leaq 0xf4280(%rsp), %r13
movq %r13, %rdi
xorl %esi, %esi
leaq 0x9370d(%rip), %rdx     # 0xa6d60
callq 0x39529
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movl %r12d, %r13d
movq %rbx, %r12
movq %r14, %rbx
movq %r15, %r14
movq 0x20(%rsp), %r15
movsd 0x28(%rsp), %xmm0
movl %r13d, %edx
movb $0x1, %al
callq 0x42e0
jmp 0x13691
leaq 0x8ff47(%rip), %rdi     # 0xa35d1
xorl %eax, %eax
callq 0x4030
incq %rbp
cmpq %rbp, %r15
jne 0x13597
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 0x1358a
movq 0x10(%rsp), %rdi
callq 0x42a0
movq 0x8(%rsp), %rdi
callq 0x42a0
movq 0x38(%rsp), %rdi
callq 0x39194
movq %r14, %rdi
callq 0x39194
movq %r12, %rdi
callq 0x39194
movq 0x30(%rsp), %rdi
callq 0x39194
jmp 0x13714
leaq 0x8fe98(%rip), %rdi     # 0xa35a2
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