#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char);
scalar_t__ isprint(char);
int /*<<< orphan*/ putc(char, int /*<<< orphan*/ *);
void listto(char *p1, FILE *fp) {
  p1--;
  while (*p1++)
    if (isprint(*p1))
      putc(*p1, fp);
    else {
      putc('\\', fp);
      switch (*p1) {
      case '\b':
        putc('b', fp);
        break;
      case '\t':
        putc('t', fp);
        break;
      case '\n':
        putc('n', fp);
        break;
      case '\r':
        putc('r', fp);
        break;
      case '\33':
        putc('e', fp);
        break;
      default:
        fprintf(fp, "%02x", *p1 & 0xFF);
      }
    }
  putc('\n', fp);
}


x86 assembly (clang, -O0):
<listto>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
cmpb   $0x0,(%rax)
je     1254 <listto+0x124>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isprint@plt>
cmp    $0x0,%rax
je     1191 <listto+0x61>
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    -0x10(%rbp),%rsi
movsbl %al,%edi
call   1030 <putc@plt>
jmp    124f <listto+0x11f>
mov    -0x10(%rbp),%rsi
mov    $0x5c,%edi
call   1030 <putc@plt>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
add    $0xfffffff8,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x13,%eax
ja     122b <listto+0xfb>
mov    -0x18(%rbp),%rax
lea    0xe3d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rsi
mov    $0x62,%edi
call   1030 <putc@plt>
jmp    124a <listto+0x11a>
mov    -0x10(%rbp),%rsi
mov    $0x74,%edi
call   1030 <putc@plt>
jmp    124a <listto+0x11a>
mov    -0x10(%rbp),%rsi
mov    $0x6e,%edi
call   1030 <putc@plt>
jmp    124a <listto+0x11a>
mov    -0x10(%rbp),%rsi
mov    $0x72,%edi
call   1030 <putc@plt>
jmp    124a <listto+0x11a>
mov    -0x10(%rbp),%rsi
mov    $0x65,%edi
call   1030 <putc@plt>
jmp    124a <listto+0x11a>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
and    $0xff,%eax
lea    0xe0e(%rip),%rsi
movsbl %al,%edx
call   1040 <fprintf@plt>
jmp    124f <listto+0x11f>
jmp    114c <listto+0x1c>
mov    -0x10(%rbp),%rsi
mov    $0xa,%edi
call   1030 <putc@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<listto>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
cmpb   $0x0,-0x1(%rdi)
je     11e4 <listto+0xb4>
mov    %rdi,%rbx
lea    0xf01(%rip),%r15
lea    0xeaa(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
movsbl (%rbx),%edi
call   1050 <isprint@plt>
test   %rax,%rax
je     1190 <listto+0x60>
movsbl (%rbx),%edi
mov    %r14,%rsi
call   1030 <putc@plt>
cmpb   $0x0,(%rbx)
lea    0x1(%rbx),%rbx
jne    1160 <listto+0x30>
jmp    11e4 <listto+0xb4>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    $0x5c,%edi
mov    %r14,%rsi
call   1030 <putc@plt>
movsbl (%rbx),%eax
lea    -0x8(%rax),%ecx
cmp    $0x13,%ecx
ja     11bf <listto+0x8f>
movslq (%r12,%rcx,4),%rcx
add    %r12,%rcx
jmp    *%rcx
mov    $0x62,%edi
jmp    1170 <listto+0x40>
mov    $0x6e,%edi
jmp    1170 <listto+0x40>
movsbl %al,%edx
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <fprintf@plt>
jmp    1178 <listto+0x48>
mov    $0x74,%edi
jmp    1170 <listto+0x40>
mov    $0x72,%edi
jmp    1170 <listto+0x40>
mov    $0x65,%edi
jmp    1170 <listto+0x40>
mov    $0xa,%edi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <putc@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"%02x\00"
define void @listto(i8* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
store i8* %0, i8** %3
store i32* %1, i32** %4
%5 = load i8*, i8** %3
%6 = getelementptr inbounds i8, i8* %5, i32 -1
store i8* %6, i8** %3
br label %7
7: ; preds = %52, %2
%8 = load i8*, i8** %3
%9 = getelementptr inbounds i8, i8* %8, i32 1
store i8* %9, i8** %3
%10 = load i8, i8* %8
%11 = icmp ne i8 %10, 0
br i1 %11, label %12, label %53
12: ; preds = %7
%13 = load i8*, i8** %3
%14 = load i8, i8* %13
%15 = call i64 @isprint(i8 signext %14)
%16 = icmp ne i64 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %12
%18 = load i8*, i8** %3
%19 = load i8, i8* %18
%20 = load i32*, i32** %4
%21 = call i32 @putc(i8 signext %19, i32* %20)
br label %52
22: ; preds = %12
%23 = load i32*, i32** %4
%24 = call i32 @putc(i8 signext 92, i32* %23)
%25 = load i8*, i8** %3
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
switch i32 %27, label %43 [
i32 8, label %28
i32 9, label %31
i32 10, label %34
i32 13, label %37
i32 27, label %40
]
28: ; preds = %22
%29 = load i32*, i32** %4
%30 = call i32 @putc(i8 signext 98, i32* %29)
br label %51
31: ; preds = %22
%32 = load i32*, i32** %4
%33 = call i32 @putc(i8 signext 116, i32* %32)
br label %51
34: ; preds = %22
%35 = load i32*, i32** %4
%36 = call i32 @putc(i8 signext 110, i32* %35)
br label %51
37: ; preds = %22
%38 = load i32*, i32** %4
%39 = call i32 @putc(i8 signext 114, i32* %38)
br label %51
40: ; preds = %22
%41 = load i32*, i32** %4
%42 = call i32 @putc(i8 signext 101, i32* %41)
br label %51
43: ; preds = %22
%44 = load i32*, i32** %4
%45 = load i8*, i8** %3
%46 = load i8, i8* %45
%47 = sext i8 %46 to i32
%48 = and i32 %47, 255
%49 = trunc i32 %48 to i8
%50 = call i32 @fprintf(i32* %44, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 signext %49)
br label %51
51: ; preds = %43, %40, %37, %34, %31, %28
br label %52
52: ; preds = %51, %17
br label %7
53: ; preds = %7
%54 = load i32*, i32** %4
%55 = call i32 @putc(i8 signext 10, i32* %54)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%02x\00"
define void @listto(i8* nocapture %0, i32* nocapture %1) {
%3 = getelementptr inbounds i8, i8* %0, i64 -1
%4 = load i8, i8* %3
%5 = icmp eq i8 %4, 0
br i1 %5, label %34, label %6
6: ; preds = %2, %30
%7 = phi i8* [ %31, %30 ], [ %0, %2 ]
%8 = load i8, i8* %7
%9 = tail call i64 @isprint(i8 signext %8)
%10 = icmp eq i64 %9, 0
br i1 %10, label %14, label %11
11: ; preds = %6
%12 = load i8, i8* %7
%13 = tail call i32 @putc(i8 signext %12, i32* %1)
br label %30
14: ; preds = %6
%15 = tail call i32 @putc(i8 signext 92, i32* %1)
%16 = load i8, i8* %7
%17 = sext i8 %16 to i32
switch i32 %17, label %28 [
i32 8, label %18
i32 9, label %20
i32 10, label %22
i32 13, label %24
i32 27, label %26
]
18: ; preds = %14
%19 = tail call i32 @putc(i8 signext 98, i32* %1)
br label %30
20: ; preds = %14
%21 = tail call i32 @putc(i8 signext 116, i32* %1)
br label %30
22: ; preds = %14
%23 = tail call i32 @putc(i8 signext 110, i32* %1)
br label %30
24: ; preds = %14
%25 = tail call i32 @putc(i8 signext 114, i32* %1)
br label %30
26: ; preds = %14
%27 = tail call i32 @putc(i8 signext 101, i32* %1)
br label %30
28: ; preds = %14
%29 = tail call i32 @fprintf(i32* %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8 signext %16)
br label %30
30: ; preds = %18, %20, %22, %24, %26, %28, %11
%31 = getelementptr inbounds i8, i8* %7, i64 1
%32 = load i8, i8* %7
%33 = icmp eq i8 %32, 0
br i1 %33, label %34, label %6
34: ; preds = %30, %2
%35 = tail call i32 @putc(i8 signext 10, i32* %1)
ret void
}