#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);
char *strdup(char *);
char *make_ident(char *name) {
  char *ret;
  char *p;
  ret = strdup(name);
  for (p = ret; p[0]; p++) {
    if (!isalnum(p[0]))
      p[0] = '_';
  }
  return ret;
}


x86 assembly (clang, -O0):
<make_ident>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strdup@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     1180 <make_ident+0x60>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%eax
jne    116a <make_ident+0x4a>
mov    -0x18(%rbp),%rax
movb   $0x5f,(%rax)
jmp    116f <make_ident+0x4f>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1141 <make_ident+0x21>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

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

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

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