#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 *, ...);
int /*<<< orphan*/ scanf(char *, char **);
int main() {
  int i;
  char string[50];
  printf("Digite uma frase");
  scanf("%[^\n]s", &string);
  for (i = 0; string[i] != '\0'; i++) {
    if (string[i] == ' ') {
      string[i] = '#';
    }
  }
  for (i = 0; string[i] != '\0'; i++) {
    printf("%c", string[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x40(%rbp),%rsi
lea    0xec9(%rip),%rdi
call   1040 <scanf@plt>
movl   $0x0,-0x8(%rbp)
movslq -0x8(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     1194 <main+0x74>
movslq -0x8(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%eax
cmp    $0x20,%eax
jne    1181 <main+0x61>
movslq -0x8(%rbp),%rax
movb   $0x23,-0x40(%rbp,%rax,1)
jmp    1186 <main+0x66>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1154 <main+0x34>
movl   $0x0,-0x8(%rbp)
movslq -0x8(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%eax
cmp    $0x0,%eax
je     11d2 <main+0xb2>
movslq -0x8(%rbp),%rax
movsbl -0x40(%rbp,%rax,1),%esi
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    119b <main+0x7b>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
lea    0xec4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec7(%rip),%rdi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1050 <scanf@plt>
jmp    1167 <main+0x37>
nopw   0x0(%rax,%rax,1)
movb   $0x23,(%rbx)
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0x20,%al
je     1160 <main+0x30>
test   %al,%al
jne    1163 <main+0x33>
mov    (%rsp),%al
test   %al,%al
je     1193 <main+0x63>
lea    0x1(%rsp),%rbx
xchg   %ax,%ax
movsbl %al,%edi
call   1030 <putchar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1180 <main+0x50>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [17 x i8] c"Digite uma frase\00"
@.str.1 = [7 x i8] c"%[^\0A]s\00"
define i32 @main() {
%1 = alloca [50 x i8]
%2 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%4 = bitcast [50 x i8]* %1 to i8**
%5 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8** %4)
br label %6
6: ; preds = %14, %0
%7 = phi i64 [ %15, %14 ], [ 0, %0 ]
%8 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %7
%9 = load i8, i8* %8
switch i8 %9, label %14 [
i8 0, label %10
i8 32, label %13
]
10: ; preds = %6
%11 = load i8, i8* %2
%12 = icmp eq i8 %11, 0
br i1 %12, label %25, label %16
13: ; preds = %6
store i8 35, i8* %8
br label %14
14: ; preds = %6, %13
%15 = add nuw i64 %7, 1
br label %6
16: ; preds = %10, %16
%17 = phi i64 [ %21, %16 ], [ 0, %10 ]
%18 = phi i8 [ %23, %16 ], [ %11, %10 ]
%19 = sext i8 %18 to i32
%20 = call i32 @putchar(i32 %19)
%21 = add nuw i64 %17, 1
%22 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %25, label %16
25: ; preds = %16, %10
ret i32 0
}