#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*/ *);
int /*<<< orphan*/ feof(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ openFile(int /*<<< orphan*/ **, char *, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ sscanf(char *, char *, char *);
int usage();
int main(int argc, char *argv[]) {
  char line[1000], filename[1000];
  FILE *fpin, *fpout, *out_file_list;
  fpin = fpout = NULL;
  if (argc != 2)
    return usage();
  openFile(&fpin, argv[1], "r");
  openFile(&out_file_list, "file_list.txt", "w");
  while (!feof(fpin)) {
    fgets(line, 1000, fpin);
    if (line[0] == '>') {
      if (fpout) {
        printf("%s finished.\n", filename);
        fclose(fpout);
      }
      sscanf(&line[1], "%s", filename);
      sprintf(filename, "%s.fa", filename);
      openFile(&fpout, filename, "w");
      fprintf(out_file_list, "%s", line);
    }
    fputs(line, fpout);
  }
  printf("%s finished.\n", filename);
  fclose(fpout);
  fclose(fpin);
  fclose(out_file_list);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x810,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x800(%rbp)
movq   $0x0,-0x7f8(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11e8 <main+0x48>
mov    $0x0,%al
call   10b0 <usage@plt>
mov    %eax,-0x4(%rbp)
jmp    1355 <main+0x1b5>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    -0x7f8(%rbp),%rdi
lea    0xe02(%rip),%rdx
call   1040 <openFile@plt>
lea    -0x808(%rbp),%rdi
lea    0xdf1(%rip),%rsi
lea    0xdf8(%rip),%rdx
call   1040 <openFile@plt>
mov    -0x7f8(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    123e <main+0x9e>
jmp    1317 <main+0x177>
lea    -0x400(%rbp),%rdi
mov    -0x7f8(%rbp),%rdx
mov    $0x3e8,%esi
call   1070 <fgets@plt>
movsbl -0x400(%rbp),%eax
cmp    $0x3e,%eax
jne    12ff <main+0x15f>
cmpq   $0x0,-0x800(%rbp)
je     1293 <main+0xf3>
lea    -0x7f0(%rbp),%rsi
lea    0xd90(%rip),%rdi
call   1050 <printf@plt>
mov    -0x800(%rbp),%rdi
call   1030 <fclose@plt>
lea    -0x400(%rbp),%rdi
add    $0x1,%rdi
lea    -0x7f0(%rbp),%rdx
lea    0xd74(%rip),%rsi
call   10a0 <sscanf@plt>
lea    -0x7f0(%rbp),%rdi
lea    -0x7f0(%rbp),%rdx
lea    0xd5d(%rip),%rsi
call   10c0 <sprintf@plt>
lea    -0x7f0(%rbp),%rsi
lea    -0x800(%rbp),%rdi
lea    0xd30(%rip),%rdx
call   1040 <openFile@plt>
mov    -0x808(%rbp),%rdi
lea    -0x400(%rbp),%rdx
lea    0xd26(%rip),%rsi
call   1080 <fprintf@plt>
lea    -0x400(%rbp),%rdi
mov    -0x800(%rbp),%rsi
call   1060 <fputs@plt>
jmp    121d <main+0x7d>
lea    -0x7f0(%rbp),%rsi
lea    0xced(%rip),%rdi
call   1050 <printf@plt>
mov    -0x800(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x7f8(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x808(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x810,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x7f8,%rsp
movq   $0x0,0x8(%rsp)
movq   $0x0,0x10(%rsp)
cmp    $0x2,%edi
jne    123d <main+0xad>
mov    0x8(%rsi),%rsi
lea    0xe39(%rip),%rdx
lea    0x10(%rsp),%rdi
call   1040 <openFile@plt>
lea    0xe2a(%rip),%rsi
lea    0xe31(%rip),%rdx
lea    0x18(%rsp),%rdi
call   1040 <openFile@plt>
mov    0x10(%rsp),%rdi
call   1080 <feof@plt>
test   %eax,%eax
je     1255 <main+0xc5>
lea    0xe14(%rip),%rdi
lea    0x410(%rsp),%rsi
call   1050 <printf@plt>
mov    0x8(%rsp),%rdi
call   1030 <fclose@plt>
mov    0x10(%rsp),%rdi
call   1030 <fclose@plt>
mov    0x18(%rsp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x7f8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
add    $0x7f8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    10a0 <usage@plt>
lea    0x20(%rsp),%rbx
lea    0xdbf(%rip),%r15
lea    0x410(%rsp),%r12
lea    0xdb3(%rip),%r13
lea    0xd99(%rip),%rbp
lea    0x8(%rsp),%r14
jmp    12d8 <main+0x148>
xchg   %ax,%ax
lea    0x21(%rsp),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1090 <sscanf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
call   10b0 <sprintf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %rbp,%rdx
call   1040 <openFile@plt>
mov    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <fputs@plt>
mov    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <fputs@plt>
mov    0x10(%rsp),%rdi
call   1080 <feof@plt>
test   %eax,%eax
jne    11f7 <main+0x67>
mov    0x10(%rsp),%rdx
mov    %rbx,%rdi
mov    $0x3e8,%esi
call   1070 <fgets@plt>
cmpb   $0x3e,0x20(%rsp)
jne    12b9 <main+0x129>
cmpq   $0x0,0x8(%rsp)
je     1280 <main+0xf0>
lea    0xd12(%rip),%rdi
mov    %r12,%rsi
call   1050 <printf@plt>
mov    0x8(%rsp),%rdi
call   1030 <fclose@plt>
jmp    1280 <main+0xf0>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [14 x i8] c"file_list.txt\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [14 x i8] c"%s finished.\0A\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [6 x i8] c"%s.fa\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [1000 x i8]
%7 = alloca [1000 x i8]
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* null, i32** %9
store i32* null, i32** %8
%11 = load i32, i32* %4
%12 = icmp ne i32 %11, 2
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 (...) @usage()
store i32 %14, i32* %3
br label %67
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @openFile(i32** %8, i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @openFile(i32** %10, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %54, %15
%22 = load i32*, i32** %8
%23 = call i32 @feof(i32* %22)
%24 = icmp ne i32 %23, 0
%25 = xor i1 %24, true
br i1 %25, label %26, label %58
26: ; preds = %21
%27 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%28 = load i32*, i32** %8
%29 = call i32 @fgets(i8* %27, i32 1000, i32* %28)
%30 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 62
br i1 %33, label %34, label %54
34: ; preds = %26
%35 = load i32*, i32** %9
%36 = icmp ne i32* %35, null
br i1 %36, label %37, label %42
37: ; preds = %34
%38 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%39 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %38)
%40 = load i32*, i32** %9
%41 = call i32 @fclose(i32* %40)
br label %42
42: ; preds = %37, %34
%43 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 1
%44 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%45 = call i32 @sscanf(i8* %43, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %44)
%46 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%47 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%48 = call i32 @sprintf(i8* %46, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %47)
%49 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%50 = call i32 @openFile(i32** %9, i8* %49, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%51 = load i32*, i32** %10
%52 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%53 = call i32 @fprintf(i32* %51, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %52)
br label %54
54: ; preds = %42, %26
%55 = getelementptr inbounds [1000 x i8], [1000 x i8]* %6, i64 0, i64 0
%56 = load i32*, i32** %9
%57 = call i32 @fputs(i8* %55, i32* %56)
br label %21
58: ; preds = %21
%59 = getelementptr inbounds [1000 x i8], [1000 x i8]* %7, i64 0, i64 0
%60 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %59)
%61 = load i32*, i32** %9
%62 = call i32 @fclose(i32* %61)
%63 = load i32*, i32** %8
%64 = call i32 @fclose(i32* %63)
%65 = load i32*, i32** %10
%66 = call i32 @fclose(i32* %65)
store i32 0, i32* %3
br label %67
67: ; preds = %58, %13
%68 = load i32, i32* %3
ret i32 %68
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [14 x i8] c"file_list.txt\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [14 x i8] c"%s finished.\0A\00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [6 x i8] c"%s.fa\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1000 x i8]
%4 = alloca [1000 x i8]
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [1000 x i8], [1000 x i8]* %4, i64 0, i64 0
%10 = bitcast i32** %5 to i8*
%11 = bitcast i32** %6 to i8*
%12 = bitcast i32** %7 to i8*
store i32* null, i32** %6
store i32* null, i32** %5
%13 = icmp eq i32 %0, 2
br i1 %13, label %16, label %14
14: ; preds = %2
%15 = tail call i32 (...) @usage()
br label %58
16: ; preds = %2
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @openFile(i32** %5, i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%20 = call i32 @openFile(i32** %7, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%21 = load i32*, i32** %5
%22 = call i32 @feof(i32* %21)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %50
24: ; preds = %16
%25 = getelementptr inbounds [1000 x i8], [1000 x i8]* %3, i64 0, i64 1
br label %26
26: ; preds = %24, %44
%27 = load i32*, i32** %5
%28 = call i32 @fgets(i8* %8, i32 1000, i32* %27)
%29 = load i8, i8* %8
%30 = icmp eq i8 %29, 62
br i1 %30, label %31, label %44
31: ; preds = %26
%32 = load i32*, i32** %6
%33 = icmp eq i32* %32, null
br i1 %33, label %38, label %34
34: ; preds = %31
%35 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %9)
%36 = load i32*, i32** %6
%37 = call i32 @fclose(i32* %36)
br label %38
38: ; preds = %34, %31
%39 = call i32 @sscanf(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %9)
%40 = call i32 @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %9)
%41 = call i32 @openFile(i32** %6, i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%42 = load i32*, i32** %7
%43 = call i32 @fputs(i8* %8, i32* %42)
br label %44
44: ; preds = %38, %26
%45 = load i32*, i32** %6
%46 = call i32 @fputs(i8* %8, i32* %45)
%47 = load i32*, i32** %5
%48 = call i32 @feof(i32* %47)
%49 = icmp eq i32 %48, 0
br i1 %49, label %26, label %50
50: ; preds = %44, %16
%51 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %9)
%52 = load i32*, i32** %6
%53 = call i32 @fclose(i32* %52)
%54 = load i32*, i32** %5
%55 = call i32 @fclose(i32* %54)
%56 = load i32*, i32** %7
%57 = call i32 @fclose(i32* %56)
br label %58
58: ; preds = %50, %14
%59 = phi i32 [ %15, %14 ], [ 0, %50 ]
ret i32 %59
}