#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ isnuc(char);
int /*<<< orphan*/ printf(char *, char *);
int strlen(char *);
void readseq(char filename[], char seq[]) {
  FILE *file;
  int i;
  char line[100];
  int j;
  file = fopen(filename, "r");
  if (file == NULL) {
    printf("Error: file %s does not exist!\n", filename);
    exit(1);
  }
  i = 0;
  while (fgets(line, sizeof line, file)) {
    if (line[0] == '>')
      continue;
    for (j = 0; j < strlen(line); j++) {
      if (isnuc(line[j]))
        seq[i++] = line[j];
    }
  }
  seq[i] = '\0';
  fclose(file);
}


x86 assembly (clang, -O0):
<readseq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe72(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11bc <readseq+0x4c>
mov    -0x8(%rbp),%rsi
lea    0xe55(%rip),%rdi
call   1060 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
movl   $0x0,-0x1c(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x64,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     1279 <readseq+0x109>
movsbl -0x80(%rbp),%eax
cmp    $0x3e,%eax
jne    11f1 <readseq+0x81>
jmp    11c3 <readseq+0x53>
movl   $0x0,-0x84(%rbp)
mov    -0x84(%rbp),%eax
mov    %eax,-0x88(%rbp)
lea    -0x80(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x88(%rbp),%eax
cmp    %ecx,%eax
jge    1274 <readseq+0x104>
movslq -0x84(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%edi
call   1050 <isnuc@plt>
cmp    $0x0,%rax
je     125b <readseq+0xeb>
movslq -0x84(%rbp),%rax
mov    -0x80(%rbp,%rax,1),%dl
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x1c(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    1260 <readseq+0xf0>
mov    -0x84(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x84(%rbp)
jmp    11fb <readseq+0x8b>
jmp    11c3 <readseq+0x53>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readseq>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x70,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xe76(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1232 <readseq+0xc2>
mov    %rax,%rbx
xor    %r12d,%r12d
mov    %rsp,%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    $0x64,%esi
mov    %rbx,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     1214 <readseq+0xa4>
cmpb   $0x3e,(%rsp)
je     11b0 <readseq+0x40>
mov    %r15,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    11b0 <readseq+0x40>
xor    %r13d,%r13d
jmp    11f3 <readseq+0x83>
nopl   0x0(%rax)
add    $0x1,%r13
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%r13
jge    11b0 <readseq+0x40>
movsbl (%rsp,%r13,1),%edi
call   1050 <isnuc@plt>
test   %rax,%rax
je     11e0 <readseq+0x70>
movzbl (%rsp,%r13,1),%eax
movslq %r12d,%rcx
add    $0x1,%r12d
mov    %al,(%r14,%rcx,1)
jmp    11e0 <readseq+0x70>
movslq %r12d,%rax
movb   $0x0,(%r14,%rax,1)
mov    %rbx,%rdi
call   1030 <fclose@plt>
add    $0x70,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xdc9(%rip),%rdi
mov    %r15,%rsi
call   1060 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [32 x i8] c"Error: file %s does not exist!\0A\00"
define void @readseq(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca [100 x i8]
%8 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%9 = load i8*, i8** %3
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %10, i32** %5
%11 = load i32*, i32** %5
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = load i8*, i8** %3
%15 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %2
store i32 0, i32* %6
br label %18
18: ; preds = %56, %28, %17
%19 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%20 = load i32*, i32** %5
%21 = call i64 @fgets(i8* %19, i32 100, i32* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %57
23: ; preds = %18
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 62
br i1 %27, label %28, label %29
28: ; preds = %23
br label %18
29: ; preds = %23
store i32 0, i32* %8
br label %30
30: ; preds = %53, %29
%31 = load i32, i32* %8
%32 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 0
%33 = call i32 @strlen(i8* %32)
%34 = icmp slt i32 %31, %33
br i1 %34, label %35, label %56
35: ; preds = %30
%36 = load i32, i32* %8
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = call i64 @isnuc(i8 signext %39)
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %52
42: ; preds = %35
%43 = load i32, i32* %8
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds [100 x i8], [100 x i8]* %7, i64 0, i64 %44
%46 = load i8, i8* %45
%47 = load i8*, i8** %4
%48 = load i32, i32* %6
%49 = add nsw i32 %48, 1
store i32 %49, i32* %6
%50 = sext i32 %48 to i64
%51 = getelementptr inbounds i8, i8* %47, i64 %50
store i8 %46, i8* %51
br label %52
52: ; preds = %42, %35
br label %53
53: ; preds = %52
%54 = load i32, i32* %8
%55 = add nsw i32 %54, 1
store i32 %55, i32* %8
br label %30
56: ; preds = %30
br label %18
57: ; preds = %18
%58 = load i8*, i8** %4
%59 = load i32, i32* %6
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8, i8* %58, i64 %60
store i8 0, i8* %61
%62 = load i32*, i32** %5
%63 = call i32 @fclose(i32* %62)
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [32 x i8] c"Error: file %s does not exist!\0A\00"
define void @readseq(i8* %0, i8* nocapture writeonly %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %34, %2
%11 = phi i32 [ 0, %2 ], [ %35, %34 ]
br label %12
12: ; preds = %10, %19
br label %13
13: ; preds = %12, %16
%14 = call i64 @fgets(i8* %4, i32 100, i32* %5)
%15 = icmp eq i64 %14, 0
br i1 %15, label %40, label %16
16: ; preds = %13
%17 = load i8, i8* %4
%18 = icmp eq i8 %17, 62
br i1 %18, label %13, label %19
19: ; preds = %16
%20 = call i32 @strlen(i8* %4)
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %12
22: ; preds = %19, %34
%23 = phi i64 [ %36, %34 ], [ 0, %19 ]
%24 = phi i32 [ %35, %34 ], [ %11, %19 ]
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 %23
%26 = load i8, i8* %25
%27 = call i64 @isnuc(i8 signext %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %34, label %29
29: ; preds = %22
%30 = load i8, i8* %25
%31 = add nsw i32 %24, 1
%32 = sext i32 %24 to i64
%33 = getelementptr inbounds i8, i8* %1, i64 %32
store i8 %30, i8* %33
br label %34
34: ; preds = %22, %29
%35 = phi i32 [ %31, %29 ], [ %24, %22 ]
%36 = add nuw nsw i64 %23, 1
%37 = call i32 @strlen(i8* %4)
%38 = sext i32 %37 to i64
%39 = icmp slt i64 %36, %38
br i1 %39, label %22, label %10
40: ; preds = %13
%41 = sext i32 %11 to i64
%42 = getelementptr inbounds i8, i8* %1, i64 %41
store i8 0, i8* %42
%43 = call i32 @fclose(i32* %5)
ret void
}