#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 */

/* Variables and functions */
int /*<<< orphan*/ free(char *);
int getopt(int, char **, char *);
scalar_t__ optind;
int /*<<< orphan*/ printf(char *, char *, ...);
int read_seq(char *, char *, char **, char **, char **);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  char *fasta = NULL;
  char *qual = NULL;
  char *extras = NULL;
  int size = 5000;
  int res = 0;
  int ch;
  int output_fasta = 0;
  int output_extras = 0;
  int only_extras = 0;
  while ((ch = getopt(argc, argv, "feEh")) != -1) {
    switch (ch) {
    case 'f':
      output_fasta = 1;
      break;
    case 'e':
      output_extras = 1;
      break;
    case 'E':
      output_extras = 1;
      only_extras = 1;
      break;
    case 'h':
      usage();
      break;
    case '?':
    default:
      usage();
    }
  }
  argc -= optind;
  argv += optind;
  if (argc != 2) {
    usage();
    return -1;
  }
  res = read_seq(argv[0], argv[1], &fasta, &qual, &extras);
  if (res == -2) {
    printf("Index file does not exist for: %s.index\n", argv[0]);
    return res;
  }
  if (res == 0) {
    if (!only_extras) {
      if (output_fasta) {
        printf(">%s\n%s\n", argv[1], fasta);
      } else {
        printf("@%s\n%s\n", argv[1], fasta);
        printf("+%s\n%s\n", argv[1], qual);
      }
    }
    if ((extras != NULL) && (output_extras))
      printf("EXTRAS:%s\n", extras);
  }
  if (fasta != NULL) {
    free(fasta);
    fasta = NULL;
  }
  if (qual != NULL) {
    free(qual);
    qual = NULL;
  }
  if (extras != NULL) {
    free(extras);
    extras = NULL;
  }
  return res;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movl   $0x1388,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xef9(%rip),%rdx
