#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*/ strcpy(char *, char const *);
char *strrchr(char *, char);
const char *isns_dirname(const char *pathname) {
  static char buffer[4096];
  char *s;
  strcpy(buffer, pathname);
  if ((s = strrchr(buffer, '/')) != NULL) {
    *s = '\0';
    return buffer;
  }
  return ".";
}


x86 assembly (clang, -O0):
<isns_dirname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0x2f09(%rip),%rdi
call   1030 <strcpy@plt>
lea    0x2efd(%rip),%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     1172 <isns_dirname+0x52>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
lea    0x2ed7(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    117d <isns_dirname+0x5d>
lea    0xe87(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isns_dirname>:
push   %rbx
mov    %rdi,%rsi
lea    0x2f15(%rip),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1040 <strrchr@plt>
test   %rax,%rax
je     114a <isns_dirname+0x2a>
movb   $0x0,(%rax)
jmp    1151 <isns_dirname+0x31>
lea    0xeaf(%rip),%rbx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@isns_dirname.buffer = internal global [4096 x i8] zeroinitializer
@.str = [2 x i8] c".\00"
define i8* @isns_dirname(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @strcpy(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @isns_dirname.buffer, i64 0, i64 0), i8* %5)
%7 = call i8* @strrchr(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @isns_dirname.buffer, i64 0, i64 0), i8 signext 47)
store i8* %7, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %11
9: ; preds = %1
%10 = load i8*, i8** %4
store i8 0, i8* %10
store i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @isns_dirname.buffer, i64 0, i64 0), i8** %2
br label %12
11: ; preds = %1
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %2
br label %12
12: ; preds = %11, %9
%13 = load i8*, i8** %2
ret i8* %13
}

LLVM IR (-O2):
@isns_dirname.buffer = internal global [4096 x i8] zeroinitializer
@.str = [2 x i8] c".\00"
define i8* @isns_dirname(i8* %0) {
%2 = tail call i32 @strcpy(i8* getelementptr inbounds ([4096 x i8], [4096 x i8]* @isns_dirname.buffer, i64 0, i64 0), i8* %0)
%3 = tail call i8* @strrchr(i8* dereferenceable(1) getelementptr inbounds ([4096 x i8], [4096 x i8]* @isns_dirname.buffer, i64 0, i64 0), i8 signext 47)
%4 = icmp eq i8* %3, null
br i1 %4, label %6, label %5
5: ; preds = %1
store i8 0, i8* %3
br label %6
6: ; preds = %1, %5
%7 = phi i8* [ getelementptr inbounds ([4096 x i8], [4096 x i8]* @isns_dirname.buffer, i64 0, i64 0), %5 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %1 ]
ret i8* %7
}