#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*/ gets(char *);
scalar_t__ isspace(char);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
int main(void) {
  char a[80 + 1], b[80 + 1];
  int longitud, i, j;
  printf("Introduce una cadena (max %d cars): ", 80);
  gets(a);
  longitud = strlen(a);
  b[0] = a[0];
  j = 1;
  for (i = 1; i < longitud; i++) {
    if ((!isspace(a[i]) || (isspace(a[i]) && !isspace(a[i - 1])))) {
      b[j++] = a[i];
    }
  }
  b[j] = '\0';
  printf("La cadena normalizada es %s\n", b);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea7(%rip),%rdi
mov    $0x50,%esi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x60(%rbp),%rdi
call   1060 <gets@plt>
lea    -0x60(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc4(%rbp)
mov    -0x60(%rbp),%al
mov    %al,-0xc0(%rbp)
movl   $0x1,-0xcc(%rbp)
movl   $0x1,-0xc8(%rbp)
mov    -0xc8(%rbp),%eax
cmp    -0xc4(%rbp),%eax
jge    123f <main+0xff>
movslq -0xc8(%rbp),%rax
movsbl -0x60(%rbp,%rax,1),%edi
call   1050 <isspace@plt>
cmp    $0x0,%rax
je     1201 <main+0xc1>
movslq -0xc8(%rbp),%rax
movsbl -0x60(%rbp,%rax,1),%edi
call   1050 <isspace@plt>
cmp    $0x0,%rax
je     1226 <main+0xe6>
mov    -0xc8(%rbp),%eax
sub    $0x1,%eax
cltq
movsbl -0x60(%rbp,%rax,1),%edi
call   1050 <isspace@plt>
cmp    $0x0,%rax
jne    1226 <main+0xe6>
movslq -0xc8(%rbp),%rax
mov    -0x60(%rbp,%rax,1),%cl
mov    -0xcc(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0xcc(%rbp)
cltq
mov    %cl,-0xc0(%rbp,%rax,1)
jmp    122b <main+0xeb>
mov    -0xc8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc8(%rbp)
jmp    119a <main+0x5a>
movslq -0xcc(%rbp),%rax
movb   $0x0,-0xc0(%rbp,%rax,1)
lea    -0xc0(%rbp),%rsi
lea    0xdc9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0xc0,%rsp
lea    0xeae(%rip),%rdi
mov    $0x50,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1060 <gets@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    (%rsp),%cl
mov    %cl,0x60(%rsp)
mov    $0x1,%ebp
cmp    $0x2,%eax
jl     11e4 <main+0xa4>
mov    %eax,%r14d
mov    $0x1,%ebp
mov    $0x1,%ebx
jmp    11b7 <main+0x77>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl (%rsp,%rbx,1),%eax
movslq %ebp,%rcx
add    $0x1,%ebp
mov    %al,0x60(%rsp,%rcx,1)
add    $0x1,%rbx
cmp    %rbx,%r14
je     11e4 <main+0xa4>
movsbl (%rsp,%rbx,1),%edi
call   1050 <isspace@plt>
test   %rax,%rax
je     11a0 <main+0x60>
movsbl (%rsp,%rbx,1),%edi
call   1050 <isspace@plt>
test   %rax,%rax
je     11ae <main+0x6e>
movsbl -0x1(%rsp,%rbx,1),%edi
call   1050 <isspace@plt>
test   %rax,%rax
jne    11ae <main+0x6e>
jmp    11a0 <main+0x60>
movslq %ebp,%rax
movb   $0x0,0x60(%rsp,%rax,1)
lea    0xe32(%rip),%rdi
lea    0x60(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0xc0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [37 x i8] c"Introduce una cadena (max %d cars): \00"
@.str.1 = [29 x i8] c"La cadena normalizada es %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [81 x i8]
%3 = alloca [81 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 80)
%8 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 0
%9 = call i32 @gets(i8* %8)
%10 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 0
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %4
%12 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 0
%13 = load i8, i8* %12
%14 = getelementptr inbounds [81 x i8], [81 x i8]* %3, i64 0, i64 0
store i8 %13, i8* %14
store i32 1, i32* %6
store i32 1, i32* %5
br label %15
15: ; preds = %51, %0
%16 = load i32, i32* %5
%17 = load i32, i32* %4
%18 = icmp slt i32 %16, %17
br i1 %18, label %19, label %54
19: ; preds = %15
%20 = load i32, i32* %5
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = call i64 @isspace(i8 signext %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %41
26: ; preds = %19
%27 = load i32, i32* %5
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 %28
%30 = load i8, i8* %29
%31 = call i64 @isspace(i8 signext %30)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %50
33: ; preds = %26
%34 = load i32, i32* %5
%35 = sub nsw i32 %34, 1
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 %36
%38 = load i8, i8* %37
%39 = call i64 @isspace(i8 signext %38)
%40 = icmp ne i64 %39, 0
br i1 %40, label %50, label %41
41: ; preds = %33, %19
%42 = load i32, i32* %5
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 %43
%45 = load i8, i8* %44
%46 = load i32, i32* %6
%47 = add nsw i32 %46, 1
store i32 %47, i32* %6
%48 = sext i32 %46 to i64
%49 = getelementptr inbounds [81 x i8], [81 x i8]* %3, i64 0, i64 %48
store i8 %45, i8* %49
br label %50
50: ; preds = %41, %33, %26
br label %51
51: ; preds = %50
%52 = load i32, i32* %5
%53 = add nsw i32 %52, 1
store i32 %53, i32* %5
br label %15
54: ; preds = %15
%55 = load i32, i32* %6
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds [81 x i8], [81 x i8]* %3, i64 0, i64 %56
store i8 0, i8* %57
%58 = getelementptr inbounds [81 x i8], [81 x i8]* %3, i64 0, i64 0
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %58)
ret i32 0
}

LLVM IR (-O2):
@.str = [37 x i8] c"Introduce una cadena (max %d cars): \00"
@.str.1 = [29 x i8] c"La cadena normalizada es %s\0A\00"
define i32 @main() {
%1 = alloca [81 x i8]
%2 = alloca [81 x i8]
%3 = getelementptr inbounds [81 x i8], [81 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i32 80)
%6 = call i32 @gets(i8* %3)
%7 = call i32 @strlen(i8* %3)
%8 = load i8, i8* %3
store i8 %8, i8* %4
%9 = icmp sgt i32 %7, 1
br i1 %9, label %10, label %38
10: ; preds = %0
%11 = zext i32 %7 to i64
br label %12
12: ; preds = %10, %34
%13 = phi i64 [ 1, %10 ], [ %36, %34 ]
%14 = phi i32 [ 1, %10 ], [ %35, %34 ]
%15 = getelementptr inbounds [81 x i8], [81 x i8]* %1, i64 0, i64 %13
%16 = load i8, i8* %15
%17 = call i64 @isspace(i8 signext %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %29, label %19
19: ; preds = %12
%20 = load i8, i8* %15
%21 = call i64 @isspace(i8 signext %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %34, label %23
23: ; preds = %19
%24 = add nsw i64 %13, -1
%25 = getelementptr inbounds [81 x i8], [81 x i8]* %1, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = call i64 @isspace(i8 signext %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %34
29: ; preds = %23, %12
%30 = load i8, i8* %15
%31 = add nsw i32 %14, 1
%32 = sext i32 %14 to i64
%33 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 %32
store i8 %30, i8* %33
br label %34
34: ; preds = %19, %23, %29
%35 = phi i32 [ %14, %23 ], [ %31, %29 ], [ %14, %19 ]
%36 = add nuw nsw i64 %13, 1
%37 = icmp eq i64 %36, %11
br i1 %37, label %38, label %12
38: ; preds = %34, %0
%39 = phi i32 [ 1, %0 ], [ %35, %34 ]
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [81 x i8], [81 x i8]* %2, i64 0, i64 %40
store i8 0, i8* %41
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %4)
ret i32 0
}