#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
char getc(int /*<<< orphan*/ *);
scalar_t__ isdigit(char);
scalar_t__ isletter(char);
scalar_t__ isspec(char);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int i;
  int digits = 0, letters = 0, specialcharacters = 0;
  char c;
  FILE *ptr;
  if ((ptr = fopen("D:\\_strukturno\\text.txt", "r")) == NULL) {
    printf("Vlez.txt can not be opened!");
    return -1;
  }
  while ((c = getc(ptr)) != EOF) {
    if (isdigit(c))
      digits++;
    else if (isletter(c))
      letters++;
    else if (isspec(c))
      specialcharacters++;
  }
  printf("Total digits: %d\n", digits);
  printf("Total leters: %d\n", letters);
  printf("Total specials: %d\n", specialcharacters);
  fclose(ptr);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe65(%rip),%rdi
lea    0xe76(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    11cf <main+0x5f>
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12a5 <main+0x135>
jmp    11d4 <main+0x64>
mov    -0x20(%rbp),%rdi
call   1090 <getc@plt>
mov    %al,-0x15(%rbp)
movsbl %al,%eax
mov    0x2dfe(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1262 <main+0xf2>
movsbl -0x15(%rbp),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     1216 <main+0xa6>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    125d <main+0xed>
movsbl -0x15(%rbp),%edi
call   1040 <isletter@plt>
cmp    $0x0,%rax
je     1237 <main+0xc7>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1258 <main+0xe8>
movsbl -0x15(%rbp),%edi
call   1080 <isspec@plt>
cmp    $0x0,%rax
je     1253 <main+0xe3>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1258 <main+0xe8>
jmp    125d <main+0xed>
jmp    11d4 <main+0x64>
mov    -0xc(%rbp),%esi
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xdcc(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1050 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%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    0xe7e(%rip),%rdi
lea    0xe8f(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
je     11f9 <main+0x89>
mov    %rax,%r13
mov    %rax,%rdi
call   1090 <getc@plt>
mov    0x2e43(%rip),%r14
mov    $0x0,%r12d
mov    $0x0,%r15d
mov    $0x0,%ebp
cmp    (%r14),%al
jne    121b <main+0xab>
lea    0xe74(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe76(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe77(%rip),%rdi
mov    %r15d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r13,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
jmp    120c <main+0x9c>
lea    0xe1a(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebp,%ebp
xor    %r15d,%r15d
xor    %r12d,%r12d
jmp    1244 <main+0xd4>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%ebp
mov    %r13,%rdi
call   1090 <getc@plt>
cmp    (%r14),%al
je     11bb <main+0x4b>
movsbl %al,%ebx
mov    %ebx,%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    1230 <main+0xc0>
mov    %ebx,%edi
call   1040 <isletter@plt>
test   %rax,%rax
je     1265 <main+0xf5>
add    $0x1,%r12d
jmp    1233 <main+0xc3>
mov    %ebx,%edi
call   1080 <isspec@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%r15d
jmp    1233 <main+0xc3>

LLVM IR (-O0):
@.str = [24 x i8] c"D:\\_strukturno\\text.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [28 x i8] c"Vlez.txt can not be opened!\00"
@EOF = global i8 0
@.str.3 = [18 x i8] c"Total digits: %d\0A\00"
@.str.4 = [18 x i8] c"Total leters: %d\0A\00"
@.str.5 = [20 x i8] c"Total specials: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
%7 = alloca i32*
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
%8 = call i32* @fopen(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %8, i32** %7
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %1
br label %53
12: ; preds = %0
br label %13
13: ; preds = %43, %12
%14 = load i32*, i32** %7
%15 = call signext i8 @getc(i32* %14)
store i8 %15, i8* %6
%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 %44
20: ; preds = %13
%21 = load i8, i8* %6
%22 = call i64 @isdigit(i8 signext %21)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %43
27: ; preds = %20
%28 = load i8, i8* %6
%29 = call i64 @isletter(i8 signext %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %27
%32 = load i32, i32* %4
%33 = add nsw i32 %32, 1
store i32 %33, i32* %4
br label %42
34: ; preds = %27
%35 = load i8, i8* %6
%36 = call i64 @isspec(i8 signext %35)
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %34
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 1
store i32 %40, i32* %5
br label %41
41: ; preds = %38, %34
br label %42
42: ; preds = %41, %31
br label %43
43: ; preds = %42, %24
br label %13
44: ; preds = %13
%45 = load i32, i32* %3
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %45)
%47 = load i32, i32* %4
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %47)
%49 = load i32, i32* %5
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %49)
%51 = load i32*, i32** %7
%52 = call i32 @fclose(i32* %51)
store i32 0, i32* %1
br label %53
53: ; preds = %44, %10
%54 = load i32, i32* %1
ret i32 %54
}

LLVM IR (-O2):
@.str = [24 x i8] c"D:\\_strukturno\\text.txt\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [28 x i8] c"Vlez.txt can not be opened!\00"
@EOF = global i8 0
@.str.3 = [18 x i8] c"Total digits: %d\0A\00"
@.str.4 = [18 x i8] c"Total leters: %d\0A\00"
@.str.5 = [20 x i8] c"Total specials: %d\0A\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([24 x i8], [24 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 @getc(i32* %1)
%5 = load i8, i8* @EOF
%6 = icmp eq i8 %4, %5
br i1 %6, label %35, label %9
7: ; preds = %0
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %43
9: ; preds = %3, %28
%10 = phi i8 [ %32, %28 ], [ %4, %3 ]
%11 = phi i32 [ %31, %28 ], [ 0, %3 ]
%12 = phi i32 [ %30, %28 ], [ 0, %3 ]
%13 = phi i32 [ %29, %28 ], [ 0, %3 ]
%14 = tail call i64 @isdigit(i8 signext %10)
%15 = icmp eq i64 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %9
%17 = add nsw i32 %11, 1
br label %28
18: ; preds = %9
%19 = tail call i64 @isletter(i8 signext %10)
%20 = icmp eq i64 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %18
%22 = add nsw i32 %13, 1
br label %28
23: ; preds = %18
%24 = tail call i64 @isspec(i8 signext %10)
%25 = icmp ne i64 %24, 0
%26 = zext i1 %25 to i32
%27 = add nsw i32 %12, %26
br label %28
28: ; preds = %23, %21, %16
%29 = phi i32 [ %13, %16 ], [ %22, %21 ], [ %13, %23 ]
%30 = phi i32 [ %12, %16 ], [ %12, %21 ], [ %27, %23 ]
%31 = phi i32 [ %17, %16 ], [ %11, %21 ], [ %11, %23 ]
%32 = tail call signext i8 @getc(i32* %1)
%33 = load i8, i8* @EOF
%34 = icmp eq i8 %32, %33
br i1 %34, label %35, label %9
35: ; preds = %28, %3
%36 = phi i32 [ 0, %3 ], [ %29, %28 ]
%37 = phi i32 [ 0, %3 ], [ %30, %28 ]
%38 = phi i32 [ 0, %3 ], [ %31, %28 ]
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %38)
%40 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0), i32 %36)
%41 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %37)
%42 = tail call i32 @fclose(i32* %1)
br label %43
43: ; preds = %35, %7
%44 = phi i32 [ -1, %7 ], [ 0, %35 ]
ret i32 %44
}