#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 */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int scanf(char *, char *);
int main() {
  char pole[21] = {
      '\0',
  };
  unsigned int velka = 0;
  printf("Zadej string maximalne 20znaku: ");
  for (unsigned int i = 0; i < 20; i++) {
    if (scanf("%c", &pole[i]) != 1) {
      printf("Spatne zadani\n");
      return 1;
    }
    if (pole[i] == '\n') {
      pole[i] = '\0';
      break;
    }
  }
  unsigned int i = 0;
  while (pole[i] != '\0') {
    if ((pole[i] >= 'A') && (pole[i] <= 'Z')) {
      velka++;
      pole[i] -= ('A' - 'a');
    }
    ++i;
  }
  printf("Nalezeno %u velkych pismen\n", velka);
  printf("%s", pole);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x15,%edx
call   1040 <memset@plt>
movl   $0x0,-0x24(%rbp)
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x28(%rbp)
cmpl   $0x14,-0x28(%rbp)
jae    11df <main+0xaf>
mov    -0x28(%rbp),%eax
lea    -0x20(%rbp),%rsi
add    %rax,%rsi
lea    0xe9b(%rip),%rdi
call   1050 <scanf@plt>
cmp    $0x1,%eax
je     11ae <main+0x7e>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1269 <main+0x139>
mov    -0x28(%rbp),%eax
movsbl -0x20(%rbp,%rax,1),%eax
cmp    $0xa,%eax
jne    11cc <main+0x9c>
mov    -0x28(%rbp),%eax
movb   $0x0,-0x20(%rbp,%rax,1)
jmp    11df <main+0xaf>
jmp    11d1 <main+0xa1>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    116b <main+0x3b>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
movsbl -0x20(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     123f <main+0x10f>
mov    -0x2c(%rbp),%eax
movsbl -0x20(%rbp,%rax,1),%eax
cmp    $0x41,%eax
jl     1231 <main+0x101>
mov    -0x2c(%rbp),%eax
movsbl -0x20(%rbp,%rax,1),%eax
cmp    $0x5a,%eax
jg     1231 <main+0x101>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x2c(%rbp),%eax
movsbl -0x20(%rbp,%rax,1),%ecx
sub    $0xffffffe0,%ecx
mov    %cl,-0x20(%rbp,%rax,1)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11e6 <main+0xb6>
mov    -0x24(%rbp),%esi
lea    0xdea(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    0xdf4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,(%rsp)
movq   $0x0,0xd(%rsp)
lea    0xeb0(%rip),%rdi
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec0(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    (%rsp,%r15,1),%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    1195 <main+0x65>
cmpb   $0xa,(%rbx)
je     11a8 <main+0x78>
add    $0x1,%r15
cmp    $0x14,%r15
jne    1170 <main+0x40>
jmp    11ad <main+0x7d>
lea    0xea7(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
jmp    1213 <main+0xe3>
movb   $0x0,(%rsp,%r15,1)
mov    (%rsp),%cl
xor    %ebx,%ebx
mov    $0x0,%esi
test   %cl,%cl
je     11f4 <main+0xc4>
xor    %esi,%esi
mov    $0x1,%eax
mov    %rsp,%rdx
jmp    11e1 <main+0xb1>
nopw   0x0(%rax,%rax,1)
mov    %eax,%ecx
lea    (%rsp,%rcx,1),%rdx
movzbl (%rsp,%rcx,1),%ecx
add    $0x1,%eax
test   %cl,%cl
je     11f4 <main+0xc4>
lea    -0x41(%rcx),%edi
cmp    $0x19,%dil
ja     11d0 <main+0xa0>
add    $0x1,%esi
add    $0x20,%cl
mov    %cl,(%rdx)
jmp    11d0 <main+0xa0>
lea    0xe29(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe37(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [33 x i8] c"Zadej string maximalne 20znaku: \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [15 x i8] c"Spatne zadani\0A\00"
@.str.3 = [28 x i8] c"Nalezeno %u velkych pismen\0A\00"
@.str.4 = [3 x i8] c"%s\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [21 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = bitcast [21 x i8]* %2 to i8*
store i32 0, i32* %3
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %8
8: ; preds = %31, %0
%9 = load i32, i32* %4
%10 = icmp ult i32 %9, 20
br i1 %10, label %11, label %34
11: ; preds = %8
%12 = load i32, i32* %4
%13 = zext i32 %12 to i64
%14 = getelementptr inbounds [21 x i8], [21 x i8]* %2, i64 0, i64 %13
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = icmp ne i32 %15, 1
br i1 %16, label %17, label %19
17: ; preds = %11
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %74
19: ; preds = %11
%20 = load i32, i32* %4
%21 = zext i32 %20 to i64
%22 = getelementptr inbounds [21 x i8], [21 x i8]* %2, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 10
br i1 %25, label %26, label %30
26: ; preds = %19
%27 = load i32, i32* %4
%28 = zext i32 %27 to i64
%29 = getelementptr inbounds [21 x i8], [21 x i8]* %2, i64 0, i64 %28
store i8 0, i8* %29
br label %34
30: ; preds = %19
br label %31
31: ; preds = %30
%32 = load i32, i32* %4
%33 = add i32 %32, 1
store i32 %33, i32* %4
br label %8
34: ; preds = %26, %8
store i32 0, i32* %5
br label %35
35: ; preds = %66, %34
%36 = load i32, i32* %5
%37 = zext i32 %36 to i64
%38 = getelementptr inbounds [21 x i8], [21 x i8]* %2, i64 0, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %69
42: ; preds = %35
%43 = load i32, i32* %5
%44 = zext i32 %43 to i64
%45 = getelementptr inbounds [21 x i8], [21 x i8]* %2, i64 0, i64 %44
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = icmp sge i32 %47, 65
br i1 %48, label %49, label %66
49: ; preds = %42
%50 = load i32, i32* %5
%51 = zext i32 %50 to i64
%52 = getelementptr inbounds [21 x i8], [21 x i8]* %2, i64 0, i64 %51
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = icmp sle i32 %54, 90
br i1 %55, label %56, label %66
56: ; preds = %49
%57 = load i32, i32* %3
%58 = add i32 %57, 1
store i32 %58, i32* %3
%59 = load i32, i32* %5
%60 = zext i32 %59 to i64
%61 = getelementptr inbounds [21 x i8], [21 x i8]* %2, i64 0, i64 %60
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = sub nsw i32 %63, -32
%65 = trunc i32 %64 to i8
store i8 %65, i8* %61
br label %66
66: ; preds = %56, %49, %42
%67 = load i32, i32* %5
%68 = add i32 %67, 1
store i32 %68, i32* %5
br label %35
69: ; preds = %35
%70 = load i32, i32* %3
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %70)
%72 = getelementptr inbounds [21 x i8], [21 x i8]* %2, i64 0, i64 0
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %72)
store i32 0, i32* %1
br label %74
74: ; preds = %69, %17
%75 = load i32, i32* %1
ret i32 %75
}

LLVM IR (-O2):
@.str = [33 x i8] c"Zadej string maximalne 20znaku: \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.3 = [28 x i8] c"Nalezeno %u velkych pismen\0A\00"
@.str.4 = [3 x i8] c"%s\00"
@str = [14 x i8] c"Spatne zadani\00"
define i32 @main() {
%1 = alloca [21 x i8]
%2 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
br label %7
4: ; preds = %14
%5 = add nuw nsw i64 %8, 1
%6 = icmp eq i64 %5, 20
br i1 %6, label %18, label %7
7: ; preds = %0, %4
%8 = phi i64 [ 0, %0 ], [ %5, %4 ]
%9 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 %8
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = icmp eq i32 %10, 1
br i1 %11, label %14, label %12
12: ; preds = %7
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %42
14: ; preds = %7
%15 = load i8, i8* %9
%16 = icmp eq i8 %15, 10
br i1 %16, label %17, label %4
17: ; preds = %14
store i8 0, i8* %9
br label %18
18: ; preds = %4, %17
%19 = load i8, i8* %2
%20 = icmp eq i8 %19, 0
br i1 %20, label %38, label %21
21: ; preds = %18, %31
%22 = phi i8 [ %36, %31 ], [ %19, %18 ]
%23 = phi i8* [ %35, %31 ], [ %2, %18 ]
%24 = phi i32 [ %33, %31 ], [ 0, %18 ]
%25 = phi i32 [ %32, %31 ], [ 0, %18 ]
%26 = add i8 %22, -65
%27 = icmp ult i8 %26, 26
br i1 %27, label %28, label %31
28: ; preds = %21
%29 = add i32 %25, 1
%30 = add nuw nsw i8 %22, 32
store i8 %30, i8* %23
br label %31
31: ; preds = %28, %21
%32 = phi i32 [ %29, %28 ], [ %25, %21 ]
%33 = add i32 %24, 1
%34 = zext i32 %33 to i64
%35 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 %34
%36 = load i8, i8* %35
%37 = icmp eq i8 %36, 0
br i1 %37, label %38, label %21
38: ; preds = %31, %18
%39 = phi i32 [ 0, %18 ], [ %32, %31 ]
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0), i32 %39)
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %2)
br label %42
42: ; preds = %12, %38
%43 = phi i32 [ 0, %38 ], [ 1, %12 ]
ret i32 %43
}