#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*/ putchar(char);
void prt_name(char *name) {
  putchar('"');
  while (*name) {
    switch (*name) {
    case '\\':
    case '"':
      putchar('\\');
      break;
    }
    putchar(*name);
    name += 1;
  }
  putchar('"');
}


x86 assembly (clang, -O0):
<prt_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x22,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1183 <prt_name+0x73>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0xc(%rbp)
sub    $0x22,%eax
je     115c <prt_name+0x4c>
jmp    114b <prt_name+0x3b>
mov    -0xc(%rbp),%eax
sub    $0x5c,%eax
jne    1166 <prt_name+0x56>
jmp    115c <prt_name+0x4c>
mov    $0x5c,%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <putchar@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1126 <prt_name+0x16>
mov    $0x22,%edi
call   1030 <putchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prt_name>:
push   %rbx
mov    %rdi,%rbx
mov    $0x22,%edi
call   1030 <putchar@plt>
mov    (%rbx),%al
test   %al,%al
je     1160 <prt_name+0x50>
add    $0x1,%rbx
jmp    1151 <prt_name+0x41>
nopw   0x0(%rax,%rax,1)
mov    $0x5c,%edi
call   1030 <putchar@plt>
movzbl -0x1(%rbx),%eax
movsbl %al,%edi
call   1030 <putchar@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1160 <prt_name+0x50>
movsbl %al,%ecx
cmp    $0x5c,%ecx
je     1130 <prt_name+0x20>
cmp    $0x22,%ecx
je     1130 <prt_name+0x20>
jmp    113e <prt_name+0x2e>
mov    $0x22,%edi
pop    %rbx
jmp    1030 <putchar@plt>

LLVM IR (-O0):
define void @prt_name(i8* %0) {
%2 = alloca i8*
store i8* %0, i8** %2
%3 = call i32 @putchar(i8 signext 34)
br label %4
4: ; preds = %14, %1
%5 = load i8*, i8** %2
%6 = load i8, i8* %5
%7 = icmp ne i8 %6, 0
br i1 %7, label %8, label %20
8: ; preds = %4
%9 = load i8*, i8** %2
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
switch i32 %11, label %14 [
i32 92, label %12
i32 34, label %12
]
12: ; preds = %8, %8
%13 = call i32 @putchar(i8 signext 92)
br label %14
14: ; preds = %8, %12
%15 = load i8*, i8** %2
%16 = load i8, i8* %15
%17 = call i32 @putchar(i8 signext %16)
%18 = load i8*, i8** %2
%19 = getelementptr inbounds i8, i8* %18, i64 1
store i8* %19, i8** %2
br label %4
20: ; preds = %4
%21 = call i32 @putchar(i8 signext 34)
ret void
}

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