#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;
scalar_t__ e_samoglaska(int /*<<< orphan*/);
int /*<<< orphan*/ exit(int);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ tolower(char);
int main() {
  int red = 0, vkupno = 0;
  FILE *dat;
  char c;
  if ((dat = fopen("SP_primer.txt", "r")) == NULL) {
    printf("Datotekata SP_primer.txt ne se otvora");
    exit(-1);
  }
  int samoglaski = 0;
  while ((c = fgetc(dat)) != EOF) {
    if (e_samoglaska(tolower(c))) {
      ++samoglaski;
      ++vkupno;
    }
    if (c == '\n') {
      if (samoglaski > 10) {
        red++;
      }
      samoglaski = 0;
    }
  }
  if (samoglaski > 10) {
    red++;
  }
  printf("Vkupno %d reda imaat povekje od 10 samoglaski\n", red);
  printf("Vo datotekata ima vkupno %d samoglaski.\n", vkupno);
  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    0xe83(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11b6 <main+0x56>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1070 <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   1080 <e_samoglaska@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>
cmpl   $0xa,-0x20(%rbp)
jle    1249 <main+0xe9>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xde3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe01(%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    0xe95(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1236 <main+0xd6>
mov    %rax,%r14
mov    %rax,%rdi
call   1040 <fgetc@plt>
mov    0x2e4f(%rip),%r12
xor    %r15d,%r15d
mov    $0x0,%r13d
cmp    (%r12),%al
je     1203 <main+0xa3>
xor    %ebp,%ebp
xor    %r13d,%r13d
xor    %r15d,%r15d
movsbl %al,%ebx
mov    %ebx,%edi
call   1050 <tolower@plt>
mov    %eax,%edi
call   1080 <e_samoglaska@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
add    %ecx,%r15d
add    %ecx,%ebp
cmp    $0xb,%ebp
setge  %al
cmp    $0xa,%bl
mov    $0x0,%ecx
cmove  %ecx,%ebp
sete   %cl
and    %al,%cl
movzbl %cl,%eax
add    %eax,%r13d
mov    %r14,%rdi
call   1040 <fgetc@plt>
cmp    (%r12),%al
jne    11b0 <main+0x50>
xor    %eax,%eax
cmp    $0xb,%ebp
setge  %al
add    %eax,%r13d
lea    0xe2c(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe4a(%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    0xdd3(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xffffffff,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [14 x i8] c"SP_primer.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [38 x i8] c"Datotekata SP_primer.txt ne se otvora\00"
@EOF = global i8 0
@.str.3 = [47 x i8] c"Vkupno %d reda imaat povekje od 10 samoglaski\0A\00"
@.str.4 = [41 x i8] c"Vo datotekata ima vkupno %d samoglaski.\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 ([14 x i8], [14 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 ([38 x i8], [38 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 @e_samoglaska(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* %6
%44 = icmp sgt i32 %43, 10
br i1 %44, label %45, label %48
45: ; preds = %42
%46 = load i32, i32* %2
%47 = add nsw i32 %46, 1
store i32 %47, i32* %2
br label %48
48: ; preds = %45, %42
%49 = load i32, i32* %2
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i32 %49)
%51 = load i32, i32* %3
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), i32 %51)
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"SP_primer.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [38 x i8] c"Datotekata SP_primer.txt ne se otvora\00"
@EOF = global i8 0
@.str.3 = [47 x i8] c"Vkupno %d reda imaat povekje od 10 samoglaski\0A\00"
@.str.4 = [41 x i8] c"Vo datotekata ima vkupno %d samoglaski.\0A\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 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 %34, label %10
7: ; preds = %0
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 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 @e_samoglaska(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
%31 = icmp sgt i32 %26, 10
%32 = zext i1 %31 to i32
%33 = add nuw nsw i32 %25, %32
br label %34
34: ; preds = %30, %3
%35 = phi i32 [ 0, %3 ], [ %19, %30 ]
%36 = phi i32 [ 0, %3 ], [ %33, %30 ]
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i32 %36)
%38 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.4, i64 0, i64 0), i32 %35)
ret i32 0
}