#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*/ isprint(int);
char *sanitise(char *name) {
  unsigned char *r;
  if (name)
    for (r = (unsigned char *)name; *r; r++)
      if (!isprint((int)*r))
        return "<name unprintable>";
  return name;
}


x86 assembly (clang, -O0):
<sanitise>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     117c <sanitise+0x6c>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     1177 <sanitise+0x67>
mov    -0x18(%rbp),%rax
movzbl (%rax),%edi
call   1030 <isprint@plt>
cmp    $0x0,%eax
jne    1161 <sanitise+0x51>
lea    0xea8(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1184 <sanitise+0x74>
jmp    1166 <sanitise+0x56>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    112f <sanitise+0x1f>
jmp    117c <sanitise+0x6c>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sanitise>:
push   %r15
push   %r14
push   %rbx
test   %rdi,%rdi
je     1149 <sanitise+0x39>
mov    %rdi,%r15
mov    (%rdi),%al
test   %al,%al
je     1151 <sanitise+0x41>
lea    0x1(%r15),%rbx
lea    0xed2(%rip),%r14
xchg   %ax,%ax
movzbl %al,%edi
call   1030 <isprint@plt>
test   %eax,%eax
je     114e <sanitise+0x3e>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <sanitise+0x20>
jmp    1151 <sanitise+0x41>
xor    %r15d,%r15d
jmp    1151 <sanitise+0x41>
mov    %r14,%r15
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [19 x i8] c"<name unprintable>\00"
define i8* @sanitise(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %25
7: ; preds = %1
%8 = load i8*, i8** %3
store i8* %8, i8** %4
br label %9
9: ; preds = %21, %7
%10 = load i8*, i8** %4
%11 = load i8, i8* %10
%12 = icmp ne i8 %11, 0
br i1 %12, label %13, label %24
13: ; preds = %9
%14 = load i8*, i8** %4
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = call i32 @isprint(i32 %16)
%18 = icmp ne i32 %17, 0
br i1 %18, label %20, label %19
19: ; preds = %13
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8** %2
br label %27
20: ; preds = %13
br label %21
21: ; preds = %20
%22 = load i8*, i8** %4
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %4
br label %9
24: ; preds = %9
br label %25
25: ; preds = %24, %1
%26 = load i8*, i8** %3
store i8* %26, i8** %2
br label %27
27: ; preds = %25, %19
%28 = load i8*, i8** %2
ret i8* %28
}

LLVM IR (-O2):
@.str = [19 x i8] c"<name unprintable>\00"
define i8* @sanitise(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %16, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %16, label %9
6: ; preds = %9
%7 = load i8, i8* %15
%8 = icmp eq i8 %7, 0
br i1 %8, label %16, label %9
9: ; preds = %3, %6
%10 = phi i8 [ %7, %6 ], [ %4, %3 ]
%11 = phi i8* [ %15, %6 ], [ %0, %3 ]
%12 = zext i8 %10 to i32
%13 = tail call i32 @isprint(i32 %12)
%14 = icmp eq i32 %13, 0
%15 = getelementptr inbounds i8, i8* %11, i64 1
br i1 %14, label %16, label %6
16: ; preds = %9, %6, %3, %1
%17 = phi i8* [ null, %1 ], [ %0, %3 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), %9 ], [ %0, %6 ]
ret i8* %17
}