#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*/ putc(int, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
void EmitTextBS(char *Pch) {
  while (*Pch != ('\0')) {
    (void)putc((int)(*Pch), stdout);
    if (*Pch == '\\')
      (void)putc((int)('\\'), stdout);
    ++Pch;
  }
}


x86 assembly (clang, -O0):
<EmitTextBS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1175 <EmitTextBS+0x65>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
mov    0x2ea6(%rip),%rax
mov    (%rax),%esi
call   1030 <putc@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5c,%eax
jne    1164 <EmitTextBS+0x54>
mov    0x2e88(%rip),%rax
mov    (%rax),%esi
mov    $0x5c,%edi
call   1030 <putc@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    111c <EmitTextBS+0xc>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EmitTextBS>:
push   %r14
push   %rbx
push   %rax
mov    (%rdi),%al
test   %al,%al
je     115b <EmitTextBS+0x4b>
mov    %rdi,%rbx
add    $0x1,%rbx
mov    0x2eb8(%rip),%r14
jmp    113b <EmitTextBS+0x2b>
nopw   0x0(%rax,%rax,1)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     115b <EmitTextBS+0x4b>
movsbl %al,%edi
mov    (%r14),%esi
call   1030 <putc@plt>
cmpb   $0x5c,-0x1(%rbx)
jne    1130 <EmitTextBS+0x20>
mov    (%r14),%esi
mov    $0x5c,%edi
call   1030 <putc@plt>
jmp    1130 <EmitTextBS+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
@stdout = global i32 0
define void @EmitTextBS(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %19, label %4
4: ; preds = %1, %15
%5 = phi i8 [ %17, %15 ], [ %2, %1 ]
%6 = phi i8* [ %16, %15 ], [ %0, %1 ]
%7 = sext i8 %5 to i32
%8 = load i32, i32* @stdout
%9 = tail call i32 @putc(i32 %7, i32 %8)
%10 = load i8, i8* %6
%11 = icmp eq i8 %10, 92
br i1 %11, label %12, label %15
12: ; preds = %4
%13 = load i32, i32* @stdout
%14 = tail call i32 @putc(i32 92, i32 %13)
br label %15
15: ; preds = %12, %4
%16 = getelementptr inbounds i8, i8* %6, i64 1
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %19, label %4
19: ; preds = %15, %1
ret void
}