#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*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
scalar_t__ isalnum(char);
scalar_t__ isupper(char);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
int main() {
  int i, inWord;
  int count = 0, total = 0;
  char row[100], zbor[20];
  FILE *ptr;
  if ((ptr = fopen("D:\\_strukturno\\text.txt", "r")) == NULL) {
    printf("Vlez.txt can not be opened!");
    return -1;
  }
  while (fgets(row, 100, ptr) != NULL) {
    inWord = count = 0;
    for (i = 0; i < strlen(row); i++) {
      if (isalnum(row[i])) {
        if (!inWord) {
          inWord = 1;
        }
        zbor[count++] = row[i];
      } else if (inWord) {
        inWord = 0;
        zbor[count] = '\0';
        if (isupper(zbor[0]) && (strlen(zbor) >= 3)) {
          printf("%s ", zbor);
          total++;
        }
        count = 0;
      }
    }
  }
  printf("\nTotal %d names found\n", total);
  fclose(ptr);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xe69(%rip),%rdi
lea    0xe7a(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0xa8(%rbp)
cmp    $0x0,%rax
jne    11ce <main+0x5e>
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1321 <main+0x1b1>
jmp    11d3 <main+0x63>
lea    -0x80(%rbp),%rdi
mov    -0xa8(%rbp),%rdx
mov    $0x64,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     12fd <main+0x18d>
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xac(%rbp)
lea    -0x80(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0xac(%rbp),%eax
cmp    %ecx,%eax
jge    12f8 <main+0x188>
movslq -0x8(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%edi
call   1060 <isalnum@plt>
cmp    $0x0,%rax
je     1273 <main+0x103>
cmpl   $0x0,-0xc(%rbp)
jne    1252 <main+0xe2>
movl   $0x1,-0xc(%rbp)
movslq -0x8(%rbp),%rax
mov    -0x80(%rbp,%rax,1),%cl
mov    -0x10(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x10(%rbp)
cltq
mov    %cl,-0xa0(%rbp,%rax,1)
jmp    12e5 <main+0x175>
cmpl   $0x0,-0xc(%rbp)
je     12e0 <main+0x170>
movl   $0x0,-0xc(%rbp)
movslq -0x10(%rbp),%rax
movb   $0x0,-0xa0(%rbp,%rax,1)
movsbl -0xa0(%rbp),%edi
call   1080 <isupper@plt>
cmp    $0x0,%rax
je     12d9 <main+0x169>
lea    -0xa0(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x3,%eax
jl     12d9 <main+0x169>
lea    -0xa0(%rbp),%rsi
lea    0xd6d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
jmp    12e5 <main+0x175>
jmp    12ea <main+0x17a>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1207 <main+0x97>
jmp    11d3 <main+0x63>
mov    -0x14(%rbp),%esi
lea    0xd33(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xa8(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x98,%rsp
lea    0xe78(%rip),%rdi
lea    0xe89(%rip),%rsi
call   1090 <fopen@plt>
test   %rax,%rax
je     12ce <main+0x15e>
mov    %rax,%rbp
lea    0x30(%rsp),%rdi
mov    $0x64,%esi
mov    %rax,%rdx
call   1070 <fgets@plt>
movl   $0x0,0x4(%rsp)
test   %rax,%rax
je     12b0 <main+0x140>
movl   $0x0,0x4(%rsp)
lea    0x30(%rsp),%rbx
mov    $0x1,%r14d
mov    %rbp,0x8(%rsp)
jmp    11fe <main+0x8e>
nopl   (%rax)
mov    %rbx,%rdi
mov    $0x64,%esi
mov    0x8(%rsp),%rbp
mov    %rbp,%rdx
call   1070 <fgets@plt>
test   %rax,%rax
je     12b0 <main+0x140>
mov    %rbx,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    11e0 <main+0x70>
xor    %r13d,%r13d
xor    %r15d,%r15d
xor    %r12d,%r12d
jmp    1251 <main+0xe1>
cs nopw 0x0(%rax,%rax,1)
nop
test   %r12d,%r12d
cmove  %r14d,%r12d
movzbl 0x30(%rsp,%r13,1),%eax
movslq %r15d,%rcx
add    $0x1,%r15d
mov    %al,0x10(%rsp,%rcx,1)
mov    %r12d,%ebp
add    $0x1,%r13
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
mov    %ebp,%r12d
cmp    %rax,%r13
jge    11e0 <main+0x70>
movsbl 0x30(%rsp,%r13,1),%edi
call   1060 <isalnum@plt>
test   %rax,%rax
jne    1220 <main+0xb0>
xor    %ebp,%ebp
test   %r12d,%r12d
je     123b <main+0xcb>
movslq %r15d,%rax
movb   $0x0,0x10(%rsp,%rax,1)
movsbl 0x10(%rsp),%edi
call   1080 <isupper@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     12ab <main+0x13b>
lea    0x10(%rsp),%r15
mov    %r15,%rdi
call   1040 <strlen@plt>
cmp    $0x3,%eax
jl     12ab <main+0x13b>
xor    %ebp,%ebp
lea    0xd9a(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
addl   $0x1,0x4(%rsp)
xor    %r15d,%r15d
jmp    123b <main+0xcb>
lea    0xd83(%rip),%rdi
mov    0x4(%rsp),%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbp,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
jmp    12e1 <main+0x171>
lea    0xd45(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xffffffff,%eax
add    $0x98,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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"
@.str.3 = [4 x i8] c"%s \00"
@.str.4 = [23 x i8] c"\0ATotal %d names found\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [100 x i8]
%7 = alloca [20 x i8]
%8 = alloca i32*
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %5
%9 = 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* %9, i32** %8
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %0
%12 = 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 %77
13: ; preds = %0
br label %14
14: ; preds = %71, %13
%15 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%16 = load i32*, i32** %8
%17 = call i32* @fgets(i8* %15, i32 100, i32* %16)
%18 = icmp ne i32* %17, null
br i1 %18, label %19, label %72
19: ; preds = %14
store i32 0, i32* %4
store i32 0, i32* %3
store i32 0, i32* %2
br label %20
20: ; preds = %68, %19
%21 = load i32, i32* %2
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%23 = call i32 @strlen(i8* %22)
%24 = icmp slt i32 %21, %23
br i1 %24, label %25, label %71
25: ; preds = %20
%26 = load i32, i32* %2
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = call i64 @isalnum(i8 signext %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %45
32: ; preds = %25
%33 = load i32, i32* %3
%34 = icmp ne i32 %33, 0
br i1 %34, label %36, label %35
35: ; preds = %32
store i32 1, i32* %3
br label %36
36: ; preds = %35, %32
%37 = load i32, i32* %2
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = load i32, i32* %4
%42 = add nsw i32 %41, 1
store i32 %42, i32* %4
%43 = sext i32 %41 to i64
%44 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 %43
store i8 %40, i8* %44
br label %67
45: ; preds = %25
%46 = load i32, i32* %3
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %66
48: ; preds = %45
store i32 0, i32* %3
%49 = load i32, i32* %4
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 %50
store i8 0, i8* %51
%52 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%53 = load i8, i8* %52
%54 = call i64 @isupper(i8 signext %53)
%55 = icmp ne i64 %54, 0
br i1 %55, label %56, label %65
56: ; preds = %48
%57 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%58 = call i32 @strlen(i8* %57)
%59 = icmp sge i32 %58, 3
br i1 %59, label %60, label %65
60: ; preds = %56
%61 = getelementptr inbounds [20 x i8], [20 x i8]* %7, i64 0, i64 0
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %61)
%63 = load i32, i32* %5
%64 = add nsw i32 %63, 1
store i32 %64, i32* %5
br label %65
65: ; preds = %60, %56, %48
store i32 0, i32* %4
br label %66
66: ; preds = %65, %45
br label %67
67: ; preds = %66, %36
br label %68
68: ; preds = %67
%69 = load i32, i32* %2
%70 = add nsw i32 %69, 1
store i32 %70, i32* %2
br label %20
71: ; preds = %20
br label %14
72: ; preds = %14
%73 = load i32, i32* %5
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %73)
%75 = load i32*, i32** %8
%76 = call i32 @fclose(i32* %75)
store i32 0, i32* %1
br label %77
77: ; preds = %72, %11
%78 = load i32, i32* %1
ret i32 %78
}

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"
@.str.3 = [4 x i8] c"%s \00"
@.str.4 = [23 x i8] c"\0ATotal %d names found\0A\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [20 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%5 = 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))
%6 = icmp eq i32* %5, null
br i1 %6, label %10, label %7
7: ; preds = %0
%8 = call i32* @fgets(i8* %3, i32 100, i32* %5)
%9 = icmp eq i32* %8, null
br i1 %9, label %57, label %16
10: ; preds = %0
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
br label %61
12: ; preds = %49, %16
%13 = phi i32 [ %17, %16 ], [ %52, %49 ]
%14 = call i32* @fgets(i8* %3, i32 100, i32* %5)
%15 = icmp eq i32* %14, null
br i1 %15, label %57, label %16
16: ; preds = %7, %12
%17 = phi i32 [ %13, %12 ], [ 0, %7 ]
%18 = call i32 @strlen(i8* %3)
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %12
20: ; preds = %16, %49
%21 = phi i64 [ %53, %49 ], [ 0, %16 ]
%22 = phi i32 [ %52, %49 ], [ %17, %16 ]
%23 = phi i32 [ %51, %49 ], [ 0, %16 ]
%24 = phi i32 [ %50, %49 ], [ 0, %16 ]
%25 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 %21
%26 = load i8, i8* %25
%27 = call i64 @isalnum(i8 signext %26)
%28 = icmp eq i64 %27, 0
%29 = icmp eq i32 %24, 0
br i1 %28, label %36, label %30
30: ; preds = %20
%31 = select i1 %29, i32 1, i32 %24
%32 = load i8, i8* %25
%33 = add nsw i32 %23, 1
%34 = sext i32 %23 to i64
%35 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %34
store i8 %32, i8* %35
br label %49
36: ; preds = %20
br i1 %29, label %49, label %37
37: ; preds = %36
%38 = sext i32 %23 to i64
%39 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 %38
store i8 0, i8* %39
%40 = load i8, i8* %4
%41 = call i64 @isupper(i8 signext %40)
%42 = icmp eq i64 %41, 0
br i1 %42, label %49, label %43
43: ; preds = %37
%44 = call i32 @strlen(i8* %4)
%45 = icmp sgt i32 %44, 2
br i1 %45, label %46, label %49
46: ; preds = %43
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%48 = add nsw i32 %22, 1
br label %49
49: ; preds = %37, %43, %46, %30, %36
%50 = phi i32 [ %31, %30 ], [ 0, %36 ], [ 0, %46 ], [ 0, %43 ], [ 0, %37 ]
%51 = phi i32 [ %33, %30 ], [ %23, %36 ], [ 0, %46 ], [ 0, %43 ], [ 0, %37 ]
%52 = phi i32 [ %22, %30 ], [ %22, %36 ], [ %48, %46 ], [ %22, %43 ], [ %22, %37 ]
%53 = add nuw nsw i64 %21, 1
%54 = call i32 @strlen(i8* %3)
%55 = sext i32 %54 to i64
%56 = icmp slt i64 %53, %55
br i1 %56, label %20, label %12
57: ; preds = %12, %7
%58 = phi i32 [ 0, %7 ], [ %13, %12 ]
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0), i32 %58)
%60 = call i32 @fclose(i32* %5)
br label %61
61: ; preds = %57, %10
%62 = phi i32 [ -1, %10 ], [ 0, %57 ]
ret i32 %62
}