#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*/ fputc(char const, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
void putstr(const char *msg) {
  char need_begin = 0;
  for (; *msg != '\0'; msg++) {
    if (need_begin) {
      fputc(('#'), stdout);
      fputc((' '), stdout);
      need_begin = 0;
    }
    fputc((*msg), stdout);
    if (*msg == '\n') {
      need_begin = 1;
    }
  }
}


x86 assembly (clang, -O0):
<putstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movb   $0x0,-0x9(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11a5 <putstr+0x95>
cmpb   $0x0,-0x9(%rbp)
je     1164 <putstr+0x54>
mov    0x2e9f(%rip),%rax
mov    (%rax),%esi
mov    $0x23,%edi
call   1030 <fputc@plt>
mov    0x2e8c(%rip),%rax
mov    (%rax),%esi
mov    $0x20,%edi
call   1030 <fputc@plt>
movb   $0x0,-0x9(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    0x2e6f(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   1030 <fputc@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    118f <putstr+0x7f>
movb   $0x1,-0x9(%rbp)
jmp    1194 <putstr+0x84>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1120 <putstr+0x10>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<putstr>:
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%al
test   %al,%al
je     1170 <putstr+0x60>
mov    %rdi,%rbx
xor    %ecx,%ecx
mov    0x2eba(%rip),%r14
jmp    114d <putstr+0x3d>
nopl   0x0(%rax,%rax,1)
mov    (%r14),%esi
movsbl %al,%edi
call   1030 <fputc@plt>
cmpb   $0xa,(%rbx)
movzbl 0x1(%rbx),%eax
sete   %cl
add    $0x1,%rbx
test   %al,%al
je     1170 <putstr+0x60>
test   %cl,%cl
je     1130 <putstr+0x20>
mov    (%r14),%esi
mov    $0x23,%edi
call   1030 <fputc@plt>
mov    (%r14),%esi
mov    $0x20,%edi
call   1030 <fputc@plt>
movzbl (%rbx),%eax
jmp    1130 <putstr+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stdout = global i32 0
define void @putstr(i8* %0) {
%2 = alloca i8*
%3 = alloca i8
store i8* %0, i8** %2
store i8 0, i8* %3
br label %4
4: ; preds = %28, %1
%5 = load i8*, i8** %2
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %31
9: ; preds = %4
%10 = load i8, i8* %3
%11 = icmp ne i8 %10, 0
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = load i32, i32* @stdout
%14 = call i32 @fputc(i8 signext 35, i32 %13)
%15 = load i32, i32* @stdout
%16 = call i32 @fputc(i8 signext 32, i32 %15)
store i8 0, i8* %3
br label %17
17: ; preds = %12, %9
%18 = load i8*, i8** %2
%19 = load i8, i8* %18
%20 = load i32, i32* @stdout
%21 = call i32 @fputc(i8 signext %19, i32 %20)
%22 = load i8*, i8** %2
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 10
br i1 %25, label %26, label %27
26: ; preds = %17
store i8 1, i8* %3
br label %27
27: ; preds = %26, %17
br label %28
28: ; preds = %27
%29 = load i8*, i8** %2
%30 = getelementptr inbounds i8, i8* %29, i32 1
store i8* %30, i8** %2
br label %4
31: ; preds = %4
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
define void @putstr(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %25, label %4
4: ; preds = %1, %15
%5 = phi i8 [ %23, %15 ], [ %2, %1 ]
%6 = phi i8 [ %21, %15 ], [ 0, %1 ]
%7 = phi i8* [ %22, %15 ], [ %0, %1 ]
%8 = icmp eq i8 %6, 0
br i1 %8, label %15, label %9
9: ; preds = %4
%10 = load i32, i32* @stdout
%11 = tail call i32 @fputc(i8 signext 35, i32 %10)
%12 = load i32, i32* @stdout
%13 = tail call i32 @fputc(i8 signext 32, i32 %12)
%14 = load i8, i8* %7
br label %15
15: ; preds = %9, %4
%16 = phi i8 [ %14, %9 ], [ %5, %4 ]
%17 = load i32, i32* @stdout
%18 = tail call i32 @fputc(i8 signext %16, i32 %17)
%19 = load i8, i8* %7
%20 = icmp eq i8 %19, 10
%21 = zext i1 %20 to i8
%22 = getelementptr inbounds i8, i8* %7, i64 1
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %25, label %4
25: ; preds = %15, %1
ret void
}