#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*/ isalnum(int);
int OLEUNWRAP_sanitize_filename(char *fname) {
  if (fname == NULL)
    return 0;
  while (*fname) {
    if (!isalnum((int)*fname) && (*fname != '.'))
      *fname = '_';
    if ((*fname < ' ') || (*fname > '~'))
      *fname = '_';
    fname++;
  }
  return 0;
}


x86 assembly (clang, -O0):
<OLEUNWRAP_sanitize_filename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1133 <OLEUNWRAP_sanitize_filename+0x23>
movl   $0x0,-0x4(%rbp)
jmp    11b0 <OLEUNWRAP_sanitize_filename+0xa0>
jmp    1138 <OLEUNWRAP_sanitize_filename+0x28>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     11a9 <OLEUNWRAP_sanitize_filename+0x99>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%eax
jne    1171 <OLEUNWRAP_sanitize_filename+0x61>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
je     1171 <OLEUNWRAP_sanitize_filename+0x61>
mov    -0x10(%rbp),%rax
movb   $0x5f,(%rax)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
jl     1191 <OLEUNWRAP_sanitize_filename+0x81>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7e,%eax
jle    1198 <OLEUNWRAP_sanitize_filename+0x88>
mov    -0x10(%rbp),%rax
movb   $0x5f,(%rax)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1138 <OLEUNWRAP_sanitize_filename+0x28>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<OLEUNWRAP_sanitize_filename>:
push   %rbp
push   %r14
push   %rbx
test   %rdi,%rdi
je     1166 <OLEUNWRAP_sanitize_filename+0x56>
mov    %rdi,%rbp
mov    (%rdi),%bl
test   %bl,%bl
je     1166 <OLEUNWRAP_sanitize_filename+0x56>
add    $0x1,%rbp
jmp    1140 <OLEUNWRAP_sanitize_filename+0x30>
nopl   0x0(%rax,%rax,1)
movb   $0x5f,-0x1(%rbp)
movzbl 0x0(%rbp),%ebx
add    $0x1,%rbp
test   %bl,%bl
je     1166 <OLEUNWRAP_sanitize_filename+0x56>
movsbl %bl,%r14d
mov    %r14d,%edi
call   1030 <isalnum@plt>
test   %eax,%eax
sete   %al
cmp    $0x2e,%r14b
setne  %cl
test   %cl,%al
jne    1130 <OLEUNWRAP_sanitize_filename+0x20>
add    $0x81,%bl
cmp    $0xa0,%bl
ja     1134 <OLEUNWRAP_sanitize_filename+0x24>
jmp    1130 <OLEUNWRAP_sanitize_filename+0x20>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @OLEUNWRAP_sanitize_filename(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %7
6: ; preds = %1
store i32 0, i32* %2
br label %41
7: ; preds = %1
br label %8
8: ; preds = %37, %7
%9 = load i8*, i8** %3
%10 = load i8, i8* %9
%11 = icmp ne i8 %10, 0
br i1 %11, label %12, label %40
12: ; preds = %8
%13 = load i8*, i8** %3
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = call i32 @isalnum(i32 %15)
%17 = icmp ne i32 %16, 0
br i1 %17, label %25, label %18
18: ; preds = %12
%19 = load i8*, i8** %3
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 46
br i1 %22, label %23, label %25
23: ; preds = %18
%24 = load i8*, i8** %3
store i8 95, i8* %24
br label %25
25: ; preds = %23, %18, %12
%26 = load i8*, i8** %3
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp slt i32 %28, 32
br i1 %29, label %35, label %30
30: ; preds = %25
%31 = load i8*, i8** %3
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp sgt i32 %33, 126
br i1 %34, label %35, label %37
35: ; preds = %30, %25
%36 = load i8*, i8** %3
store i8 95, i8* %36
br label %37
37: ; preds = %35, %30
%38 = load i8*, i8** %3
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %3
br label %8
40: ; preds = %8
store i32 0, i32* %2
br label %41
41: ; preds = %40, %6
%42 = load i32, i32* %2
ret i32 %42
}

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