#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 */
scalar_t__ islower(unsigned char);
scalar_t__ isupper(char);
scalar_t__ strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
char toupper(unsigned char);
char *label_name(char *filename, int verbose, int *mangled, char *ans) {
  int len;
  int i;
  int have_lower, have_upper;
  strcpy(ans, "           ");
  len = strlen(filename);
  if (len > 11) {
    *mangled = 1;
    len = 11;
  } else
    *mangled = 0;
  strncpy(ans, filename, len);
  have_lower = have_upper = 0;
  for (i = 0; i < 11; i++) {
    if (islower((unsigned char)ans[i]))
      have_lower = 1;
    if (isupper(ans[i]))
      have_upper = 1;
    ans[i] = toupper((unsigned char)ans[i]);
    if (strchr("^+=/[]:,?*\\<>|\".", ans[i])) {
      *mangled = 1;
      ans[i] = '~';
    }
  }
  if (have_lower && have_upper)
    *mangled = 1;
  return ans;
}


x86 assembly (clang, -O0):
<label_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xe6e(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x8(%rbp),%rdi
call   1070 <strlen@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xb,-0x24(%rbp)
jle    11c3 <label_name+0x53>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
movl   $0xb,-0x24(%rbp)
jmp    11cd <label_name+0x5d>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1030 <strncpy@plt>
movl   $0x0,-0x30(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0xb,-0x28(%rbp)
jge    12a9 <label_name+0x139>
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
call   1050 <islower@plt>
cmp    $0x0,%rax
je     121e <label_name+0xae>
movl   $0x1,-0x2c(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1090 <isupper@plt>
cmp    $0x0,%rax
je     1240 <label_name+0xd0>
movl   $0x1,-0x30(%rbp)
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
call   1060 <toupper@plt>
mov    %al,%dl
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
lea    0xd9f(%rip),%rdi
movsbl (%rax,%rcx,1),%esi
call   1080 <strchr@plt>
cmp    $0x0,%rax
je     1296 <label_name+0x126>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x20(%rbp),%rax
movslq -0x28(%rbp),%rcx
movb   $0x7e,(%rax,%rcx,1)
jmp    129b <label_name+0x12b>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11f2 <label_name+0x82>
cmpl   $0x0,-0x2c(%rbp)
je     12c7 <label_name+0x157>
cmpl   $0x0,-0x30(%rbp)
je     12c7 <label_name+0x157>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<label_name>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%rbx
mov    %rdx,%rbp
mov    %rdi,%r14
lea    0xe75(%rip),%rsi
mov    %rcx,%rdi
call   1040 <strcpy@plt>
mov    %r14,%rdi
call   1070 <strlen@plt>
xor    %ecx,%ecx
cmp    $0xc,%eax
setge  %cl
mov    $0xb,%edx
cmovl  %eax,%edx
mov    %rbp,%r15
mov    %ecx,0x0(%rbp)
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strncpy@plt>
xor    %ebp,%ebp
mov    $0x1,%r13d
xor    %r12d,%r12d
xor    %r14d,%r14d
jmp    11da <label_name+0x6a>
nopl   0x0(%rax)
add    $0x1,%rbp
cmp    $0xb,%rbp
je     1227 <label_name+0xb7>
movzbl (%rbx,%rbp,1),%edi
call   1050 <islower@plt>
test   %rax,%rax
cmovne %r13d,%r14d
movsbl (%rbx,%rbp,1),%edi
call   1090 <isupper@plt>
test   %rax,%rax
cmovne %r13d,%r12d
movzbl (%rbx,%rbp,1),%edi
call   1060 <toupper@plt>
mov    %al,(%rbx,%rbp,1)
movsbl %al,%esi
lea    0xdfc(%rip),%rdi
call   1080 <strchr@plt>
test   %rax,%rax
je     11d0 <label_name+0x60>
movl   $0x1,(%r15)
movb   $0x7e,(%rbx,%rbp,1)
jmp    11d0 <label_name+0x60>
test   %r14d,%r14d
je     1238 <label_name+0xc8>
test   %r12d,%r12d
je     1238 <label_name+0xc8>
movl   $0x1,(%r15)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [12 x i8] c" \00"
@.str.1 = [17 x i8] c"^+=/[]:,?*\\<>|\22.\00"
define i8* @label_name(i8* %0, i32 %1, i32* %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32* %2, i32** %7
store i8* %3, i8** %8
%13 = load i8*, i8** %8
%14 = call i32 @strcpy(i8* %13, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%15 = load i8*, i8** %5
%16 = call i32 @strlen(i8* %15)
store i32 %16, i32* %9
%17 = load i32, i32* %9
%18 = icmp sgt i32 %17, 11
br i1 %18, label %19, label %21
19: ; preds = %4
%20 = load i32*, i32** %7
store i32 1, i32* %20
store i32 11, i32* %9
br label %23
21: ; preds = %4
%22 = load i32*, i32** %7
store i32 0, i32* %22
br label %23
23: ; preds = %21, %19
%24 = load i8*, i8** %8
%25 = load i8*, i8** %5
%26 = load i32, i32* %9
%27 = call i32 @strncpy(i8* %24, i8* %25, i32 %26)
store i32 0, i32* %12
store i32 0, i32* %11
store i32 0, i32* %10
br label %28
28: ; preds = %74, %23
%29 = load i32, i32* %10
%30 = icmp slt i32 %29, 11
br i1 %30, label %31, label %77
31: ; preds = %28
%32 = load i8*, i8** %8
%33 = load i32, i32* %10
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %32, i64 %34
%36 = load i8, i8* %35
%37 = call i64 @islower(i8 zeroext %36)
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %31
store i32 1, i32* %11
br label %40
40: ; preds = %39, %31
%41 = load i8*, i8** %8
%42 = load i32, i32* %10
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
%45 = load i8, i8* %44
%46 = call i64 @isupper(i8 signext %45)
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %49
48: ; preds = %40
store i32 1, i32* %12
br label %49
49: ; preds = %48, %40
%50 = load i8*, i8** %8
%51 = load i32, i32* %10
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %50, i64 %52
%54 = load i8, i8* %53
%55 = call signext i8 @toupper(i8 zeroext %54)
%56 = load i8*, i8** %8
%57 = load i32, i32* %10
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %56, i64 %58
store i8 %55, i8* %59
%60 = load i8*, i8** %8
%61 = load i32, i32* %10
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i8, i8* %60, i64 %62
%64 = load i8, i8* %63
%65 = call i64 @strchr(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8 signext %64)
%66 = icmp ne i64 %65, 0
br i1 %66, label %67, label %73
67: ; preds = %49
%68 = load i32*, i32** %7
store i32 1, i32* %68
%69 = load i8*, i8** %8
%70 = load i32, i32* %10
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i8, i8* %69, i64 %71
store i8 126, i8* %72
br label %73
73: ; preds = %67, %49
br label %74
74: ; preds = %73
%75 = load i32, i32* %10
%76 = add nsw i32 %75, 1
store i32 %76, i32* %10
br label %28
77: ; preds = %28
%78 = load i32, i32* %11
%79 = icmp ne i32 %78, 0
br i1 %79, label %80, label %85
80: ; preds = %77
%81 = load i32, i32* %12
%82 = icmp ne i32 %81, 0
br i1 %82, label %83, label %85
83: ; preds = %80
%84 = load i32*, i32** %7
store i32 1, i32* %84
br label %85
85: ; preds = %83, %80, %77
%86 = load i8*, i8** %8
ret i8* %86
}

LLVM IR (-O2):
@.str = [12 x i8] c" \00"
@.str.1 = [17 x i8] c"^+=/[]:,?*\\<>|\22.\00"
define i8* @label_name(i8* %0, i32 %1, i32* nocapture writeonly %2, i8* returned %3) {
%5 = tail call i32 @strcpy(i8* %3, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @strlen(i8* %0)
%7 = icmp sgt i32 %6, 11
%8 = zext i1 %7 to i32
%9 = select i1 %7, i32 11, i32 %6
store i32 %8, i32* %2
%10 = tail call i32 @strncpy(i8* %3, i8* %0, i32 %9)
br label %11
11: ; preds = %4, %29
%12 = phi i64 [ 0, %4 ], [ %30, %29 ]
%13 = phi i32 [ 0, %4 ], [ %23, %29 ]
%14 = phi i32 [ 0, %4 ], [ %19, %29 ]
%15 = getelementptr inbounds i8, i8* %3, i64 %12
%16 = load i8, i8* %15
%17 = tail call i64 @islower(i8 zeroext %16)
%18 = icmp eq i64 %17, 0
%19 = select i1 %18, i32 %14, i32 1
%20 = load i8, i8* %15
%21 = tail call i64 @isupper(i8 signext %20)
%22 = icmp eq i64 %21, 0
%23 = select i1 %22, i32 %13, i32 1
%24 = load i8, i8* %15
%25 = tail call signext i8 @toupper(i8 zeroext %24)
store i8 %25, i8* %15
%26 = tail call i64 @strchr(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i8 signext %25)
%27 = icmp eq i64 %26, 0
br i1 %27, label %29, label %28
28: ; preds = %11
store i32 1, i32* %2
store i8 126, i8* %15
br label %29
29: ; preds = %11, %28
%30 = add nuw nsw i64 %12, 1
%31 = icmp eq i64 %30, 11
br i1 %31, label %32, label %11
32: ; preds = %29
%33 = icmp ne i32 %19, 0
%34 = icmp ne i32 %23, 0
%35 = select i1 %33, i1 %34, i1 false
br i1 %35, label %36, label %37
36: ; preds = %32
store i32 1, i32* %2
br label %37
37: ; preds = %36, %32
ret i8* %3
}