#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 strlen(char *);
char toupper(char);
void cleanup_name(char *fname) {
  int i;
  int len = strlen(fname);
  for (i = 0; i < len; i++) {
    if (!isalnum(fname[i])) {
      fname[i] = '_';
    }
    fname[i] = toupper(fname[i]);
  }
}


x86 assembly (clang, -O0):
<cleanup_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11ad <cleanup_name+0x7d>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <isalnum@plt>
cmp    $0x0,%eax
jne    1181 <cleanup_name+0x51>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x5f,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <toupper@plt>
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114f <cleanup_name+0x1f>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cleanup_name>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
call   1040 <strlen@plt>
test   %eax,%eax
jle    1181 <cleanup_name+0x51>
mov    %eax,%r14d
xor    %ebx,%ebx
jmp    116c <cleanup_name+0x3c>
nopl   0x0(%rax,%rax,1)
movb   $0x5f,(%r15,%rbx,1)
mov    $0x5f,%al
movsbl %al,%edi
call   1030 <toupper@plt>
mov    %al,(%r15,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r14
je     1181 <cleanup_name+0x51>
movsbl (%r15,%rbx,1),%edi
call   1050 <isalnum@plt>
test   %eax,%eax
je     1150 <cleanup_name+0x20>
movzbl (%r15,%rbx,1),%eax
jmp    1157 <cleanup_name+0x27>
pop    %rbx
pop    %r14
pop    %r15
ret

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

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