#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*/ memcpy(char *, char const *, int);
scalar_t__ smalloc(int);
int /*<<< orphan*/ strcpy(char *, char const *);
int strlen(char const *);
int /*<<< orphan*/ strncmp(char const *, char *, int);
char *krocetc_make_namedlabel(const char *lbl) {
  int lbl_len = strlen(lbl);
  char *belbl = (char *)smalloc(lbl_len + 5);
  char *ch;
  int offs = 0;
  if (!strncmp(lbl, "C.", 2)) {
    strcpy(belbl, lbl);
    offs = 2;
  } else if (!strncmp(lbl, "CIF.", 4)) {
    strcpy(belbl, lbl);
    offs = 4;
  } else if (!strncmp(lbl, "B.", 2)) {
    strcpy(belbl, lbl);
    offs = 2;
  } else if (!strncmp(lbl, "BX.", 3)) {
    strcpy(belbl, lbl);
    offs = 3;
  } else {
    strcpy(belbl, "O_");
    memcpy(belbl + 2, lbl, lbl_len + 1);
    offs = 2;
  }
  for (ch = belbl + offs; *ch != '\0'; ch++) {
    switch (*ch) {
    case '.':
      *ch = '_';
      break;
    }
  }
  return belbl;
}


x86 assembly (clang, -O0):
<krocetc_make_namedlabel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
add    $0x5,%edi
call   1070 <smalloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe77(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11b5 <krocetc_make_namedlabel+0x65>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
movl   $0x2,-0x24(%rbp)
jmp    1297 <krocetc_make_namedlabel+0x147>
mov    -0x8(%rbp),%rdi
lea    0xe43(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11ec <krocetc_make_namedlabel+0x9c>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
movl   $0x4,-0x24(%rbp)
jmp    1292 <krocetc_make_namedlabel+0x142>
mov    -0x8(%rbp),%rdi
lea    0xe11(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    1223 <krocetc_make_namedlabel+0xd3>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
movl   $0x2,-0x24(%rbp)
jmp    128d <krocetc_make_namedlabel+0x13d>
mov    -0x8(%rbp),%rdi
lea    0xddd(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    125a <krocetc_make_namedlabel+0x10a>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
movl   $0x3,-0x24(%rbp)
jmp    1288 <krocetc_make_namedlabel+0x138>
mov    -0x18(%rbp),%rdi
lea    0xdaa(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x18(%rbp),%rdi
add    $0x2,%rdi
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
add    $0x1,%edx
call   1060 <memcpy@plt>
movl   $0x2,-0x24(%rbp)
jmp    128d <krocetc_make_namedlabel+0x13d>
jmp    1292 <krocetc_make_namedlabel+0x142>
jmp    1297 <krocetc_make_namedlabel+0x147>
mov    -0x18(%rbp),%rax
movslq -0x24(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     12e6 <krocetc_make_namedlabel+0x196>
mov    -0x20(%rbp),%rax
mov    (%rax),%al
sub    $0x2e,%al
jne    12d0 <krocetc_make_namedlabel+0x180>
jmp    12c9 <krocetc_make_namedlabel+0x179>
mov    -0x20(%rbp),%rax
movb   $0x5f,(%rax)
jmp    12d5 <krocetc_make_namedlabel+0x185>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    12a6 <krocetc_make_namedlabel+0x156>
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<krocetc_make_namedlabel>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
call   1050 <strlen@plt>
mov    %eax,%r15d
lea    0x5(%r15),%edi
call   1070 <smalloc@plt>
mov    %rax,%r14
lea    0xe8d(%rip),%rsi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11f0 <krocetc_make_namedlabel+0xa0>
lea    0xe78(%rip),%rsi
mov    %rbx,%rdi
mov    $0x4,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1202 <krocetc_make_namedlabel+0xb2>
lea    0xe65(%rip),%rsi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     11f0 <krocetc_make_namedlabel+0xa0>
lea    0xe50(%rip),%rsi
mov    %rbx,%rdi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1214 <krocetc_make_namedlabel+0xc4>
lea    0xe3c(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcpy@plt>
lea    0x2(%r14),%rdi
add    $0x1,%r15d
mov    %rbx,%rsi
mov    %r15d,%edx
call   1060 <memcpy@plt>
jmp    11fb <krocetc_make_namedlabel+0xab>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    $0x2,%ecx
jmp    1224 <krocetc_make_namedlabel+0xd4>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    $0x4,%ecx
jmp    1224 <krocetc_make_namedlabel+0xd4>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    $0x3,%ecx
mov    %r14,%rax
add    %rcx,%rax
jmp    1237 <krocetc_make_namedlabel+0xe7>
nopl   0x0(%rax)
movb   $0x5f,(%rax)
add    $0x1,%rax
movzbl (%rax),%ecx
cmp    $0x2e,%cl
je     1230 <krocetc_make_namedlabel+0xe0>
test   %cl,%cl
jne    1233 <krocetc_make_namedlabel+0xe3>
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"C.\00"
@.str.1 = [5 x i8] c"CIF.\00"
@.str.2 = [3 x i8] c"B.\00"
@.str.3 = [4 x i8] c"BX.\00"
@.str.4 = [3 x i8] c"O_\00"
define i8* @krocetc_make_namedlabel(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = call i32 @strlen(i8* %7)
store i32 %8, i32* %3
%9 = load i32, i32* %3
%10 = add nsw i32 %9, 5
%11 = call i64 @smalloc(i32 %10)
%12 = inttoptr i64 %11 to i8*
store i8* %12, i8** %4
store i32 0, i32* %6
%13 = load i8*, i8** %2
%14 = call i32 @strncmp(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%15 = icmp ne i32 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %1
%17 = load i8*, i8** %4
%18 = load i8*, i8** %2
%19 = call i32 @strcpy(i8* %17, i8* %18)
store i32 2, i32* %6
br label %56
20: ; preds = %1
%21 = load i8*, i8** %2
%22 = call i32 @strncmp(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%23 = icmp ne i32 %22, 0
br i1 %23, label %28, label %24
24: ; preds = %20
%25 = load i8*, i8** %4
%26 = load i8*, i8** %2
%27 = call i32 @strcpy(i8* %25, i8* %26)
store i32 4, i32* %6
br label %55
28: ; preds = %20
%29 = load i8*, i8** %2
%30 = call i32 @strncmp(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
%31 = icmp ne i32 %30, 0
br i1 %31, label %36, label %32
32: ; preds = %28
%33 = load i8*, i8** %4
%34 = load i8*, i8** %2
%35 = call i32 @strcpy(i8* %33, i8* %34)
store i32 2, i32* %6
br label %54
36: ; preds = %28
%37 = load i8*, i8** %2
%38 = call i32 @strncmp(i8* %37, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
%39 = icmp ne i32 %38, 0
br i1 %39, label %44, label %40
40: ; preds = %36
%41 = load i8*, i8** %4
%42 = load i8*, i8** %2
%43 = call i32 @strcpy(i8* %41, i8* %42)
store i32 3, i32* %6
br label %53
44: ; preds = %36
%45 = load i8*, i8** %4
%46 = call i32 @strcpy(i8* %45, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%47 = load i8*, i8** %4
%48 = getelementptr inbounds i8, i8* %47, i64 2
%49 = load i8*, i8** %2
%50 = load i32, i32* %3
%51 = add nsw i32 %50, 1
%52 = call i32 @memcpy(i8* %48, i8* %49, i32 %51)
store i32 2, i32* %6
br label %53
53: ; preds = %44, %40
br label %54
54: ; preds = %53, %32
br label %55
55: ; preds = %54, %24
br label %56
56: ; preds = %55, %16
%57 = load i8*, i8** %4
%58 = load i32, i32* %6
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds i8, i8* %57, i64 %59
store i8* %60, i8** %5
br label %61
61: ; preds = %73, %56
%62 = load i8*, i8** %5
%63 = load i8, i8* %62
%64 = sext i8 %63 to i32
%65 = icmp ne i32 %64, 0
br i1 %65, label %66, label %76
66: ; preds = %61
%67 = load i8*, i8** %5
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
switch i32 %69, label %72 [
i32 46, label %70
]
70: ; preds = %66
%71 = load i8*, i8** %5
store i8 95, i8* %71
br label %72
72: ; preds = %66, %70
br label %73
73: ; preds = %72
%74 = load i8*, i8** %5
%75 = getelementptr inbounds i8, i8* %74, i32 1
store i8* %75, i8** %5
br label %61
76: ; preds = %61
%77 = load i8*, i8** %4
ret i8* %77
}

LLVM IR (-O2):
@.str = [3 x i8] c"C.\00"
@.str.1 = [5 x i8] c"CIF.\00"
@.str.2 = [3 x i8] c"B.\00"
@.str.3 = [4 x i8] c"BX.\00"
@.str.4 = [3 x i8] c"O_\00"
define i8* @krocetc_make_namedlabel(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = add nsw i32 %2, 5
%4 = tail call i64 @smalloc(i32 %3)
%5 = inttoptr i64 %4 to i8*
%6 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = tail call i32 @strcpy(i8* %5, i8* %0)
br label %30
10: ; preds = %1
%11 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 4)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 @strcpy(i8* %5, i8* %0)
br label %30
15: ; preds = %10
%16 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32 2)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = tail call i32 @strcpy(i8* %5, i8* %0)
br label %30
20: ; preds = %15
%21 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 3)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = tail call i32 @strcpy(i8* %5, i8* %0)
br label %30
25: ; preds = %20
%26 = tail call i32 @strcpy(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%27 = getelementptr inbounds i8, i8* %5, i64 2
%28 = add nsw i32 %2, 1
%29 = tail call i32 @memcpy(i8* %27, i8* %0, i32 %28)
br label %30
30: ; preds = %13, %23, %25, %18, %8
%31 = phi i64 [ 2, %25 ], [ 3, %23 ], [ 2, %18 ], [ 4, %13 ], [ 2, %8 ]
%32 = getelementptr inbounds i8, i8* %5, i64 %31
br label %33
33: ; preds = %37, %30
%34 = phi i8* [ %32, %30 ], [ %38, %37 ]
%35 = load i8, i8* %34
switch i8 %35, label %37 [
i8 0, label %39
i8 46, label %36
]
36: ; preds = %33
store i8 95, i8* %34
br label %37
37: ; preds = %33, %36
%38 = getelementptr inbounds i8, i8* %34, i64 1
br label %33
39: ; preds = %33
ret i8* %5
}