#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__ isalpha(char const);
scalar_t__ isdigit(char const);
char *strrchr(char const *, char);
void get_state_space_name(const char *in, char *out) {
  const char *str = strrchr(in, '/');
  if (*str == 0)
    str = in;
  str++;
  while (*str && (isalpha(*str) || isdigit(*str) || *str == '_')) {
    *out++ = *str++;
  }
  *out = 0;
}


x86 assembly (clang, -O0):
<get_state_space_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    116a <get_state_space_name+0x3a>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x19(%rbp)
je     11dd <get_state_space_name+0xad>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1050 <isalpha@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x1a(%rbp)
jne    11d7 <get_state_space_name+0xa7>
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
mov    %rax,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x1a(%rbp)
jne    11d7 <get_state_space_name+0xa7>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
sete   %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    11ed <get_state_space_name+0xbd>
jmp    1214 <get_state_space_name+0xe4>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
mov    (%rax),%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
jmp    1176 <get_state_space_name+0x46>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_state_space_name>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    $0x2f,%esi
call   1040 <strrchr@plt>
mov    %rax,%rbx
cmpb   $0x0,(%rax)
cmove  %r15,%rbx
mov    0x1(%rbx),%al
test   %al,%al
je     1195 <get_state_space_name+0x65>
add    $0x1,%rbx
jmp    1176 <get_state_space_name+0x46>
nopl   0x0(%rax)
movzbl (%rbx),%eax
mov    %al,(%r14)
add    $0x1,%r14
movzbl 0x1(%rbx),%eax
add    $0x1,%rbx
test   %al,%al
je     1195 <get_state_space_name+0x65>
movsbl %al,%edi
call   1050 <isalpha@plt>
test   %rax,%rax
jne    1160 <get_state_space_name+0x30>
movsbl (%rbx),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    1160 <get_state_space_name+0x30>
cmpb   $0x5f,(%rbx)
je     1160 <get_state_space_name+0x30>
movb   $0x0,(%r14)
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define void @get_state_space_name(i8* %0, i8* nocapture writeonly %1) {
%3 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 47)
%4 = load i8, i8* %3
%5 = icmp eq i8 %4, 0
%6 = select i1 %5, i8* %0, i8* %3
%7 = getelementptr inbounds i8, i8* %6, i64 1
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
br i1 %9, label %29, label %10
10: ; preds = %2, %23
%11 = phi i8 [ %27, %23 ], [ %8, %2 ]
%12 = phi i8* [ %26, %23 ], [ %7, %2 ]
%13 = phi i8* [ %25, %23 ], [ %1, %2 ]
%14 = tail call i64 @isalpha(i8 signext %11)
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %10
%17 = load i8, i8* %12
%18 = tail call i64 @isdigit(i8 signext %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = load i8, i8* %12
%22 = icmp eq i8 %21, 95
br i1 %22, label %23, label %29
23: ; preds = %10, %16, %20
%24 = load i8, i8* %12
%25 = getelementptr inbounds i8, i8* %13, i64 1
store i8 %24, i8* %13
%26 = getelementptr inbounds i8, i8* %12, i64 1
%27 = load i8, i8* %26
%28 = icmp eq i8 %27, 0
br i1 %28, label %29, label %10
29: ; preds = %20, %23, %2
%30 = phi i8* [ %1, %2 ], [ %25, %23 ], [ %13, %20 ]
store i8 0, i8* %30
ret void
}