#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 */
char *strchr(char const *, char);
size_t strlen(char const *);
const char *get_method_name(const char *pretty_function, size_t *length) {
  const char *pbrace = strchr(pretty_function, '(');
  if (pbrace == NULL) {
    *length = strlen(pretty_function);
    return pretty_function;
  }
  const char *pcls = pbrace;
  while (pcls >= pretty_function && *pcls != ' ') {
    --pcls;
  }
  ++pcls;
  *length = pbrace - pcls;
  return pcls;
}


x86 assembly (clang, -O0):
<get_method_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x28,%esi
call   1040 <strchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    116d <get_method_name+0x4d>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11df <get_method_name+0xbf>
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rcx
xor    %eax,%eax
cmp    -0x10(%rbp),%rcx
mov    %al,-0x29(%rbp)
jb     1198 <get_method_name+0x78>
mov    -0x28(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x20,%eax
setne  %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
test   $0x1,%al
jne    11a8 <get_method_name+0x88>
jmp    11b9 <get_method_name+0x99>
mov    -0x28(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x28(%rbp)
jmp    1175 <get_method_name+0x55>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%rax
sub    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_method_name>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x28,%esi
call   1040 <strchr@plt>
test   %rax,%rax
je     116a <get_method_name+0x4a>
mov    %rax,%rcx
cmp    %rbx,%rax
jb     115e <get_method_name+0x3e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmpb   $0x20,(%rcx)
je     115e <get_method_name+0x3e>
add    $0xffffffffffffffff,%rcx
cmp    %rbx,%rcx
jae    1150 <get_method_name+0x30>
add    $0x1,%rcx
sub    %rcx,%rax
mov    %rcx,%rbx
jmp    1172 <get_method_name+0x52>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rax,(%r14)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @get_method_name(i8* %0, i64* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i64*
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %4
store i64* %1, i64** %5
%8 = load i8*, i8** %4
%9 = call i8* @strchr(i8* %8, i8 signext 40)
store i8* %9, i8** %6
%10 = load i8*, i8** %6
%11 = icmp eq i8* %10, null
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i8*, i8** %4
%14 = call i64 @strlen(i8* %13)
%15 = load i64*, i64** %5
store i64 %14, i64* %15
%16 = load i8*, i8** %4
store i8* %16, i8** %3
br label %43
17: ; preds = %2
%18 = load i8*, i8** %6
store i8* %18, i8** %7
br label %19
19: ; preds = %30, %17
%20 = load i8*, i8** %7
%21 = load i8*, i8** %4
%22 = icmp uge i8* %20, %21
br i1 %22, label %23, label %28
23: ; preds = %19
%24 = load i8*, i8** %7
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 32
br label %28
28: ; preds = %23, %19
%29 = phi i1 [ false, %19 ], [ %27, %23 ]
br i1 %29, label %30, label %33
30: ; preds = %28
%31 = load i8*, i8** %7
%32 = getelementptr inbounds i8, i8* %31, i32 -1
store i8* %32, i8** %7
br label %19
33: ; preds = %28
%34 = load i8*, i8** %7
%35 = getelementptr inbounds i8, i8* %34, i32 1
store i8* %35, i8** %7
%36 = load i8*, i8** %6
%37 = load i8*, i8** %7
%38 = ptrtoint i8* %36 to i64
%39 = ptrtoint i8* %37 to i64
%40 = sub i64 %38, %39
%41 = load i64*, i64** %5
store i64 %40, i64* %41
%42 = load i8*, i8** %7
store i8* %42, i8** %3
br label %43
43: ; preds = %33, %12
%44 = load i8*, i8** %3
ret i8* %44
}

LLVM IR (-O2):
define i8* @get_method_name(i8* %0, i64* nocapture writeonly %1) {
%3 = tail call i8* @strchr(i8* dereferenceable(1) %0, i8 signext 40)
%4 = icmp eq i8* %3, null
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = icmp ult i8* %3, %0
br i1 %6, label %16, label %9
7: ; preds = %2
%8 = tail call i64 @strlen(i8* dereferenceable(1) %0)
br label %22
9: ; preds = %5, %13
%10 = phi i8* [ %14, %13 ], [ %3, %5 ]
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 32
br i1 %12, label %16, label %13
13: ; preds = %9
%14 = getelementptr inbounds i8, i8* %10, i64 -1
%15 = icmp ult i8* %14, %0
br i1 %15, label %16, label %9
16: ; preds = %9, %13, %5
%17 = phi i8* [ %3, %5 ], [ %14, %13 ], [ %10, %9 ]
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = ptrtoint i8* %3 to i64
%20 = ptrtoint i8* %18 to i64
%21 = sub i64 %19, %20
br label %22
22: ; preds = %16, %7
%23 = phi i64 [ %21, %16 ], [ %8, %7 ]
%24 = phi i8* [ %18, %16 ], [ %0, %7 ]
store i64 %23, i64* %1
ret i8* %24
}