#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 */
int strlen(char const *);
const char *sasutil_extract_name(const char *cmdline) {
  const char *slash;
  if (!cmdline || !*cmdline)
    return NULL;
  slash = cmdline + strlen(cmdline);
  while (cmdline <= slash && (*slash != '/'))
    slash--;
  if (slash >= cmdline)
    return slash + 1;
  return cmdline;
}


x86 assembly (clang, -O0):
<sasutil_extract_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1134 <sasutil_extract_name+0x24>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
jne    1141 <sasutil_extract_name+0x31>
movq   $0x0,-0x8(%rbp)
jmp    11cd <sasutil_extract_name+0xbd>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
cmp    -0x18(%rbp),%rcx
mov    %al,-0x21(%rbp)
ja     1185 <sasutil_extract_name+0x75>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1195 <sasutil_extract_name+0x85>
jmp    11a6 <sasutil_extract_name+0x96>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    1162 <sasutil_extract_name+0x52>
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jb     11c5 <sasutil_extract_name+0xb5>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11cd <sasutil_extract_name+0xbd>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sasutil_extract_name>:
push   %rbx
test   %rdi,%rdi
je     1140 <sasutil_extract_name+0x30>
mov    %rdi,%rbx
cmpb   $0x0,(%rdi)
je     1140 <sasutil_extract_name+0x30>
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
js     1142 <sasutil_extract_name+0x32>
mov    %eax,%eax
add    %rbx,%rax
nop
cmpb   $0x2f,(%rax)
je     1147 <sasutil_extract_name+0x37>
add    $0xffffffffffffffff,%rax
cmp    %rbx,%rax
jae    1130 <sasutil_extract_name+0x20>
jmp    1142 <sasutil_extract_name+0x32>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
ret
add    $0x1,%rax
mov    %rax,%rbx
jmp    1142 <sasutil_extract_name+0x32>

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

LLVM IR (-O2):
define i8* @sasutil_extract_name(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %21, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 0
br i1 %5, label %21, label %6
6: ; preds = %3
%7 = tail call i32 @strlen(i8* %0)
%8 = icmp slt i32 %7, 0
br i1 %8, label %21, label %9
9: ; preds = %6
%10 = zext i32 %7 to i64
%11 = getelementptr inbounds i8, i8* %0, i64 %10
br label %12
12: ; preds = %9, %16
%13 = phi i8* [ %17, %16 ], [ %11, %9 ]
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 47
br i1 %15, label %19, label %16
16: ; preds = %12
%17 = getelementptr inbounds i8, i8* %13, i64 -1
%18 = icmp ult i8* %17, %0
br i1 %18, label %21, label %12
19: ; preds = %12
%20 = getelementptr inbounds i8, i8* %13, i64 1
br label %21
21: ; preds = %16, %6, %19, %1, %3
%22 = phi i8* [ null, %3 ], [ null, %1 ], [ %20, %19 ], [ %0, %6 ], [ %0, %16 ]
ret i8* %22
}