#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 */
char EOF;
char getchar();
int /*<<< orphan*/ printf(char *, ...);
main() {
  const int SI = 1;
  const int NO = 0;
  char car;
  int palabra = NO;
  int ncaracteres = 0, npalabras = 0, nlineas = 0;
  printf("Introducir texto. ");
  printf("Pulse Entrar después de cada línea.\n");
  printf("Para finalizar introducir la marca EOF.\n\n");
  while ((car = getchar()) != EOF) {
    ++ncaracteres;
    if (car == ' ' || car == '\n' || car == '\t')
      palabra = NO;
    else if (palabra == NO) {
      ++npalabras;
      palabra = SI;
    }
    if (car == '\n')
      ++nlineas;
  }
  printf("%d %d %d\n", ncaracteres, npalabras, nlineas);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
mov    %al,-0xd(%rbp)
movsbl %al,%eax
mov    0x2e51(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1218 <main+0xf8>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
movsbl -0xd(%rbp),%eax
cmp    $0x20,%eax
je     11d2 <main+0xb2>
movsbl -0xd(%rbp),%eax
cmp    $0xa,%eax
je     11d2 <main+0xb2>
movsbl -0xd(%rbp),%eax
cmp    $0x9,%eax
jne    11de <main+0xbe>
movl   $0x0,-0x14(%rbp)
jmp    11fd <main+0xdd>
cmpl   $0x0,-0x14(%rbp)
jne    11f8 <main+0xd8>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
movl   $0x1,-0x14(%rbp)
jmp    11fd <main+0xdd>
movsbl -0xd(%rbp),%eax
cmp    $0xa,%eax
jne    1213 <main+0xf3>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1183 <main+0x63>
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
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    0xebe(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecb(%rip),%rdi
call   1030 <puts@plt>
lea    0xee5(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1050 <getchar@plt>
mov    0x2e77(%rip),%r15
mov    $0x0,%r14d
mov    $0x0,%ebp
cmp    (%r15),%al
jne    11a7 <main+0x77>
lea    0xe8b(%rip),%rdi
mov    %ebx,%esi
mov    %r14d,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movabs $0x100000600,%r12
xor    %ebp,%ebp
xor    %r14d,%r14d
xor    %ebx,%ebx
xor    %r13d,%r13d
jmp    11e6 <main+0xb6>
nopl   (%rax)
cmp    $0x1,%r13d
adc    $0x0,%r14d
mov    $0x1,%r13d
xor    %ecx,%ecx
cmp    $0xa,%al
sete   %cl
add    %ecx,%ebp
xor    %eax,%eax
call   1050 <getchar@plt>
add    $0x1,%ebx
cmp    (%r15),%al
je     1181 <main+0x51>
cmp    $0x20,%al
ja     11c0 <main+0x90>
movzbl %al,%ecx
bt     %rcx,%r12
jae    11c0 <main+0x90>
xor    %r13d,%r13d
jmp    11ce <main+0x9e>

LLVM IR (-O0):
@.str = [19 x i8] c"Introducir texto. \00"
@.str.1 = [39 x i8] c"Pulse Entrar despu\C3\A9s de cada l\C3\ADnea.\0A\00"
@.str.2 = [42 x i8] c"Para finalizar introducir la marca EOF.\0A\0A\00"
@EOF = global i8 0
@.str.3 = [10 x i8] c"%d %d %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
store i32 0, i32* %3
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0))
br label %12
12: ; preds = %47, %0
%13 = call signext i8 (...) @getchar()
store i8 %13, i8* %4
%14 = sext i8 %13 to i32
%15 = load i8, i8* @EOF
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %14, %16
br i1 %17, label %18, label %48
18: ; preds = %12
%19 = load i32, i32* %6
%20 = add nsw i32 %19, 1
store i32 %20, i32* %6
%21 = load i8, i8* %4
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 32
br i1 %23, label %32, label %24
24: ; preds = %18
%25 = load i8, i8* %4
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 10
br i1 %27, label %32, label %28
28: ; preds = %24
%29 = load i8, i8* %4
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 9
br i1 %31, label %32, label %33
32: ; preds = %28, %24, %18
store i32 0, i32* %5
br label %40
33: ; preds = %28
%34 = load i32, i32* %5
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
store i32 1, i32* %5
br label %39
39: ; preds = %36, %33
br label %40
40: ; preds = %39, %32
%41 = load i8, i8* %4
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 10
br i1 %43, label %44, label %47
44: ; preds = %40
%45 = load i32, i32* %8
%46 = add nsw i32 %45, 1
store i32 %46, i32* %8
br label %47
47: ; preds = %44, %40
br label %12
48: ; preds = %12
%49 = load i32, i32* %6
%50 = load i32, i32* %7
%51 = load i32, i32* %8
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %49, i32 %50, i32 %51)
%53 = load i32, i32* %1
ret i32 %53
}

LLVM IR (-O2):
@.str = [19 x i8] c"Introducir texto. \00"
@EOF = global i8 0
@.str.3 = [10 x i8] c"%d %d %d\0A\00"
@str = [38 x i8] c"Pulse Entrar despu\C3\A9s de cada l\C3\ADnea.\00"
@str.4 = [41 x i8] c"Para finalizar introducir la marca EOF.\0A\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str.4, i64 0, i64 0))
%4 = tail call signext i8 (...) @getchar()
%5 = load i8, i8* @EOF
%6 = icmp eq i8 %4, %5
br i1 %6, label %27, label %7
7: ; preds = %0, %19
%8 = phi i8 [ %24, %19 ], [ %4, %0 ]
%9 = phi i32 [ %23, %19 ], [ 0, %0 ]
%10 = phi i32 [ %21, %19 ], [ 0, %0 ]
%11 = phi i32 [ %13, %19 ], [ 0, %0 ]
%12 = phi i32 [ %20, %19 ], [ 0, %0 ]
%13 = add nuw nsw i32 %11, 1
%14 = icmp eq i8 %8, 10
switch i8 %8, label %15 [
i8 32, label %19
i8 10, label %19
i8 9, label %19
]
15: ; preds = %7
%16 = icmp eq i32 %12, 0
%17 = zext i1 %16 to i32
%18 = add nsw i32 %10, %17
br label %19
19: ; preds = %15, %7, %7, %7
%20 = phi i32 [ 0, %7 ], [ 0, %7 ], [ 0, %7 ], [ 1, %15 ]
%21 = phi i32 [ %10, %7 ], [ %10, %7 ], [ %10, %7 ], [ %18, %15 ]
%22 = zext i1 %14 to i32
%23 = add nuw nsw i32 %9, %22
%24 = tail call signext i8 (...) @getchar()
%25 = load i8, i8* @EOF
%26 = icmp eq i8 %24, %25
br i1 %26, label %27, label %7
27: ; preds = %19, %0
%28 = phi i32 [ 0, %0 ], [ %13, %19 ]
%29 = phi i32 [ 0, %0 ], [ %21, %19 ]
%30 = phi i32 [ 0, %0 ], [ %23, %19 ]
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %28, i32 %29, i32 %30)
ret i32 0
}