#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 const);
void action_to_name(const char *str, char *buf) {
  for (; *str; ++str, ++buf) {
    if (!isalnum(*str))
      *buf = '_';
    else
      *buf = *str;
  }
  *buf = 0;
}


x86 assembly (clang, -O0):
<action_to_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     117c <action_to_name+0x6c>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%eax
jne    114e <action_to_name+0x3e>
mov    -0x10(%rbp),%rax
movb   $0x5f,(%rax)
jmp    115a <action_to_name+0x4a>
mov    -0x8(%rbp),%rax
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
jmp    115f <action_to_name+0x4f>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1120 <action_to_name+0x10>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<action_to_name>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    (%rdi),%al
test   %al,%al
je     1156 <action_to_name+0x46>
mov    %rdi,%rbx
add    $0x1,%rbx
jmp    1146 <action_to_name+0x36>
cs nopw 0x0(%rax,%rax,1)
movzbl -0x1(%rbx),%eax
mov    %al,(%r14)
add    $0x1,%r14
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1156 <action_to_name+0x46>
movsbl %al,%edi
call   1030 <isalnum@plt>
test   %eax,%eax
jne    1130 <action_to_name+0x20>
mov    $0x5f,%al
jmp    1134 <action_to_name+0x24>
movb   $0x0,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

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