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


x86 assembly (clang, -O0):
<tag_suffix>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
cmpl   $0x1,-0xc(%rbp)
jl     11e7 <tag_suffix+0xa7>
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_suffix+0x57>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x30(%rbp)
jmp    119f <tag_suffix+0x5f>
mov    -0x28(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    $0x2e,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11d1 <tag_suffix+0x91>
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    11ef <tag_suffix+0xaf>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tag_suffix>:
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
jle    1187 <tag_suffix+0x47>
mov    (%rsi),%rdi
call   1050 <process_text@plt>
mov    %rax,%r14
mov    %rax,%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
lea    0x1(%rax),%rdi
test   %rax,%rax
cmove  %r14,%rdi
mov    $0x2e,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
je     118b <tag_suffix+0x4b>
mov    %rax,%rdi
call   1060 <strdup@plt>
mov    %rax,%rbx
jmp    118d <tag_suffix+0x4d>
xor    %ebx,%ebx
jmp    1195 <tag_suffix+0x55>
xor    %ebx,%ebx
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @tag_suffix(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 %37
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* @strrchr(i8* %26, i8 signext 46)
store i8* %27, i8** %6
%28 = load i8*, i8** %6
%29 = icmp ne i8* %28, null
br i1 %29, label %30, label %33
30: ; preds = %24
%31 = load i8*, i8** %6
%32 = call i8* @strdup(i8* %31)
store i8* %32, i8** %6
br label %33
33: ; preds = %30, %24
%34 = load i8*, i8** %7
%35 = call i32 @free(i8* %34)
%36 = load i8*, i8** %6
store i8* %36, i8** %3
br label %38
37: ; preds = %2
store i8* null, i8** %3
br label %38
38: ; preds = %37, %33
%39 = load i8*, i8** %3
ret i8* %39
}

LLVM IR (-O2):
define noalias i8* @tag_suffix(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 0
br i1 %3, label %4, label %18
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* @strrchr(i8* dereferenceable(1) %10, i8 signext 46)
%12 = icmp eq i8* %11, null
br i1 %12, label %15, label %13
13: ; preds = %4
%14 = tail call i8* @strdup(i8* %11)
br label %15
15: ; preds = %13, %4
%16 = phi i8* [ %14, %13 ], [ null, %4 ]
%17 = tail call i32 @free(i8* %6)
br label %18
18: ; preds = %2, %15
%19 = phi i8* [ %16, %15 ], [ null, %2 ]
ret i8* %19
}