#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*/ strlen(char *);
scalar_t__ strncmp(char const *, char *, int /*<<< orphan*/);
char *strstr(char *, char *);
char *epk_archive_is_epik(const char *path) {
  int is_epik;
  char *ch, *begch = (char *)path;
  if (!path)
    return NULL;
  while ((ch = strstr(begch, "/"
                             "epik_")) != NULL)
    begch = ch + 1;
  is_epik = ((begch != path) || (strncmp(path, "epik_", strlen("epik_")) == 0));
  if (is_epik)
    return begch;
  else
    return NULL;
}


x86 assembly (clang, -O0):
<epk_archive_is_epik>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    115c <epk_archive_is_epik+0x2c>
movq   $0x0,-0x8(%rbp)
jmp    11fd <epk_archive_is_epik+0xcd>
jmp    1161 <epk_archive_is_epik+0x31>
mov    -0x28(%rbp),%rdi
lea    0xe94(%rip),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1190 <epk_archive_is_epik+0x60>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1161 <epk_archive_is_epik+0x31>
mov    -0x28(%rbp),%rcx
mov    $0x1,%al
cmp    -0x10(%rbp),%rcx
mov    %al,-0x29(%rbp)
jne    11d3 <epk_archive_is_epik+0xa3>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
lea    0xe4f(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%edx
lea    0xe3d(%rip),%rsi
call   1030 <strncmp@plt>
cmp    $0x0,%rax
sete   %al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11f5 <epk_archive_is_epik+0xc5>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11fd <epk_archive_is_epik+0xcd>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<epk_archive_is_epik>:
push   %r15
push   %r14
push   %rbx
test   %rdi,%rdi
je     118d <epk_archive_is_epik+0x5d>
mov    %rdi,%r14
lea    0xebc(%rip),%r15
mov    %rdi,%rcx
nopw   0x0(%rax,%rax,1)
mov    %rcx,%rbx
mov    %rcx,%rdi
mov    %r15,%rsi
call   1050 <strstr@plt>
lea    0x1(%rax),%rcx
test   %rax,%rax
jne    1150 <epk_archive_is_epik+0x20>
cmp    %r14,%rbx
jne    118f <epk_archive_is_epik+0x5f>
lea    0xe8e(%rip),%r15
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     118f <epk_archive_is_epik+0x5f>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [7 x i8] c"/epik_\00"
@.str.1 = [6 x i8] c"epik_\00"
define i8* @epk_archive_is_epik(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %15, label %3
3: ; preds = %1, %3
%4 = phi i8* [ %7, %3 ], [ %0, %1 ]
%5 = tail call i8* @strstr(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i8* %5, null
%7 = getelementptr inbounds i8, i8* %5, i64 1
br i1 %6, label %8, label %3
8: ; preds = %3
%9 = icmp eq i8* %4, %0
br i1 %9, label %10, label %14
10: ; preds = %8
%11 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%12 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %8, %10
br label %15
15: ; preds = %14, %10, %1
%16 = phi i8* [ null, %1 ], [ %4, %14 ], [ null, %10 ]
ret i8* %16
}