#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;
  int i, j, count;
  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+");
  if (inpfile) {
    line = (char *)malloc(1000 * sizeof(char));
    i = 0;
    count = 0;
    while (fgets(line, 1000, inpfile)) {
      linetemp = (char *)malloc(1000 * sizeof(char));
      strcpy(linetemp, line);
      if (count == 0) {
        label = strtok(linetemp, "\n");
        label = strtok(linetemp, "|");
        label = strtok(NULL, "|");
        fprintf(labfile, "%s\n", label);
        count = 1;
      } else {
        string_replace(linetemp);
        j = 0;
        while (linetemp[j] != '\0') {
          fprintf(opfile, "%c ", linetemp[j]);
          j++;
        }
        fprintf(opfile, "\n");
        count = 0;
      }
      free(linetemp);
      i++;
    }
    fclose(inpfile);
    fclose(labfile);
    fclose(opfile);
    free(line);
  } else {
    perror(filename);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%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    13db <main+0x21b>
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,-0x68(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xdc9(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x70(%rbp)
mov    -0x28(%rbp),%rdi
lea    0xdb5(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x78(%rbp)
cmpq   $0x0,-0x68(%rbp)
je     13d2 <main+0x212>
mov    $0x3e8,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x54(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x68(%rbp),%rdx
mov    $0x3e8,%esi
call   1090 <fgets@plt>
cmp    $0x0,%rax
je     13a9 <main+0x1e9>
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,-0x5c(%rbp)
jne    1328 <main+0x168>
mov    -0x40(%rbp),%rdi
lea    0xd35(%rip),%rsi
call   10e0 <strtok@plt>
mov    %rax,-0x50(%rbp)
mov    -0x40(%rbp),%rdi
lea    0xd28(%rip),%rsi
call   10e0 <strtok@plt>
mov    %rax,-0x50(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xd14(%rip),%rsi
call   10e0 <strtok@plt>
mov    %rax,-0x50(%rbp)
mov    -0x70(%rbp),%rdi
mov    -0x50(%rbp),%rdx
lea    0xcf3(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x5c(%rbp)
jmp    1392 <main+0x1d2>
mov    -0x40(%rbp),%rdi
call   1030 <string_replace@plt>
movl   $0x0,-0x58(%rbp)
mov    -0x40(%rbp),%rax
movslq -0x58(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1379 <main+0x1b9>
mov    -0x78(%rbp),%rdi
mov    -0x40(%rbp),%rax
movslq -0x58(%rbp),%rcx
movsbl (%rax,%rcx,1),%edx
lea    0xcaf(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x58(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x58(%rbp)
jmp    1338 <main+0x178>
mov    -0x78(%rbp),%rdi
lea    0xc86(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x0,-0x5c(%rbp)
mov    -0x40(%rbp),%rdi
call   1040 <free@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1289 <main+0xc9>
mov    -0x68(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x70(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x78(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x48(%rbp),%rdi
call   1040 <free@plt>
jmp    13db <main+0x21b>
mov    -0x18(%rbp),%rdi
call   10d0 <perror@plt>
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
cmp    $0x4,%edi
jne    1340 <main+0x170>
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    0x8(%rsi),%rbp
mov    0x10(%rsi),%rbx
mov    0x18(%rsi),%r14
lea    0xe09(%rip),%rdi
mov    %rbp,%rsi
call   1080 <printf@plt>
lea    0xe06(%rip),%rsi
mov    %rbp,%rdi
call   10d0 <fopen@plt>
mov    %rax,%r15
lea    0xdf6(%rip),%r12
mov    %rbx,%rdi
mov    %r12,%rsi
call   10d0 <fopen@plt>
mov    %rax,(%rsp)
mov    %r14,%rdi
mov    %r12,%rsi
call   10d0 <fopen@plt>
test   %r15,%r15
je     1379 <main+0x1a9>
mov    %rax,%rbx
mov    $0x3e8,%edi
call   10c0 <malloc@plt>
mov    %rax,%r12
mov    %rax,%rdi
mov    $0x3e8,%esi
mov    %r15,%rdx
call   10a0 <fgets@plt>
test   %rax,%rax
je     1347 <main+0x177>
lea    0xda8(%rip),%r13
xor    %ebp,%ebp
jmp    12cf <main+0xff>
nop
lea    0xd93(%rip),%rsi
call   10f0 <strtok@plt>
mov    %r14,%rdi
lea    0xd8b(%rip),%rbp
mov    %rbp,%rsi
call   10f0 <strtok@plt>
xor    %edi,%edi
mov    %rbp,%rsi
call   10f0 <strtok@plt>
mov    (%rsp),%rdi
lea    0xd65(%rip),%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x1,%ebp
mov    %r14,%rdi
call   1040 <free@plt>
mov    %r12,%rdi
mov    $0x3e8,%esi
mov    %r15,%rdx
call   10a0 <fgets@plt>
test   %rax,%rax
je     1347 <main+0x177>
mov    $0x3e8,%edi
call   10c0 <malloc@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    %r12,%rsi
call   1050 <strcpy@plt>
mov    %r14,%rdi
test   %ebp,%ebp
je     1270 <main+0xa0>
call   1030 <string_replace@plt>
mov    (%r14),%al
test   %al,%al
je     132c <main+0x15c>
mov    %r14,%rbp
add    $0x1,%rbp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl %al,%edx
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
movzbl 0x0(%rbp),%eax
add    $0x1,%rbp
test   %al,%al
jne    1310 <main+0x140>
mov    $0xa,%edi
mov    %rbx,%rsi
call   1090 <fputc@plt>
xor    %ebp,%ebp
jmp    12b2 <main+0xe2>
xor    %eax,%eax
jmp    1070 <help2@plt>
mov    %r15,%rdi
call   1060 <fclose@plt>
mov    (%rsp),%rdi
call   1060 <fclose@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    %r12,%rdi
call   1040 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbp,%rdi
call   10e0 <perror@plt>
jmp    1368 <main+0x198>

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

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"\0A\00"
@.str.4 = [2 x i8] c"|\00"
@.str.5 = [4 x i8] c"%s\0A\00"
@.str.6 = [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 %61
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 %59, 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 %54, label %23
23: ; preds = %18, %49
%24 = phi i32 [ %50, %49 ], [ 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 %34
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* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%32 = tail call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%33 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %32)
br label %49
34: ; preds = %23
%35 = tail call i32 @string_replace(i8* %26)
%36 = load i8, i8* %26
%37 = icmp eq i8 %36, 0
br i1 %37, label %47, label %38
38: ; preds = %34, %38
%39 = phi i64 [ %43, %38 ], [ 0, %34 ]
%40 = phi i8 [ %45, %38 ], [ %36, %34 ]
%41 = sext i8 %40 to i32
%42 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %41)
%43 = add nuw i64 %39, 1
%44 = getelementptr inbounds i8, i8* %26, i64 %43
%45 = load i8, i8* %44
%46 = icmp eq i8 %45, 0
br i1 %46, label %47, label %38
47: ; preds = %38, %34
%48 = tail call i32 @fputc(i32 10, i32* %16)
br label %49
49: ; preds = %47, %29
%50 = phi i32 [ 1, %29 ], [ 0, %47 ]
%51 = tail call i32 @free(i8* %26)
%52 = tail call i64 @fgets(i8* %20, i32 1000, i32* %14)
%53 = icmp eq i64 %52, 0
br i1 %53, label %54, label %23
54: ; preds = %49, %18
%55 = tail call i32 @fclose(i32* %14)
%56 = tail call i32 @fclose(i32* %15)
%57 = tail call i32 @fclose(i32* %16)
%58 = tail call i32 @free(i8* %20)
br label %61
59: ; preds = %6
%60 = tail call i32 @perror(i8* %8)
br label %61
61: ; preds = %54, %59, %4
%62 = phi i32 [ %5, %4 ], [ 0, %59 ], [ 0, %54 ]
ret i32 %62
}