#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*/ mcharout(char);
int /*<<< orphan*/ mswait(int);
int /*<<< orphan*/ purgeline();
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ wait(int);
void mstrout(char *string, int echo) {
  static char c;
  while (c = *string++) {
    if ((c == '!') || (c == '\n')) {
      mcharout(13);
      mcharout(10);
      c = '\n';
    } else if (c == '~')
      wait(1);
    else
      mcharout(c);
    if (echo)
      putchar(c);
  }
  mswait(100);
  purgeline();
}


x86 assembly (clang, -O0):
<mstrout>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%al
mov    %al,0x2ed3(%rip)
cmp    $0x0,%al
je     1209 <mstrout+0xb9>
movsbl 0x2ec4(%rip),%eax
cmp    $0x21,%eax
je     119e <mstrout+0x4e>
movsbl 0x2eb4(%rip),%eax
cmp    $0xa,%eax
jne    11be <mstrout+0x6e>
mov    $0xd,%edi
call   1050 <mcharout@plt>
mov    $0xa,%edi
call   1050 <mcharout@plt>
movb   $0xa,0x2e90(%rip)
jmp    11ee <mstrout+0x9e>
movsbl 0x2e84(%rip),%eax
cmp    $0x7e,%eax
jne    11dd <mstrout+0x8d>
mov    $0x1,%edi
call   1070 <wait@plt>
jmp    11e9 <mstrout+0x99>
movsbl 0x2e65(%rip),%edi
call   1050 <mcharout@plt>
jmp    11ee <mstrout+0x9e>
cmpl   $0x0,-0xc(%rbp)
je     1204 <mstrout+0xb4>
movsbl 0x2e4a(%rip),%edi
call   1030 <putchar@plt>
jmp    115f <mstrout+0xf>
mov    $0x64,%edi
call   1060 <mswait@plt>
mov    $0x0,%al
call   1040 <purgeline@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mstrout>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
nopl   0x0(%rax,%rax,1)
movzbl (%rbx),%eax
mov    %al,0x2ee0(%rip)
cmp    $0x20,%al
jle    1180 <mstrout+0x30>
cmp    $0x7e,%al
je     11b0 <mstrout+0x60>
cmp    $0x21,%al
je     1184 <mstrout+0x34>
jmp    11c0 <mstrout+0x70>
nopw   0x0(%rax,%rax,1)
cmp    $0xa,%al
jne    11bc <mstrout+0x6c>
mov    $0xd,%edi
call   1050 <mcharout@plt>
mov    $0xa,%edi
call   1050 <mcharout@plt>
movb   $0xa,0x2eaa(%rip)
jmp    11c8 <mstrout+0x78>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x1,%edi
call   1070 <wait@plt>
jmp    11c8 <mstrout+0x78>
test   %al,%al
je     11de <mstrout+0x8e>
movsbl %al,%edi
call   1050 <mcharout@plt>
add    $0x1,%rbx
test   %ebp,%ebp
je     1160 <mstrout+0x10>
movsbl 0x2e72(%rip),%edi
call   1030 <putchar@plt>
jmp    1160 <mstrout+0x10>
mov    $0x64,%edi
call   1060 <mswait@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <purgeline@plt>

LLVM IR (-O0):
@mstrout.c = internal global i8 0
define void @mstrout(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
br label %5
5: ; preds = %37, %2
%6 = load i8*, i8** %3
%7 = getelementptr inbounds i8, i8* %6, i32 1
store i8* %7, i8** %3
%8 = load i8, i8* %6
store i8 %8, i8* @mstrout.c
%9 = icmp ne i8 %8, 0
br i1 %9, label %10, label %38
10: ; preds = %5
%11 = load i8, i8* @mstrout.c
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %12, 33
br i1 %13, label %18, label %14
14: ; preds = %10
%15 = load i8, i8* @mstrout.c
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 10
br i1 %17, label %18, label %21
18: ; preds = %14, %10
%19 = call i32 @mcharout(i8 signext 13)
%20 = call i32 @mcharout(i8 signext 10)
store i8 10, i8* @mstrout.c
br label %31
21: ; preds = %14
%22 = load i8, i8* @mstrout.c
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 126
br i1 %24, label %25, label %27
25: ; preds = %21
%26 = call i32 @wait(i32 1)
br label %30
27: ; preds = %21
%28 = load i8, i8* @mstrout.c
%29 = call i32 @mcharout(i8 signext %28)
br label %30
30: ; preds = %27, %25
br label %31
31: ; preds = %30, %18
%32 = load i32, i32* %4
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %37
34: ; preds = %31
%35 = load i8, i8* @mstrout.c
%36 = call i32 @putchar(i8 signext %35)
br label %37
37: ; preds = %34, %31
br label %5
38: ; preds = %5
%39 = call i32 @mswait(i32 100)
%40 = call i32 (...) @purgeline()
ret void
}

LLVM IR (-O2):
@mstrout.c = internal unnamed_addr global i8 0
define void @mstrout(i8* nocapture %0, i32 %1) {
%3 = icmp eq i32 %1, 0
br label %4
4: ; preds = %19, %2
%5 = phi i8* [ %0, %2 ], [ %6, %19 ]
%6 = getelementptr inbounds i8, i8* %5, i64 1
%7 = load i8, i8* %5
store i8 %7, i8* @mstrout.c
switch i8 %7, label %13 [
i8 0, label %20
i8 33, label %8
i8 10, label %8
i8 126, label %11
]
8: ; preds = %4, %4
%9 = tail call i32 @mcharout(i8 signext 13)
%10 = tail call i32 @mcharout(i8 signext 10)
store i8 10, i8* @mstrout.c
br label %15
11: ; preds = %4
%12 = tail call i32 @wait(i32 1)
br label %15
13: ; preds = %4
%14 = tail call i32 @mcharout(i8 signext %7)
br label %15
15: ; preds = %11, %13, %8
br i1 %3, label %19, label %16
16: ; preds = %15
%17 = load i8, i8* @mstrout.c
%18 = tail call i32 @putchar(i8 signext %17)
br label %19
19: ; preds = %16, %15
br label %4
20: ; preds = %4
%21 = tail call i32 @mswait(i32 100)
%22 = tail call i32 (...) @purgeline()
ret void
}