#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__ smalloc(scalar_t__);
int /*<<< orphan*/ sprintf(char *, char *, char const *);
scalar_t__ strlen(char const *);
char *cccsp_make_entryname(const char *name, const int procabs) {
  char *rname = (char *)smalloc(strlen(name) + 10);
  char *ch;
  if (procabs) {
    sprintf(rname, "gproc_%s", name);
  } else {
    sprintf(rname, "gcf_%s", name);
  }
  for (ch = rname + 4; *ch; ch++) {
    switch (*ch) {
    case '.':
      *ch = '_';
      break;
    default:
      break;
    }
  }
  return rname;
}


x86 assembly (clang, -O0):
<cccsp_make_entryname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rdi
add    $0xa,%rdi
call   1040 <smalloc@plt>
mov    %rax,-0x18(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     117b <cccsp_make_entryname+0x4b>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe8f(%rip),%rsi
call   1050 <sprintf@plt>
jmp    118f <cccsp_make_entryname+0x5f>
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe7f(%rip),%rsi
call   1050 <sprintf@plt>
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpb   $0x0,(%rax)
je     11e2 <cccsp_make_entryname+0xb2>
mov    -0x20(%rbp),%rax
mov    (%rax),%al
sub    $0x2e,%al
jne    11c7 <cccsp_make_entryname+0x97>
jmp    11bb <cccsp_make_entryname+0x8b>
mov    -0x20(%rbp),%rax
movb   $0x5f,(%rax)
jmp    11cc <cccsp_make_entryname+0x9c>
jmp    11cc <cccsp_make_entryname+0x9c>
jmp    11d1 <cccsp_make_entryname+0xa1>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    119b <cccsp_make_entryname+0x6b>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cccsp_make_entryname>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbp
call   1030 <strlen@plt>
lea    0xa(%rax),%rdi
call   1040 <smalloc@plt>
mov    %rax,%rbx
test   %r14d,%r14d
lea    0xeb4(%rip),%rax
lea    0xea4(%rip),%rsi
cmove  %rax,%rsi
mov    %rbx,%rdi
mov    %rbp,%rdx
call   1050 <sprintf@plt>
mov    %rbx,%rax
add    $0x4,%rax
jmp    1187 <cccsp_make_entryname+0x57>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movb   $0x5f,(%rax)
add    $0x1,%rax
movzbl (%rax),%ecx
cmp    $0x2e,%cl
je     1180 <cccsp_make_entryname+0x50>
test   %cl,%cl
jne    1183 <cccsp_make_entryname+0x53>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"gproc_%s\00"
@.str.1 = [7 x i8] c"gcf_%s\00"
define i8* @cccsp_make_entryname(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i8*, i8** %3
%8 = call i64 @strlen(i8* %7)
%9 = add nsw i64 %8, 10
%10 = call i64 @smalloc(i64 %9)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %5
%12 = load i32, i32* %4
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %2
%15 = load i8*, i8** %5
%16 = load i8*, i8** %3
%17 = call i32 @sprintf(i8* %15, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %16)
br label %22
18: ; preds = %2
%19 = load i8*, i8** %5
%20 = load i8*, i8** %3
%21 = call i32 @sprintf(i8* %19, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %20)
br label %22
22: ; preds = %18, %14
%23 = load i8*, i8** %5
%24 = getelementptr inbounds i8, i8* %23, i64 4
store i8* %24, i8** %6
br label %25
25: ; preds = %37, %22
%26 = load i8*, i8** %6
%27 = load i8, i8* %26
%28 = icmp ne i8 %27, 0
br i1 %28, label %29, label %40
29: ; preds = %25
%30 = load i8*, i8** %6
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
switch i32 %32, label %35 [
i32 46, label %33
]
33: ; preds = %29
%34 = load i8*, i8** %6
store i8 95, i8* %34
br label %36
35: ; preds = %29
br label %36
36: ; preds = %35, %33
br label %37
37: ; preds = %36
%38 = load i8*, i8** %6
%39 = getelementptr inbounds i8, i8* %38, i32 1
store i8* %39, i8** %6
br label %25
40: ; preds = %25
%41 = load i8*, i8** %5
ret i8* %41
}

LLVM IR (-O2):
@.str = [9 x i8] c"gproc_%s\00"
@.str.1 = [7 x i8] c"gcf_%s\00"
define i8* @cccsp_make_entryname(i8* %0, i32 %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = add nsw i64 %3, 10
%5 = tail call i64 @smalloc(i64 %4)
%6 = inttoptr i64 %5 to i8*
%7 = icmp eq i32 %1, 0
%8 = select i1 %7, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0)
%9 = tail call i32 @sprintf(i8* dereferenceable(1) %6, i8* dereferenceable(1) %8, i8* %0)
%10 = getelementptr inbounds i8, i8* %6, i64 4
br label %11
11: ; preds = %15, %2
%12 = phi i8* [ %10, %2 ], [ %16, %15 ]
%13 = load i8, i8* %12
switch i8 %13, label %15 [
i8 0, label %17
i8 46, label %14
]
14: ; preds = %11
store i8 95, i8* %12
br label %15
15: ; preds = %11, %14
%16 = getelementptr inbounds i8, i8* %12, i64 1
br label %11
17: ; preds = %11
ret i8* %6
}