#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 *get_buffer();
scalar_t__ isalpha(unsigned char);
int /*<<< orphan*/ tolower(unsigned char);
char *make_identifier(const char *name) {
  char *p = get_buffer();
  char *cp;
  for (cp = p; *name; name++)
    if (isalpha((unsigned char)*name))
      *cp++ = tolower((unsigned char)(*name));
    else
      *cp++ = '_';
  *cp = '\0';
  return p;
}


x86 assembly (clang, -O0):
<make_identifier>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1050 <get_buffer@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     11be <make_identifier+0x8e>
mov    -0x8(%rbp),%rax
movzbl (%rax),%edi
call   1040 <isalpha@plt>
cmp    $0x0,%rax
je     1196 <make_identifier+0x66>
mov    -0x8(%rbp),%rax
movzbl (%rax),%edi
call   1030 <tolower@plt>
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
jmp    11a8 <make_identifier+0x78>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movb   $0x5f,(%rax)
jmp    11ad <make_identifier+0x7d>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    114f <make_identifier+0x1f>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_identifier>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
xor    %eax,%eax
call   1050 <get_buffer@plt>
mov    %rax,%r14
mov    (%r15),%al
mov    %r14,%rbx
test   %al,%al
je     118d <make_identifier+0x5d>
add    $0x1,%r15
mov    %r14,%rbx
jmp    117c <make_identifier+0x4c>
cs nopw 0x0(%rax,%rax,1)
nop
movzbl -0x1(%r15),%edi
call   1030 <tolower@plt>
mov    %al,(%rbx)
add    $0x1,%rbx
movzbl (%r15),%eax
add    $0x1,%r15
test   %al,%al
je     118d <make_identifier+0x5d>
movzbl %al,%edi
call   1040 <isalpha@plt>
test   %rax,%rax
jne    1160 <make_identifier+0x30>
mov    $0x5f,%al
jmp    116a <make_identifier+0x3a>
movb   $0x0,(%rbx)
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i8* @make_identifier(i8* nocapture %0) {
%2 = tail call i8* (...) @get_buffer()
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %21, label %5
5: ; preds = %1, %15
%6 = phi i8 [ %19, %15 ], [ %3, %1 ]
%7 = phi i8* [ %17, %15 ], [ %2, %1 ]
%8 = phi i8* [ %18, %15 ], [ %0, %1 ]
%9 = tail call i64 @isalpha(i8 zeroext %6)
%10 = icmp eq i64 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %5
%12 = load i8, i8* %8
%13 = tail call i32 @tolower(i8 zeroext %12)
%14 = trunc i32 %13 to i8
br label %15
15: ; preds = %5, %11
%16 = phi i8 [ %14, %11 ], [ 95, %5 ]
%17 = getelementptr inbounds i8, i8* %7, i64 1
store i8 %16, i8* %7
%18 = getelementptr inbounds i8, i8* %8, i64 1
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 0
br i1 %20, label %21, label %5
21: ; preds = %15, %1
%22 = phi i8* [ %2, %1 ], [ %17, %15 ]
store i8 0, i8* %22
ret i8* %2
}