#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 */
struct message {
  int dummy;
};

/* Variables and functions */
int charcount(char *, char);
int /*<<< orphan*/ name1(struct message *, int);
char *skin(int /*<<< orphan*/);
char *strrchr(char *, char);
char *nameof(struct message *mp, int reptype) {
  char *cp, *cp2;
  cp = skin(name1(mp, reptype));
  if (reptype != 0 || charcount(cp, '!') < 2)
    return (cp);
  cp2 = strrchr(cp, '!');
  cp2--;
  while (cp2 > cp && *cp2 != '!')
    cp2--;
  if (*cp2 == '!')
    return (cp2 + 1);
  return (cp);
}


x86 assembly (clang, -O0):
<nameof>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1060 <name1@plt>
mov    %eax,%edi
call   1030 <skin@plt>
mov    %rax,-0x20(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1187 <nameof+0x47>
mov    -0x20(%rbp),%rdi
mov    $0x21,%esi
call   1040 <charcount@plt>
cmp    $0x2,%eax
jge    1194 <nameof+0x54>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    121f <nameof+0xdf>
mov    -0x20(%rbp),%rdi
mov    $0x21,%esi
call   1050 <strrchr@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rcx
xor    %eax,%eax
cmp    -0x20(%rbp),%rcx
mov    %al,-0x29(%rbp)
jbe    11d5 <nameof+0x95>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x21,%eax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11e5 <nameof+0xa5>
jmp    11f6 <nameof+0xb6>
mov    -0x28(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x28(%rbp)
jmp    11b2 <nameof+0x72>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x21,%eax
jne    1217 <nameof+0xd7>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    121f <nameof+0xdf>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nameof>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
call   1060 <name1@plt>
mov    %eax,%edi
call   1030 <skin@plt>
mov    %rax,%rbx
test   %ebp,%ebp
jne    11a5 <nameof+0x65>
mov    %rbx,%rdi
mov    $0x21,%esi
call   1040 <charcount@plt>
cmp    $0x2,%eax
jl     11a5 <nameof+0x65>
mov    %rbx,%rdi
mov    $0x21,%esi
call   1050 <strrchr@plt>
add    $0xffffffffffffffff,%rax
nopl   0x0(%rax,%rax,1)
movzbl (%rax),%ecx
cmp    %rbx,%rax
jbe    119a <nameof+0x5a>
add    $0xffffffffffffffff,%rax
cmp    $0x21,%cl
jne    1180 <nameof+0x40>
add    $0x2,%rax
mov    %rax,%rbx
jmp    11a5 <nameof+0x65>
add    $0x1,%rax
cmp    $0x21,%cl
cmove  %rax,%rbx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.message = type { i32 }
define i8* @nameof(%struct.message* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca %struct.message*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
store %struct.message* %0, %struct.message** %4
store i32 %1, i32* %5
%8 = load %struct.message*, %struct.message** %4
%9 = load i32, i32* %5
%10 = call i32 @name1(%struct.message* %8, i32 %9)
%11 = call i8* @skin(i32 %10)
store i8* %11, i8** %6
%12 = load i32, i32* %5
%13 = icmp ne i32 %12, 0
br i1 %13, label %18, label %14
14: ; preds = %2
%15 = load i8*, i8** %6
%16 = call i32 @charcount(i8* %15, i8 signext 33)
%17 = icmp slt i32 %16, 2
br i1 %17, label %18, label %20
18: ; preds = %14, %2
%19 = load i8*, i8** %6
store i8* %19, i8** %3
br label %49
20: ; preds = %14
%21 = load i8*, i8** %6
%22 = call i8* @strrchr(i8* %21, i8 signext 33)
store i8* %22, i8** %7
%23 = load i8*, i8** %7
%24 = getelementptr inbounds i8, i8* %23, i32 -1
store i8* %24, i8** %7
br label %25
25: ; preds = %36, %20
%26 = load i8*, i8** %7
%27 = load i8*, i8** %6
%28 = icmp ugt i8* %26, %27
br i1 %28, label %29, label %34
29: ; preds = %25
%30 = load i8*, i8** %7
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 33
br label %34
34: ; preds = %29, %25
%35 = phi i1 [ false, %25 ], [ %33, %29 ]
br i1 %35, label %36, label %39
36: ; preds = %34
%37 = load i8*, i8** %7
%38 = getelementptr inbounds i8, i8* %37, i32 -1
store i8* %38, i8** %7
br label %25
39: ; preds = %34
%40 = load i8*, i8** %7
%41 = load i8, i8* %40
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 33
br i1 %43, label %44, label %47
44: ; preds = %39
%45 = load i8*, i8** %7
%46 = getelementptr inbounds i8, i8* %45, i64 1
store i8* %46, i8** %3
br label %49
47: ; preds = %39
%48 = load i8*, i8** %6
store i8* %48, i8** %3
br label %49
49: ; preds = %47, %44, %18
%50 = load i8*, i8** %3
ret i8* %50
}

LLVM IR (-O2):
%struct.message = type { i32 }
define i8* @nameof(%struct.message* %0, i32 %1) {
%3 = tail call i32 @name1(%struct.message* %0, i32 %1)
%4 = tail call i8* @skin(i32 %3)
%5 = icmp eq i32 %1, 0
br i1 %5, label %6, label %20
6: ; preds = %2
%7 = tail call i32 @charcount(i8* %4, i8 signext 33)
%8 = icmp slt i32 %7, 2
br i1 %8, label %20, label %9
9: ; preds = %6
%10 = tail call i8* @strrchr(i8* dereferenceable(1) %4, i8 signext 33)
br label %11
11: ; preds = %19, %9
%12 = phi i8* [ %10, %9 ], [ %13, %19 ]
%13 = getelementptr inbounds i8, i8* %12, i64 -1
%14 = icmp ugt i8* %13, %4
%15 = load i8, i8* %13
%16 = icmp eq i8 %15, 33
br i1 %14, label %19, label %17
17: ; preds = %11
%18 = select i1 %16, i8* %12, i8* %4
br label %20
19: ; preds = %11
br i1 %16, label %20, label %11
20: ; preds = %19, %17, %2, %6
%21 = phi i8* [ %4, %6 ], [ %4, %2 ], [ %18, %17 ], [ %12, %19 ]
ret i8* %21
}