#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*/ printf(char *, char *);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
main() {
  char frase[500], frase1[500], c;
  int i, j = 0, flag = 0;
  for (i = 0; c != '\n'; i++) {
    scanf("%c", &c);
    frase[i] = c;
  }
  frase[i - 1] = '\0';
  for (i = 0; i < strlen(frase); i++) {
    if (frase[i] == ' ') {
      if (flag == 0) {
        frase1[j] = ' ';
        j++;
        flag = 1;
      }
    } else {
      frase1[j] = frase[i];
      j++;
      flag = 0;
    }
  }
  frase1[i] = '\0';
  printf("%s\n", frase1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x40c(%rbp)
movl   $0x0,-0x410(%rbp)
movl   $0x0,-0x408(%rbp)
movsbl -0x401(%rbp),%eax
cmp    $0xa,%eax
je     11ab <main+0x7b>
lea    0xe89(%rip),%rdi
lea    -0x401(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x401(%rbp),%cl
movslq -0x408(%rbp),%rax
mov    %cl,-0x200(%rbp,%rax,1)
mov    -0x408(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x408(%rbp)
jmp    1160 <main+0x30>
mov    -0x408(%rbp),%eax
sub    $0x1,%eax
cltq
movb   $0x0,-0x200(%rbp,%rax,1)
movl   $0x0,-0x408(%rbp)
mov    -0x408(%rbp),%eax
mov    %eax,-0x414(%rbp)
lea    -0x200(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x414(%rbp),%eax
cmp    %ecx,%eax
jge    1290 <main+0x160>
movslq -0x408(%rbp),%rax
movsbl -0x200(%rbp,%rax,1),%eax
ff
cmp    $0x20,%eax
jne    1242 <main+0x112>
cmpl   $0x0,-0x410(%rbp)
jne    123d <main+0x10d>
movslq -0x40c(%rbp),%rax
movb   $0x20,-0x400(%rbp,%rax,1)
20
mov    -0x40c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40c(%rbp)
movl   $0x1,-0x410(%rbp)
jmp    1277 <main+0x147>
movslq -0x408(%rbp),%rax
mov    -0x200(%rbp,%rax,1),%cl
movslq -0x40c(%rbp),%rax
mov    %cl,-0x400(%rbp,%rax,1)
mov    -0x40c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40c(%rbp)
movl   $0x0,-0x410(%rbp)
jmp    127c <main+0x14c>
mov    -0x408(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x408(%rbp)
jmp    11c8 <main+0x98>
movslq -0x408(%rbp),%rax
movb   $0x0,-0x400(%rbp,%rax,1)
lea    -0x400(%rbp),%rsi
lea    0xd56(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x410,%rsp
movabs $0xffffffff00000000,%rbp
ff ff ff
lea    0x10(%rsp),%rbx
lea    0xeab(%rip),%r14
lea    0xf(%rsp),%r15
movabs $0x100000000,%r12
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    %r12,%rbp
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
movzbl 0xf(%rsp),%eax
mov    %al,(%rbx)
add    $0x1,%rbx
cmp    $0xa,%al
jne    1170 <main+0x40>
sar    $0x20,%rbp
movb   $0x0,0x10(%rsp,%rbp,1)
lea    0x10(%rsp),%rdi
call   1030 <strlen@plt>
xor    %ecx,%ecx
test   %eax,%eax
jle    11fc <main+0xcc>
lea    0x10(%rsp),%r14
xor    %ebx,%ebx
xor    %r15d,%r15d
jmp    11e4 <main+0xb4>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movslq %r15d,%r15
mov    %al,0x210(%rsp,%r15,1)
add    $0x1,%r15d
add    $0x1,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
mov    %ebp,%ecx
cmp    %rax,%rbx
jge    11fe <main+0xce>
movzbl 0x10(%rsp,%rbx,1),%eax
xor    %ebp,%ebp
cmp    $0x20,%al
jne    11c0 <main+0x90>
mov    $0x1,%ebp
test   %ecx,%ecx
jne    11cf <main+0x9f>
mov    $0x20,%al
jmp    11c0 <main+0x90>
xor    %ebx,%ebx
movb   $0x0,0x210(%rsp,%rbx,1)
lea    0xdf6(%rip),%rdi
lea    0x210(%rsp),%rsi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x410,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%c\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca [500 x i8]
%2 = alloca [500 x i8]
%3 = alloca i8
%4 = getelementptr inbounds [500 x i8], [500 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 0
br label %6
6: ; preds = %0, %6
%7 = phi i64 [ 0, %0 ], [ %11, %6 ]
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %3)
%9 = load i8, i8* %3
%10 = getelementptr inbounds [500 x i8], [500 x i8]* %1, i64 0, i64 %7
store i8 %9, i8* %10
%11 = add nuw i64 %7, 1
%12 = icmp eq i8 %9, 10
br i1 %12, label %13, label %6
13: ; preds = %6
%14 = shl i64 %7, 32
%15 = ashr exact i64 %14, 32
%16 = getelementptr inbounds [500 x i8], [500 x i8]* %1, i64 0, i64 %15
store i8 0, i8* %16
%17 = call i32 @strlen(i8* %4)
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %43
19: ; preds = %13, %34
%20 = phi i64 [ %37, %34 ], [ 0, %13 ]
%21 = phi i32 [ %36, %34 ], [ 0, %13 ]
%22 = phi i32 [ %35, %34 ], [ 0, %13 ]
%23 = getelementptr inbounds [500 x i8], [500 x i8]* %1, i64 0, i64 %20
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 32
br i1 %25, label %26, label %28
26: ; preds = %19
%27 = icmp eq i32 %21, 0
br i1 %27, label %28, label %34
28: ; preds = %19, %26
%29 = phi i8 [ 32, %26 ], [ %24, %19 ]
%30 = phi i32 [ 1, %26 ], [ 0, %19 ]
%31 = sext i32 %22 to i64
%32 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 %31
store i8 %29, i8* %32
%33 = add nsw i32 %22, 1
br label %34
34: ; preds = %28, %26
%35 = phi i32 [ %22, %26 ], [ %33, %28 ]
%36 = phi i32 [ 1, %26 ], [ %30, %28 ]
%37 = add nuw nsw i64 %20, 1
%38 = call i32 @strlen(i8* %4)
%39 = sext i32 %38 to i64
%40 = icmp slt i64 %37, %39
br i1 %40, label %19, label %41
41: ; preds = %34
%42 = and i64 %37, 4294967295
br label %43
43: ; preds = %41, %13
%44 = phi i64 [ 0, %13 ], [ %42, %41 ]
%45 = getelementptr inbounds [500 x i8], [500 x i8]* %2, i64 0, i64 %44
store i8 0, i8* %45
%46 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %5)
ret i32 0
}