#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 MAXPATHLEN;
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
void filetail(char *tail) {
  char *cptr;
  char temp[MAXPATHLEN];
  cptr = tail + strlen(tail);
  while ((cptr != tail) && (*cptr != '/'))
    cptr--;
  if (cptr != tail) {
    cptr++;
    strcpy(temp, cptr);
    strcpy(tail, temp);
  }
}


x86 assembly (clang, -O0):
<filetail>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2eb5(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
cmp    -0x8(%rbp),%rcx
mov    %al,-0x31(%rbp)
je     119c <filetail+0x7c>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2f,%eax
setne  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    11ac <filetail+0x8c>
jmp    11bd <filetail+0x9d>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
jmp    1179 <filetail+0x59>
mov    -0x10(%rbp),%rax
cmp    -0x8(%rbp),%rax
je     11f1 <filetail+0xd1>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x30(%rbp),%rsi
mov    -0x8(%rbp),%rdi
call   1030 <strcpy@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filetail>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    0x2eb7(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r14
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
call   1040 <strlen@plt>
test   %eax,%eax
je     1179 <filetail+0x59>
cltq
nop
cmpb   $0x2f,(%rbx,%rax,1)
je     115e <filetail+0x3e>
add    $0xffffffffffffffff,%rax
jne    1150 <filetail+0x30>
jmp    1179 <filetail+0x59>
lea    (%rbx,%rax,1),%rsi
add    $0x1,%rsi
mov    %r14,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@MAXPATHLEN = global i32 0
define void @filetail(i8* %0) {
%2 = load i32, i32* @MAXPATHLEN
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = tail call i32 @strlen(i8* %0)
%6 = icmp eq i32 %5, 0
br i1 %6, label %21, label %7
7: ; preds = %1
%8 = sext i32 %5 to i64
%9 = getelementptr inbounds i8, i8* %0, i64 %8
br label %10
10: ; preds = %7, %14
%11 = phi i8* [ %15, %14 ], [ %9, %7 ]
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 47
br i1 %13, label %17, label %14
14: ; preds = %10
%15 = getelementptr inbounds i8, i8* %11, i64 -1
%16 = icmp eq i8* %15, %0
br i1 %16, label %21, label %10
17: ; preds = %10
%18 = getelementptr inbounds i8, i8* %11, i64 1
%19 = call i32 @strcpy(i8* %4, i8* %18)
%20 = call i32 @strcpy(i8* %0, i8* %4)
br label %21
21: ; preds = %14, %1, %17
ret void
}