#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 *__gnu_basename(char *);
scalar_t__ strcmp(char *, char *);
char *__xpg_basename(char *filename) {
  char *r = __gnu_basename(filename);
  char *p;
  if (strcmp(r, "."))
    for (p = r + 1; *p; p++)
      if (*p == '/')
        *p = 0;
  return r;
}


x86 assembly (clang, -O0):
<__xpg_basename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <__gnu_basename@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xebc(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     119e <__xpg_basename+0x7e>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     1199 <__xpg_basename+0x79>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    1183 <__xpg_basename+0x63>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
jmp    1188 <__xpg_basename+0x68>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    115f <__xpg_basename+0x3f>
jmp    119e <__xpg_basename+0x7e>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__xpg_basename>:
push   %rbx
call   1040 <__gnu_basename@plt>
mov    %rax,%rbx
lea    0xed0(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     1163 <__xpg_basename+0x43>
mov    %rbx,%rax
jmp    1153 <__xpg_basename+0x33>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movb   $0x0,(%rax)
add    $0x1,%rax
movzbl (%rax),%ecx
cmp    $0x2f,%cl
je     1150 <__xpg_basename+0x30>
test   %cl,%cl
jne    1153 <__xpg_basename+0x33>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c".\00"
define i8* @__xpg_basename(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
%6 = call i8* @__gnu_basename(i8* %5)
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = call i64 @strcmp(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %29
10: ; preds = %1
%11 = load i8*, i8** %3
%12 = getelementptr inbounds i8, i8* %11, i64 1
store i8* %12, i8** %4
br label %13
13: ; preds = %25, %10
%14 = load i8*, i8** %4
%15 = load i8, i8* %14
%16 = icmp ne i8 %15, 0
br i1 %16, label %17, label %28
17: ; preds = %13
%18 = load i8*, i8** %4
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 47
br i1 %21, label %22, label %24
22: ; preds = %17
%23 = load i8*, i8** %4
store i8 0, i8* %23
br label %24
24: ; preds = %22, %17
br label %25
25: ; preds = %24
%26 = load i8*, i8** %4
%27 = getelementptr inbounds i8, i8* %26, i32 1
store i8* %27, i8** %4
br label %13
28: ; preds = %13
br label %29
29: ; preds = %28, %1
%30 = load i8*, i8** %3
ret i8* %30
}

LLVM IR (-O2):
@.str = [2 x i8] c".\00"
define i8* @__xpg_basename(i8* %0) {
%2 = tail call i8* @__gnu_basename(i8* %0)
%3 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %11, label %5
5: ; preds = %1, %9
%6 = phi i8* [ %7, %9 ], [ %2, %1 ]
%7 = getelementptr inbounds i8, i8* %6, i64 1
%8 = load i8, i8* %7
switch i8 %8, label %9 [
i8 0, label %11
i8 47, label %10
]
9: ; preds = %5, %10
br label %5
10: ; preds = %5
store i8 0, i8* %7
br label %9
11: ; preds = %5, %1
ret i8* %2
}