#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*/ assert(int);
scalar_t__ strcmp(int /*<<< orphan*/, char *);
int /*<<< orphan*/ xbasename(char *);
void example__xbasename(void) {
  assert(strcmp(xbasename(""), "") == 0);
  assert(strcmp(xbasename("/"), "") == 0);
  assert(strcmp(xbasename("///"), "") == 0);
  assert(strcmp(xbasename("a"), "a") == 0);
  assert(strcmp(xbasename("a/b"), "b") == 0);
  assert(strcmp(xbasename("a/b/c/def"), "def") == 0);
  assert(strcmp(xbasename("a/b/c/"), "") == 0);
  assert(strcmp(xbasename("a/b/c//"), "") == 0);
}


x86 assembly (clang, -O0):
<example__xbasename>:
push   %rbp
mov    %rsp,%rbp
lea    0xec8(%rip),%rdi
call   1030 <xbasename@plt>
mov    %eax,%edi
lea    0xeba(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    0xe9c(%rip),%rdi
call   1030 <xbasename@plt>
mov    %eax,%edi
lea    0xe8f(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    0xe6f(%rip),%rdi
call   1030 <xbasename@plt>
mov    %eax,%edi
lea    0xe64(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    0xe48(%rip),%rdi
call   1030 <xbasename@plt>
mov    %eax,%edi
lea    0xe3a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    0xe1f(%rip),%rdi
call   1030 <xbasename@plt>
mov    %eax,%edi
lea    0xe13(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    0xdf8(%rip),%rdi
call   1030 <xbasename@plt>
mov    %eax,%edi
lea    0xdf0(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    0xdd7(%rip),%rdi
call   1030 <xbasename@plt>
mov    %eax,%edi
lea    0xdb8(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
lea    0xdb3(%rip),%rdi
call   1030 <xbasename@plt>
mov    %eax,%edi
lea    0xd8d(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<example__xbasename>:
push   %r14
push   %rbx
push   %rax
lea    0xec8(%rip),%r14
mov    %r14,%rdi
call   1030 <xbasename@plt>
mov    %eax,%edi
mov    %r14,%rsi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
lea    0xea0(%rip),%rdi
call   1030 <xbasename@plt>
mov    %eax,%edi
mov    %r14,%rsi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
lea    0xe7a(%rip),%rdi
call   1030 <xbasename@plt>
mov    %eax,%edi
mov    %r14,%rsi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
lea    0xe5a(%rip),%rbx
mov    %rbx,%rdi
call   1030 <xbasename@plt>
mov    %eax,%edi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
lea    0xe35(%rip),%rdi
call   1030 <xbasename@plt>
lea    0xe2b(%rip),%rsi
mov    %eax,%edi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
lea    0xe11(%rip),%rdi
call   1030 <xbasename@plt>
lea    0xe0b(%rip),%rsi
mov    %eax,%edi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
lea    0xdf3(%rip),%rdi
call   1030 <xbasename@plt>
mov    %eax,%edi
mov    %r14,%rsi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
call   1050 <assert@plt>
lea    0xdd6(%rip),%rdi
call   1030 <xbasename@plt>
mov    %eax,%edi
mov    %r14,%rsi
call   1040 <strcmp@plt>
xor    %edi,%edi
test   %rax,%rax
sete   %dil
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <assert@plt>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c"/\00"
@.str.2 = [4 x i8] c"///\00"
@.str.3 = [2 x i8] c"a\00"
@.str.4 = [4 x i8] c"a/b\00"
@.str.5 = [2 x i8] c"b\00"
@.str.6 = [10 x i8] c"a/b/c/def\00"
@.str.7 = [4 x i8] c"def\00"
@.str.8 = [7 x i8] c"a/b/c/\00"
@.str.9 = [8 x i8] c"a/b/c//\00"
define void @example__xbasename() {
%1 = call i32 @xbasename(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%2 = call i64 @strcmp(i32 %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
%4 = zext i1 %3 to i32
%5 = call i32 @assert(i32 %4)
%6 = call i32 @xbasename(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = call i64 @strcmp(i32 %6, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
%9 = zext i1 %8 to i32
%10 = call i32 @assert(i32 %9)
%11 = call i32 @xbasename(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%12 = call i64 @strcmp(i32 %11, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = call i32 @xbasename(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%17 = call i64 @strcmp(i32 %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = call i32 @xbasename(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%22 = call i64 @strcmp(i32 %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = call i32 @xbasename(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%27 = call i64 @strcmp(i32 %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = call i32 @xbasename(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%32 = call i64 @strcmp(i32 %31, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
%34 = zext i1 %33 to i32
%35 = call i32 @assert(i32 %34)
%36 = call i32 @xbasename(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
%37 = call i64 @strcmp(i32 %36, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
%39 = zext i1 %38 to i32
%40 = call i32 @assert(i32 %39)
ret void
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c"/\00"
@.str.2 = [4 x i8] c"///\00"
@.str.3 = [2 x i8] c"a\00"
@.str.4 = [4 x i8] c"a/b\00"
@.str.5 = [2 x i8] c"b\00"
@.str.6 = [10 x i8] c"a/b/c/def\00"
@.str.7 = [4 x i8] c"def\00"
@.str.8 = [7 x i8] c"a/b/c/\00"
@.str.9 = [8 x i8] c"a/b/c//\00"
define void @example__xbasename() {
%1 = tail call i32 @xbasename(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%2 = tail call i64 @strcmp(i32 %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = tail call i32 @xbasename(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i64 @strcmp(i32 %6, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
%9 = zext i1 %8 to i32
%10 = tail call i32 @assert(i32 %9)
%11 = tail call i32 @xbasename(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
%12 = tail call i64 @strcmp(i32 %11, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i64 %12, 0
%14 = zext i1 %13 to i32
%15 = tail call i32 @assert(i32 %14)
%16 = tail call i32 @xbasename(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%17 = tail call i64 @strcmp(i32 %16, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
%19 = zext i1 %18 to i32
%20 = tail call i32 @assert(i32 %19)
%21 = tail call i32 @xbasename(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%22 = tail call i64 @strcmp(i32 %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
%24 = zext i1 %23 to i32
%25 = tail call i32 @assert(i32 %24)
%26 = tail call i32 @xbasename(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%27 = tail call i64 @strcmp(i32 %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
%29 = zext i1 %28 to i32
%30 = tail call i32 @assert(i32 %29)
%31 = tail call i32 @xbasename(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%32 = tail call i64 @strcmp(i32 %31, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
%34 = zext i1 %33 to i32
%35 = tail call i32 @assert(i32 %34)
%36 = tail call i32 @xbasename(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
%37 = tail call i64 @strcmp(i32 %36, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
%39 = zext i1 %38 to i32
%40 = tail call i32 @assert(i32 %39)
ret void
}