#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);
scalar_t__ feof(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
scalar_t__ isalpha(char);
int /*<<< orphan*/ isspace(char);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
char toupper(char);
int cntlets(FILE *input, int lettersonly) {
  int numread = 0;
  char temp[1024];
  char currchar = '~';
  rewind(input);
  if (feof(input))
    return 0;
  fgets(temp, 1024, input);
  if (temp[0] != '>') {
    fprintf(stderr, "File is not in FASTA format!!\n");
    exit(1);
  }
  currchar = fgetc(input);
  while ((currchar != '>') && !feof(input)) {
    if (!isspace(currchar)) {
      currchar = toupper(currchar);
      if (!lettersonly || isalpha(currchar)) {
        numread++;
      }
    }
    currchar = fgetc(input);
  }
  rewind(input);
  return numread;
}


x86 assembly (clang, -O0):
<cntlets>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movb   $0x7e,-0x421(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <rewind@plt>
mov    -0x10(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%rax
je     11d8 <cntlets+0x48>
movl   $0x0,-0x4(%rbp)
jmp    12e6 <cntlets+0x156>
lea    -0x420(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x400,%esi
call   1070 <fgets@plt>
movsbl -0x420(%rbp),%eax
cmp    $0x3e,%eax
je     121c <cntlets+0x8c>
mov    0x2ddc(%rip),%rax
mov    (%rax),%edi
lea    0xdf3(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x421(%rbp)
movsbl -0x421(%rbp),%ecx
xor    %eax,%eax
cmp    $0x3e,%ecx
mov    %al,-0x422(%rbp)
je     125b <cntlets+0xcb>
mov    -0x10(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
mov    %al,-0x422(%rbp)
mov    -0x422(%rbp),%al
test   $0x1,%al
jne    126e <cntlets+0xde>
jmp    12d7 <cntlets+0x147>
movsbl -0x421(%rbp),%edi
call   1060 <isspace@plt>
cmp    $0x0,%eax
jne    12c3 <cntlets+0x133>
movsbl -0x421(%rbp),%edi
call   1030 <toupper@plt>
mov    %al,-0x421(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     12b5 <cntlets+0x125>
movsbl -0x421(%rbp),%edi
call   10a0 <isalpha@plt>
cmp    $0x0,%rax
je     12be <cntlets+0x12e>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    12c3 <cntlets+0x133>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x421(%rbp)
jmp    122b <cntlets+0x9b>
mov    -0x10(%rbp),%rdi
call   1040 <rewind@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cntlets>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %esi,%r14d
mov    %rdi,%rbp
call   1040 <rewind@plt>
mov    %rbp,%rdi
call   1090 <feof@plt>
xor    %r15d,%r15d
test   %rax,%rax
jne    11e5 <cntlets+0x55>
mov    %rsp,%rdi
mov    $0x400,%esi
mov    %rbp,%rdx
call   1070 <fgets@plt>
cmpb   $0x3e,(%rsp)
jne    1248 <cntlets+0xb8>
mov    %rbp,%rdi
call   1050 <fgetc@plt>
xor    %r15d,%r15d
cmp    $0x3e,%al
jne    11f6 <cntlets+0x66>
mov    %rbp,%rdi
call   1040 <rewind@plt>
mov    %r15d,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %eax,%ebx
xor    %r15d,%r15d
jmp    1212 <cntlets+0x82>
nopl   (%rax)
add    $0x1,%r15d
mov    %rbp,%rdi
call   1050 <fgetc@plt>
mov    %eax,%ebx
cmp    $0x3e,%al
je     11dd <cntlets+0x4d>
mov    %rbp,%rdi
call   1090 <feof@plt>
test   %rax,%rax
jne    11dd <cntlets+0x4d>
movsbl %bl,%ebx
mov    %ebx,%edi
call   1060 <isspace@plt>
test   %eax,%eax
jne    1204 <cntlets+0x74>
mov    %ebx,%edi
call   1030 <toupper@plt>
test   %r14d,%r14d
je     1200 <cntlets+0x70>
movsbl %al,%edi
call   10a0 <isalpha@plt>
test   %rax,%rax
jne    1200 <cntlets+0x70>
jmp    1204 <cntlets+0x74>
mov    0x2d91(%rip),%rax
mov    (%rax),%edi
lea    0xda8(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [31 x i8] c"File is not in FASTA format!!\0A\00"
define i32 @cntlets(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [1024 x i8]
%8 = alloca i8
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 0, i32* %6
store i8 126, i8* %8
%9 = load i32*, i32** %4
%10 = call i32 @rewind(i32* %9)
%11 = load i32*, i32** %4
%12 = call i64 @feof(i32* %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %2
store i32 0, i32* %3
br label %65
15: ; preds = %2
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%17 = load i32*, i32** %4
%18 = call i32 @fgets(i8* %16, i32 1024, i32* %17)
%19 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 62
br i1 %22, label %23, label %27
23: ; preds = %15
%24 = load i32, i32* @stderr
%25 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%26 = call i32 @exit(i32 1)
unreachable
27: ; preds = %15
%28 = load i32*, i32** %4
%29 = call signext i8 @fgetc(i32* %28)
store i8 %29, i8* %8
br label %30
30: ; preds = %58, %27
%31 = load i8, i8* %8
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 62
br i1 %33, label %34, label %39
34: ; preds = %30
%35 = load i32*, i32** %4
%36 = call i64 @feof(i32* %35)
%37 = icmp ne i64 %36, 0
%38 = xor i1 %37, true
br label %39
39: ; preds = %34, %30
%40 = phi i1 [ false, %30 ], [ %38, %34 ]
br i1 %40, label %41, label %61
41: ; preds = %39
%42 = load i8, i8* %8
%43 = call i32 @isspace(i8 signext %42)
%44 = icmp ne i32 %43, 0
br i1 %44, label %58, label %45
45: ; preds = %41
%46 = load i8, i8* %8
%47 = call signext i8 @toupper(i8 signext %46)
store i8 %47, i8* %8
%48 = load i32, i32* %5
%49 = icmp ne i32 %48, 0
br i1 %49, label %50, label %54
50: ; preds = %45
%51 = load i8, i8* %8
%52 = call i64 @isalpha(i8 signext %51)
%53 = icmp ne i64 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %50, %45
%55 = load i32, i32* %6
%56 = add nsw i32 %55, 1
store i32 %56, i32* %6
br label %57
57: ; preds = %54, %50
br label %58
58: ; preds = %57, %41
%59 = load i32*, i32** %4
%60 = call signext i8 @fgetc(i32* %59)
store i8 %60, i8* %8
br label %30
61: ; preds = %39
%62 = load i32*, i32** %4
%63 = call i32 @rewind(i32* %62)
%64 = load i32, i32* %6
store i32 %64, i32* %3
br label %65
65: ; preds = %61, %14
%66 = load i32, i32* %3
ret i32 %66
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [31 x i8] c"File is not in FASTA format!!\0A\00"
define i32 @cntlets(i32* nocapture %0, i32 %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @rewind(i32* %0)
%6 = tail call i64 @feof(i32* %0)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %43
8: ; preds = %2
%9 = call i32 @fgets(i8* %4, i32 1024, i32* %0)
%10 = load i8, i8* %4
%11 = icmp eq i8 %10, 62
br i1 %11, label %16, label %12
12: ; preds = %8
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %8
%17 = call signext i8 @fgetc(i32* %0)
%18 = icmp eq i8 %17, 62
br i1 %18, label %40, label %19
19: ; preds = %16
%20 = icmp eq i32 %1, 0
br label %21
21: ; preds = %19, %36
%22 = phi i8 [ %17, %19 ], [ %38, %36 ]
%23 = phi i32 [ 0, %19 ], [ %37, %36 ]
%24 = call i64 @feof(i32* %0)
%25 = icmp eq i64 %24, 0
br i1 %25, label %26, label %40
26: ; preds = %21
%27 = call i32 @isspace(i8 signext %22)
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %36
29: ; preds = %26
%30 = call signext i8 @toupper(i8 signext %22)
br i1 %20, label %34, label %31
31: ; preds = %29
%32 = call i64 @isalpha(i8 signext %30)
%33 = icmp eq i64 %32, 0
br i1 %33, label %36, label %34
34: ; preds = %31, %29
%35 = add nsw i32 %23, 1
br label %36
36: ; preds = %31, %34, %26
%37 = phi i32 [ %23, %26 ], [ %35, %34 ], [ %23, %31 ]
%38 = call signext i8 @fgetc(i32* %0)
%39 = icmp eq i8 %38, 62
br i1 %39, label %40, label %21
40: ; preds = %21, %36, %16
%41 = phi i32 [ 0, %16 ], [ %37, %36 ], [ %23, %21 ]
%42 = call i32 @rewind(i32* %0)
br label %43
43: ; preds = %2, %40
%44 = phi i32 [ %41, %40 ], [ 0, %2 ]
ret i32 %44
}