#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 /*<<< orphan*/ isalpha(char);
char *mystrdup(char const *);
int /*<<< orphan*/ strcmp(char const *, char *);
char *mk_var_prefix(const char *fname) {
  char *prefix;
  char *p;
  if (!strcmp(fname, "-"))
    return mystrdup("stdin");
  else
    prefix = mystrdup(fname);
  p = prefix;
  while (*p) {
    if (!isalnum(*p))
      *p = '_';
    ++p;
  }
  if (!isalpha(*prefix))
    *prefix = '_';
  return prefix;
}


x86 assembly (clang, -O0):
<mk_var_prefix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea9(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    117a <mk_var_prefix+0x3a>
lea    0xe96(%rip),%rdi
call   1040 <mystrdup@plt>
mov    %rax,-0x8(%rbp)
jmp    11ed <mk_var_prefix+0xad>
mov    -0x10(%rbp),%rdi
call   1040 <mystrdup@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     11c9 <mk_var_prefix+0x89>
mov    -0x20(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isalnum@plt>
cmp    $0x0,%eax
jne    11b8 <mk_var_prefix+0x78>
mov    -0x20(%rbp),%rax
movb   $0x5f,(%rax)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    118f <mk_var_prefix+0x4f>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1060 <isalpha@plt>
cmp    $0x0,%eax
jne    11e5 <mk_var_prefix+0xa5>
mov    -0x18(%rbp),%rax
movb   $0x5f,(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mk_var_prefix>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xeb2(%rip),%rsi
call   1050 <strcmp@plt>
test   %eax,%eax
je     11a2 <mk_var_prefix+0x62>
mov    %rbx,%rdi
call   1040 <mystrdup@plt>
mov    %rax,%r14
mov    (%rax),%al
test   %al,%al
je     11b5 <mk_var_prefix+0x75>
mov    %r14,%rbx
add    $0x1,%rbx
jmp    118b <mk_var_prefix+0x4b>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     119d <mk_var_prefix+0x5d>
movsbl %al,%edi
call   1030 <isalnum@plt>
test   %eax,%eax
jne    1180 <mk_var_prefix+0x40>
movb   $0x5f,-0x1(%rbx)
jmp    1180 <mk_var_prefix+0x40>
mov    (%r14),%al
jmp    11b7 <mk_var_prefix+0x77>
lea    0xe59(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <mystrdup@plt>
xor    %eax,%eax
movsbl %al,%edi
call   1060 <isalpha@plt>
test   %eax,%eax
jne    11c7 <mk_var_prefix+0x87>
movb   $0x5f,(%r14)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c"-\00"
@.str.1 = [6 x i8] c"stdin\00"
define i8* @mk_var_prefix(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = call i32 @strcmp(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp ne i32 %7, 0
br i1 %8, label %11, label %9
9: ; preds = %1
%10 = call i8* @mystrdup(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i8* %10, i8** %2
br label %39
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = call i8* @mystrdup(i8* %12)
store i8* %13, i8** %4
br label %14
14: ; preds = %11
%15 = load i8*, i8** %4
store i8* %15, i8** %5
br label %16
16: ; preds = %27, %14
%17 = load i8*, i8** %5
%18 = load i8, i8* %17
%19 = icmp ne i8 %18, 0
br i1 %19, label %20, label %30
20: ; preds = %16
%21 = load i8*, i8** %5
%22 = load i8, i8* %21
%23 = call i32 @isalnum(i8 signext %22)
%24 = icmp ne i32 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %20
%26 = load i8*, i8** %5
store i8 95, i8* %26
br label %27
27: ; preds = %25, %20
%28 = load i8*, i8** %5
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %5
br label %16
30: ; preds = %16
%31 = load i8*, i8** %4
%32 = load i8, i8* %31
%33 = call i32 @isalpha(i8 signext %32)
%34 = icmp ne i32 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %30
%36 = load i8*, i8** %4
store i8 95, i8* %36
br label %37
37: ; preds = %35, %30
%38 = load i8*, i8** %4
store i8* %38, i8** %2
br label %39
39: ; preds = %37, %9
%40 = load i8*, i8** %2
ret i8* %40
}

LLVM IR (-O2):
@.str = [2 x i8] c"-\00"
@.str.1 = [6 x i8] c"stdin\00"
define i8* @mk_var_prefix(i8* %0) {
%2 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(2) getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i8* @mystrdup(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %27
6: ; preds = %1
%7 = tail call i8* @mystrdup(i8* %0)
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
br i1 %9, label %22, label %10
10: ; preds = %6, %16
%11 = phi i8 [ %18, %16 ], [ %8, %6 ]
%12 = phi i8* [ %17, %16 ], [ %7, %6 ]
%13 = tail call i32 @isalnum(i8 signext %11)
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %10
store i8 95, i8* %12
br label %16
16: ; preds = %15, %10
%17 = getelementptr inbounds i8, i8* %12, i64 1
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %20, label %10
20: ; preds = %16
%21 = load i8, i8* %7
br label %22
22: ; preds = %20, %6
%23 = phi i8 [ %21, %20 ], [ 0, %6 ]
%24 = tail call i32 @isalpha(i8 signext %23)
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %22
store i8 95, i8* %7
br label %27
27: ; preds = %22, %26, %4
%28 = phi i8* [ %5, %4 ], [ %7, %26 ], [ %7, %22 ]
ret i8* %28
}