#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*/ printf(char *, char const *);
char *rindex(char const *, char);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strlcpy(char *, char const *, int);
int fn2cn(char *out, const char *in, int outsz) {
  char *p;
  p = rindex(in, '/');
  if (p)
    in = p + 1;
  p = rindex(in, '\\');
  if (p)
    in = p + 1;
  p = rindex(in, ':');
  if (p)
    in = p + 1;
  strlcpy(out, in, outsz);
  out[outsz - 1] = '\0';
  p = rindex(out, '.');
  if ((p != 0) && (0 == strcmp(p, ".pc"))) {
    *p = '\0';
    return 0;
  }
  printf("input file (%s) has no '.pc' extension, skip, ", in);
  return 1;
}


x86 assembly (clang, -O0):
<fn2cn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x2f,%esi
call   1060 <rindex@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     117c <fn2cn+0x3c>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x5c,%esi
call   1060 <rindex@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11a5 <fn2cn+0x65>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x3a,%esi
call   1060 <rindex@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11ce <fn2cn+0x8e>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1050 <strlcpy@plt>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1060 <rindex@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     123d <fn2cn+0xfd>
mov    -0x28(%rbp),%rdi
lea    0xde9(%rip),%rsi
call   1040 <strcmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    %rcx,%rax
jne    123d <fn2cn+0xfd>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    1254 <fn2cn+0x114>
mov    -0x18(%rbp),%rsi
lea    0xdbc(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fn2cn>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%rbp
mov    %rdi,%r15
mov    %rsi,%rdi
mov    $0x2f,%esi
call   1060 <rindex@plt>
lea    0x1(%rax),%rbx
test   %rax,%rax
cmove  %rbp,%rbx
mov    %rbx,%rdi
mov    $0x5c,%esi
call   1060 <rindex@plt>
lea    0x1(%rax),%rbp
test   %rax,%rax
cmove  %rbx,%rbp
mov    %rbp,%rdi
mov    $0x3a,%esi
call   1060 <rindex@plt>
lea    0x1(%rax),%rbx
test   %rax,%rax
cmove  %rbp,%rbx
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1050 <strlcpy@plt>
movslq %r14d,%rax
movb   $0x0,-0x1(%rax,%r15,1)
mov    %r15,%rdi
mov    $0x2e,%esi
call   1060 <rindex@plt>
test   %rax,%rax
je     11d8 <fn2cn+0x98>
mov    %rax,%rbp
lea    0xe35(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11ee <fn2cn+0xae>
lea    0xe25(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
mov    $0x1,%eax
jmp    11f4 <fn2cn+0xb4>
movb   $0x0,0x0(%rbp)
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c".pc\00"
@.str.1 = [47 x i8] c"input file (%s) has no '.pc' extension, skip, \00"
define i32 @fn2cn(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%9 = load i8*, i8** %6
%10 = call i8* @rindex(i8* %9, i8 signext 47)
store i8* %10, i8** %8
%11 = load i8*, i8** %8
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %16
13: ; preds = %3
%14 = load i8*, i8** %8
%15 = getelementptr inbounds i8, i8* %14, i64 1
store i8* %15, i8** %6
br label %16
16: ; preds = %13, %3
%17 = load i8*, i8** %6
%18 = call i8* @rindex(i8* %17, i8 signext 92)
store i8* %18, i8** %8
%19 = load i8*, i8** %8
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %24
21: ; preds = %16
%22 = load i8*, i8** %8
%23 = getelementptr inbounds i8, i8* %22, i64 1
store i8* %23, i8** %6
br label %24
24: ; preds = %21, %16
%25 = load i8*, i8** %6
%26 = call i8* @rindex(i8* %25, i8 signext 58)
store i8* %26, i8** %8
%27 = load i8*, i8** %8
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %32
29: ; preds = %24
%30 = load i8*, i8** %8
%31 = getelementptr inbounds i8, i8* %30, i64 1
store i8* %31, i8** %6
br label %32
32: ; preds = %29, %24
%33 = load i8*, i8** %5
%34 = load i8*, i8** %6
%35 = load i32, i32* %7
%36 = call i32 @strlcpy(i8* %33, i8* %34, i32 %35)
%37 = load i8*, i8** %5
%38 = load i32, i32* %7
%39 = sub nsw i32 %38, 1
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %37, i64 %40
store i8 0, i8* %41
%42 = load i8*, i8** %5
%43 = call i8* @rindex(i8* %42, i8 signext 46)
store i8* %43, i8** %8
%44 = load i8*, i8** %8
%45 = icmp ne i8* %44, null
br i1 %45, label %46, label %52
46: ; preds = %32
%47 = load i8*, i8** %8
%48 = call i64 @strcmp(i8* %47, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%49 = icmp eq i64 0, %48
br i1 %49, label %50, label %52
50: ; preds = %46
%51 = load i8*, i8** %8
store i8 0, i8* %51
store i32 0, i32* %4
br label %55
52: ; preds = %46, %32
%53 = load i8*, i8** %6
%54 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i8* %53)
store i32 1, i32* %4
br label %55
55: ; preds = %52, %50
%56 = load i32, i32* %4
ret i32 %56
}

LLVM IR (-O2):
@.str = [4 x i8] c".pc\00"
@.str.1 = [47 x i8] c"input file (%s) has no '.pc' extension, skip, \00"
define i32 @fn2cn(i8* %0, i8* %1, i32 %2) {
%4 = tail call i8* @rindex(i8* %1, i8 signext 47)
%5 = icmp eq i8* %4, null
%6 = getelementptr inbounds i8, i8* %4, i64 1
%7 = select i1 %5, i8* %1, i8* %6
%8 = tail call i8* @rindex(i8* %7, i8 signext 92)
%9 = icmp eq i8* %8, null
%10 = getelementptr inbounds i8, i8* %8, i64 1
%11 = select i1 %9, i8* %7, i8* %10
%12 = tail call i8* @rindex(i8* %11, i8 signext 58)
%13 = icmp eq i8* %12, null
%14 = getelementptr inbounds i8, i8* %12, i64 1
%15 = select i1 %13, i8* %11, i8* %14
%16 = tail call i32 @strlcpy(i8* %0, i8* %15, i32 %2)
%17 = add nsw i32 %2, -1
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %0, i64 %18
store i8 0, i8* %19
%20 = tail call i8* @rindex(i8* %0, i8 signext 46)
%21 = icmp eq i8* %20, null
br i1 %21, label %26, label %22
22: ; preds = %3
%23 = tail call i64 @strcmp(i8* %20, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %22
store i8 0, i8* %20
br label %28
26: ; preds = %22, %3
%27 = tail call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i8* %15)
br label %28
28: ; preds = %26, %25
%29 = phi i32 [ 0, %25 ], [ 1, %26 ]
ret i32 %29
}