#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) {
  char cadena[200];
  int i = 0, car;
  int blanc = 1, cont = 0;
  printf("Introdueix el text acabat en PUNT: \n\n");
  while (i < 200 - 1 && (car = mygetchar()) != '.') {
    if (blanc) {
      if (car != ' ') {
        cont++;
        blanc = 0;
      }
    } else {
      if (car == ' ' || car == '\n') {
        blanc = 1;
      }
    }
    cadena[i] = car;
    i++;
  }
  cadena[i] = 0;
  printf("\n\nText introduït: \n\n%s \n", cadena);
  printf("\nNº paraules: %d", cont);
  printf("\n");
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0xe4(%rbp)
movl   $0x1,-0xec(%rbp)
movl   $0x0,-0xf0(%rbp)
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
cmpl   $0xc7,-0xe4(%rbp)
mov    %al,-0xf1(%rbp)
jge    1196 <main+0x76>
mov    $0x0,%al
call   1030 <mygetchar@plt>
mov    %eax,-0xe8(%rbp)
cmp    $0x2e,%eax
setne  %al
mov    %al,-0xf1(%rbp)
mov    -0xf1(%rbp),%al
test   $0x1,%al
jne    11a9 <main+0x89>
jmp    1234 <main+0x114>
cmpl   $0x0,-0xec(%rbp)
je     11e1 <main+0xc1>
cmpl   $0x20,-0xe8(%rbp)
je     11dc <main+0xbc>
mov    -0xf0(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xf0(%rbp)
movl   $0x0,-0xec(%rbp)
jmp    120a <main+0xea>
cmpl   $0x20,-0xe8(%rbp)
je     11fb <main+0xdb>
cmpl   $0xa,-0xe8(%rbp)
jne    1205 <main+0xe5>
movl   $0x1,-0xec(%rbp)
jmp    120a <main+0xea>
mov    -0xe8(%rbp),%eax
mov    %al,%cl
movslq -0xe4(%rbp),%rax
mov    %cl,-0xe0(%rbp,%rax,1)
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xe4(%rbp)
jmp    1165 <main+0x45>
movslq -0xe4(%rbp),%rax
movb   $0x0,-0xe0(%rbp,%rax,1)
lea    -0xe0(%rbp),%rsi
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xf0(%rbp),%esi
lea    0xddb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdb1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d5f(%rip),%rax
mov    (%rax),%eax
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0xd0,%rsp
lea    0xeda(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%ebp
xor    %ebx,%ebx
xor    %r14d,%r14d
jmp    1191 <main+0x51>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %ecx,%ecx
xor    %ebp,%ebp
cmp    $0x20,%eax
setne  %cl
sete   %bpl
add    %ecx,%r14d
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0xc7,%rbx
je     11b4 <main+0x74>
xor    %eax,%eax
call   1050 <mygetchar@plt>
cmp    $0x2e,%eax
je     11b9 <main+0x79>
test   %ebp,%ebp
jne    1170 <main+0x30>
cmp    $0x20,%eax
je     11ad <main+0x6d>
xor    %ebp,%ebp
cmp    $0xa,%eax
jne    1181 <main+0x41>
mov    $0x1,%ebp
jmp    1181 <main+0x41>
mov    $0xc7,%ebx
mov    %ebx,%eax
movb   $0x0,(%rsp,%rax,1)
lea    0xe3a(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe43(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2dee(%rip),%rax
mov    (%rax),%eax
add    $0xd0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Introdueix el text acabat en PUNT: \0A\0A\00"
@.str.1 = [26 x i8] c"\0A\0AText introdu\C3\AFt: \0A\0A%s \0A\00"
@.str.2 = [18 x i8] c"\0AN\C2\BA paraules: %d\00"
@.str.3 = [2 x i8] c"\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 [200 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %7
store i32 1, i32* %9
store i32 0, i32* %10
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %38, %2
%13 = load i32, i32* %7
%14 = icmp slt i32 %13, 199
br i1 %14, label %15, label %18
15: ; preds = %12
%16 = call i32 (...) @mygetchar()
store i32 %16, i32* %8
%17 = icmp ne i32 %16, 46
br label %18
18: ; preds = %15, %12
%19 = phi i1 [ false, %12 ], [ %17, %15 ]
br i1 %19, label %20, label %46
20: ; preds = %18
%21 = load i32, i32* %9
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %30
23: ; preds = %20
%24 = load i32, i32* %8
%25 = icmp ne i32 %24, 32
br i1 %25, label %26, label %29
26: ; preds = %23
%27 = load i32, i32* %10
%28 = add nsw i32 %27, 1
store i32 %28, i32* %10
store i32 0, i32* %9
br label %29
29: ; preds = %26, %23
br label %38
30: ; preds = %20
%31 = load i32, i32* %8
%32 = icmp eq i32 %31, 32
br i1 %32, label %36, label %33
33: ; preds = %30
%34 = load i32, i32* %8
%35 = icmp eq i32 %34, 10
br i1 %35, label %36, label %37
36: ; preds = %33, %30
store i32 1, i32* %9
br label %37
37: ; preds = %36, %33
br label %38
38: ; preds = %37, %29
%39 = load i32, i32* %8
%40 = trunc i32 %39 to i8
%41 = load i32, i32* %7
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 %42
store i8 %40, i8* %43
%44 = load i32, i32* %7
%45 = add nsw i32 %44, 1
store i32 %45, i32* %7
br label %12
46: ; preds = %18
%47 = load i32, i32* %7
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 %48
store i8 0, i8* %49
%50 = getelementptr inbounds [200 x i8], [200 x i8]* %6, i64 0, i64 0
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %50)
%52 = load i32, i32* %10
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %52)
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%55 = load i32, i32* @EXIT_SUCCESS
ret i32 %55
}

LLVM IR (-O2):
@.str.1 = [26 x i8] c"\0A\0AText introdu\C3\AFt: \0A\0A%s \0A\00"
@.str.2 = [18 x i8] c"\0AN\C2\BA paraules: %d\00"
@EXIT_SUCCESS = global i32 0
@str = [37 x i8] c"Introdueix el text acabat en PUNT: \0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [200 x i8]
%4 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
br label %6
6: ; preds = %2, %22
%7 = phi i64 [ 0, %2 ], [ %27, %22 ]
%8 = phi i32 [ 0, %2 ], [ %24, %22 ]
%9 = phi i32 [ 1, %2 ], [ %23, %22 ]
%10 = tail call i32 (...) @mygetchar()
%11 = icmp eq i32 %10, 46
br i1 %11, label %29, label %12
12: ; preds = %6
%13 = icmp eq i32 %9, 0
br i1 %13, label %20, label %14
14: ; preds = %12
%15 = icmp eq i32 %10, 32
%16 = zext i1 %15 to i32
%17 = xor i1 %15, true
%18 = zext i1 %17 to i32
%19 = add nsw i32 %8, %18
br label %22
20: ; preds = %12
switch i32 %10, label %22 [
i32 32, label %21
i32 10, label %21
]
21: ; preds = %20, %20
br label %22
22: ; preds = %14, %20, %21
%23 = phi i32 [ 1, %21 ], [ 0, %20 ], [ %16, %14 ]
%24 = phi i32 [ %8, %21 ], [ %8, %20 ], [ %19, %14 ]
%25 = trunc i32 %10 to i8
%26 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 %7
store i8 %25, i8* %26
%27 = add nuw nsw i64 %7, 1
%28 = icmp eq i64 %27, 199
br i1 %28, label %29, label %6
29: ; preds = %22, %6
%30 = phi i64 [ 199, %22 ], [ %7, %6 ]
%31 = phi i32 [ %24, %22 ], [ %8, %6 ]
%32 = and i64 %30, 4294967295
%33 = getelementptr inbounds [200 x i8], [200 x i8]* %3, i64 0, i64 %32
store i8 0, i8* %33
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %4)
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %31)
%36 = call i32 @putchar(i32 10)
%37 = load i32, i32* @EXIT_SUCCESS
ret i32 %37
}