#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__ isalnum(int);
void remove_spec_chars(char *filename) {
  int c = 0;
  while ((c = *filename)) {
    if (!(isalnum(c) || (c == '_') || (c == '-'))) {
      *filename = '_';
    }
    filename++;
  }
  return;
}


x86 assembly (clang, -O0):
<remove_spec_chars>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0xc(%rbp)
cmp    $0x0,%eax
je     1174 <remove_spec_chars+0x64>
mov    -0xc(%rbp),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%rax
jne    1163 <remove_spec_chars+0x53>
cmpl   $0x5f,-0xc(%rbp)
je     1163 <remove_spec_chars+0x53>
cmpl   $0x2d,-0xc(%rbp)
je     1163 <remove_spec_chars+0x53>
mov    -0x8(%rbp),%rax
movb   $0x5f,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1123 <remove_spec_chars+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remove_spec_chars>:
push   %rbp
push   %rbx
push   %rax
mov    (%rdi),%bpl
test   %bpl,%bpl
je     115c <remove_spec_chars+0x4c>
mov    %rdi,%rbx
add    $0x1,%rbx
jmp    113c <remove_spec_chars+0x2c>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl (%rbx),%ebp
add    $0x1,%rbx
test   %bpl,%bpl
je     115c <remove_spec_chars+0x4c>
movsbl %bpl,%edi
call   1030 <isalnum@plt>
test   %rax,%rax
jne    1130 <remove_spec_chars+0x20>
cmp    $0x2d,%bpl
je     1130 <remove_spec_chars+0x20>
cmp    $0x5f,%bpl
je     1130 <remove_spec_chars+0x20>
movb   $0x5f,-0x1(%rbx)
jmp    1130 <remove_spec_chars+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @remove_spec_chars(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %21, %1
%5 = load i8*, i8** %2
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
store i32 %7, i32* %3
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %24
9: ; preds = %4
%10 = load i32, i32* %3
%11 = call i64 @isalnum(i32 %10)
%12 = icmp ne i64 %11, 0
br i1 %12, label %21, label %13
13: ; preds = %9
%14 = load i32, i32* %3
%15 = icmp eq i32 %14, 95
br i1 %15, label %21, label %16
16: ; preds = %13
%17 = load i32, i32* %3
%18 = icmp eq i32 %17, 45
br i1 %18, label %21, label %19
19: ; preds = %16
%20 = load i8*, i8** %2
store i8 95, i8* %20
br label %21
21: ; preds = %19, %16, %13, %9
%22 = load i8*, i8** %2
%23 = getelementptr inbounds i8, i8* %22, i32 1
store i8* %23, i8** %2
br label %4
24: ; preds = %4
ret void
}

LLVM IR (-O2):
define void @remove_spec_chars(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %17, label %4
4: ; preds = %1, %13
%5 = phi i8 [ %15, %13 ], [ %2, %1 ]
%6 = phi i8* [ %14, %13 ], [ %0, %1 ]
%7 = sext i8 %5 to i32
%8 = tail call i64 @isalnum(i32 %7)
%9 = freeze i64 %8
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %4
switch i8 %5, label %12 [
i8 95, label %13
i8 45, label %13
]
12: ; preds = %11
store i8 95, i8* %6
br label %13
13: ; preds = %11, %11, %4, %12
%14 = getelementptr inbounds i8, i8* %6, i64 1
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %4
17: ; preds = %13, %1
ret void
}