#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 tolower(char);
void convertname(char *tmp) {
  for (; tmp[0]; tmp++) {
    if (!isalnum(tmp[0]))
      tmp[0] = '_';
    else
      tmp[0] = tolower(tmp[0]);
  }
}


x86 assembly (clang, -O0):
<convertname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1184 <convertname+0x64>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%eax
jne    115a <convertname+0x3a>
mov    -0x8(%rbp),%rax
movb   $0x5f,(%rax)
jmp    116e <convertname+0x4e>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1040 <tolower@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
jmp    1173 <convertname+0x53>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    112c <convertname+0xc>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<convertname>:
push   %rbx
mov    (%rdi),%al
test   %al,%al
je     1156 <convertname+0x36>
mov    %rdi,%rbx
jmp    1146 <convertname+0x26>
nopl   0x0(%rax)
movsbl (%rbx),%edi
call   1040 <tolower@plt>
mov    %al,(%rbx)
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1156 <convertname+0x36>
movsbl %al,%edi
call   1030 <isalnum@plt>
test   %eax,%eax
jne    1130 <convertname+0x10>
mov    $0x5f,%al
jmp    1138 <convertname+0x18>
pop    %rbx
ret

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

LLVM IR (-O2):
define void @convertname(i8* nocapture %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 0
br i1 %3, label %17, label %4
4: ; preds = %1, %12
%5 = phi i8 [ %15, %12 ], [ %2, %1 ]
%6 = phi i8* [ %14, %12 ], [ %0, %1 ]
%7 = tail call i32 @isalnum(i8 signext %5)
%8 = icmp eq i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %4
%10 = load i8, i8* %6
%11 = tail call signext i8 @tolower(i8 signext %10)
br label %12
12: ; preds = %4, %9
%13 = phi i8 [ %11, %9 ], [ 95, %4 ]
store i8 %13, i8* %6
%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 = %12, %1
ret void
}