#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 *);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  int i, j = 0, cont = 0, cont2 = 0;
  char ent[30], sai[30];
  printf("entre com uma frase: \n");
  gets(ent);
  for (i = 0; i < 30; i++) {
    if (ent[i] != 32) {
      sai[j] = ent[i];
      j++;
    }
  }
  for (i = 0; ent[i] != '\0'; i++)
    cont++;
  for (i = 0; sai[i] != '\0'; i++)
    cont2++;
  printf("%s\n", sai);
  printf("tamanho da string ENT: %d\n", cont);
  printf("tamanho da string SAI: %d\n", cont2);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x40(%rbp),%rdi
call   1040 <gets@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x1e,-0x8(%rbp)
jge    11aa <main+0x8a>
movslq -0x8(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%eax
cmp    $0x20,%eax
je     1197 <main+0x77>
movslq -0x8(%rbp),%rax
mov    -0x40(%rbp,%rax,1),%cl
movslq -0xc(%rbp),%rax
mov    %cl,-0x60(%rbp,%rax,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    119c <main+0x7c>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1162 <main+0x42>
movl   $0x0,-0x8(%rbp)
movslq -0x8(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11da <main+0xba>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11b1 <main+0x91>
movl   $0x0,-0x8(%rbp)
movslq -0x8(%rbp),%rax
movsbl -0x60(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     120a <main+0xea>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11e1 <main+0xc1>
lea    -0x60(%rbp),%rsi
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x48,%rsp
lea    0xef8(%rip),%rdi
call   1030 <puts@plt>
lea    0x20(%rsp),%rdi
call   1050 <gets@plt>
xor    %eax,%eax
mov    $0x1,%ecx
jmp    116a <main+0x3a>
cs nopw 0x0(%rax,%rax,1)
add    $0x2,%rcx
cmp    $0x1f,%rcx
je     1190 <main+0x60>
movzbl 0x1f(%rsp,%rcx,1),%edx
cmp    $0x20,%dl
je     117c <main+0x4c>
cltq
mov    %dl,(%rsp,%rax,1)
add    $0x1,%eax
movzbl 0x20(%rsp,%rcx,1),%edx
cmp    $0x20,%dl
je     1160 <main+0x30>
cltq
mov    %dl,(%rsp,%rax,1)
add    $0x1,%eax
jmp    1160 <main+0x30>
xor    %r14d,%r14d
cmpb   $0x0,0x20(%rsp)
mov    $0x0,%ebx
je     11bb <main+0x8b>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmpb   $0x0,0x21(%rsp,%rbx,1)
lea    0x1(%rbx),%rbx
jne    11b0 <main+0x80>
cmpb   $0x0,(%rsp)
je     11dc <main+0xac>
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmpb   $0x0,0x1(%rsp,%r14,1)
lea    0x1(%r14),%r14
jne    11d0 <main+0xa0>
mov    %rsp,%rdi
call   1030 <puts@plt>
lea    0xe15(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe20(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@.str.2 = [27 x i8] c"tamanho da string ENT: %d\0A\00"
@.str.3 = [27 x i8] c"tamanho da string SAI: %d\0A\00"
@str = [22 x i8] c"entre com uma frase: \00"
define i32 @main() {
%1 = alloca [30 x i8]
%2 = alloca [30 x i8]
%3 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
%6 = call i32 @gets(i8* %3)
br label %10
7: ; preds = %30
%8 = load i8, i8* %3
%9 = icmp eq i8 %8, 0
br i1 %9, label %36, label %40
10: ; preds = %30, %0
%11 = phi i64 [ 0, %0 ], [ %32, %30 ]
%12 = phi i32 [ 0, %0 ], [ %31, %30 ]
%13 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 %11
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 32
br i1 %15, label %20, label %16
16: ; preds = %10
%17 = sext i32 %12 to i64
%18 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 %17
store i8 %14, i8* %18
%19 = add nsw i32 %12, 1
br label %20
20: ; preds = %10, %16
%21 = phi i32 [ %19, %16 ], [ %12, %10 ]
%22 = or i64 %11, 1
%23 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 32
br i1 %25, label %30, label %26
26: ; preds = %20
%27 = sext i32 %21 to i64
%28 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 %27
store i8 %24, i8* %28
%29 = add nsw i32 %21, 1
br label %30
30: ; preds = %26, %20
%31 = phi i32 [ %29, %26 ], [ %21, %20 ]
%32 = add nuw nsw i64 %11, 2
%33 = icmp eq i64 %32, 30
br i1 %33, label %7, label %10
34: ; preds = %40
%35 = trunc i64 %42 to i32
br label %36
36: ; preds = %34, %7
%37 = phi i32 [ 0, %7 ], [ %35, %34 ]
%38 = load i8, i8* %4
%39 = icmp eq i8 %38, 0
br i1 %39, label %54, label %46
40: ; preds = %7, %40
%41 = phi i64 [ %42, %40 ], [ 0, %7 ]
%42 = add nuw nsw i64 %41, 1
%43 = getelementptr inbounds [30 x i8], [30 x i8]* %1, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = icmp eq i8 %44, 0
br i1 %45, label %34, label %40
46: ; preds = %36, %46
%47 = phi i64 [ %48, %46 ], [ 0, %36 ]
%48 = add nuw nsw i64 %47, 1
%49 = getelementptr inbounds [30 x i8], [30 x i8]* %2, i64 0, i64 %48
%50 = load i8, i8* %49
%51 = icmp eq i8 %50, 0
br i1 %51, label %52, label %46
52: ; preds = %46
%53 = trunc i64 %48 to i32
br label %54
54: ; preds = %52, %36
%55 = phi i32 [ 0, %36 ], [ %53, %52 ]
%56 = call i32 @puts(i8* %4)
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i32 %37)
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i32 %55)
ret i32 0
}