#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*/ memcmp(char const *, char *, int);
char *strchr(char const *, char);
int /*<<< orphan*/ strcmp(char const *, char *);
const char *strip_antisocial_prefixes(const char *file_name) {
  while (*file_name == '/' || !memcmp(file_name, "./", 2) ||
         !memcmp(file_name, "../", 3)) {
    file_name = strchr(file_name, '/') + 1;
  }
  return *file_name == '\0' || !strcmp(file_name, "..") ? "." : file_name;
}


x86 assembly (clang, -O0):
<strip_antisocial_prefixes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x2f,%ecx
mov    %al,-0x9(%rbp)
je     1196 <strip_antisocial_prefixes+0x66>
mov    -0x8(%rbp),%rdi
lea    0xea5(%rip),%rsi
mov    $0x2,%edx
call   1040 <memcmp@plt>
mov    %eax,%ecx
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x9(%rbp)
je     1196 <strip_antisocial_prefixes+0x66>
mov    -0x8(%rbp),%rdi
lea    0xe7f(%rip),%rsi
mov    $0x3,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    11a6 <strip_antisocial_prefixes+0x76>
jmp    11c1 <strip_antisocial_prefixes+0x91>
mov    -0x8(%rbp),%rdi
mov    $0x2f,%esi
call   1030 <strchr@plt>
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    113c <strip_antisocial_prefixes+0xc>
mov    -0x8(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11ea <strip_antisocial_prefixes+0xba>
mov    -0x8(%rbp),%rdi
lea    0xe28(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11fa <strip_antisocial_prefixes+0xca>
lea    0xe14(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1202 <strip_antisocial_prefixes+0xd2>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<strip_antisocial_prefixes>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
lea    0xec2(%rip),%r14
lea    0xeba(%rip),%r15
jmp    1164 <strip_antisocial_prefixes+0x34>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1030 <strchr@plt>
mov    %rax,%rbx
add    $0x1,%rbx
cmpb   $0x2f,(%rbx)
je     1150 <strip_antisocial_prefixes+0x20>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x2,%edx
call   1040 <memcmp@plt>
test   %eax,%eax
je     1150 <strip_antisocial_prefixes+0x20>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x3,%edx
call   1040 <memcmp@plt>
test   %eax,%eax
je     1150 <strip_antisocial_prefixes+0x20>
cmpb   $0x0,(%rbx)
je     11b4 <strip_antisocial_prefixes+0x84>
lea    0xe67(%rip),%rsi
mov    %rbx,%rdi
call   1050 <strcmp@plt>
test   %eax,%eax
lea    0xe57(%rip),%rax
cmovne %rbx,%rax
jmp    11bb <strip_antisocial_prefixes+0x8b>
lea    0xe4a(%rip),%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"./\00"
@.str.1 = [4 x i8] c"../\00"
@.str.2 = [3 x i8] c"..\00"
@.str.3 = [2 x i8] c".\00"
define i8* @strip_antisocial_prefixes(i8* %0) {
br label %2
2: ; preds = %12, %1
%3 = phi i8* [ %0, %1 ], [ %14, %12 ]
%4 = load i8, i8* %3
%5 = icmp eq i8 %4, 47
br i1 %5, label %12, label %6
6: ; preds = %2
%7 = tail call i32 @memcmp(i8* %3, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%8 = icmp eq i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = tail call i32 @memcmp(i8* %3, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 3)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %2, %6, %9
%13 = tail call i8* @strchr(i8* %3, i8 signext 47)
%14 = getelementptr inbounds i8, i8* %13, i64 1
br label %2
15: ; preds = %9
%16 = load i8, i8* %3
%17 = icmp eq i8 %16, 0
br i1 %17, label %22, label %18
18: ; preds = %15
%19 = tail call i32 @strcmp(i8* %3, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%20 = icmp eq i32 %19, 0
%21 = select i1 %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* %3
br label %22
22: ; preds = %18, %15
%23 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), %15 ], [ %21, %18 ]
ret i8* %23
}