#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);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ is_vowel(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ tolower(char);
int main() {
  int row = 0, total = 0;
  FILE *dat;
  char c;
  if ((dat = fopen("SP_example.txt", "r")) == NULL) {
    printf("The file `SP_example.txt` can not be opened");
    exit(-1);
  }
  int vowels = 0;
  while ((c = fgetc(dat)) != EOF) {
    if (is_vowel(tolower(c))) {
      ++vowels;
      ++total;
    }
    if (c == '\n') {
      if (vowels > 10) {
        row++;
      }
      vowels = 0;
    }
  }
  printf("Total of %d rows has more than 10 vowels\n", row);
  printf("The file has total %d vowels.\n", total);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xe7c(%rip),%rdi
lea    0xe84(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11b6 <main+0x56>
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <fgetc@plt>
mov    %al,-0x19(%rbp)
movsbl %al,%eax
mov    0x2e15(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1236 <main+0xd6>
movsbl -0x19(%rbp),%edi
call   1050 <tolower@plt>
mov    %eax,%edi
call   1060 <is_vowel@plt>
cmp    $0x0,%rax
je     120a <main+0xaa>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
movsbl -0x19(%rbp),%eax
cmp    $0xa,%eax
jne    1231 <main+0xd1>
cmpl   $0xa,-0x20(%rbp)
jle    122a <main+0xca>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
movl   $0x0,-0x20(%rbp)
jmp    11bd <main+0x5d>
mov    -0x8(%rbp),%esi
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xe8e(%rip),%rdi
lea    0xe96(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     122d <main+0xcd>
mov    %rax,%r14
mov    %rax,%rdi
call   1040 <fgetc@plt>
mov    0x2e4f(%rip),%r13
xor    %r15d,%r15d
mov    $0x0,%ebx
cmp    0x0(%r13),%al
je     11fb <main+0x9b>
xor    %r12d,%r12d
xor    %ebx,%ebx
xor    %r15d,%r15d
nop
movsbl %al,%ebp
mov    %ebp,%edi
call   1050 <tolower@plt>
mov    %eax,%edi
call   1060 <is_vowel@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
add    %ecx,%r15d
add    %ecx,%r12d
cmp    $0xb,%r12d
setge  %al
cmp    $0xa,%bpl
mov    $0x0,%ecx
cmove  %ecx,%r12d
sete   %cl
and    %al,%cl
movzbl %cl,%eax
add    %eax,%ebx
mov    %r14,%rdi
call   1040 <fgetc@plt>
cmp    0x0(%r13),%al
jne    11b0 <main+0x50>
lea    0xe3b(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe55(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xddd(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"SP_example.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [44 x i8] c"The file `SP_example.txt` can not be opened\00"
@EOF = global i8 0
@.str.3 = [42 x i8] c"Total of %d rows has more than 10 vowels\0A\00"
@.str.4 = [31 x i8] c"The file has total %d vowels.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8
%6 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%7 = call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %4
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @exit(i32 -1)
unreachable
12: ; preds = %0
store i32 0, i32* %6
br label %13
13: ; preds = %41, %12
%14 = load i32*, i32** %4
%15 = call signext i8 @fgetc(i32* %14)
store i8 %15, i8* %5
%16 = sext i8 %15 to i32
%17 = load i8, i8* @EOF
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %16, %18
br i1 %19, label %20, label %42
20: ; preds = %13
%21 = load i8, i8* %5
%22 = call i32 @tolower(i8 signext %21)
%23 = call i64 @is_vowel(i32 %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %20
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 1
store i32 %27, i32* %6
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
store i32 %29, i32* %3
br label %30
30: ; preds = %25, %20
%31 = load i8, i8* %5
%32 = sext i8 %31 to i32
%33 = icmp eq i32 %32, 10
br i1 %33, label %34, label %41
34: ; preds = %30
%35 = load i32, i32* %6
%36 = icmp sgt i32 %35, 10
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load i32, i32* %2
%39 = add nsw i32 %38, 1
store i32 %39, i32* %2
br label %40
40: ; preds = %37, %34
store i32 0, i32* %6
br label %41
41: ; preds = %40, %30
br label %13
42: ; preds = %13
%43 = load i32, i32* %2
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i32 %43)
%45 = load i32, i32* %3
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32 %45)
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"SP_example.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [44 x i8] c"The file `SP_example.txt` can not be opened\00"
@EOF = global i8 0
@.str.3 = [42 x i8] c"Total of %d rows has more than 10 vowels\0A\00"
@.str.4 = [31 x i8] c"The file has total %d vowels.\0A\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %7, label %3
3: ; preds = %0
%4 = tail call signext i8 @fgetc(i32* %1)
%5 = load i8, i8* @EOF
%6 = icmp eq i8 %4, %5
br i1 %6, label %30, label %10
7: ; preds = %0
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.2, i64 0, i64 0))
%9 = tail call i32 @exit(i32 -1)
unreachable
10: ; preds = %3, %10
%11 = phi i8 [ %27, %10 ], [ %4, %3 ]
%12 = phi i32 [ %26, %10 ], [ 0, %3 ]
%13 = phi i32 [ %25, %10 ], [ 0, %3 ]
%14 = phi i32 [ %19, %10 ], [ 0, %3 ]
%15 = tail call i32 @tolower(i8 signext %11)
%16 = tail call i64 @is_vowel(i32 %15)
%17 = icmp ne i64 %16, 0
%18 = zext i1 %17 to i32
%19 = add nuw nsw i32 %14, %18
%20 = add nsw i32 %12, %18
%21 = icmp eq i8 %11, 10
%22 = icmp sgt i32 %20, 10
%23 = select i1 %21, i1 %22, i1 false
%24 = zext i1 %23 to i32
%25 = add nuw nsw i32 %13, %24
%26 = select i1 %21, i32 0, i32 %20
%27 = tail call signext i8 @fgetc(i32* %1)
%28 = load i8, i8* @EOF
%29 = icmp eq i8 %27, %28
br i1 %29, label %30, label %10
30: ; preds = %10, %3
%31 = phi i32 [ 0, %3 ], [ %19, %10 ]
%32 = phi i32 [ 0, %3 ], [ %25, %10 ]
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.3, i64 0, i64 0), i32 %32)
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0), i32 %31)
ret i32 0
}