#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*/ ACL_ISASCII(int);
int /*<<< orphan*/ ACL_ISPRINT(int);
char *printable(char *string, int replacement) {
  char *cp;
  int ch;
  for (cp = string; (ch = *(unsigned char *)cp) != 0; cp++)
    if (!ACL_ISASCII(ch) || !ACL_ISPRINT(ch))
      *cp = replacement;
  return (string);
}


x86 assembly (clang, -O0):
<printable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
je     118d <printable+0x6d>
mov    -0x1c(%rbp),%edi
call   1030 <ACL_ISASCII@plt>
cmp    $0x0,%eax
je     116c <printable+0x4c>
mov    -0x1c(%rbp),%edi
call   1040 <ACL_ISPRINT@plt>
cmp    $0x0,%eax
jne    1177 <printable+0x57>
mov    -0xc(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
jmp    117c <printable+0x5c>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1137 <printable+0x17>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printable>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    (%rdi),%al
test   %al,%al
je     116b <printable+0x4b>
mov    %esi,%r15d
lea    0x1(%r14),%rbp
jmp    1150 <printable+0x30>
nopl   0x0(%rax)
mov    %r15b,-0x1(%rbp)
movzbl 0x0(%rbp),%eax
add    $0x1,%rbp
test   %al,%al
je     116b <printable+0x4b>
movzbl %al,%ebx
mov    %ebx,%edi
call   1030 <ACL_ISASCII@plt>
test   %eax,%eax
je     1140 <printable+0x20>
mov    %ebx,%edi
call   1040 <ACL_ISPRINT@plt>
test   %eax,%eax
jne    1144 <printable+0x24>
jmp    1140 <printable+0x20>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @printable(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i8*, i8** %3
store i8* %7, i8** %5
br label %8
8: ; preds = %26, %2
%9 = load i8*, i8** %5
%10 = load i8, i8* %9
%11 = zext i8 %10 to i32
store i32 %11, i32* %6
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %29
13: ; preds = %8
%14 = load i32, i32* %6
%15 = call i32 @ACL_ISASCII(i32 %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %13
%18 = load i32, i32* %6
%19 = call i32 @ACL_ISPRINT(i32 %18)
%20 = icmp ne i32 %19, 0
br i1 %20, label %25, label %21
21: ; preds = %17, %13
%22 = load i32, i32* %4
%23 = trunc i32 %22 to i8
%24 = load i8*, i8** %5
store i8 %23, i8* %24
br label %25
25: ; preds = %21, %17
br label %26
26: ; preds = %25
%27 = load i8*, i8** %5
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %5
br label %8
29: ; preds = %8
%30 = load i8*, i8** %3
ret i8* %30
}

LLVM IR (-O2):
define i8* @printable(i8* returned %0, i32 %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %21, label %5
5: ; preds = %2
%6 = trunc i32 %1 to i8
br label %7
7: ; preds = %5, %17
%8 = phi i8 [ %3, %5 ], [ %19, %17 ]
%9 = phi i8* [ %0, %5 ], [ %18, %17 ]
%10 = zext i8 %8 to i32
%11 = tail call i32 @ACL_ISASCII(i32 %10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %7
%14 = tail call i32 @ACL_ISPRINT(i32 %10)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %13, %7
store i8 %6, i8* %9
br label %17
17: ; preds = %13, %16
%18 = getelementptr inbounds i8, i8* %9, i64 1
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %7
21: ; preds = %17, %2
ret i8* %0
}