#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 */
struct file_data {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ close_sequential_reads(struct file_data *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ initialize_sequential_reads(struct file_data **, char *);
int /*<<< orphan*/ printf(char *, char *, ...);
int read_data_sequential(struct file_data *, char **, char **, char **,
                         char **);
int main(int argc, char *argv[]) {
  char *fasta = NULL;
  char *qual = NULL;
  char *extras = NULL;
  int size = 5000;
  int res = 0;
  struct file_data *filed = NULL;
  if (argc != 2) {
    printf("Usage %s fbin_file\n\n", argv[0]);
    return -1;
  }
  initialize_sequential_reads(&filed, argv[1]);
  char *sname = NULL;
  while ((res = read_data_sequential(filed, &sname, &fasta, &qual, &extras)) ==
         0) {
    if (res == 0) {
      printf(">%s\n%s\n", sname, fasta);
      printf("%s\n", qual);
      if (extras != NULL)
        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;
    }
  }
  close_sequential_reads(filed);
  return res;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%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)
movq   $0x0,-0x38(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11bf <main+0x6f>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe54(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12b9 <main+0x169>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    -0x38(%rbp),%rdi
call   1070 <initialize_sequential_reads@plt>
movq   $0x0,-0x40(%rbp)
mov    -0x38(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rcx
lea    -0x28(%rbp),%r8
call   1050 <read_data_sequential@plt>
mov    %eax,-0x30(%rbp)
cmp    $0x0,%eax
jne    12aa <main+0x15a>
cmpl   $0x0,-0x30(%rbp)
jne    1251 <main+0x101>
mov    -0x40(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rsi
lea    0xdf1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpq   $0x0,-0x28(%rbp)
je     124c <main+0xfc>
mov    -0x28(%rbp),%rsi
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1251 <main+0x101>
cmpq   $0x0,-0x18(%rbp)
je     126d <main+0x11d>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x18(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1289 <main+0x139>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x20(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12a5 <main+0x155>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x28(%rbp)
jmp    11d8 <main+0x88>
mov    -0x38(%rbp),%rdi
call   1060 <close_sequential_reads@plt>
mov    -0x30(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
movq   $0x0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
movq   $0x0,0x18(%rsp)
cmp    $0x2,%edi
jne    129b <main+0x14b>
mov    0x8(%rsi),%rsi
lea    0x18(%rsp),%rdi
call   1070 <initialize_sequential_reads@plt>
movq   $0x0,0x20(%rsp)
mov    0x18(%rsp),%rdi
lea    0x20(%rsp),%rsi
lea    0x10(%rsp),%rdx
lea    0x8(%rsp),%rcx
mov    %rsp,%r8
call   1050 <read_data_sequential@plt>
mov    %eax,%r14d
test   %eax,%eax
jne    12b7 <main+0x167>
lea    0xe4a(%rip),%r15
lea    0x20(%rsp),%r12
lea    0x10(%rsp),%r13
lea    0x8(%rsp),%rbx
mov    %rsp,%rbp
jmp    120e <main+0xbe>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x18(%rsp),%rdi
mov    %r12,%rsi
mov    %r13,%rdx
mov    %rbx,%rcx
mov    %rbp,%r8
call   1050 <read_data_sequential@plt>
test   %eax,%eax
jne    12b4 <main+0x164>
mov    0x20(%rsp),%rsi
mov    0x10(%rsp),%rdx
lea    0xdf6(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%rsi
test   %rsi,%rsi
je     124c <main+0xfc>
lea    0xdd8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%rdi
test   %rdi,%rdi
je     1264 <main+0x114>
call   1030 <free@plt>
movq   $0x0,0x10(%rsp)
mov    0x8(%rsp),%rdi
test   %rdi,%rdi
je     127c <main+0x12c>
call   1030 <free@plt>
movq   $0x0,0x8(%rsp)
mov    (%rsp),%rdi
test   %rdi,%rdi
je     11f0 <main+0xa0>
call   1030 <free@plt>
movq   $0x0,(%rsp)
jmp    11f0 <main+0xa0>
mov    (%rsi),%rsi
lea    0xd5b(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%r14d
jmp    12c1 <main+0x171>
mov    %eax,%r14d
mov    0x18(%rsp),%rdi
call   1060 <close_sequential_reads@plt>
mov    %r14d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.file_data = type { i32 }
@.str = [21 x i8] c"Usage %s fbin_file\0A\0A\00"
@.str.1 = [8 x i8] c">%s\0A%s\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [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 %struct.file_data*
%12 = alloca i8*
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 %struct.file_data* null, %struct.file_data** %11
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 2
br i1 %14, label %15, label %20
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %18)
store i32 -1, i32* %3
br label %67
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @initialize_sequential_reads(%struct.file_data** %11, i8* %23)
store i8* null, i8** %12
br label %25
25: ; preds = %62, %20
%26 = load %struct.file_data*, %struct.file_data** %11
%27 = call i32 @read_data_sequential(%struct.file_data* %26, i8** %12, i8** %6, i8** %7, i8** %8)
store i32 %27, i32* %10
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %63
29: ; preds = %25
%30 = load i32, i32* %10
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %44
32: ; preds = %29
%33 = load i8*, i8** %12
%34 = load i8*, i8** %6
%35 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %33, i8* %34)
%36 = load i8*, i8** %7
%37 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %36)
%38 = load i8*, i8** %8
%39 = icmp ne i8* %38, null
br i1 %39, label %40, label %43
40: ; preds = %32
%41 = load i8*, i8** %8
%42 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %41)
br label %43
43: ; preds = %40, %32
br label %44
44: ; preds = %43, %29
%45 = load i8*, i8** %6
%46 = icmp ne i8* %45, null
br i1 %46, label %47, label %50
47: ; preds = %44
%48 = load i8*, i8** %6
%49 = call i32 @free(i8* %48)
store i8* null, i8** %6
br label %50
50: ; preds = %47, %44
%51 = load i8*, i8** %7
%52 = icmp ne i8* %51, null
br i1 %52, label %53, label %56
53: ; preds = %50
%54 = load i8*, i8** %7
%55 = call i32 @free(i8* %54)
store i8* null, i8** %7
br label %56
56: ; preds = %53, %50
%57 = load i8*, i8** %8
%58 = icmp ne i8* %57, null
br i1 %58, label %59, label %62
59: ; preds = %56
%60 = load i8*, i8** %8
%61 = call i32 @free(i8* %60)
store i8* null, i8** %8
br label %62
62: ; preds = %59, %56
br label %25
63: ; preds = %25
%64 = load %struct.file_data*, %struct.file_data** %11
%65 = call i32 @close_sequential_reads(%struct.file_data* %64)
%66 = load i32, i32* %10
store i32 %66, i32* %3
br label %67
67: ; preds = %63, %15
%68 = load i32, i32* %3
ret i32 %68
}

LLVM IR (-O2):
%struct.file_data = type { i32 }
@.str = [21 x i8] c"Usage %s fbin_file\0A\0A\00"
@.str.1 = [8 x i8] c">%s\0A%s\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [11 x i8] c"extras:%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca %struct.file_data*
%7 = alloca i8*
%8 = bitcast i8** %3 to i8*
store i8* null, i8** %3
%9 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%10 = bitcast i8** %5 to i8*
store i8* null, i8** %5
%11 = bitcast %struct.file_data** %6 to i8*
store %struct.file_data* null, %struct.file_data** %6
%12 = icmp eq i32 %0, 2
br i1 %12, label %16, label %13
13: ; preds = %2
%14 = load i8*, i8** %1
%15 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %14)
br label %57
16: ; preds = %2
%17 = getelementptr inbounds i8*, i8** %1, i64 1
%18 = load i8*, i8** %17
%19 = call i32 @initialize_sequential_reads(%struct.file_data** %6, i8* %18)
%20 = bitcast i8** %7 to i8*
store i8* null, i8** %7
%21 = load %struct.file_data*, %struct.file_data** %6
%22 = call i32 @read_data_sequential(%struct.file_data* %21, i8** %7, i8** %3, i8** %4, i8** %5)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %53
24: ; preds = %16, %49
%25 = load i8*, i8** %7
%26 = load i8*, i8** %3
%27 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %25, i8* %26)
%28 = load i8*, i8** %4
%29 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %28)
%30 = load i8*, i8** %5
%31 = icmp eq i8* %30, null
br i1 %31, label %34, label %32
32: ; preds = %24
%33 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), i8* %30)
br label %34
34: ; preds = %24, %32
%35 = load i8*, i8** %3
%36 = icmp eq i8* %35, null
br i1 %36, label %39, label %37
37: ; preds = %34
%38 = call i32 @free(i8* %35)
store i8* null, i8** %3
br label %39
39: ; preds = %37, %34
%40 = load i8*, i8** %4
%41 = icmp eq i8* %40, null
br i1 %41, label %44, label %42
42: ; preds = %39
%43 = call i32 @free(i8* %40)
store i8* null, i8** %4
br label %44
44: ; preds = %42, %39
%45 = load i8*, i8** %5
%46 = icmp eq i8* %45, null
br i1 %46, label %49, label %47
47: ; preds = %44
%48 = call i32 @free(i8* %45)
store i8* null, i8** %5
br label %49
49: ; preds = %47, %44
%50 = load %struct.file_data*, %struct.file_data** %6
%51 = call i32 @read_data_sequential(%struct.file_data* %50, i8** %7, i8** %3, i8** %4, i8** %5)
%52 = icmp eq i32 %51, 0
br i1 %52, label %24, label %53
53: ; preds = %49, %16
%54 = phi i32 [ %22, %16 ], [ %51, %49 ]
%55 = load %struct.file_data*, %struct.file_data** %6
%56 = call i32 @close_sequential_reads(%struct.file_data* %55)
br label %57
57: ; preds = %53, %13
%58 = phi i32 [ -1, %13 ], [ %54, %53 ]
ret i32 %58
}