#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ free(char *);
int help2();
scalar_t__ malloc(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ string_replace(char *);
char *strtok(char *, char *);
int main(int argc, char **argv) {
  char *filename, *labelfile, *seqfile;
  int **S;
  char *str, *linetemp, *line, *label, *seq, *conv, *conv1, *conv2, *conv3,
      *conv4;
  int i, j;
  FILE *inpfile, *labfile, *opfile;
  if (argc != 3 + 1) {
    return help2();
  }
  filename = argv[1];
  labelfile = argv[2];
  seqfile = argv[3];
  printf("Reading %s\n", filename);
  inpfile = fopen(filename, "r");
  labfile = fopen(labelfile, "w+");
  opfile = fopen(seqfile, "w+");
  i = 0;
  if (inpfile) {
    line = (char *)malloc(1000 * sizeof(char));
    while (fgets(line, 1000, inpfile)) {
      linetemp = (char *)malloc(1000 * sizeof(char));
      strcpy(linetemp, line);
      if (i == 0) {
        seq = strtok(linetemp, "|");
        label = strtok(NULL, "|");
        fprintf(labfile, "%s", label);
        i++;
      } else {
        seq = linetemp;
        string_replace(seq);
        j = 0;
        while (seq[j] != '\0') {
          fprintf(opfile, "%c ", seq[j]);
          j++;
        }
        fprintf(opfile, "\n");
        i = 0;
      }
      free(linetemp);
    }
    fclose(inpfile);
    fclose(labfile);
    fclose(opfile);
    free(line);
  } else {
    perror(filename);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     11f2 <main+0x32>
mov    $0x0,%al
call   1070 <help2@plt>
mov    %eax,-0x4(%rbp)
jmp    1400 <main+0x240>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xddf(%rip),%rdi
call   1080 <printf@plt>
mov    -0x18(%rbp),%rdi
lea    0xddb(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x90(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xdc6(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x98(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xdaf(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0xa0(%rbp)
movl   $0x0,-0x84(%rbp)
cmpq   $0x0,-0x90(%rbp)
je     13f7 <main+0x237>
mov    $0x3e8,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x90(%rbp),%rdx
mov    $0x3e8,%esi
call   1090 <fgets@plt>
cmp    $0x0,%rax
je     13c5 <main+0x205>
mov    $0x3e8,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rsi
call   1050 <strcpy@plt>
cmpl   $0x0,-0x84(%rbp)
jne    132d <main+0x16d>
mov    -0x40(%rbp),%rdi
lea    0xd2e(%rip),%rsi
call   10e0 <strtok@plt>
mov    %rax,-0x58(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xd1a(%rip),%rsi
call   10e0 <strtok@plt>
mov    %rax,-0x50(%rbp)
mov    -0x98(%rbp),%rdi
mov    -0x50(%rbp),%rdx
lea    0xd01(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    13b7 <main+0x1f7>
mov    -0x40(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rdi
call   1030 <string_replace@plt>
movl   $0x0,-0x88(%rbp)
mov    -0x58(%rbp),%rax
movslq -0x88(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1398 <main+0x1d8>
mov    -0xa0(%rbp),%rdi
mov    -0x58(%rbp),%rax
movslq -0x88(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
lea    0xc99(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    1348 <main+0x188>
mov    -0xa0(%rbp),%rdi
lea    0xc64(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x0,-0x84(%rbp)
mov    -0x40(%rbp),%rdi
call   1040 <free@plt>
jmp    1291 <main+0xd1>
mov    -0x90(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x98(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0xa0(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x48(%rbp),%rdi
call   1040 <free@plt>
jmp    1400 <main+0x240>
mov    -0x18(%rbp),%rdi
call   10d0 <perror@plt>
mov    -0x4(%rbp),%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
cmp    $0x4,%edi
jne    1346 <main+0x166>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    0x8(%rsi),%r15
mov    0x10(%rsi),%rbx
mov    0x18(%rsi),%r14
lea    0xdf6(%rip),%rdi
mov    %r15,%rsi
call   1080 <printf@plt>
lea    0xdf3(%rip),%rsi
mov    %r15,%rdi
call   10e0 <fopen@plt>
mov    %rax,%r13
lea    0xde3(%rip),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   10e0 <fopen@plt>
mov    %rax,0x8(%rsp)
mov    %r14,%rdi
mov    %r12,%rsi
call   10e0 <fopen@plt>
test   %r13,%r13
je     1380 <main+0x1a0>
mov    %rax,%rbx
mov    $0x3e8,%edi
call   10d0 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    $0x3e8,%esi
mov    %r13,%rdx
call   10b0 <fgets@plt>
test   %rax,%rax
mov    %r13,%r12
je     134d <main+0x16d>
lea    0xd91(%rip),%r15
xor    %r13d,%r13d
mov    %rbp,0x10(%rsp)
jmp    12d9 <main+0xf9>
nopl   0x0(%rax)
lea    0xd7a(%rip),%r13
mov    %r13,%rsi
call   1100 <strtok@plt>
xor    %edi,%edi
mov    %r13,%rsi
call   1100 <strtok@plt>
mov    %rax,%rdi
mov    0x8(%rsp),%rsi
call   1090 <fputs@plt>
mov    $0x1,%r13d
mov    %r14,%rdi
call   1040 <free@plt>
mov    %rbp,%rdi
mov    $0x3e8,%esi
mov    %r12,%rdx
call   10b0 <fgets@plt>
test   %rax,%rax
je     134d <main+0x16d>
mov    $0x3e8,%edi
call   10d0 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %rbp,%rsi
call   1050 <strcpy@plt>
mov    %r14,%rdi
test   %r13d,%r13d
je     1290 <main+0xb0>
call   1030 <string_replace@plt>
mov    (%r14),%al
test   %al,%al
je     132c <main+0x14c>
mov    %r14,%rbp
add    $0x1,%rbp
nopl   0x0(%rax)
movsbl %al,%edx
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   10c0 <fprintf@plt>
movzbl 0x0(%rbp),%eax
add    $0x1,%rbp
test   %al,%al
jne    1310 <main+0x130>
mov    $0xa,%edi
mov    %rbx,%rsi
call   10a0 <fputc@plt>
xor    %r13d,%r13d
mov    0x10(%rsp),%rbp
jmp    12bc <main+0xdc>
xor    %eax,%eax
jmp    1070 <help2@plt>
mov    %r12,%rdi
call   1060 <fclose@plt>
mov    0x8(%rsp),%rdi
call   1060 <fclose@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    %rbp,%rdi
call   1040 <free@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r15,%rdi
call   10f0 <perror@plt>
jmp    136f <main+0x18f>

LLVM IR (-O0):
@.str = [12 x i8] c"Reading %s\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"w+\00"
@.str.3 = [2 x i8] c"|\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [4 x i8] c"%c \00"
@.str.6 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32**
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca i8*
%20 = alloca i32
%21 = alloca i32
%22 = alloca i32*
%23 = alloca i32*
%24 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%25 = load i32, i32* %4
%26 = icmp ne i32 %25, 4
br i1 %26, label %27, label %29
27: ; preds = %2
%28 = call i32 (...) @help2()
store i32 %28, i32* %3
br label %115
29: ; preds = %2
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
store i8* %32, i8** %6
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 2
%35 = load i8*, i8** %34
store i8* %35, i8** %7
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 3
%38 = load i8*, i8** %37
store i8* %38, i8** %8
%39 = load i8*, i8** %6
%40 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %39)
%41 = load i8*, i8** %6
%42 = call i32* @fopen(i8* %41, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %42, i32** %22
%43 = load i8*, i8** %7
%44 = call i32* @fopen(i8* %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %44, i32** %23
%45 = load i8*, i8** %8
%46 = call i32* @fopen(i8* %45, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %46, i32** %24
store i32 0, i32* %20
%47 = load i32*, i32** %22
%48 = icmp ne i32* %47, null
br i1 %48, label %49, label %112
49: ; preds = %29
%50 = call i64 @malloc(i32 1000)
%51 = inttoptr i64 %50 to i8*
store i8* %51, i8** %12
br label %52
52: ; preds = %100, %49
%53 = load i8*, i8** %12
%54 = load i32*, i32** %22
%55 = call i64 @fgets(i8* %53, i32 1000, i32* %54)
%56 = icmp ne i64 %55, 0
br i1 %56, label %57, label %103
57: ; preds = %52
%58 = call i64 @malloc(i32 1000)
%59 = inttoptr i64 %58 to i8*
store i8* %59, i8** %11
%60 = load i8*, i8** %11
%61 = load i8*, i8** %12
%62 = call i32 @strcpy(i8* %60, i8* %61)
%63 = load i32, i32* %20
%64 = icmp eq i32 %63, 0
br i1 %64, label %65, label %74
65: ; preds = %57
%66 = load i8*, i8** %11
%67 = call i8* @strtok(i8* %66, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i8* %67, i8** %14
%68 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i8* %68, i8** %13
%69 = load i32*, i32** %23
%70 = load i8*, i8** %13
%71 = call i32 (i32*, i8*, ...) @fprintf(i32* %69, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %70)
%72 = load i32, i32* %20
%73 = add nsw i32 %72, 1
store i32 %73, i32* %20
br label %100
74: ; preds = %57
%75 = load i8*, i8** %11
store i8* %75, i8** %14
%76 = load i8*, i8** %14
%77 = call i32 @string_replace(i8* %76)
store i32 0, i32* %21
br label %78
78: ; preds = %86, %74
%79 = load i8*, i8** %14
%80 = load i32, i32* %21
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i8, i8* %79, i64 %81
%83 = load i8, i8* %82
%84 = sext i8 %83 to i32
%85 = icmp ne i32 %84, 0
br i1 %85, label %86, label %97
86: ; preds = %78
%87 = load i32*, i32** %24
%88 = load i8*, i8** %14
%89 = load i32, i32* %21
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds i8, i8* %88, i64 %90
%92 = load i8, i8* %91
%93 = sext i8 %92 to i32
%94 = call i32 (i32*, i8*, ...) @fprintf(i32* %87, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %93)
%95 = load i32, i32* %21
%96 = add nsw i32 %95, 1
store i32 %96, i32* %21
br label %78
97: ; preds = %78
%98 = load i32*, i32** %24
%99 = call i32 (i32*, i8*, ...) @fprintf(i32* %98, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %20
br label %100
100: ; preds = %97, %65
%101 = load i8*, i8** %11
%102 = call i32 @free(i8* %101)
br label %52
103: ; preds = %52
%104 = load i32*, i32** %22
%105 = call i32 @fclose(i32* %104)
%106 = load i32*, i32** %23
%107 = call i32 @fclose(i32* %106)
%108 = load i32*, i32** %24
%109 = call i32 @fclose(i32* %108)
%110 = load i8*, i8** %12
%111 = call i32 @free(i8* %110)
br label %115
112: ; preds = %29
%113 = load i8*, i8** %6
%114 = call i32 @perror(i8* %113)
br label %115
115: ; preds = %27, %112, %103
%116 = load i32, i32* %3
ret i32 %116
}

LLVM IR (-O2):
@.str = [12 x i8] c"Reading %s\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"w+\00"
@.str.3 = [2 x i8] c"|\00"
@.str.5 = [4 x i8] c"%c \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 4
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 (...) @help2()
br label %60
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = getelementptr inbounds i8*, i8** %1, i64 2
%10 = load i8*, i8** %9
%11 = getelementptr inbounds i8*, i8** %1, i64 3
%12 = load i8*, i8** %11
%13 = tail call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %8)
%14 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%16 = tail call i32* @fopen(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i32* %14, null
br i1 %17, label %58, label %18
18: ; preds = %6
%19 = tail call i64 @malloc(i32 1000)
%20 = inttoptr i64 %19 to i8*
%21 = tail call i64 @fgets(i8* %20, i32 1000, i32* %14)
%22 = icmp eq i64 %21, 0
br i1 %22, label %53, label %23
23: ; preds = %18, %48
%24 = phi i32 [ %49, %48 ], [ 0, %18 ]
%25 = tail call i64 @malloc(i32 1000)
%26 = inttoptr i64 %25 to i8*
%27 = tail call i32 @strcpy(i8* %26, i8* %20)
%28 = icmp eq i32 %24, 0
br i1 %28, label %29, label %33
29: ; preds = %23
%30 = tail call i8* @strtok(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%31 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%32 = tail call i32 @fputs(i8* %31, i32* %15)
br label %48
33: ; preds = %23
%34 = tail call i32 @string_replace(i8* %26)
%35 = load i8, i8* %26
%36 = icmp eq i8 %35, 0
br i1 %36, label %46, label %37
37: ; preds = %33, %37
%38 = phi i64 [ %42, %37 ], [ 0, %33 ]
%39 = phi i8 [ %44, %37 ], [ %35, %33 ]
%40 = sext i8 %39 to i32
%41 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %40)
%42 = add nuw i64 %38, 1
%43 = getelementptr inbounds i8, i8* %26, i64 %42
%44 = load i8, i8* %43
%45 = icmp eq i8 %44, 0
br i1 %45, label %46, label %37
46: ; preds = %37, %33
%47 = tail call i32 @fputc(i32 10, i32* %16)
br label %48
48: ; preds = %46, %29
%49 = phi i32 [ 1, %29 ], [ 0, %46 ]
%50 = tail call i32 @free(i8* %26)
%51 = tail call i64 @fgets(i8* %20, i32 1000, i32* %14)
%52 = icmp eq i64 %51, 0
br i1 %52, label %53, label %23
53: ; preds = %48, %18
%54 = tail call i32 @fclose(i32* %14)
%55 = tail call i32 @fclose(i32* %15)
%56 = tail call i32 @fclose(i32* %16)
%57 = tail call i32 @free(i8* %20)
br label %60
58: ; preds = %6
%59 = tail call i32 @perror(i8* %8)
br label %60
60: ; preds = %53, %58, %4
%61 = phi i32 [ %5, %4 ], [ 0, %58 ], [ 0, %53 ]
ret i32 %61
}