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

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ fputc(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ iscntrl(unsigned char);
scalar_t__ isprint(unsigned char);
void fprint_visible_string(FILE *f, unsigned char *p, unsigned char *e) {
  fprintf(f, "\"");
  while (p < e)
    if (isprint(*p) && !iscntrl(*p))
      fputc(*p++, f);
    else
      fprintf(f, "\\x%x", (uint)*p++);
  fprintf(f, "\"");
}


x86 assembly (clang, -O0):
<fprint_visible_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xea1(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11e8 <fprint_visible_string+0xa8>
mov    -0x10(%rbp),%rax
movzbl (%rax),%edi
call   1060 <isprint@plt>
cmp    $0x0,%rax
je     11bf <fprint_visible_string+0x7f>
mov    -0x10(%rbp),%rax
movzbl (%rax),%edi
call   1030 <iscntrl@plt>
cmp    $0x0,%eax
jne    11bf <fprint_visible_string+0x7f>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movzbl (%rax),%edi
mov    -0x8(%rbp),%rsi
call   1040 <fputc@plt>
jmp    11e3 <fprint_visible_string+0xa3>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movzbl (%rax),%edx
lea    0xe26(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
jmp    1166 <fprint_visible_string+0x26>
mov    -0x8(%rbp),%rdi
lea    0xe0d(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fprint_visible_string>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r15
mov    %rsi,%r13
mov    %rdi,%r14
mov    $0x22,%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
cmp    %r15,%r13
jae    11cb <fprint_visible_string+0x8b>
sub    %r13,%r15
lea    0xe92(%rip),%r12
xor    %ebx,%ebx
jmp    119c <fprint_visible_string+0x5c>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl 0x0(%r13,%rbx,1),%edx
mov    %r14,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
je     11cb <fprint_visible_string+0x8b>
movzbl 0x0(%r13,%rbx,1),%edi
call   1060 <isprint@plt>
test   %rax,%rax
je     1180 <fprint_visible_string+0x40>
movzbl 0x0(%r13,%rbx,1),%edi
call   1030 <iscntrl@plt>
test   %eax,%eax
jne    1180 <fprint_visible_string+0x40>
movzbl 0x0(%r13,%rbx,1),%edi
mov    %r14,%rsi
call   1040 <fputc@plt>
jmp    1193 <fprint_visible_string+0x53>
mov    $0x22,%edi
mov    %r14,%rsi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1040 <fputc@plt>

LLVM IR (-O0):
@.str = [2 x i8] c"\22\00"
@.str.1 = [5 x i8] c"\\x%x\00"
define void @fprint_visible_string(i32* %0, i8* %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
store i32* %0, i32** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = load i32*, i32** %4
%8 = call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %37, %3
%10 = load i8*, i8** %5
%11 = load i8*, i8** %6
%12 = icmp ult i8* %10, %11
br i1 %12, label %13, label %38
13: ; preds = %9
%14 = load i8*, i8** %5
%15 = load i8, i8* %14
%16 = call i64 @isprint(i8 zeroext %15)
%17 = icmp ne i64 %16, 0
br i1 %17, label %18, label %30
18: ; preds = %13
%19 = load i8*, i8** %5
%20 = load i8, i8* %19
%21 = call i32 @iscntrl(i8 zeroext %20)
%22 = icmp ne i32 %21, 0
br i1 %22, label %30, label %23
23: ; preds = %18
%24 = load i8*, i8** %5
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %5
%26 = load i8, i8* %24
%27 = zext i8 %26 to i32
%28 = load i32*, i32** %4
%29 = call i32 @fputc(i32 %27, i32* %28)
br label %37
30: ; preds = %18, %13
%31 = load i32*, i32** %4
%32 = load i8*, i8** %5
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %5
%34 = load i8, i8* %32
%35 = zext i8 %34 to i32
%36 = call i32 (i32*, i8*, ...) @fprintf(i32* %31, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %30, %23
br label %9
38: ; preds = %9
%39 = load i32*, i32** %4
%40 = call i32 (i32*, i8*, ...) @fprintf(i32* %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"\\x%x\00"
define void @fprint_visible_string(i32* nocapture %0, i8* %1, i8* readnone %2) {
%4 = tail call i32 @fputc(i32 34, i32* %0)
%5 = icmp ult i8* %1, %2
br i1 %5, label %6, label %31
6: ; preds = %3
%7 = ptrtoint i8* %2 to i64
%8 = ptrtoint i8* %1 to i64
%9 = sub i64 %7, %8
%10 = getelementptr i8, i8* %1, i64 %9
br label %11
11: ; preds = %6, %28
%12 = phi i8* [ %29, %28 ], [ %1, %6 ]
%13 = load i8, i8* %12
%14 = tail call i64 @isprint(i8 zeroext %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %24, label %16
16: ; preds = %11
%17 = load i8, i8* %12
%18 = tail call i32 @iscntrl(i8 zeroext %17)
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = load i8, i8* %12
%22 = zext i8 %21 to i32
%23 = tail call i32 @fputc(i32 %22, i32* %0)
br label %28
24: ; preds = %16, %11
%25 = load i8, i8* %12
%26 = zext i8 %25 to i32
%27 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %24, %20
%29 = getelementptr inbounds i8, i8* %12, i64 1
%30 = icmp eq i8* %29, %10
br i1 %30, label %31, label %11
31: ; preds = %28, %3
%32 = tail call i32 @fputc(i32 34, i32* %0)
ret void
}