#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*/ clear();
int /*<<< orphan*/ endwin();
int /*<<< orphan*/ getch();
int /*<<< orphan*/ getstr(char *);
int /*<<< orphan*/ initscr();
scalar_t__ ispunct(char);
scalar_t__ isspace(char);
int /*<<< orphan*/ printw(char *, ...);
int /*<<< orphan*/ puts(char *);
int strlen(char *);
void main(void) {
  char name[100];
  char daStr[80] = "";
  int i, count = 1;
  initscr();
  clear();
  printw("Bienvenido Usuario. Para empezar porfavor introdusca su nombre\n>>");
  getstr(name);
  puts("Este programa lee y evalua todos los caracteres de una cadena de hasta "
       "80 caracteres \n");
  puts("Al terminar de evaluar la cadena se determina y despliega el numero de "
       "palabras que forman la cadena \n");
  printw("%s, Porfavor introduce una cadena para ser evaluada \n>>", name);
  getstr(daStr);
  for (i = 0; i < strlen(daStr); i++)
    if (isspace(daStr[i]) || ispunct(daStr[i])) {
      count++;
    }
  if (ispunct(daStr[strlen(daStr) - 1])) {
    count--;
  }
  printw("%s, Su cadena consiste de %d palabras\n", name, count);
  getch();
  endwin();
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
lea    -0xc0(%rbp),%rdi
xor    %esi,%esi
mov    $0x50,%edx
call   1060 <memset@plt>
movl   $0x1,-0xc8(%rbp)
mov    $0x0,%al
call   1050 <initscr@plt>
mov    $0x0,%al
call   10d0 <clear@plt>
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   10a0 <printw@plt>
lea    -0x70(%rbp),%rdi
call   1090 <getstr@plt>
lea    0xe3e(%rip),%rdi
call   1030 <puts@plt>
lea    0xe89(%rip),%rdi
call   1030 <puts@plt>
lea    -0x70(%rbp),%rsi
lea    0xee0(%rip),%rdi
mov    $0x0,%al
call   10a0 <printw@plt>
lea    -0xc0(%rbp),%rdi
call   1090 <getstr@plt>
movl   $0x0,-0xc4(%rbp)
mov    -0xc4(%rbp),%eax
mov    %eax,-0xcc(%rbp)
lea    -0xc0(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0xcc(%rbp),%eax
cmp    %ecx,%eax
jge    12c9 <main+0x119>
movslq -0xc4(%rbp),%rax
movsbl -0xc0(%rbp,%rax,1),%edi
ff
call   1080 <isspace@plt>
cmp    $0x0,%rax
jne    12a1 <main+0xf1>
movslq -0xc4(%rbp),%rax
movsbl -0xc0(%rbp,%rax,1),%edi
ff
call   1070 <ispunct@plt>
cmp    $0x0,%rax
je     12b0 <main+0x100>
mov    -0xc8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc8(%rbp)
jmp    12b5 <main+0x105>
mov    -0xc4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc4(%rbp)
jmp    123d <main+0x8d>
lea    -0xc0(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0xc0(%rbp,%rax,1),%edi
ff
call   1070 <ispunct@plt>
cmp    $0x0,%rax
je     1300 <main+0x150>
mov    -0xc8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc8(%rbp)
lea    -0x70(%rbp),%rsi
mov    -0xc8(%rbp),%edx
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   10a0 <printw@plt>
mov    $0x0,%al
call   10b0 <getch@plt>
mov    $0x0,%al
call   10c0 <endwin@plt>
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0xb8,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
xor    %eax,%eax
call   1050 <initscr@plt>
xor    %eax,%eax
call   10c0 <clear@plt>
lea    0xe23(%rip),%rdi
xor    %eax,%eax
call   1090 <printw@plt>
lea    0x50(%rsp),%rbx
mov    %rbx,%rdi
call   1080 <getstr@plt>
lea    0xe4a(%rip),%rdi
call   1030 <puts@plt>
lea    0xe95(%rip),%rdi
call   1030 <puts@plt>
lea    0xef0(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1090 <printw@plt>
mov    %rsp,%r14
mov    %r14,%rdi
call   1080 <getstr@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    $0x1,%ebp
test   %eax,%eax
jle    1274 <main+0xd4>
xor    %ebx,%ebx
mov    %rsp,%r15
jmp    1256 <main+0xb6>
nopl   (%rax)
add    $0x1,%ebp
add    $0x1,%rbx
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jge    1274 <main+0xd4>
movsbl (%rsp,%rbx,1),%edi
call   1070 <isspace@plt>
test   %rax,%rax
jne    1240 <main+0xa0>
movsbl (%rsp,%rbx,1),%edi
call   1060 <ispunct@plt>
test   %rax,%rax
jne    1240 <main+0xa0>
jmp    1243 <main+0xa3>
mov    %r14,%rdi
call   1040 <strlen@plt>
cltq
movsbl -0x1(%rax,%r14,1),%edi
call   1060 <ispunct@plt>
cmp    $0x1,%rax
adc    $0xffffffff,%ebp
lea    0xea1(%rip),%rdi
lea    0x50(%rsp),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1090 <printw@plt>
xor    %eax,%eax
call   10a0 <getch@plt>
xor    %eax,%eax
call   10b0 <endwin@plt>
add    $0xb8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [66 x i8] c"Bienvenido Usuario. Para empezar porfavor introdusca su nombre\0A>>\00"
@.str.1 = [87 x i8] c"Este programa lee y evalua todos los caracteres de una cadena de hasta 80 caracteres \0A\00"
@.str.2 = [103 x i8] c"Al terminar de evaluar la cadena se determina y despliega el numero de palabras que forman la cadena \0A\00"
@.str.3 = [56 x i8] c"%s, Porfavor introduce una cadena para ser evaluada \0A>>\00"
@.str.4 = [39 x i8] c"%s, Su cadena consiste de %d palabras\0A\00"
define void @main() {
%1 = alloca [100 x i8]
%2 = alloca [80 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = bitcast [80 x i8]* %2 to i8*
store i32 1, i32* %4
%6 = call i32 (...) @initscr()
%7 = call i32 (...) @clear()
%8 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0))
%9 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%10 = call i32 @getstr(i8* %9)
%11 = call i32 @puts(i8* getelementptr inbounds ([87 x i8], [87 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 @puts(i8* getelementptr inbounds ([103 x i8], [103 x i8]* @.str.2, i64 0, i64 0))
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%14 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.3, i64 0, i64 0), i8* %13)
%15 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%16 = call i32 @getstr(i8* %15)
store i32 0, i32* %3
br label %17
17: ; preds = %40, %0
%18 = load i32, i32* %3
%19 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%20 = call i32 @strlen(i8* %19)
%21 = icmp slt i32 %18, %20
br i1 %21, label %22, label %43
22: ; preds = %17
%23 = load i32, i32* %3
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = call i64 @isspace(i8 signext %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %36, label %29
29: ; preds = %22
%30 = load i32, i32* %3
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = call i64 @ispunct(i8 signext %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %29, %22
%37 = load i32, i32* %4
%38 = add nsw i32 %37, 1
store i32 %38, i32* %4
br label %39
39: ; preds = %36, %29
br label %40
40: ; preds = %39
%41 = load i32, i32* %3
%42 = add nsw i32 %41, 1
store i32 %42, i32* %3
br label %17
43: ; preds = %17
%44 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%45 = call i32 @strlen(i8* %44)
%46 = sub nsw i32 %45, 1
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 %47
%49 = load i8, i8* %48
%50 = call i64 @ispunct(i8 signext %49)
%51 = icmp ne i64 %50, 0
br i1 %51, label %52, label %55
52: ; preds = %43
%53 = load i32, i32* %4
%54 = add nsw i32 %53, -1
store i32 %54, i32* %4
br label %55
55: ; preds = %52, %43
%56 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%57 = load i32, i32* %4
%58 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i8* %56, i32 %57)
%59 = call i32 (...) @getch()
%60 = call i32 (...) @endwin()
ret void
}

LLVM IR (-O2):
@.str = [66 x i8] c"Bienvenido Usuario. Para empezar porfavor introdusca su nombre\0A>>\00"
@.str.1 = [87 x i8] c"Este programa lee y evalua todos los caracteres de una cadena de hasta 80 caracteres \0A\00"
@.str.2 = [103 x i8] c"Al terminar de evaluar la cadena se determina y despliega el numero de palabras que forman la cadena \0A\00"
@.str.3 = [56 x i8] c"%s, Porfavor introduce una cadena para ser evaluada \0A>>\00"
@.str.4 = [39 x i8] c"%s, Su cadena consiste de %d palabras\0A\00"
define void @main() {
%1 = alloca [100 x i8]
%2 = alloca [80 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (...) @initscr()
%6 = tail call i32 (...) @clear()
%7 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([66 x i8], [66 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @getstr(i8* %3)
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([87 x i8], [87 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([103 x i8], [103 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.3, i64 0, i64 0), i8* %3)
%12 = call i32 @getstr(i8* %4)
%13 = call i32 @strlen(i8* %4)
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %34
15: ; preds = %0, %28
%16 = phi i64 [ %30, %28 ], [ 0, %0 ]
%17 = phi i32 [ %29, %28 ], [ 1, %0 ]
%18 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 %16
%19 = load i8, i8* %18
%20 = call i64 @isspace(i8 signext %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %15
%23 = load i8, i8* %18
%24 = call i64 @ispunct(i8 signext %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %28, label %26
26: ; preds = %22, %15
%27 = add nsw i32 %17, 1
br label %28
28: ; preds = %22, %26
%29 = phi i32 [ %27, %26 ], [ %17, %22 ]
%30 = add nuw nsw i64 %16, 1
%31 = call i32 @strlen(i8* %4)
%32 = sext i32 %31 to i64
%33 = icmp slt i64 %30, %32
br i1 %33, label %15, label %34
34: ; preds = %28, %0
%35 = phi i32 [ 1, %0 ], [ %29, %28 ]
%36 = call i32 @strlen(i8* %4)
%37 = add nsw i32 %36, -1
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 %38
%40 = load i8, i8* %39
%41 = call i64 @ispunct(i8 signext %40)
%42 = icmp ne i64 %41, 0
%43 = sext i1 %42 to i32
%44 = add nsw i32 %35, %43
%45 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i8* %3, i32 %44)
%46 = call i32 (...) @getch()
%47 = call i32 (...) @endwin()
ret void
}