#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*/ isgraph(int);
char *sanitize_file_string(char *str) {
  char *p;
  if (str) {
    for (p = str; *p; p++) {
      if (!isgraph((int)*p) || (*p == '/'))
        *p = '_';
    }
  }
  return (str);
}


x86 assembly (clang, -O0):
<sanitize_file_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1183 <sanitize_file_string+0x73>
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     117e <sanitize_file_string+0x6e>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isgraph@plt>
cmp    $0x0,%eax
je     1161 <sanitize_file_string+0x51>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    1168 <sanitize_file_string+0x58>
mov    -0x10(%rbp),%rax
movb   $0x5f,(%rax)
jmp    116d <sanitize_file_string+0x5d>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    112f <sanitize_file_string+0x1f>
jmp    1183 <sanitize_file_string+0x73>
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sanitize_file_string>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%r14
test   %rdi,%rdi
je     1155 <sanitize_file_string+0x45>
mov    (%r14),%bpl
test   %bpl,%bpl
je     1155 <sanitize_file_string+0x45>
lea    0x1(%r14),%rbx
jmp    1140 <sanitize_file_string+0x30>
nopw   0x0(%rax,%rax,1)
movb   $0x5f,-0x1(%rbx)
movzbl (%rbx),%ebp
add    $0x1,%rbx
test   %bpl,%bpl
je     1155 <sanitize_file_string+0x45>
movsbl %bpl,%edi
call   1030 <isgraph@plt>
test   %eax,%eax
je     1130 <sanitize_file_string+0x20>
cmp    $0x2f,%bpl
jne    1134 <sanitize_file_string+0x24>
jmp    1130 <sanitize_file_string+0x20>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i8* @sanitize_file_string(i8* returned %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %19, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %19, label %6
6: ; preds = %3, %15
%7 = phi i8 [ %17, %15 ], [ %4, %3 ]
%8 = phi i8* [ %16, %15 ], [ %0, %3 ]
%9 = sext i8 %7 to i32
%10 = tail call i32 @isgraph(i32 %9)
%11 = icmp eq i32 %10, 0
%12 = icmp eq i8 %7, 47
%13 = select i1 %11, i1 true, i1 %12
br i1 %13, label %14, label %15
14: ; preds = %6
store i8 95, i8* %8
br label %15
15: ; preds = %6, %14
%16 = getelementptr inbounds i8, i8* %8, i64 1
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %19, label %6
19: ; preds = %15, %3, %1
ret i8* %0
}