call   1070 <getopt@plt>
mov    %eax,-0x34(%rbp)
cmp    $0xffffffff,%eax
je     1231 <main+0xe1>
mov    -0x34(%rbp),%eax
add    $0xffffffc1,%eax
mov    %eax,%ecx
mov    %rcx,-0x48(%rbp)
sub    $0x29,%eax
ja     1225 <main+0xd5>
mov    -0x48(%rbp),%rax
lea    0xe20(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x1,-0x38(%rbp)
jmp    122c <main+0xdc>
movl   $0x1,-0x3c(%rbp)
jmp    122c <main+0xdc>
movl   $0x1,-0x3c(%rbp)
movl   $0x1,-0x40(%rbp)
jmp    122c <main+0xdc>
mov    $0x0,%al
call   1060 <usage@plt>
jmp    122c <main+0xdc>
jmp    1225 <main+0xd5>
mov    $0x0,%al
call   1060 <usage@plt>
jmp    11a1 <main+0x51>
mov    0x2db0(%rip),%rax
mov    (%rax),%rcx
movslq -0x8(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    0x2d9c(%rip),%rax
mov    (%rax),%rax
shl    $0x3,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1278 <main+0x128>
mov    $0x0,%al
call   1060 <usage@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    13c1 <main+0x271>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rcx
lea    -0x28(%rbp),%r8
call   1050 <read_seq@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0xfffffffe,-0x30(%rbp)
jne    12c5 <main+0x175>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    13c1 <main+0x271>
cmpl   $0x0,-0x30(%rbp)
jne    1367 <main+0x217>
cmpl   $0x0,-0x40(%rbp)
jne    133b <main+0x1eb>
cmpl   $0x0,-0x38(%rbp)
je     1302 <main+0x1b2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x18(%rbp),%rdx
lea    0xde0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1336 <main+0x1e6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x18(%rbp),%rdx
lea    0xdc9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x20(%rbp),%rdx
lea    0xdb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    133b <main+0x1eb>
cmpq   $0x0,-0x28(%rbp)
je     1362 <main+0x212>
cmpl   $0x0,-0x3c(%rbp)
je     1362 <main+0x212>
mov    -0x28(%rbp),%rsi
lea    0xd93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1367 <main+0x217>
cmpq   $0x0,-0x18(%rbp)
je     1383 <main+0x233>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x18(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     139f <main+0x24f>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     13bb <main+0x26b>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
movq   $0x0,0x18(%rsp)
movq   $0x0,0x10(%rsp)
movq   $0x0,0x20(%rsp)
mov    $0x1,%al
mov    %eax,0xc(%rsp)
lea    0xf05(%rip),%r14
lea    0xe6e(%rip),%r12
xor    %r13d,%r13d
xor    %r15d,%r15d
jmp    11ac <main+0x5c>
nopw   0x0(%rax,%rax,1)
cmp    $0xffffffff,%eax
je     11e2 <main+0x92>
xor    %eax,%eax
call   1060 <usage@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1070 <getopt@plt>
lea    -0x45(%rax),%ecx
cmp    $0x23,%ecx
ja     11a0 <main+0x50>
movslq (%r12,%rcx,4),%rax
add    %r12,%rax
jmp    *%rax
mov    $0x1,%r13d
mov    $0x1,%r15d
jmp    11ac <main+0x5c>
movl   $0x0,0xc(%rsp)
jmp    11ac <main+0x5c>
mov    0x2dff(%rip),%rax
mov    (%rax),%r14
sub    %r14d,%ebp
cmp    $0x2,%ebp
jne    123c <main+0xec>
mov    (%rbx,%r14,8),%rdi
mov    0x8(%rbx,%r14,8),%rsi
lea    0x18(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0x20(%rsp),%r8
call   1050 <read_seq@plt>
mov    %eax,%ebp
test   %eax,%eax
je     124d <main+0xfd>
cmp    $0xfffffffe,%ebp
jne    12af <main+0x15f>
mov    (%rbx,%r14,8),%rsi
lea    0xe6a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xfffffffe,%ebp
jmp    12ee <main+0x19e>
xor    %eax,%eax
call   1060 <usage@plt>
mov    $0xffffffff,%ebp
jmp    12ee <main+0x19e>
test   %r13d,%r13d
jne    1292 <main+0x142>
mov    0x8(%rbx,%r14,8),%rsi
mov    0x18(%rsp),%rdx
testb  $0x1,0xc(%rsp)
je     1284 <main+0x134>
lea    0xe5c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rbx,%r14,8),%rsi
mov    0x10(%rsp),%rdx
lea    0xe4c(%rip),%rdi
jmp    128b <main+0x13b>
lea    0xe33(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x20(%rsp),%rsi
test   %rsi,%rsi
je     12af <main+0x15f>
test   %r15d,%r15d
je     12af <main+0x15f>
lea    0xe2e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp),%rdi
test   %rdi,%rdi
je     12c7 <main+0x177>
call   1030 <free@plt>
movq   $0x0,0x18(%rsp)
mov    0x10(%rsp),%rdi
test   %rdi,%rdi
je     12df <main+0x18f>
call   1030 <free@plt>
movq   $0x0,0x10(%rsp)
mov    0x20(%rsp),%rdi
test   %rdi,%rdi
je     12ee <main+0x19e>
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"feEh\00"
@optind = global i64 0
@.str.1 = [41 x i8] c"Index file does not exist for: %s.index\0A\00"
@.str.2 = [8 x i8] c">%s\0A%s\0A\00"
@.str.3 = [8 x i8] c"@%s\0A%s\0A\00"
@.str.4 = [8 x i8] c"+%s\0A%s\0A\00"
@.str.5 = [11 x i8] c"EXTRAS:%s\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 i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* null, i8** %6
store i8* null, i8** %7
store i8* null, i8** %8
store i32 5000, i32* %9
store i32 0, i32* %10
store i32 0, i32* %12
store i32 0, i32* %13
store i32 0, i32* %14
br label %15
15: ; preds = %30, %2
%16 = load i32, i32* %4
%17 = load i8**, i8*** %5
%18 = call i32 @getopt(i32 %16, i8** %17, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i32 %18, i32* %11
%19 = icmp ne i32 %18, -1
br i1 %19, label %20, label %31
20: ; preds = %15
%21 = load i32, i32* %11
switch i32 %21, label %28 [
i32 102, label %22
i32 101, label %23
i32 69, label %24
i32 104, label %25
i32 63, label %27
]
22: ; preds = %20
store i32 1, i32* %12
br label %30
23: ; preds = %20
store i32 1, i32* %13
br label %30
24: ; preds = %20
store i32 1, i32* %13
store i32 1, i32* %14
br label %30
25: ; preds = %20
%26 = call i32 (...) @usage()
br label %30
27: ; preds = %20
br label %28
28: ; preds = %20, %27
%29 = call i32 (...) @usage()
br label %30
30: ; preds = %28, %25, %24, %23, %22
br label %15
31: ; preds = %15
%32 = load i64, i64* @optind
%33 = load i32, i32* %4
%34 = sext i32 %33 to i64
%35 = sub nsw i64 %34, %32
%36 = trunc i64 %35 to i32
store i32 %36, i32* %4
%37 = load i64, i64* @optind
%38 = load i8**, i8*** %5
%39 = getelementptr inbounds i8*, i8** %38, i64 %37
store i8** %39, i8*** %5
%40 = load i32, i32* %4
%41 = icmp ne i32 %40, 2
br i1 %41, label %42, label %44
42: ; preds = %31
%43 = call i32 (...) @usage()
store i32 -1, i32* %3
br label %117
44: ; preds = %31
%45 = load i8**, i8*** %5
%46 = getelementptr inbounds i8*, i8** %45, i64 0
%47 = load i8*, i8** %46
%48 = load i8**, i8*** %5
%49 = getelementptr inbounds i8*, i8** %48, i64 1
%50 = load i8*, i8** %49
%51 = call i32 @read_seq(i8* %47, i8* %50, i8** %6, i8** %7, i8** %8)
store i32 %51, i32* %10
%52 = load i32, i32* %10
%53 = icmp eq i32 %52, -2
br i1 %53, label %54, label %60
54: ; preds = %44
%55 = load i8**, i8*** %5
%56 = getelementptr inbounds i8*, i8** %55, i64 0
%57 = load i8*, i8** %56
%58 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %57)
%59 = load i32, i32* %10
store i32 %59, i32* %3
br label %117
60: ; preds = %44
%61 = load i32, i32* %10
%62 = icmp eq i32 %61, 0
br i1 %62, label %63, label %97
63: ; preds = %60
%64 = load i32, i32* %14
%65 = icmp ne i32 %64, 0
br i1 %65, label %87, label %66
66: ; preds = %63
%67 = load i32, i32* %12
%68 = icmp ne i32 %67, 0
br i1 %68, label %69, label %75
69: ; preds = %66
%70 = load i8**, i8*** %5
%71 = getelementptr inbounds i8*, i8** %70, i64 1
%72 = load i8*, i8** %71
%73 = load i8*, i8** %6
%74 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %72, i8* %73)
br label %86
75: ; preds = %66
%76 = load i8**, i8*** %5
%77 = getelementptr inbounds i8*, i8** %76, i64 1
%78 = load i8*, i8** %77
%79 = load i8*, i8** %6
%80 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %78, i8* %79)
%81 = load i8**, i8*** %5
%82 = getelementptr inbounds i8*, i8** %81, i64 1
%83 = load i8*, i8** %82
%84 = load i8*, i8** %7
%85 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %83, i8* %84)
br label %86
86: ; preds = %75, %69
br label %87
87: ; preds = %86, %63
%88 = load i8*, i8** %8
%89 = icmp ne i8* %88, null
br i1 %89, label %90, label %96
90: ; preds = %87
%91 = load i32, i32* %13
%92 = icmp ne i32 %91, 0
br i1 %92, label %93, label %96
93: ; preds = %90
%94 = load i8*, i8** %8
%95 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %94)
br label %96
96: ; preds = %93, %90, %87
br label %97
97: ; preds = %96, %60
%98 = load i8*, i8** %6
%99 = icmp ne i8* %98, null
br i1 %99, label %100, label %103
100: ; preds = %97
%101 = load i8*, i8** %6
%102 = call i32 @free(i8* %101)
store i8* null, i8** %6
br label %103
103: ; preds = %100, %97
%104 = load i8*, i8** %7
%105 = icmp ne i8* %104, null
br i1 %105, label %106, label %109
106: ; preds = %103
%107 = load i8*, i8** %7
%108 = call i32 @free(i8* %107)
store i8* null, i8** %7
br label %109
109: ; preds = %106, %103
%110 = load i8*, i8** %8
%111 = icmp ne i8* %110, null
br i1 %111, label %112, label %115
112: ; preds = %109
%113 = load i8*, i8** %8
%114 = call i32 @free(i8* %113)
store i8* null, i8** %8
br label %115
115: ; preds = %112, %109
%116 = load i32, i32* %10
store i32 %116, i32* %3
br label %117
117: ; preds = %115, %54, %42
%118 = load i32, i32* %3
ret i32 %118
}

