#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 strlen(char *);
int main() {
  int i, tam, tipo;
  char frase[10000];
  gets(frase);
  while (frase[0] != '_') {
    tam = strlen(frase);
    for (i = 0; i < tam; ++i) {
      if (i == 0 && frase[i] == '+') {
        printf("*");
        tipo = 0;
      } else if (i == (tam - 1) && frase[i] == '+') {
        printf("#\n");
        tipo = 1;
      } else if (i == (tam - 1))
        printf("%c\n", frase[i]);
      else if (frase[i] == '+') {
        if (tipo == 0) {
          printf("#");
          tipo = 1;
        } else if (tipo == 1) {
          printf("*");
          tipo = 0;
        }
      } else if (frase[i] == ' ')
        printf(" ");
      else
        printf("%c", frase[i]);
    }
    gets(frase);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2720,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x2720(%rbp),%rdi
call   1050 <gets@plt>
movsbl -0x2720(%rbp),%eax
cmp    $0x5f,%eax
je     1305 <main+0x1d5>
lea    -0x2720(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12f4 <main+0x1c4>
cmpl   $0x0,-0x8(%rbp)
jne    11b9 <main+0x89>
movslq -0x8(%rbp),%rax
movsbl -0x2720(%rbp,%rax,1),%eax
ff
cmp    $0x2b,%eax
jne    11b9 <main+0x89>
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x10(%rbp)
jmp    12e1 <main+0x1b1>
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    11f9 <main+0xc9>
movslq -0x8(%rbp),%rax
movsbl -0x2720(%rbp,%rax,1),%eax
ff
cmp    $0x2b,%eax
jne    11f9 <main+0xc9>
lea    0xe1c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x10(%rbp)
jmp    12dc <main+0x1ac>
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jne    1229 <main+0xf9>
movslq -0x8(%rbp),%rax
movsbl -0x2720(%rbp,%rax,1),%esi
ff
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12d7 <main+0x1a7>
movslq -0x8(%rbp),%rax
movsbl -0x2720(%rbp,%rax,1),%eax
ff
cmp    $0x2b,%eax
jne    128b <main+0x15b>
cmpl   $0x0,-0x10(%rbp)
jne    1262 <main+0x132>
lea    0xdba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x10(%rbp)
jmp    1286 <main+0x156>
cmpl   $0x1,-0x10(%rbp)
jne    1281 <main+0x151>
lea    0xd8d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x10(%rbp)
jmp    1286 <main+0x156>
jmp    12d2 <main+0x1a2>
movslq -0x8(%rbp),%rax
movsbl -0x2720(%rbp,%rax,1),%eax
ff
cmp    $0x20,%eax
jne    12b3 <main+0x183>
lea    0xd64(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12cd <main+0x19d>
movslq -0x8(%rbp),%rax
movsbl -0x2720(%rbp,%rax,1),%esi
ff
lea    0xd47(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12d2 <main+0x1a2>
jmp    12d7 <main+0x1a7>
jmp    12dc <main+0x1ac>
jmp    12e1 <main+0x1b1>
jmp    12e6 <main+0x1b6>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1174 <main+0x44>
lea    -0x2720(%rbp),%rdi
call   1050 <gets@plt>
jmp    114e <main+0x1e>
xor    %eax,%eax
add    $0x2720,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2718,%rsp
mov    %rsp,%rdi
call   1070 <gets@plt>
cmpb   $0x5f,(%rsp)
jne    1183 <main+0x33>
xor    %eax,%eax
add    $0x2718,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsp,%rbx
lea    0xe77(%rip),%r15
lea    0xe6c(%rip),%r12
jmp    11b1 <main+0x61>
cs nopw 0x0(%rax,%rax,1)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1070 <gets@plt>
cmpb   $0x5f,(%rsp)
je     116f <main+0x1f>
mov    %rbx,%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    11a0 <main+0x50>
lea    -0x1(%rax),%r13d
mov    %eax,%ebx
xor    %r14d,%r14d
jmp    11e5 <main+0x95>
nopl   0x0(%rax,%rax,1)
mov    $0x2a,%edi
call   1030 <putchar@plt>
xor    %ebp,%ebp
add    $0x1,%r14
cmp    %r14,%rbx
je     11a0 <main+0x50>
test   %r14,%r14
jne    11f0 <main+0xa0>
cmpb   $0x2b,(%rsp)
je     11d0 <main+0x80>
cmp    %r14,%r13
jne    1210 <main+0xc0>
movsbl (%rsp,%r13,1),%esi
cmp    $0x2b,%esi
jne    123a <main+0xea>
mov    %r15,%rdi
call   1040 <puts@plt>
mov    $0x1,%ebp
jmp    11dc <main+0x8c>
xchg   %ax,%ax
movsbl (%rsp,%r14,1),%edi
cmp    $0x20,%edi
je     1246 <main+0xf6>
cmp    $0x2b,%dil
jne    124b <main+0xfb>
cmp    $0x1,%ebp
je     11d0 <main+0x80>
test   %ebp,%ebp
jne    11dc <main+0x8c>
mov    $0x23,%edi
call   1030 <putchar@plt>
mov    $0x1,%ebp
jmp    11dc <main+0x8c>
mov    %r12,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11dc <main+0x8c>
mov    $0x20,%edi
call   1030 <putchar@plt>
jmp    11dc <main+0x8c>

LLVM IR (-O0):
@.str = [2 x i8] c"*\00"
@.str.1 = [3 x i8] c"#\0A\00"
@.str.2 = [4 x i8] c"%c\0A\00"
@.str.3 = [2 x i8] c"#\00"
@.str.4 = [2 x i8] c" \00"
@.str.5 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [10000 x i8]
store i32 0, i32* %1
%6 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 0
%7 = call i32 @gets(i8* %6)
br label %8
8: ; preds = %101, %0
%9 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 0
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp ne i32 %11, 95
br i1 %12, label %13, label %104
13: ; preds = %8
%14 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 0
%15 = call i32 @strlen(i8* %14)
store i32 %15, i32* %3
store i32 0, i32* %2
br label %16
16: ; preds = %98, %13
%17 = load i32, i32* %2
%18 = load i32, i32* %3
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %101
20: ; preds = %16
%21 = load i32, i32* %2
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %32
23: ; preds = %20
%24 = load i32, i32* %2
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 43
br i1 %29, label %30, label %32
30: ; preds = %23
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %97
32: ; preds = %23, %20
%33 = load i32, i32* %2
%34 = load i32, i32* %3
%35 = sub nsw i32 %34, 1
%36 = icmp eq i32 %33, %35
br i1 %36, label %37, label %46
37: ; preds = %32
%38 = load i32, i32* %2
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 %39
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 43
br i1 %43, label %44, label %46
44: ; preds = %37
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %4
br label %96
46: ; preds = %37, %32
%47 = load i32, i32* %2
%48 = load i32, i32* %3
%49 = sub nsw i32 %48, 1
%50 = icmp eq i32 %47, %49
br i1 %50, label %51, label %58
51: ; preds = %46
%52 = load i32, i32* %2
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 %53
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %56)
br label %95
58: ; preds = %46
%59 = load i32, i32* %2
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 %60
%62 = load i8, i8* %61
%63 = sext i8 %62 to i32
%64 = icmp eq i32 %63, 43
br i1 %64, label %65, label %77
65: ; preds = %58
%66 = load i32, i32* %4
%67 = icmp eq i32 %66, 0
br i1 %67, label %68, label %70
68: ; preds = %65
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %4
br label %76
70: ; preds = %65
%71 = load i32, i32* %4
%72 = icmp eq i32 %71, 1
br i1 %72, label %73, label %75
73: ; preds = %70
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %4
br label %75
75: ; preds = %73, %70
br label %76
76: ; preds = %75, %68
br label %94
77: ; preds = %58
%78 = load i32, i32* %2
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 %79
%81 = load i8, i8* %80
%82 = sext i8 %81 to i32
%83 = icmp eq i32 %82, 32
br i1 %83, label %84, label %86
84: ; preds = %77
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %93
86: ; preds = %77
%87 = load i32, i32* %2
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 %88
%90 = load i8, i8* %89
%91 = sext i8 %90 to i32
%92 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %91)
br label %93
93: ; preds = %86, %84
br label %94
94: ; preds = %93, %76
br label %95
95: ; preds = %94, %51
br label %96
96: ; preds = %95, %44
br label %97
97: ; preds = %96, %30
br label %98
98: ; preds = %97
%99 = load i32, i32* %2
%100 = add nsw i32 %99, 1
store i32 %100, i32* %2
br label %16
101: ; preds = %16
%102 = getelementptr inbounds [10000 x i8], [10000 x i8]* %5, i64 0, i64 0
%103 = call i32 @gets(i8* %102)
br label %8
104: ; preds = %8
ret i32 0
}

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