#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 *);
char *base_name(char *path) {
  char *p, *b;
  static char base[256];
  b = path;
  for (p = path; *p; ++p) {
    if (*p == '/')
      b = p + 1;
  }
  strcpy(base, b);
  for (p = base; *p; ++p) {
    if (*p == '.') {
      *p = 0;
      break;
    }
  }
  return base;
}


x86 assembly (clang, -O0):
<base_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     116b <base_name+0x5b>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
jne    1155 <base_name+0x45>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    115a <base_name+0x4a>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    112c <base_name+0x1c>
mov    -0x18(%rbp),%rsi
lea    0x2eca(%rip),%rdi
call   1030 <strcpy@plt>
lea    0x2ebe(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     11c5 <base_name+0xb5>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    11af <base_name+0x9f>
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
jmp    11c5 <base_name+0xb5>
jmp    11b4 <base_name+0xa4>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1186 <base_name+0x76>
lea    0x2e74(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<base_name>:
push   %rbx
mov    %rdi,%rsi
lea    0x1(%rdi),%rax
jmp    1127 <base_name+0x17>
nopw   0x0(%rax,%rax,1)
mov    %rax,%rsi
add    $0x1,%rax
movzbl -0x1(%rax),%ecx
cmp    $0x2f,%cl
je     1120 <base_name+0x10>
test   %cl,%cl
jne    1123 <base_name+0x13>
lea    0x2f05(%rip),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movzbl (%rbx),%eax
test   %al,%al
je     1164 <base_name+0x54>
cmp    $0x2e,%al
je     1161 <base_name+0x51>
add    $0x1,%rbx
jmp    1150 <base_name+0x40>
movb   $0x0,(%rbx)
lea    0x2ed5(%rip),%rax
pop    %rbx
ret

LLVM IR (-O0):
@base_name.base = internal global [256 x i8] zeroinitializer
define i8* @base_name(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %2
%5 = load i8*, i8** %2
store i8* %5, i8** %4
%6 = load i8*, i8** %2
store i8* %6, i8** %3
br label %7
7: ; preds = %20, %1
%8 = load i8*, i8** %3
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %23
11: ; preds = %7
%12 = load i8*, i8** %3
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 47
br i1 %15, label %16, label %19
16: ; preds = %11
%17 = load i8*, i8** %3
%18 = getelementptr inbounds i8, i8* %17, i64 1
store i8* %18, i8** %4
br label %19
19: ; preds = %16, %11
br label %20
20: ; preds = %19
%21 = load i8*, i8** %3
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %3
br label %7
23: ; preds = %7
%24 = load i8*, i8** %4
%25 = call i32 @strcpy(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @base_name.base, i64 0, i64 0), i8* %24)
store i8* getelementptr inbounds ([256 x i8], [256 x i8]* @base_name.base, i64 0, i64 0), i8** %3
br label %26
26: ; preds = %38, %23
%27 = load i8*, i8** %3
%28 = load i8, i8* %27
%29 = icmp ne i8 %28, 0
br i1 %29, label %30, label %41
30: ; preds = %26
%31 = load i8*, i8** %3
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 46
br i1 %34, label %35, label %37
35: ; preds = %30
%36 = load i8*, i8** %3
store i8 0, i8* %36
br label %41
37: ; preds = %30
br label %38
38: ; preds = %37
%39 = load i8*, i8** %3
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %3
br label %26
41: ; preds = %35, %26
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @base_name.base, i64 0, i64 0)
}

LLVM IR (-O2):
@base_name.base = internal global [256 x i8] zeroinitializer
define i8* @base_name(i8* %0) {
br label %2
2: ; preds = %8, %1
%3 = phi i8* [ %0, %1 ], [ %10, %8 ]
%4 = phi i8* [ %0, %1 ], [ %9, %8 ]
%5 = load i8, i8* %3
switch i8 %5, label %8 [
i8 0, label %11
i8 47, label %6
]
6: ; preds = %2
%7 = getelementptr inbounds i8, i8* %3, i64 1
br label %8
8: ; preds = %2, %6
%9 = phi i8* [ %7, %6 ], [ %4, %2 ]
%10 = getelementptr inbounds i8, i8* %3, i64 1
br label %2
11: ; preds = %2
%12 = tail call i32 @strcpy(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @base_name.base, i64 0, i64 0), i8* %4)
br label %13
13: ; preds = %17, %11
%14 = phi i8* [ getelementptr inbounds ([256 x i8], [256 x i8]* @base_name.base, i64 0, i64 0), %11 ], [ %18, %17 ]
%15 = load i8, i8* %14
switch i8 %15, label %17 [
i8 0, label %19
i8 46, label %16
]
16: ; preds = %13
store i8 0, i8* %14
br label %19
17: ; preds = %13
%18 = getelementptr inbounds i8, i8* %14, i64 1
br label %13
19: ; preds = %13, %16
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @base_name.base, i64 0, i64 0)
}