LLVM IR (-O2):
@.str = [5 x i8] c"feEh\00"
@optind = global i64 0
@.str.1 = [41 x i8] c"Index file does not exist for: %s.index\0A\00"
@.str.2 = [8 x i8] c">%s\0A%s\0A\00"
@.str.3 = [8 x i8] c"@%s\0A%s\0A\00"
@.str.4 = [8 x i8] c"+%s\0A%s\0A\00"
@.str.5 = [11 x i8] c"EXTRAS:%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%7 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%8 = bitcast i8** %5 to i8*
store i8* null, i8** %5
br label %9
9: ; preds = %18, %2
%10 = phi i1 [ true, %2 ], [ false, %18 ]
%11 = phi i32 [ 0, %2 ], [ %17, %18 ]
%12 = phi i32 [ 0, %2 ], [ %15, %18 ]
br label %13
13: ; preds = %18, %9
%14 = phi i32 [ %11, %9 ], [ 1, %18 ]
%15 = phi i32 [ %12, %9 ], [ 1, %18 ]
br label %16
16: ; preds = %18, %13
%17 = phi i32 [ %14, %13 ], [ 1, %18 ]
br label %18
18: ; preds = %24, %16
%19 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
switch i32 %19, label %22 [
i32 -1, label %25
i32 102, label %9
i32 101, label %16
i32 69, label %13
i32 104, label %20
]
20: ; preds = %18
%21 = tail call i32 (...) @usage()
br label %24
22: ; preds = %18
%23 = tail call i32 (...) @usage()
br label %24
24: ; preds = %22, %20
br label %18
25: ; preds = %18
%26 = load i64, i64* @optind
%27 = trunc i64 %26 to i32
%28 = sub i32 %0, %27
%29 = getelementptr inbounds i8*, i8** %1, i64 %26
%30 = icmp eq i32 %28, 2
br i1 %30, label %33, label %31
31: ; preds = %25
%32 = tail call i32 (...) @usage()
br label %75
33: ; preds = %25
%34 = load i8*, i8** %29
%35 = getelementptr inbounds i8*, i8** %29, i64 1
%36 = load i8*, i8** %35
%37 = call i32 @read_seq(i8* %34, i8* %36, i8** %3, i8** %4, i8** %5)
switch i32 %37, label %60 [
i32 -2, label %38
i32 0, label %41
]
38: ; preds = %33
%39 = load i8*, i8** %29
%40 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i8* %39)
br label %75
41: ; preds = %33
%42 = icmp eq i32 %15, 0
br i1 %42, label %43, label %53
43: ; preds = %41
%44 = load i8*, i8** %35
%45 = load i8*, i8** %3
br i1 %10, label %48, label %46
46: ; preds = %43
%47 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %44, i8* %45)
br label %53
48: ; preds = %43
%49 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8* %44, i8* %45)
%50 = load i8*, i8** %35
%51 = load i8*, i8** %4
%52 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %50, i8* %51)
br label %53
53: ; preds = %46, %48, %41
%54 = load i8*, i8** %5
%55 = icmp ne i8* %54, null
%56 = icmp ne i32 %17, 0
%57 = select i1 %55, i1 %56, i1 false
br i1 %57, label %58, label %60
58: ; preds = %53
%59 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0), i8* %54)
br label %60
60: ; preds = %33, %53, %58
%61 = load i8*, i8** %3
%62 = icmp eq i8* %61, null
br i1 %62, label %65, label %63
63: ; preds = %60
%64 = call i32 @free(i8* %61)
store i8* null, i8** %3
br label %65
65: ; preds = %63, %60
%66 = load i8*, i8** %4
%67 = icmp eq i8* %66, null
br i1 %67, label %70, label %68
68: ; preds = %65
%69 = call i32 @free(i8* %66)
store i8* null, i8** %4
br label %70
70: ; preds = %68, %65
%71 = load i8*, i8** %5
%72 = icmp eq i8* %71, null
br i1 %72, label %75, label %73
73: ; preds = %70
%74 = call i32 @free(i8* %71)
br label %75
75: ; preds = %70, %73, %38, %31
%76 = phi i32 [ -1, %31 ], [ -2, %38 ], [ %37, %73 ], [ %37, %70 ]
ret i32 %76
}