#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 /*<<< orphan*/ free(char *);
char *process_text(char *);
char *strdup(char *);
char *strrchr(char *, char);
char *tag_notdir(int argc, char *argv[]) {
  if (argc >= 1) {
    char *s, *filename = process_text(argv[0]);
    s = strrchr(filename, '/');
    s = (s) ? s + 1 : filename;
    s = strdup(s);
    free(filename);
    return s;
  } else
    return 0;
}


x86 assembly (clang, -O0):
<tag_notdir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
cmpl   $0x1,-0xc(%rbp)
jl     11ca <tag_notdir+0x8a>
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1050 <process_text@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1197 <tag_notdir+0x57>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    119f <tag_notdir+0x5f>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <strdup@plt>
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11d2 <tag_notdir+0x92>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tag_notdir>:
test   %edi,%edi
jle    1186 <tag_notdir+0x46>
push   %r14
push   %rbx
push   %rax
mov    (%rsi),%rdi
call   1050 <process_text@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
lea    0x1(%rax),%rdi
test   %rax,%rax
cmove  %rbx,%rdi
call   1060 <strdup@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
xor    %eax,%eax
ret

LLVM IR (-O0):
define i8* @tag_notdir(i32 %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp sge i32 %8, 1
br i1 %9, label %10, label %31
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 0
%13 = load i8*, i8** %12
%14 = call i8* @process_text(i8* %13)
store i8* %14, i8** %7
%15 = load i8*, i8** %7
%16 = call i8* @strrchr(i8* %15, i8 signext 47)
store i8* %16, i8** %6
%17 = load i8*, i8** %6
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %22
19: ; preds = %10
%20 = load i8*, i8** %6
%21 = getelementptr inbounds i8, i8* %20, i64 1
br label %24
22: ; preds = %10
%23 = load i8*, i8** %7
br label %24
24: ; preds = %22, %19
%25 = phi i8* [ %21, %19 ], [ %23, %22 ]
store i8* %25, i8** %6
%26 = load i8*, i8** %6
%27 = call i8* @strdup(i8* %26)
store i8* %27, i8** %6
%28 = load i8*, i8** %7
%29 = call i32 @free(i8* %28)
%30 = load i8*, i8** %6
store i8* %30, i8** %3
br label %32
31: ; preds = %2
store i8* null, i8** %3
br label %32
32: ; preds = %31, %24
%33 = load i8*, i8** %3
ret i8* %33
}

LLVM IR (-O2):
define noalias i8* @tag_notdir(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %13
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i8* @process_text(i8* %5)
%7 = tail call i8* @strrchr(i8* dereferenceable(1) %6, i8 signext 47)
%8 = icmp eq i8* %7, null
%9 = getelementptr inbounds i8, i8* %7, i64 1
%10 = select i1 %8, i8* %6, i8* %9
%11 = tail call i8* @strdup(i8* %10)
%12 = tail call i32 @free(i8* %6)
br label %13
13: ; preds = %2, %4
%14 = phi i8* [ %11, %4 ], [ null, %2 ]
ret i8* %14
}