#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 */
scalar_t__ isgraph(char);
void unspace(char *dest, const char *src, int len) {
  while (len-- > 0) {
    char ch = *src++;
    *dest++ = isgraph(ch) ? ch : '_';
  }
}


x86 assembly (clang, -O0):
<unspace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
jle    1192 <unspace+0x82>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%al
mov    %al,-0x15(%rbp)
movsbl -0x15(%rbp),%edi
call   1030 <isgraph@plt>
cmp    $0x0,%rax
je     116a <unspace+0x5a>
movsbl -0x15(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1177 <unspace+0x67>
mov    $0x5f,%eax
mov    %eax,-0x1c(%rbp)
jmp    1177 <unspace+0x67>
mov    -0x1c(%rbp),%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x8(%rbp)
mov    %cl,(%rax)
jmp    1123 <unspace+0x13>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unspace>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %edx,%edx
jle    1165 <unspace+0x55>
mov    %edx,%r12d
mov    %rsi,%r14
mov    %rdi,%r15
add    $0x1,%r12d
xor    %ebx,%ebx
mov    $0x5f,%r13d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl (%r14,%rbx,1),%ebp
mov    %ebp,%edi
call   1030 <isgraph@plt>
test   %rax,%rax
cmove  %r13d,%ebp
mov    %bpl,(%r15,%rbx,1)
add    $0x1,%rbx
add    $0xffffffff,%r12d
cmp    $0x1,%r12d
ja     1140 <unspace+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @unspace(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
br label %8
8: ; preds = %23, %3
%9 = load i32, i32* %6
%10 = add nsw i32 %9, -1
store i32 %10, i32* %6
%11 = icmp sgt i32 %9, 0
br i1 %11, label %12, label %28
12: ; preds = %8
%13 = load i8*, i8** %5
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %5
%15 = load i8, i8* %13
store i8 %15, i8* %7
%16 = load i8, i8* %7
%17 = call i64 @isgraph(i8 signext %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %12
%20 = load i8, i8* %7
%21 = sext i8 %20 to i32
br label %23
22: ; preds = %12
br label %23
23: ; preds = %22, %19
%24 = phi i32 [ %21, %19 ], [ 95, %22 ]
%25 = trunc i32 %24 to i8
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %4
store i8 %25, i8* %26
br label %8
28: ; preds = %8
ret void
}

LLVM IR (-O2):
define void @unspace(i8* nocapture writeonly %0, i8* nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %17
5: ; preds = %3, %5
%6 = phi i8* [ %15, %5 ], [ %0, %3 ]
%7 = phi i32 [ %9, %5 ], [ %2, %3 ]
%8 = phi i8* [ %10, %5 ], [ %1, %3 ]
%9 = add nsw i32 %7, -1
%10 = getelementptr inbounds i8, i8* %8, i64 1
%11 = load i8, i8* %8
%12 = tail call i64 @isgraph(i8 signext %11)
%13 = icmp eq i64 %12, 0
%14 = select i1 %13, i8 95, i8 %11
%15 = getelementptr inbounds i8, i8* %6, i64 1
store i8 %14, i8* %6
%16 = icmp ugt i32 %7, 1
br i1 %16, label %5, label %17
17: ; preds = %5, %3
ret void
}