#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*/ ChompStr(char *);
char *Srealloc(char *, scalar_t__);
int /*<<< orphan*/ StrTolower(char *);
int /*<<< orphan*/ *fgets(char *, int const, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
char *strcat(char *, char *);
char *strdup(char *);
scalar_t__ strlen(char *);
char *strndup(char *, scalar_t__);
int /*<<< orphan*/ *strstr(char *, char const *);
char *RnaFoldPs_GetSequence(FILE *fd) {
  const int max_line_length = 1024;
  char *seq;
  char line[max_line_length];
  const char seq_start[] = "/sequence ";
  const char seq_end[] = " def";
  char *cpstr;
  int inseq;
  seq = NULL;
  inseq = 0;
  while (fgets(line, max_line_length, fd) != NULL) {
    ChompStr(line);
    if (strstr(line, seq_start) != NULL) {
      inseq = 1;
      continue;
    }
    if (inseq) {
      if (strstr(line, seq_end) != NULL) {
        StrTolower(seq);
        break;
      }
      cpstr = strndup(line, strlen(line) - 1);
      if (seq != NULL) {
        seq = Srealloc(seq, strlen(seq) + 1 + strlen(cpstr));
        seq = strcat(seq, cpstr);
      } else {
        seq = strdup(cpstr);
      }
      free(cpstr);
    }
  }
  return seq;
}


x86 assembly (clang, -O0):
<RnaFoldPs_GetSequence>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x400,-0xc(%rbp)
mov    %rsp,%rax
mov    %rax,-0x20(%rbp)
mov    0xe3c(%rip),%rax
mov    %rax,-0x2b(%rbp)
mov    0xe39(%rip),%ax
mov    %ax,-0x23(%rbp)
mov    0xe31(%rip),%al
mov    %al,-0x21(%rbp)
mov    0xe29(%rip),%eax
mov    %eax,-0x30(%rbp)
mov    0xe24(%rip),%al
mov    %al,-0x2c(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x8(%rbp),%rdx
lea    -0x440(%rbp),%rdi
mov    $0x400,%esi
call   1060 <fgets@plt>
cmp    $0x0,%rax
je     1321 <RnaFoldPs_GetSequence+0x181>
lea    -0x440(%rbp),%rdi
call   1090 <ChompStr@plt>
lea    -0x2b(%rbp),%rsi
lea    -0x440(%rbp),%rdi
call   10c0 <strstr@plt>
cmp    $0x0,%rax
je     124e <RnaFoldPs_GetSequence+0xae>
movl   $0x1,-0x3c(%rbp)
jmp    11fd <RnaFoldPs_GetSequence+0x5d>
cmpl   $0x0,-0x3c(%rbp)
je     131c <RnaFoldPs_GetSequence+0x17c>
lea    -0x30(%rbp),%rsi
lea    -0x440(%rbp),%rdi
call   10c0 <strstr@plt>
cmp    $0x0,%rax
je     1280 <RnaFoldPs_GetSequence+0xe0>
mov    -0x18(%rbp),%rdi
call   10a0 <StrTolower@plt>
jmp    1321 <RnaFoldPs_GetSequence+0x181>
lea    -0x440(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,%rsi
sub    $0x1,%rsi
lea    -0x440(%rbp),%rdi
call   1050 <strndup@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1306 <RnaFoldPs_GetSequence+0x166>
mov    -0x18(%rbp),%rax
mov    %rax,-0x448(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x1,%rax
mov    %rax,-0x450(%rbp)
mov    -0x38(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x450(%rbp),%rsi
mov    -0x448(%rbp),%rdi
add    %rax,%rsi
call   1080 <Srealloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1070 <strcat@plt>
mov    %rax,-0x18(%rbp)
jmp    1313 <RnaFoldPs_GetSequence+0x173>
mov    -0x38(%rbp),%rdi
call   10b0 <strdup@plt>
mov    %rax,-0x18(%rbp)
mov    -0x38(%rbp),%rdi
call   1030 <free@plt>
jmp    11fd <RnaFoldPs_GetSequence+0x5d>
mov    -0x18(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rcx,%rsp
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RnaFoldPs_GetSequence>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x418,%rsp
mov    %rdi,%r14
xor    %r15d,%r15d
lea    0x10(%rsp),%rbx
lea    0xe3d(%rip),%r12
lea    0xe41(%rip),%r13
xor    %ebp,%ebp
mov    %ebp,%ecx
xchg   %ax,%ax
mov    %ecx,%ebp
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r14,%rdx
call   1060 <fgets@plt>
test   %rax,%rax
je     1297 <RnaFoldPs_GetSequence+0xf7>
mov    %rbx,%rdi
call   1090 <ChompStr@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   10c0 <strstr@plt>
mov    $0x1,%ecx
test   %rax,%rax
jne    11d0 <RnaFoldPs_GetSequence+0x30>
test   %ebp,%ebp
je     11cc <RnaFoldPs_GetSequence+0x2c>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10c0 <strstr@plt>
test   %rax,%rax
jne    128f <RnaFoldPs_GetSequence+0xef>
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    -0x1(%rax),%rsi
mov    %rbx,%rdi
call   1050 <strndup@plt>
mov    %rax,(%rsp)
test   %r15,%r15
je     1275 <RnaFoldPs_GetSequence+0xd5>
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %rax,0x8(%rsp)
mov    (%rsp),%rdi
call   1040 <strlen@plt>
mov    0x8(%rsp),%rcx
lea    (%rcx,%rax,1),%rsi
add    $0x1,%rsi
mov    %r15,%rdi
call   1080 <Srealloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    (%rsp),%rsi
call   1070 <strcat@plt>
jmp    1281 <RnaFoldPs_GetSequence+0xe1>
mov    (%rsp),%rdi
call   10b0 <strdup@plt>
mov    %rax,%r15
mov    (%rsp),%rdi
call   1030 <free@plt>
jmp    11cc <RnaFoldPs_GetSequence+0x2c>
mov    %r15,%rdi
call   10a0 <StrTolower@plt>
mov    %r15,%rax
add    $0x418,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.RnaFoldPs_GetSequence.seq_start = [11 x i8] c"/sequence \00"
@__const.RnaFoldPs_GetSequence.seq_end = [5 x i8] c" def\00"
define i8* @RnaFoldPs_GetSequence(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca [11 x i8]
%7 = alloca [5 x i8]
%8 = alloca i8*
%9 = alloca i32
store i32* %0, i32** %2
store i32 1024, i32* %3
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %5
%11 = alloca i8, i64 1024
%12 = bitcast [11 x i8]* %6 to i8*
%13 = bitcast [5 x i8]* %7 to i8*
store i8* null, i8** %4
store i32 0, i32* %9
br label %14
14: ; preds = %58, %23, %1
%15 = load i32*, i32** %2
%16 = call i32* @fgets(i8* %11, i32 1024, i32* %15)
%17 = icmp ne i32* %16, null
br i1 %17, label %18, label %59
18: ; preds = %14
%19 = call i32 @ChompStr(i8* %11)
%20 = getelementptr inbounds [11 x i8], [11 x i8]* %6, i64 0, i64 0
%21 = call i32* @strstr(i8* %11, i8* %20)
%22 = icmp ne i32* %21, null
br i1 %22, label %23, label %24
23: ; preds = %18
store i32 1, i32* %9
br label %14
24: ; preds = %18
%25 = load i32, i32* %9
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %58
27: ; preds = %24
%28 = getelementptr inbounds [5 x i8], [5 x i8]* %7, i64 0, i64 0
%29 = call i32* @strstr(i8* %11, i8* %28)
%30 = icmp ne i32* %29, null
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = load i8*, i8** %4
%33 = call i32 @StrTolower(i8* %32)
br label %59
34: ; preds = %27
%35 = call i64 @strlen(i8* %11)
%36 = sub nsw i64 %35, 1
%37 = call i8* @strndup(i8* %11, i64 %36)
store i8* %37, i8** %8
%38 = load i8*, i8** %4
%39 = icmp ne i8* %38, null
br i1 %39, label %40, label %52
40: ; preds = %34
%41 = load i8*, i8** %4
%42 = load i8*, i8** %4
%43 = call i64 @strlen(i8* %42)
%44 = add nsw i64 %43, 1
%45 = load i8*, i8** %8
%46 = call i64 @strlen(i8* %45)
%47 = add nsw i64 %44, %46
%48 = call i8* @Srealloc(i8* %41, i64 %47)
store i8* %48, i8** %4
%49 = load i8*, i8** %4
%50 = load i8*, i8** %8
%51 = call i8* @strcat(i8* %49, i8* %50)
store i8* %51, i8** %4
br label %55
52: ; preds = %34
%53 = load i8*, i8** %8
%54 = call i8* @strdup(i8* %53)
store i8* %54, i8** %4
br label %55
55: ; preds = %52, %40
%56 = load i8*, i8** %8
%57 = call i32 @free(i8* %56)
br label %58
58: ; preds = %55, %24
br label %14
59: ; preds = %31, %14
%60 = load i8*, i8** %4
%61 = load i8*, i8** %5
ret i8* %60
}

LLVM IR (-O2):
@__const.RnaFoldPs_GetSequence.seq_start = [11 x i8] c"/sequence \00"
@__const.RnaFoldPs_GetSequence.seq_end = [5 x i8] c" def\00"
define i8* @RnaFoldPs_GetSequence(i32* nocapture %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
br label %4
4: ; preds = %38, %1
%5 = phi i8* [ %39, %38 ], [ null, %1 ]
%6 = phi i32 [ %10, %38 ], [ 0, %1 ]
br label %7
7: ; preds = %4, %17
%8 = phi i32 [ %10, %17 ], [ %6, %4 ]
br label %9
9: ; preds = %7, %13
%10 = phi i32 [ 1, %13 ], [ %8, %7 ]
%11 = call i32* @fgets(i8* %3, i32 1024, i32* %0)
%12 = icmp eq i32* %11, null
br i1 %12, label %41, label %13
13: ; preds = %9
%14 = call i32 @ChompStr(i8* %3)
%15 = call i32* @strstr(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @__const.RnaFoldPs_GetSequence.seq_start, i64 0, i64 0))
%16 = icmp eq i32* %15, null
br i1 %16, label %17, label %9
17: ; preds = %13
%18 = icmp eq i32 %10, 0
br i1 %18, label %7, label %19
19: ; preds = %17
%20 = call i32* @strstr(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @__const.RnaFoldPs_GetSequence.seq_end, i64 0, i64 0))
%21 = icmp eq i32* %20, null
br i1 %21, label %24, label %22
22: ; preds = %19
%23 = call i32 @StrTolower(i8* %5)
br label %41
24: ; preds = %19
%25 = call i64 @strlen(i8* %3)
%26 = add nsw i64 %25, -1
%27 = call i8* @strndup(i8* %3, i64 %26)
%28 = icmp eq i8* %5, null
br i1 %28, label %36, label %29
29: ; preds = %24
%30 = call i64 @strlen(i8* %5)
%31 = add nsw i64 %30, 1
%32 = call i64 @strlen(i8* dereferenceable(1) %27)
%33 = add nsw i64 %31, %32
%34 = call i8* @Srealloc(i8* %5, i64 %33)
%35 = call i8* @strcat(i8* dereferenceable(1) %34, i8* dereferenceable(1) %27)
br label %38
36: ; preds = %24
%37 = call i8* @strdup(i8* %27)
br label %38
38: ; preds = %36, %29
%39 = phi i8* [ %34, %29 ], [ %37, %36 ]
%40 = call i32 @free(i8* %27)
br label %4
41: ; preds = %9, %22
ret i8* %5
}