#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 */
char getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int main(void) {
  char c;
  int n = 0;
  printf("Please enter something ends with '#'\n");
  while ((c = getchar()) != '#') {
    if ('.' == c) {
      putchar('!');
      n++;
    } else if ('!' == c) {
      putchar('!');
      putchar('!');
      n++;
    } else
      putchar(c);
  }
  putchar('\n');
  printf("You've made %d substitutions!\n", n);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
mov    %al,-0x5(%rbp)
movsbl %al,%eax
cmp    $0x23,%eax
je     11d9 <main+0xa9>
movsbl -0x5(%rbp),%ecx
mov    $0x2e,%eax
cmp    %ecx,%eax
jne    1193 <main+0x63>
mov    $0x21,%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11d4 <main+0xa4>
movsbl -0x5(%rbp),%ecx
mov    $0x21,%eax
cmp    %ecx,%eax
jne    11c6 <main+0x96>
mov    $0x21,%edi
call   1030 <putchar@plt>
mov    $0x21,%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11cf <main+0x9f>
movsbl -0x5(%rbp),%edi
call   1030 <putchar@plt>
jmp    11d4 <main+0xa4>
jmp    1154 <main+0x24>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0xc(%rbp),%esi
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xed7(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
jmp    1170 <main+0x30>
mov    $0x21,%edi
call   1030 <putchar@plt>
mov    $0x21,%edi
call   1030 <putchar@plt>
add    $0x1,%ebx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <getchar@plt>
cmp    $0x21,%al
je     1151 <main+0x11>
cmp    $0x23,%al
je     118d <main+0x4d>
cmp    $0x2e,%al
je     115b <main+0x1b>
movsbl %al,%edi
call   1030 <putchar@plt>
jmp    1170 <main+0x30>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xe62(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Please enter something ends with '#'\0A\00"
@.str.1 = [31 x i8] c"You've made %d substitutions!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %30, %0
%6 = call signext i8 (...) @getchar()
store i8 %6, i8* %2
%7 = sext i8 %6 to i32
%8 = icmp ne i32 %7, 35
br i1 %8, label %9, label %31
9: ; preds = %5
%10 = load i8, i8* %2
%11 = sext i8 %10 to i32
%12 = icmp eq i32 46, %11
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = call i32 @putchar(i8 signext 33)
%15 = load i32, i32* %3
%16 = add nsw i32 %15, 1
store i32 %16, i32* %3
br label %30
17: ; preds = %9
%18 = load i8, i8* %2
%19 = sext i8 %18 to i32
%20 = icmp eq i32 33, %19
br i1 %20, label %21, label %26
21: ; preds = %17
%22 = call i32 @putchar(i8 signext 33)
%23 = call i32 @putchar(i8 signext 33)
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %29
26: ; preds = %17
%27 = load i8, i8* %2
%28 = call i32 @putchar(i8 signext %27)
br label %29
29: ; preds = %26, %21
br label %30
30: ; preds = %29, %13
br label %5
31: ; preds = %5
%32 = call i32 @putchar(i8 signext 10)
%33 = load i32, i32* %3
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %1
ret i32 %35
}

LLVM IR (-O2):
@.str.1 = [31 x i8] c"You've made %d substitutions!\0A\00"
@str = [37 x i8] c"Please enter something ends with '#'\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
br label %2
2: ; preds = %8, %0
%3 = phi i32 [ 0, %0 ], [ %9, %8 ]
br label %4
4: ; preds = %2, %13
%5 = tail call signext i8 (...) @getchar()
switch i8 %5, label %13 [
i8 35, label %15
i8 46, label %6
i8 33, label %10
]
6: ; preds = %4
%7 = tail call i32 @putchar(i8 signext 33)
br label %8
8: ; preds = %6, %10
%9 = add nuw nsw i32 %3, 1
br label %2
10: ; preds = %4
%11 = tail call i32 @putchar(i8 signext 33)
%12 = tail call i32 @putchar(i8 signext 33)
br label %8
13: ; preds = %4
%14 = tail call i32 @putchar(i8 signext %5)
br label %4
15: ; preds = %4
%16 = tail call i32 @putchar(i8 signext 10)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %3)
ret i32 0
}