#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 EXIT_SUCCESS;
int mygetchar();
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  int contCaracters[126 - 32] = {0};
  int i = 0, car;
  printf("Introdueix un text acabat en PUNT: \n");
  while ((car = mygetchar()) != '.') {
    contCaracters[car - 32]++;
  }
  contCaracters[car - 32] = 1;
  printf("\n");
  for (i = 0; i < 126 - 32 + 1; i++) {
    if (contCaracters[i] != 0) {
      printf("\nEl caracter %c ha aparegut %d vegades.\n", i + 32,
             contCaracters[i]);
    }
  }
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1a0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x190(%rbp),%rdi
xor    %esi,%esi
mov    $0x178,%edx
call   1050 <memset@plt>
movl   $0x0,-0x194(%rbp)
lea    0xe93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <mygetchar@plt>
mov    %eax,-0x198(%rbp)
cmp    $0x2e,%eax
je     11ab <main+0x7b>
mov    -0x198(%rbp),%eax
sub    $0x20,%eax
cltq
mov    -0x190(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x190(%rbp,%rax,4)
jmp    1174 <main+0x44>
mov    -0x198(%rbp),%eax
sub    $0x20,%eax
cltq
movl   $0x1,-0x190(%rbp,%rax,4)
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x194(%rbp)
cmpl   $0x5f,-0x194(%rbp)
jge    1239 <main+0x109>
movslq -0x194(%rbp),%rax
cmpl   $0x0,-0x190(%rbp,%rax,4)
je     1220 <main+0xf0>
mov    -0x194(%rbp),%esi
add    $0x20,%esi
movslq -0x194(%rbp),%rax
mov    -0x190(%rbp,%rax,4),%edx
lea    0xe0c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1225 <main+0xf5>
mov    -0x194(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x194(%rbp)
jmp    11d9 <main+0xa9>
mov    0x2da0(%rip),%rax
mov    (%rax),%eax
add    $0x1a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x178,%rsp
mov    %rsp,%rdi
mov    $0x178,%edx
xor    %esi,%esi
call   1070 <memset@plt>
lea    0xeb9(%rip),%rdi
call   1040 <puts@plt>
cs nopw 0x0(%rax,%rax,1)
nop
xor    %eax,%eax
call   1050 <mygetchar@plt>
cmp    $0x2e,%eax
je     1195 <main+0x45>
cltq
addl   $0x1,-0x80(%rsp,%rax,4)
jmp    1180 <main+0x30>
movl   $0x1,0x38(%rsp)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe52(%rip),%r14
xor    %ebx,%ebx
jmp    11ca <main+0x7a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%rbx
cmp    $0x5f,%rbx
je     11e0 <main+0x90>
mov    (%rsp,%rbx,4),%edx
test   %edx,%edx
je     11c0 <main+0x70>
lea    0x20(%rbx),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11c0 <main+0x70>
mov    0x2df9(%rip),%rax
mov    (%rax),%eax
add    $0x178,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [37 x i8] c"Introdueix un text acabat en PUNT: \0A\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [41 x i8] c"\0AEl caracter %c ha aparegut %d vegades.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [94 x i32]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [94 x i32]* %6 to i8*
store i32 0, i32* %7
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %14, %2
%12 = call i32 (...) @mygetchar()
store i32 %12, i32* %8
%13 = icmp ne i32 %12, 46
br i1 %13, label %14, label %21
14: ; preds = %11
%15 = load i32, i32* %8
%16 = sub nsw i32 %15, 32
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds [94 x i32], [94 x i32]* %6, i64 0, i64 %17
%19 = load i32, i32* %18
%20 = add nsw i32 %19, 1
store i32 %20, i32* %18
br label %11
21: ; preds = %11
%22 = load i32, i32* %8
%23 = sub nsw i32 %22, 32
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [94 x i32], [94 x i32]* %6, i64 0, i64 %24
store i32 1, i32* %25
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %7
br label %27
27: ; preds = %45, %21
%28 = load i32, i32* %7
%29 = icmp slt i32 %28, 95
br i1 %29, label %30, label %48
30: ; preds = %27
%31 = load i32, i32* %7
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds [94 x i32], [94 x i32]* %6, i64 0, i64 %32
%34 = load i32, i32* %33
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %44
36: ; preds = %30
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 32
%39 = load i32, i32* %7
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [94 x i32], [94 x i32]* %6, i64 0, i64 %40
%42 = load i32, i32* %41
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 %38, i32 %42)
br label %44
44: ; preds = %36, %30
br label %45
45: ; preds = %44
%46 = load i32, i32* %7
%47 = add nsw i32 %46, 1
store i32 %47, i32* %7
br label %27
48: ; preds = %27
%49 = load i32, i32* @EXIT_SUCCESS
ret i32 %49
}

LLVM IR (-O2):
@.str.2 = [41 x i8] c"\0AEl caracter %c ha aparegut %d vegades.\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [36 x i8] c"Introdueix un text acabat en PUNT: \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [94 x i32]
%4 = bitcast [94 x i32]* %3 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 (...) @mygetchar()
%7 = icmp eq i32 %6, 46
br i1 %7, label %17, label %8
8: ; preds = %2, %8
%9 = phi i32 [ %15, %8 ], [ %6, %2 ]
%10 = add nsw i32 %9, -32
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [94 x i32], [94 x i32]* %3, i64 0, i64 %11
%13 = load i32, i32* %12
%14 = add nsw i32 %13, 1
store i32 %14, i32* %12
%15 = tail call i32 (...) @mygetchar()
%16 = icmp eq i32 %15, 46
br i1 %16, label %17, label %8
17: ; preds = %8, %2
%18 = getelementptr inbounds [94 x i32], [94 x i32]* %3, i64 0, i64 14
store i32 1, i32* %18
%19 = tail call i32 @putchar(i32 10)
br label %20
20: ; preds = %17, %29
%21 = phi i64 [ 0, %17 ], [ %30, %29 ]
%22 = getelementptr inbounds [94 x i32], [94 x i32]* %3, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = icmp eq i32 %23, 0
br i1 %24, label %29, label %25
25: ; preds = %20
%26 = trunc i64 %21 to i32
%27 = add i32 %26, 32
%28 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 %27, i32 %23)
br label %29
29: ; preds = %20, %25
%30 = add nuw nsw i64 %21, 1
%31 = icmp eq i64 %30, 95
br i1 %31, label %32, label %20
32: ; preds = %29
%33 = load i32, i32* @EXIT_SUCCESS
ret i32 %33
}