#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 */
typedef int /*<<< orphan*/ string;

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int strlen(char *);
int main() {
  char string[101];
  printf("Forneca uma string com espacos em branco: ");
  fgets(string, sizeof(string), stdin);
  int len = strlen(string);
  printf("%s\n", string);
  for (int i = 0, posicao = 0; i < len; i++, posicao++) {
    if (string[posicao] == ' ')
      posicao++;
    string[i] = string[posicao];
  }
  printf("String sem espaços em branco: %s\n", string);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    0x2e8d(%rip),%rax
mov    (%rax),%edx
mov    $0x65,%esi
call   1050 <fgets@plt>
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x74(%rbp)
lea    -0x70(%rbp),%rsi
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x78(%rbp)
movl   $0x0,-0x7c(%rbp)
mov    -0x78(%rbp),%eax
cmp    -0x74(%rbp),%eax
jge    11e1 <main+0xb1>
movslq -0x7c(%rbp),%rax
movsbl -0x70(%rbp,%rax,1),%eax
cmp    $0x20,%eax
jne    11ba <main+0x8a>
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
movslq -0x7c(%rbp),%rax
mov    -0x70(%rbp,%rax,1),%cl
movslq -0x78(%rbp),%rax
mov    %cl,-0x70(%rbp,%rax,1)
mov    -0x78(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x78(%rbp)
mov    -0x7c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x7c(%rbp)
jmp    1193 <main+0x63>
lea    -0x70(%rbp),%rsi
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x70,%rsp
lea    0xeb1(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e89(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x65,%esi
call   1060 <fgets@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1030 <puts@plt>
test   %ebp,%ebp
jle    1201 <main+0xc1>
mov    %ebp,%ecx
cmp    $0x1,%ebp
jne    1192 <main+0x52>
xor    %eax,%eax
jmp    11e5 <main+0xa5>
mov    %ecx,%edx
and    $0xfffffffe,%edx
xor    %eax,%eax
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movslq %ebx,%rsi
xor    %edi,%edi
cmpb   $0x20,(%rsp,%rsi,1)
sete   %dil
add    %edi,%esi
movslq %esi,%rsi
movzbl (%rsp,%rsi,1),%ebx
mov    %bl,(%rsp,%rax,1)
lea    0x1(%rsi),%rdi
xor    %ebp,%ebp
cmpb   $0x20,0x1(%rsp,%rsi,1)
sete   %bpl
lea    (%rdi,%rbp,1),%esi
movslq %esi,%rsi
movzbl (%rsp,%rsi,1),%ebx
mov    %bl,0x1(%rsp,%rax,1)
add    $0x2,%rax
lea    (%rdi,%rbp,1),%ebx
add    $0x1,%ebx
cmp    %rax,%rdx
jne    11a0 <main+0x60>
test   $0x1,%cl
je     1201 <main+0xc1>
movslq %ebx,%rcx
xor    %edx,%edx
cmpb   $0x20,(%rsp,%rcx,1)
sete   %dl
add    %edx,%ecx
movslq %ecx,%rcx
mov    (%rsp,%rcx,1),%cl
mov    %cl,(%rsp,%rax,1)
lea    0xe23(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [43 x i8] c"Forneca uma string com espacos em branco: \00"
@stdin = global i32 0
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [35 x i8] c"String sem espa\C3\A7os em branco: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [101 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%7 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 0
%8 = load i32, i32* @stdin
%9 = call i32 @fgets(i8* %7, i32 101, i32 %8)
%10 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 0
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %3
%12 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %12)
store i32 0, i32* %4
store i32 0, i32* %5
br label %14
14: ; preds = %36, %0
%15 = load i32, i32* %4
%16 = load i32, i32* %3
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %41
18: ; preds = %14
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 32
br i1 %24, label %25, label %28
25: ; preds = %18
%26 = load i32, i32* %5
%27 = add nsw i32 %26, 1
store i32 %27, i32* %5
br label %28
28: ; preds = %25, %18
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 %30
%32 = load i8, i8* %31
%33 = load i32, i32* %4
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 %34
store i8 %32, i8* %35
br label %36
36: ; preds = %28
%37 = load i32, i32* %4
%38 = add nsw i32 %37, 1
store i32 %38, i32* %4
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 1
store i32 %40, i32* %5
br label %14
41: ; preds = %14
%42 = getelementptr inbounds [101 x i8], [101 x i8]* %2, i64 0, i64 0
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* %42)
%44 = load i32, i32* %1
ret i32 %44
}

LLVM IR (-O2):
@.str = [43 x i8] c"Forneca uma string com espacos em branco: \00"
@stdin = global i32 0
@.str.2 = [35 x i8] c"String sem espa\C3\A7os em branco: %s\0A\00"
define i32 @main() {
%1 = alloca [101 x i8]
%2 = getelementptr inbounds [101 x i8], [101 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0))
%4 = load i32, i32* @stdin
%5 = call i32 @fgets(i8* %2, i32 101, i32 %4)
%6 = call i32 @strlen(i8* %2)
%7 = call i32 @puts(i8* %2)
%8 = icmp sgt i32 %6, 0
br i1 %8, label %9, label %30
9: ; preds = %0
%10 = zext i32 %6 to i64
%11 = and i64 %10, 1
%12 = icmp eq i32 %6, 1
br i1 %12, label %15, label %13
13: ; preds = %9
%14 = and i64 %10, 4294967294
br label %32
15: ; preds = %32, %9
%16 = phi i64 [ 0, %9 ], [ %58, %32 ]
%17 = phi i32 [ 0, %9 ], [ %59, %32 ]
%18 = icmp eq i64 %11, 0
br i1 %18, label %30, label %19
19: ; preds = %15
%20 = sext i32 %17 to i64
%21 = getelementptr inbounds [101 x i8], [101 x i8]* %1, i64 0, i64 %20
%22 = load i8, i8* %21
%23 = icmp eq i8 %22, 32
%24 = zext i1 %23 to i32
%25 = add nsw i32 %17, %24
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [101 x i8], [101 x i8]* %1, i64 0, i64 %26
%28 = load i8, i8* %27
%29 = getelementptr inbounds [101 x i8], [101 x i8]* %1, i64 0, i64 %16
store i8 %28, i8* %29
br label %30
30: ; preds = %19, %15, %0
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i8* %2)
ret i32 0
32: ; preds = %32, %13
%33 = phi i64 [ 0, %13 ], [ %58, %32 ]
%34 = phi i32 [ 0, %13 ], [ %59, %32 ]
%35 = phi i64 [ 0, %13 ], [ %60, %32 ]
%36 = sext i32 %34 to i64
%37 = getelementptr inbounds [101 x i8], [101 x i8]* %1, i64 0, i64 %36
%38 = load i8, i8* %37
%39 = icmp eq i8 %38, 32
%40 = zext i1 %39 to i32
%41 = add nsw i32 %34, %40
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [101 x i8], [101 x i8]* %1, i64 0, i64 %42
%44 = load i8, i8* %43
%45 = getelementptr inbounds [101 x i8], [101 x i8]* %1, i64 0, i64 %33
store i8 %44, i8* %45
%46 = or i64 %33, 1
%47 = add nsw i32 %41, 1
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [101 x i8], [101 x i8]* %1, i64 0, i64 %48
%50 = load i8, i8* %49
%51 = icmp eq i8 %50, 32
%52 = zext i1 %51 to i32
%53 = add nsw i32 %47, %52
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [101 x i8], [101 x i8]* %1, i64 0, i64 %54
%56 = load i8, i8* %55
%57 = getelementptr inbounds [101 x i8], [101 x i8]* %1, i64 0, i64 %46
store i8 %56, i8* %57
%58 = add nuw nsw i64 %33, 2
%59 = add nsw i32 %53, 1
%60 = add i64 %35, 2
%61 = icmp eq i64 %60, %14
br i1 %61, label %15, label %32
}