#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 *, unsigned char);
int /*<<< orphan*/ fputc(char const, int /*<<< orphan*/ *);
scalar_t__ isblank(unsigned char);
scalar_t__ iscntrl(unsigned char);
int /*<<< orphan*/ isprint(unsigned char);
void fputs_nonblank(const char *data, FILE *out) {
  const char *p;
  for (p = data; p && *p; p++) {
    if (isblank((unsigned char)*p) || (unsigned char)*p == 0x5c ||
        !isprint((unsigned char)*p) || iscntrl((unsigned char)*p)) {
      fprintf(out, "\\x%02x", (unsigned char)*p);
    } else
      fputc(*p, out);
  }
}


x86 assembly (clang, -O0):
<fputs_nonblank>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x19(%rbp)
je     1188 <fputs_nonblank+0x38>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1198 <fputs_nonblank+0x48>
jmp    122d <fputs_nonblank+0xdd>
mov    -0x18(%rbp),%rax
movzbl (%rax),%edi
call   1040 <isblank@plt>
cmp    $0x0,%rax
jne    11e9 <fputs_nonblank+0x99>
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x5c,%eax
je     11e9 <fputs_nonblank+0x99>
mov    -0x18(%rbp),%rax
movzbl (%rax),%edi
call   1070 <isprint@plt>
cmp    $0x0,%eax
je     11e9 <fputs_nonblank+0x99>
mov    -0x18(%rbp),%rax
movzbl (%rax),%edi
call   1030 <iscntrl@plt>
cmp    $0x0,%rax
je     1205 <fputs_nonblank+0xb5>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
lea    0xe08(%rip),%rsi
movzbl (%rax),%edx
call   1060 <fprintf@plt>
jmp    1217 <fputs_nonblank+0xc7>
mov    -0x18(%rbp),%rax
mov    (%rax),%al
mov    -0x10(%rbp),%rsi
movsbl %al,%edi
call   1050 <fputc@plt>
jmp    121c <fputs_nonblank+0xcc>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1168 <fputs_nonblank+0x18>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fputs_nonblank>:
push   %r15
push   %r14
push   %rbx
test   %rdi,%rdi
je     11c9 <fputs_nonblank+0x79>
mov    %rdi,%rbx
mov    (%rdi),%al
test   %al,%al
je     11c9 <fputs_nonblank+0x79>
mov    %rsi,%r14
lea    0xe93(%rip),%r15
nopl   (%rax)
movzbl %al,%edi
call   1040 <isblank@plt>
test   %rax,%rax
jne    11a0 <fputs_nonblank+0x50>
movzbl (%rbx),%eax
cmp    $0x5c,%al
je     11a0 <fputs_nonblank+0x50>
movzbl %al,%edi
call   1070 <isprint@plt>
test   %eax,%eax
je     11a0 <fputs_nonblank+0x50>
movzbl (%rbx),%edi
call   1030 <iscntrl@plt>
test   %rax,%rax
je     11bc <fputs_nonblank+0x6c>
nopl   (%rax)
movzbl (%rbx),%edx
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <fprintf@plt>
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1170 <fputs_nonblank+0x20>
jmp    11c9 <fputs_nonblank+0x79>
movsbl (%rbx),%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
jmp    11ae <fputs_nonblank+0x5e>
pop    %rbx
pop    %r14
pop    %r15
ret

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

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