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


x86 assembly (clang, -O0):
<cntlets>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movb   $0x7e,-0x121(%rbp)
mov    -0x10(%rbp),%rdi
call   1090 <feof@plt>
cmp    $0x0,%rax
je     11bc <cntlets+0x3c>
movl   $0x0,-0x4(%rbp)
jmp    12a2 <cntlets+0x122>
lea    -0x120(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0xff,%esi
call   1070 <fgets@plt>
movsbl -0x120(%rbp),%eax
cmp    $0x3e,%eax
je     1200 <cntlets+0x80>
mov    0x2df0(%rip),%rax
mov    (%rax),%edi
lea    0xe0f(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
jmp    1205 <cntlets+0x85>
movsbl -0x121(%rbp),%ecx
xor    %eax,%eax
cmp    $0x3e,%ecx
mov    %al,-0x122(%rbp)
je     1239 <cntlets+0xb9>
movsbl -0x121(%rbp),%eax
mov    0x2dbd(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
setne  %al
mov    %al,-0x122(%rbp)
mov    -0x122(%rbp),%al
test   $0x1,%al
jne    124c <cntlets+0xcc>
jmp    1290 <cntlets+0x110>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x121(%rbp)
movsbl -0x121(%rbp),%edi
call   1060 <isspace@plt>
cmp    $0x0,%eax
jne    128b <cntlets+0x10b>
movsbl -0x121(%rbp),%edi
call   1030 <toupper@plt>
mov    %al,-0x121(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1205 <cntlets+0x85>
mov    -0x10(%rbp),%rdi
call   1040 <rewind@plt>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cntlets>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x100,%rsp
mov    %rdi,%r14
call   1090 <feof@plt>
xor    %r15d,%r15d
test   %rax,%rax
jne    120c <cntlets+0x8c>
mov    %rsp,%rdi
mov    $0xff,%esi
mov    %r14,%rdx
call   1070 <fgets@plt>
cmpb   $0x3e,(%rsp)
jne    121f <cntlets+0x9f>
mov    0x2e2c(%rip),%r12
xor    %r15d,%r15d
cmpb   $0x7e,(%r12)
je     1200 <cntlets+0x80>
xor    %r15d,%r15d
nopl   0x0(%rax)
mov    %r14,%rdi
call   1050 <fgetc@plt>
mov    %eax,%ebx
movsbl %al,%ebp
mov    %ebp,%edi
call   1060 <isspace@plt>
test   %eax,%eax
jne    11f5 <cntlets+0x75>
mov    %ebp,%edi
call   1030 <toupper@plt>
mov    %eax,%ebx
add    $0x1,%r15d
cmp    $0x3e,%bl
je     1200 <cntlets+0x80>
cmp    (%r12),%bl
jne    11d0 <cntlets+0x50>
mov    %r14,%rdi
call   1040 <rewind@plt>
add    $0xffffffff,%r15d
mov    %r15d,%eax
add    $0x100,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2db2(%rip),%rax
mov    (%rax),%edi
lea    0xdd1(%rip),%rsi
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

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

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