#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*/ text;

/* Variables and functions */
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdin;
int main() {
  char text[500 + 1];
  printf("Informe o texto (tamanho maximo %d caracteres:", 500);
  fgets(text, sizeof(text), stdin);
  text[0] = '*';
  for (int i = 0; i <= 500; i++)
    if (text[i] == ' ')
      text[i + 1] = '*';
  printf("\nO texto final e %s\n", text);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x210,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec7(%rip),%rdi
mov    $0x1f4,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x200(%rbp),%rdi
mov    0x2e95(%rip),%rax
mov    (%rax),%edx
mov    $0x1f5,%esi
call   1040 <fgets@plt>
movb   $0x2a,-0x200(%rbp)
movl   $0x0,-0x204(%rbp)
cmpl   $0x1f4,-0x204(%rbp)
jg     11c4 <main+0xa4>
movslq -0x204(%rbp),%rax
movsbl -0x200(%rbp,%rax,1),%eax
ff
cmp    $0x20,%eax
jne    11ab <main+0x8b>
mov    -0x204(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x2a,-0x200(%rbp,%rax,1)
2a
jmp    11b0 <main+0x90>
mov    -0x204(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x204(%rbp)
jmp    1170 <main+0x50>
lea    -0x200(%rbp),%rsi
lea    0xe5d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x210,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x1f8,%rsp
lea    0xed2(%rip),%rdi
mov    $0x1f4,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2ea7(%rip),%rax
mov    (%rax),%edx
mov    %rsp,%rdi
mov    $0x1f5,%esi
call   1040 <fgets@plt>
movb   $0x2a,(%rsp)
mov    $0x2a,%cl
mov    $0x3,%eax
cmp    $0x20,%cl
je     1180 <main+0x60>
cmpb   $0x20,-0x2(%rsp,%rax,1)
je     118c <main+0x6c>
cmpb   $0x20,-0x1(%rsp,%rax,1)
je     1198 <main+0x78>
cmp    $0x1f5,%rax
jne    11a4 <main+0x84>
jmp    11b2 <main+0x92>
nopl   0x0(%rax,%rax,1)
movb   $0x2a,-0x2(%rsp,%rax,1)
cmpb   $0x20,-0x2(%rsp,%rax,1)
jne    1167 <main+0x47>
movb   $0x2a,-0x1(%rsp,%rax,1)
cmpb   $0x20,-0x1(%rsp,%rax,1)
jne    116e <main+0x4e>
movb   $0x2a,(%rsp,%rax,1)
cmp    $0x1f5,%rax
je     11b2 <main+0x92>
mov    (%rsp,%rax,1),%cl
add    $0x3,%rax
cmp    $0x20,%cl
je     1180 <main+0x60>
jmp    1160 <main+0x40>
lea    0xe76(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x1f8,%rsp
ret

LLVM IR (-O0):
@.str = [47 x i8] c"Informe o texto (tamanho maximo %d caracteres:\00"
@stdin = global i32 0
@.str.1 = [21 x i8] c"\0AO texto final e %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [501 x i8]
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 500)
%5 = getelementptr inbounds [501 x i8], [501 x i8]* %2, i64 0, i64 0
%6 = load i32, i32* @stdin
%7 = call i32 @fgets(i8* %5, i32 501, i32 %6)
%8 = getelementptr inbounds [501 x i8], [501 x i8]* %2, i64 0, i64 0
store i8 42, i8* %8
store i32 0, i32* %3
br label %9
9: ; preds = %25, %0
%10 = load i32, i32* %3
%11 = icmp sle i32 %10, 500
br i1 %11, label %12, label %28
12: ; preds = %9
%13 = load i32, i32* %3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [501 x i8], [501 x i8]* %2, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp eq i32 %17, 32
br i1 %18, label %19, label %24
19: ; preds = %12
%20 = load i32, i32* %3
%21 = add nsw i32 %20, 1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [501 x i8], [501 x i8]* %2, i64 0, i64 %22
store i8 42, i8* %23
br label %24
24: ; preds = %19, %12
br label %25
25: ; preds = %24
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %9
28: ; preds = %9
%29 = getelementptr inbounds [501 x i8], [501 x i8]* %2, i64 0, i64 0
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %29)
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
@.str = [47 x i8] c"Informe o texto (tamanho maximo %d caracteres:\00"
@stdin = global i32 0
@.str.1 = [21 x i8] c"\0AO texto final e %s\0A\00"
define i32 @main() {
%1 = alloca [501 x i8]
%2 = getelementptr inbounds [501 x i8], [501 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0), i32 500)
%4 = load i32, i32* @stdin
%5 = call i32 @fgets(i8* %2, i32 501, i32 %4)
store i8 42, i8* %2
br label %8
6: ; preds = %29
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i8* %2)
ret i32 0
8: ; preds = %31, %0
%9 = phi i8 [ 42, %0 ], [ %33, %31 ]
%10 = phi i64 [ 0, %0 ], [ %26, %31 ]
%11 = icmp eq i8 %9, 32
%12 = add nuw nsw i64 %10, 1
br i1 %11, label %13, label %15
13: ; preds = %8
%14 = getelementptr inbounds [501 x i8], [501 x i8]* %1, i64 0, i64 %12
store i8 42, i8* %14
br label %15
15: ; preds = %13, %8
%16 = getelementptr inbounds [501 x i8], [501 x i8]* %1, i64 0, i64 %12
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 32
%19 = add nuw nsw i64 %10, 2
br i1 %18, label %20, label %22
20: ; preds = %15
%21 = getelementptr inbounds [501 x i8], [501 x i8]* %1, i64 0, i64 %19
store i8 42, i8* %21
br label %22
22: ; preds = %15, %20
%23 = getelementptr inbounds [501 x i8], [501 x i8]* %1, i64 0, i64 %19
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 32
%26 = add nuw nsw i64 %10, 3
br i1 %25, label %27, label %29
27: ; preds = %22
%28 = getelementptr inbounds [501 x i8], [501 x i8]* %1, i64 0, i64 %26
store i8 42, i8* %28
br label %29
29: ; preds = %27, %22
%30 = icmp eq i64 %26, 501
br i1 %30, label %6, label %31
31: ; preds = %29
%32 = getelementptr inbounds [501 x i8], [501 x i8]* %1, i64 0, i64 %26
%33 = load i8, i8* %32
br label %8
}