#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 *strrchr(char const *, char);
const char *sxi_log_appname(const char *argv0) {
  const char *bname;
  if (!argv0)
    return NULL;
  bname = strrchr(argv0, '/');
  if (bname && *bname && bname[1])
    return bname + 1;
  return argv0;
}


x86 assembly (clang, -O0):
<sxi_log_appname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1134 <sxi_log_appname+0x24>
movq   $0x0,-0x8(%rbp)
jmp    118b <sxi_log_appname+0x7b>
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1183 <sxi_log_appname+0x73>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1183 <sxi_log_appname+0x73>
mov    -0x18(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
je     1183 <sxi_log_appname+0x73>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    118b <sxi_log_appname+0x7b>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sxi_log_appname>:
push   %rbx
test   %rdi,%rdi
je     113c <sxi_log_appname+0x2c>
mov    %rdi,%rbx
mov    $0x2f,%esi
call   1030 <strrchr@plt>
test   %rax,%rax
je     113e <sxi_log_appname+0x2e>
cmpb   $0x0,(%rax)
je     113e <sxi_log_appname+0x2e>
cmpb   $0x0,0x1(%rax)
je     113e <sxi_log_appname+0x2e>
add    $0x1,%rax
mov    %rax,%rbx
jmp    113e <sxi_log_appname+0x2e>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i8* @sxi_log_appname(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 %8, label %7
7: ; preds = %1
store i8* null, i8** %2
br label %29
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i8* @strrchr(i8* %9, i8 signext 47)
store i8* %10, i8** %4
%11 = load i8*, i8** %4
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %27
13: ; preds = %8
%14 = load i8*, i8** %4
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %27
18: ; preds = %13
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i64 1
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %18
%25 = load i8*, i8** %4
%26 = getelementptr inbounds i8, i8* %25, i64 1
store i8* %26, i8** %2
br label %29
27: ; preds = %18, %13, %8
%28 = load i8*, i8** %3
store i8* %28, i8** %2
br label %29
29: ; preds = %27, %24, %7
%30 = load i8*, i8** %2
ret i8* %30
}

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