// File: /workspace/github_c_makefile_star2_O0/sc932[P]ALE/src/readFileSplitter.c
// Function: main
int main(int argc, char **argv){
    static char *prog;
    char *p;
    prog = argv[0];
    if((p = strrchr(prog, '/')) != NULL)
        prog = ++p;
    if (argc < 2) { usage(prog); return 1; }
    if (strcmp(argv[1], "-h") ==  0) { usage(prog); return 0; }
    if (strcmp(argv[1], "--helph")  == 0) { usage(prog); return 0; }
    printf("Input file to split: %s\n", argv[argc - 1]);
    
    int hasQualityInfo = 1;
    
    if (argc == 3) {
        if(strcmp(argv[1], "-ro")==0){
            hasQualityInfo = 0;
        }else{
            printf("Could not find option %s\n", argv[1]);
            return 0;
        }
    }
    
    // attempt to open the input file
    FILE *ins = fopen(argv[argc - 1], "r");
    if(ins == NULL){
        printf("Error! Could not open input file: %s\n", argv[argc - 1]);
        return 1;
    }
    
    
    
    // open up output file
    FILE *fo1, *fo2;
    char fileName1[100] = "part1_", fileName2[100] = "part2_";
    strcat(fileName1, argv[argc - 1]);
    strcat(fileName2, argv[argc - 1]);
    fo1 = fopen(fileName1, "w");
    fo2 = fopen(fileName2, "w");
    if(fo1 == NULL || fo2 == NULL){
        printf("Error! Could not open output files: %s or %s\n", fileName1, fileName2);
    }
    
    // read in and output the files
    int keepGoing = 1;
    char seqName[256];
    char seq[256];
    char qual[256];
    char temp[5];
    if(hasQualityInfo == 1){
        while(keepGoing > 0){
            // first read
            keepGoing = fscanf( ins, "%255s%255s%5s%255s", seqName, seq, temp, qual);
            if(keepGoing > 0){
                fprintf(fo1, "%s\n%s\n+\n%s\n", seqName, seq, qual);
                keepGoing = fscanf( ins, "%255s%255s%5s%255s", seqName, seq, temp, qual);
                fprintf(fo2, "%s\n%s\n+\n%s\n", seqName, seq, qual);
            }
        }
        fclose(fo1);
        fclose(fo2);
        fclose(ins);
    }else{
        while(keepGoing > 0){
            // first read
            keepGoing = fscanf( ins, "%255s%255s", seqName, seq);
            if(keepGoing > 0){
                fprintf(fo1, "%s\n%s\n", seqName, seq);
                keepGoing = fscanf( ins, "%255s%255s", seqName, seq);
                fprintf(fo2, "%s\n%s\n", seqName, seq);
            }
        }
        fclose(fo1);
        fclose(fo2);
        fclose(ins);
    }
    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x430, %rsp            # imm = 0x430
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, 0x2e61(%rip)      # 0x4078
movq 0x2e5a(%rip), %rdi      # 0x4078
movl $0x2f, %esi
callq 0x1060
movq %rax, -0x18(%rbp)
cmpq $0x0, %rax
je 0x1245
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x18(%rbp)
movq %rax, 0x2e33(%rip)      # 0x4078
cmpl $0x2, -0x8(%rbp)
jge 0x1263
movq 0x2e26(%rip), %rdi      # 0x4078
callq 0x11c0
movl $0x1, -0x4(%rbp)
jmp 0x166c
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0xe20(%rip), %rsi       # 0x2092
callq 0x1080
cmpl $0x0, %eax
jne 0x1294
movq 0x2df5(%rip), %rdi      # 0x4078
callq 0x11c0
movl $0x0, -0x4(%rbp)
jmp 0x166c
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0xdf2(%rip), %rsi       # 0x2095
callq 0x1080
cmpl $0x0, %eax
jne 0x12c5
movq 0x2dc4(%rip), %rdi      # 0x4078
callq 0x11c0
movl $0x0, -0x4(%rbp)
jmp 0x166c
movq -0x10(%rbp), %rax
movl -0x8(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
leaq 0xdc0(%rip), %rdi       # 0x209d
movb $0x0, %al
callq 0x1050
movl $0x1, -0x1c(%rbp)
cmpl $0x3, -0x8(%rbp)
jne 0x1337
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0xdb6(%rip), %rsi       # 0x20b6
callq 0x1080
cmpl $0x0, %eax
jne 0x1313
movl $0x0, -0x1c(%rbp)
jmp 0x1335
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
leaq 0xd98(%rip), %rdi       # 0x20ba
movb $0x0, %al
callq 0x1050
movl $0x0, -0x4(%rbp)
jmp 0x166c
jmp 0x1337
movq -0x10(%rbp), %rax
movl -0x8(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xd85(%rip), %rsi       # 0x20d4
callq 0x10a0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0x138a
movq -0x10(%rbp), %rax
movl -0x8(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
leaq 0xd5f(%rip), %rdi       # 0x20d6
movb $0x0, %al
callq 0x1050
movl $0x1, -0x4(%rbp)
jmp 0x166c
leaq -0xa0(%rbp), %rdi
xorl %esi, %esi
movl $0x64, %edx
callq 0x1070
movb $0x70, -0xa0(%rbp)
movb $0x61, -0x9f(%rbp)
movb $0x72, -0x9e(%rbp)
movb $0x74, -0x9d(%rbp)
movb $0x31, -0x9c(%rbp)
movb $0x5f, -0x9b(%rbp)
leaq -0x110(%rbp), %rdi
xorl %esi, %esi
movl $0x64, %edx
callq 0x1070
movb $0x70, -0x110(%rbp)
movb $0x61, -0x10f(%rbp)
movb $0x72, -0x10e(%rbp)
movb $0x74, -0x10d(%rbp)
movb $0x32, -0x10c(%rbp)
movb $0x5f, -0x10b(%rbp)
leaq -0xa0(%rbp), %rdi
movq -0x10(%rbp), %rax
movl -0x8(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
callq 0x10b0
leaq -0x110(%rbp), %rdi
movq -0x10(%rbp), %rax
movl -0x8(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
callq 0x10b0
leaq -0xa0(%rbp), %rdi
leaq 0xcb0(%rip), %rsi       # 0x20fc
callq 0x10a0
movq %rax, -0x30(%rbp)
leaq -0x110(%rbp), %rdi
leaq 0xc99(%rip), %rsi       # 0x20fc
callq 0x10a0
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0x147a
cmpq $0x0, -0x38(%rbp)
jne 0x1496
leaq -0xa0(%rbp), %rsi
leaq -0x110(%rbp), %rdx
leaq 0xc6f(%rip), %rdi       # 0x20fe
movb $0x0, %al
callq 0x1050
movl $0x1, -0x114(%rbp)
cmpl $0x1, -0x1c(%rbp)
jne 0x15a1
jmp 0x14ac
cmpl $0x0, -0x114(%rbp)
jle 0x1581
movq -0x28(%rbp), %rdi
leaq -0x220(%rbp), %rdx
leaq -0x320(%rbp), %rcx
leaq -0x425(%rbp), %r8
leaq -0x420(%rbp), %r9
leaq 0xc4c(%rip), %rsi       # 0x212c
movb $0x0, %al
callq 0x1030
movl %eax, -0x114(%rbp)
cmpl $0x0, -0x114(%rbp)
jle 0x157c
movq -0x30(%rbp), %rdi
leaq -0x220(%rbp), %rdx
leaq -0x320(%rbp), %rcx
leaq -0x420(%rbp), %r8
leaq 0xc25(%rip), %rsi       # 0x213f
movb $0x0, %al
callq 0x1090
movq -0x28(%rbp), %rdi
leaq -0x220(%rbp), %rdx
leaq -0x320(%rbp), %rcx
leaq -0x425(%rbp), %r8
leaq -0x420(%rbp), %r9
leaq 0xbe4(%rip), %rsi       # 0x212c
movb $0x0, %al
callq 0x1030
movl %eax, -0x114(%rbp)
movq -0x38(%rbp), %rdi
leaq -0x220(%rbp), %rdx
leaq -0x320(%rbp), %rcx
leaq -0x420(%rbp), %r8
leaq 0xbca(%rip), %rsi       # 0x213f
movb $0x0, %al
callq 0x1090
jmp 0x14ac
movq -0x30(%rbp), %rdi
callq 0x1040
movq -0x38(%rbp), %rdi
callq 0x1040
movq -0x28(%rbp), %rdi
callq 0x1040
jmp 0x1665
jmp 0x15a3
cmpl $0x0, -0x114(%rbp)
jle 0x164a
movq -0x28(%rbp), %rdi
leaq -0x220(%rbp), %rdx
leaq -0x320(%rbp), %rcx
leaq 0xb82(%rip), %rsi       # 0x214b
movb $0x0, %al
callq 0x1030
movl %eax, -0x114(%rbp)
cmpl $0x0, -0x114(%rbp)
jle 0x1645
movq -0x30(%rbp), %rdi
leaq -0x220(%rbp), %rdx
leaq -0x320(%rbp), %rcx
leaq 0xb5e(%rip), %rsi       # 0x2156
movb $0x0, %al
callq 0x1090
movq -0x28(%rbp), %rdi
leaq -0x220(%rbp), %rdx
leaq -0x320(%rbp), %rcx
leaq 0xb33(%rip), %rsi       # 0x214b
movb $0x0, %al
callq 0x1030
movl %eax, -0x114(%rbp)
movq -0x38(%rbp), %rdi
leaq -0x220(%rbp), %rdx
leaq -0x320(%rbp), %rcx
leaq 0xb18(%rip), %rsi       # 0x2156
movb $0x0, %al
callq 0x1090
jmp 0x15a3
movq -0x30(%rbp), %rdi
callq 0x1040
movq -0x38(%rbp), %rdi
callq 0x1040
movq -0x28(%rbp), %rdi
callq 0x1040
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x430, %rsp            # imm = 0x430
popq %rbp
retq