#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 */
char ascii_tolower(char const);
char *enum_map_name(const char *name, size_t namelen) {
  static char buf[1024];
  int bufpos;
  for (bufpos = 0; bufpos <= namelen; bufpos++) {
    buf[bufpos] = ascii_tolower(name[bufpos]);
    if (buf[bufpos] == '_')
      buf[bufpos] = '-';
  }
  buf[bufpos] = 0;
  return buf;
}


x86 assembly (clang, -O0):
<enum_map_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movslq -0x14(%rbp),%rax
cmp    -0x10(%rbp),%rax
ja     1190 <enum_map_name+0x80>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <ascii_tolower@plt>
mov    %al,%dl
movslq -0x14(%rbp),%rcx
lea    0x2eed(%rip),%rax
mov    %dl,(%rax,%rcx,1)
movslq -0x14(%rbp),%rcx
lea    0x2edf(%rip),%rax
movsbl (%rax,%rcx,1),%eax
cmp    $0x5f,%eax
jne    117d <enum_map_name+0x6d>
movslq -0x14(%rbp),%rcx
lea    0x2ec7(%rip),%rax
movb   $0x2d,(%rax,%rcx,1)
jmp    1182 <enum_map_name+0x72>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1127 <enum_map_name+0x17>
movslq -0x14(%rbp),%rcx
lea    0x2ea5(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0x2e9a(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<enum_map_name>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r12
lea    0x1(%rsi),%r13
xor    %ebx,%ebx
lea    0x2f12(%rip),%r15
mov    $0x2d,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl (%r12,%rbx,1),%edi
call   1030 <ascii_tolower@plt>
cmp    $0x5f,%al
movzbl %al,%eax
cmove  %ebp,%eax
mov    %al,(%rbx,%r15,1)
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1140 <enum_map_name+0x30>
add    $0x1,%r14d
movb   $0x0,(%r14,%r15,1)
mov    %r15,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@enum_map_name.buf = internal global [1024 x i8] zeroinitializer
define i8* @enum_map_name(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
store i8* %0, i8** %3
store i64 %1, i64* %4
store i32 0, i32* %5
br label %6
6: ; preds = %32, %2
%7 = load i32, i32* %5
%8 = sext i32 %7 to i64
%9 = load i64, i64* %4
%10 = icmp ule i64 %8, %9
br i1 %10, label %11, label %35
11: ; preds = %6
%12 = load i8*, i8** %3
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = call signext i8 @ascii_tolower(i8 signext %16)
%18 = load i32, i32* %5
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [1024 x i8], [1024 x i8]* @enum_map_name.buf, i64 0, i64 %19
store i8 %17, i8* %20
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds [1024 x i8], [1024 x i8]* @enum_map_name.buf, i64 0, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp eq i32 %25, 95
br i1 %26, label %27, label %31
27: ; preds = %11
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* @enum_map_name.buf, i64 0, i64 %29
store i8 45, i8* %30
br label %31
31: ; preds = %27, %11
br label %32
32: ; preds = %31
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
br label %6
35: ; preds = %6
%36 = load i32, i32* %5
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [1024 x i8], [1024 x i8]* @enum_map_name.buf, i64 0, i64 %37
store i8 0, i8* %38
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @enum_map_name.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@enum_map_name.buf = internal global [1024 x i8] zeroinitializer
define i8* @enum_map_name(i8* nocapture %0, i64 %1) {
br label %3
3: ; preds = %2, %3
%4 = phi i64 [ 0, %2 ], [ %11, %3 ]
%5 = getelementptr inbounds i8, i8* %0, i64 %4
%6 = load i8, i8* %5
%7 = tail call signext i8 @ascii_tolower(i8 signext %6)
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* @enum_map_name.buf, i64 0, i64 %4
%9 = icmp eq i8 %7, 95
%10 = select i1 %9, i8 45, i8 %7
store i8 %10, i8* %8
%11 = add nuw i64 %4, 1
%12 = icmp eq i64 %4, %1
br i1 %12, label %13, label %3
13: ; preds = %3
%14 = add i64 %1, 1
%15 = and i64 %14, 4294967295
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* @enum_map_name.buf, i64 0, i64 %15
store i8 0, i8* %16
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @enum_map_name.buf, i64 0, i64 0)
}