#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 */
size_t get_length_without_asterisks_brackets_or_parenthesis(char *);
int is_function_pointer(char *);
char *malloc(size_t const);
char *strip_asterisks_and_brackets(char *variable_name) {
  const size_t len =
      get_length_without_asterisks_brackets_or_parenthesis(variable_name);
  size_t pos = 0;
  const int function_pointer = is_function_pointer(variable_name);
  size_t dst_pos = 0;
  char *buf = malloc(len + 1);
  if (NULL == buf) {
    return NULL;
  }
  if (function_pointer) {
    variable_name++;
  }
  while (dst_pos < len) {
    if ('*' == variable_name[pos]) {
      pos++;
      continue;
    }
    if ((1 == function_pointer) && (')' == variable_name[pos])) {
      break;
    }
    buf[dst_pos++] = variable_name[pos++];
  }
  buf[dst_pos] = '\0';
  return buf;
}


x86 assembly (clang, -O0):
<strip_asterisks_and_brackets>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <get_length_without_asterisks_brackets_or_parenthesis@plt>
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <is_function_pointer@plt>
mov    %eax,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
call   1040 <malloc@plt>
mov    %rax,-0x38(%rbp)
xor    %eax,%eax
cmp    -0x38(%rbp),%rax
jne    118f <strip_asterisks_and_brackets+0x5f>
movq   $0x0,-0x8(%rbp)
jmp    1253 <strip_asterisks_and_brackets+0x123>
cmpl   $0x0,-0x24(%rbp)
je     11a5 <strip_asterisks_and_brackets+0x75>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    11aa <strip_asterisks_and_brackets+0x7a>
mov    -0x30(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    123f <strip_asterisks_and_brackets+0x10f>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
mov    $0x2a,%eax
cmp    %ecx,%eax
jne    11e2 <strip_asterisks_and_brackets+0xb2>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    11aa <strip_asterisks_and_brackets+0x7a>
mov    $0x1,%eax
cmp    -0x24(%rbp),%eax
jne    120e <strip_asterisks_and_brackets+0xde>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
mov    $0x29,%eax
cmp    %ecx,%eax
jne    120e <strip_asterisks_and_brackets+0xde>
jmp    123f <strip_asterisks_and_brackets+0x10f>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
mov    %rcx,%rdx
add    $0x1,%rdx
mov    %rdx,-0x20(%rbp)
mov    (%rax,%rcx,1),%dl
mov    -0x38(%rbp),%rax
mov    -0x30(%rbp),%rcx
mov    %rcx,%rsi
add    $0x1,%rsi
mov    %rsi,-0x30(%rbp)
mov    %dl,(%rax,%rcx,1)
jmp    11aa <strip_asterisks_and_brackets+0x7a>
mov    -0x38(%rbp),%rax
mov    -0x30(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strip_asterisks_and_brackets>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbp
call   1050 <get_length_without_asterisks_brackets_or_parenthesis@plt>
mov    %rax,%r14
mov    %rbp,%rdi
call   1030 <is_function_pointer@plt>
mov    %eax,%r15d
lea    0x1(%r14),%rdi
call   1040 <malloc@plt>
test   %rax,%rax
je     11c5 <strip_asterisks_and_brackets+0x95>
cmp    $0x1,%r15d
sbb    $0xffffffffffffffff,%rbp
test   %r14,%r14
je     11bf <strip_asterisks_and_brackets+0x8f>
mov    $0x1,%cl
xor    %esi,%esi
xor    %edx,%edx
add    $0x1,%rdx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movzbl -0x1(%rbp,%rdx,1),%ebx
cmp    $0x2a,%bl
jne    11a0 <strip_asterisks_and_brackets+0x70>
add    $0x1,%rdx
test   $0x1,%cl
jne    1180 <strip_asterisks_and_brackets+0x50>
jmp    11c1 <strip_asterisks_and_brackets+0x91>
cs nopw 0x0(%rax,%rax,1)
nop
cmp    $0x1,%r15d
jne    11ab <strip_asterisks_and_brackets+0x7b>
cmp    $0x29,%bl
je     11c1 <strip_asterisks_and_brackets+0x91>
mov    %bl,(%rax,%rsi,1)
add    $0x1,%rsi
cmp    %r14,%rsi
setb   %cl
jne    116e <strip_asterisks_and_brackets+0x3e>
mov    %r14,%rsi
jmp    11c1 <strip_asterisks_and_brackets+0x91>
xor    %esi,%esi
movb   $0x0,(%rax,%rsi,1)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @strip_asterisks_and_brackets(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32
%7 = alloca i64
%8 = alloca i8*
store i8* %0, i8** %3
%9 = load i8*, i8** %3
%10 = call i64 @get_length_without_asterisks_brackets_or_parenthesis(i8* %9)
store i64 %10, i64* %4
store i64 0, i64* %5
%11 = load i8*, i8** %3
%12 = call i32 @is_function_pointer(i8* %11)
store i32 %12, i32* %6
store i64 0, i64* %7
%13 = load i64, i64* %4
%14 = add i64 %13, 1
%15 = call i8* @malloc(i64 %14)
store i8* %15, i8** %8
%16 = load i8*, i8** %8
%17 = icmp eq i8* null, %16
br i1 %17, label %18, label %19
18: ; preds = %1
store i8* null, i8** %2
br label %66
19: ; preds = %1
%20 = load i32, i32* %6
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %3
br label %25
25: ; preds = %22, %19
br label %26
26: ; preds = %51, %37, %25
%27 = load i64, i64* %7
%28 = load i64, i64* %4
%29 = icmp ult i64 %27, %28
br i1 %29, label %30, label %61
30: ; preds = %26
%31 = load i8*, i8** %3
%32 = load i64, i64* %5
%33 = getelementptr inbounds i8, i8* %31, i64 %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 42, %35
br i1 %36, label %37, label %40
37: ; preds = %30
%38 = load i64, i64* %5
%39 = add i64 %38, 1
store i64 %39, i64* %5
br label %26
40: ; preds = %30
%41 = load i32, i32* %6
%42 = icmp eq i32 1, %41
br i1 %42, label %43, label %51
43: ; preds = %40
%44 = load i8*, i8** %3
%45 = load i64, i64* %5
%46 = getelementptr inbounds i8, i8* %44, i64 %45
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = icmp eq i32 41, %48
br i1 %49, label %50, label %51
50: ; preds = %43
br label %61
51: ; preds = %43, %40
%52 = load i8*, i8** %3
%53 = load i64, i64* %5
%54 = add i64 %53, 1
store i64 %54, i64* %5
%55 = getelementptr inbounds i8, i8* %52, i64 %53
%56 = load i8, i8* %55
%57 = load i8*, i8** %8
%58 = load i64, i64* %7
%59 = add i64 %58, 1
store i64 %59, i64* %7
%60 = getelementptr inbounds i8, i8* %57, i64 %58
store i8 %56, i8* %60
br label %26
61: ; preds = %50, %26
%62 = load i8*, i8** %8
%63 = load i64, i64* %7
%64 = getelementptr inbounds i8, i8* %62, i64 %63
store i8 0, i8* %64
%65 = load i8*, i8** %8
store i8* %65, i8** %2
br label %66
66: ; preds = %61, %18
%67 = load i8*, i8** %2
ret i8* %67
}

LLVM IR (-O2):
define noalias i8* @strip_asterisks_and_brackets(i8* %0) {
%2 = tail call i64 @get_length_without_asterisks_brackets_or_parenthesis(i8* %0)
%3 = tail call i32 @is_function_pointer(i8* %0)
%4 = add i64 %2, 1
%5 = tail call i8* @malloc(i64 %4)
%6 = icmp eq i8* %5, null
br i1 %6, label %37, label %7
7: ; preds = %1
%8 = icmp ne i32 %3, 0
%9 = zext i1 %8 to i64
%10 = getelementptr i8, i8* %0, i64 %9
%11 = icmp eq i64 %2, 0
br i1 %11, label %34, label %12
12: ; preds = %7
%13 = icmp eq i32 %3, 1
br label %14
14: ; preds = %12, %28
%15 = phi i1 [ true, %12 ], [ %32, %28 ]
%16 = phi i64 [ 0, %12 ], [ %30, %28 ]
%17 = phi i64 [ 0, %12 ], [ %29, %28 ]
br label %18
18: ; preds = %14, %23
%19 = phi i64 [ %17, %14 ], [ %24, %23 ]
%20 = getelementptr inbounds i8, i8* %10, i64 %19
%21 = load i8, i8* %20
%22 = icmp eq i8 %21, 42
br i1 %22, label %23, label %25
23: ; preds = %18
%24 = add i64 %19, 1
br i1 %15, label %18, label %34
25: ; preds = %18
%26 = icmp eq i8 %21, 41
%27 = select i1 %13, i1 %26, i1 false
br i1 %27, label %34, label %28
28: ; preds = %25
%29 = add i64 %19, 1
%30 = add nuw i64 %16, 1
%31 = getelementptr inbounds i8, i8* %5, i64 %16
store i8 %21, i8* %31
%32 = icmp ult i64 %30, %2
%33 = icmp eq i64 %30, %2
br i1 %33, label %34, label %14
34: ; preds = %25, %28, %23, %7
%35 = phi i64 [ 0, %7 ], [ %16, %23 ], [ %2, %28 ], [ %16, %25 ]
%36 = getelementptr inbounds i8, i8* %5, i64 %35
store i8 0, i8* %36
br label %37
37: ; preds = %1, %34
ret i8* %5
}