#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(char);
int /*<<< orphan*/ strcpy(char *, char const *);
void symname(char *dst, const char *fname) {
  strcpy(dst, fname);
  for (int lpc = 0; dst[lpc]; lpc++) {
    if (!isalnum(dst[lpc])) {
      dst[lpc] = '_';
    }
  }
}


x86 assembly (clang, -O0):
<symname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     118f <symname+0x6f>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isalnum@plt>
cmp    $0x0,%eax
jne    117c <symname+0x5c>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x5f,(%rax,%rcx,1)
jmp    1181 <symname+0x61>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1144 <symname+0x24>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<symname>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strcpy@plt>
mov    (%rbx),%al
test   %al,%al
je     115d <symname+0x3d>
add    $0x1,%rbx
jmp    114b <symname+0x2b>
cs nopw 0x0(%rax,%rax,1)
nop
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     115d <symname+0x3d>
movsbl %al,%edi
call   1040 <isalnum@plt>
test   %eax,%eax
jne    1140 <symname+0x20>
movb   $0x5f,-0x1(%rbx)
jmp    1140 <symname+0x20>
pop    %rbx
ret

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

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