#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 */
char *strchr(char const *, char);
int /*<<< orphan*/ strncmp(char const *, char *, int);
int elide_dependency(const char *key, int key_len, const char **unpacked_end) {
  int i;
  int unpacked = 0;
  for (i = 0; i < key_len - 1; i++) {
    if (key[i] == '/') {
      if (0 == unpacked) {
        if (!strncmp(key + i + 1, "workdir/", 8)) {
          unpacked = 1;
          continue;
        }
      } else {
        if (!strncmp(key + i + 1, "UnpackedTarball/", 16)) {
          if (unpacked_end)
            *unpacked_end = strchr(key + i + 17, '/');
          return 1;
        }
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<elide_dependency>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
movl   $0x0,-0x28(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    122c <elide_dependency+0x10c>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    1219 <elide_dependency+0xf9>
xor    %eax,%eax
cmp    -0x28(%rbp),%eax
jne    11ac <elide_dependency+0x8c>
mov    -0x10(%rbp),%rdi
movslq -0x24(%rbp),%rax
add    %rax,%rdi
add    $0x1,%rdi
lea    0xe78(%rip),%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11a7 <elide_dependency+0x87>
movl   $0x1,-0x28(%rbp)
jmp    121e <elide_dependency+0xfe>
jmp    1214 <elide_dependency+0xf4>
mov    -0x10(%rbp),%rdi
movslq -0x24(%rbp),%rax
add    %rax,%rdi
add    $0x1,%rdi
lea    0xe47(%rip),%rsi
mov    $0x10,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    120f <elide_dependency+0xef>
cmpq   $0x0,-0x20(%rbp)
je     1203 <elide_dependency+0xe3>
mov    -0x10(%rbp),%rdi
movslq -0x24(%rbp),%rax
add    %rax,%rdi
add    $0x11,%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    1233 <elide_dependency+0x113>
jmp    1214 <elide_dependency+0xf4>
jmp    1219 <elide_dependency+0xf9>
jmp    121e <elide_dependency+0xfe>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1141 <elide_dependency+0x21>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<elide_dependency>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %ebp,%ebp
cmp    $0x2,%esi
jl     11bc <elide_dependency+0x9c>
mov    %rdx,%r14
mov    %esi,%r15d
mov    %rdi,%rbx
add    $0xffffffff,%r15d
add    $0x11,%rbx
xor    %ecx,%ecx
lea    0xeb0(%rip),%r12
lea    0xeb2(%rip),%r13
jmp    117a <elide_dependency+0x5a>
mov    %r12,%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
xor    %ecx,%ecx
test   %eax,%eax
sete   %cl
nopl   (%rax)
add    $0x1,%rbx
add    $0xffffffffffffffff,%r15
je     11ba <elide_dependency+0x9a>
cmpb   $0x2f,-0x11(%rbx)
jne    1170 <elide_dependency+0x50>
lea    -0x10(%rbx),%rdi
test   %ecx,%ecx
je     1159 <elide_dependency+0x39>
mov    %r13,%rsi
mov    $0x10,%edx
call   1030 <strncmp@plt>
mov    $0x1,%ecx
test   %eax,%eax
jne    1170 <elide_dependency+0x50>
mov    $0x1,%ebp
test   %r14,%r14
je     11bc <elide_dependency+0x9c>
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1040 <strchr@plt>
mov    %rax,(%r14)
jmp    11bc <elide_dependency+0x9c>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"workdir/\00"
@.str.1 = [17 x i8] c"UnpackedTarball/\00"
define i32 @elide_dependency(i8* %0, i32 %1, i8** %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8**
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8** %2, i8*** %7
store i32 0, i32* %9
store i32 0, i32* %8
br label %10
10: ; preds = %59, %3
%11 = load i32, i32* %8
%12 = load i32, i32* %6
%13 = sub nsw i32 %12, 1
%14 = icmp slt i32 %11, %13
br i1 %14, label %15, label %62
15: ; preds = %10
%16 = load i8*, i8** %5
%17 = load i32, i32* %8
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 47
br i1 %22, label %23, label %58
23: ; preds = %15
%24 = load i32, i32* %9
%25 = icmp eq i32 0, %24
br i1 %25, label %26, label %36
26: ; preds = %23
%27 = load i8*, i8** %5
%28 = load i32, i32* %8
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = getelementptr inbounds i8, i8* %30, i64 1
%32 = call i32 @strncmp(i8* %31, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 8)
%33 = icmp ne i32 %32, 0
br i1 %33, label %35, label %34
34: ; preds = %26
store i32 1, i32* %9
br label %59
35: ; preds = %26
br label %57
36: ; preds = %23
%37 = load i8*, i8** %5
%38 = load i32, i32* %8
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %37, i64 %39
%41 = getelementptr inbounds i8, i8* %40, i64 1
%42 = call i32 @strncmp(i8* %41, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 16)
%43 = icmp ne i32 %42, 0
br i1 %43, label %56, label %44
44: ; preds = %36
%45 = load i8**, i8*** %7
%46 = icmp ne i8** %45, null
br i1 %46, label %47, label %55
47: ; preds = %44
%48 = load i8*, i8** %5
%49 = load i32, i32* %8
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8, i8* %48, i64 %50
%52 = getelementptr inbounds i8, i8* %51, i64 17
%53 = call i8* @strchr(i8* %52, i8 signext 47)
%54 = load i8**, i8*** %7
store i8* %53, i8** %54
br label %55
55: ; preds = %47, %44
store i32 1, i32* %4
br label %63
56: ; preds = %36
br label %57
57: ; preds = %56, %35
br label %58
58: ; preds = %57, %15
br label %59
59: ; preds = %58, %34
%60 = load i32, i32* %8
%61 = add nsw i32 %60, 1
store i32 %61, i32* %8
br label %10
62: ; preds = %10
store i32 0, i32* %4
br label %63
63: ; preds = %62, %55
%64 = load i32, i32* %4
ret i32 %64
}

LLVM IR (-O2):
@.str = [9 x i8] c"workdir/\00"
@.str.1 = [17 x i8] c"UnpackedTarball/\00"
define i32 @elide_dependency(i8* %0, i32 %1, i8** writeonly %2) {
%4 = icmp sgt i32 %1, 1
br i1 %4, label %5, label %33
5: ; preds = %3
%6 = add nsw i32 %1, -1
%7 = zext i32 %6 to i64
br label %8
8: ; preds = %5, %29
%9 = phi i64 [ 0, %5 ], [ %31, %29 ]
%10 = phi i32 [ 0, %5 ], [ %30, %29 ]
%11 = getelementptr inbounds i8, i8* %0, i64 %9
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 47
br i1 %13, label %14, label %29
14: ; preds = %8
%15 = icmp eq i32 %10, 0
%16 = getelementptr inbounds i8, i8* %11, i64 1
br i1 %15, label %17, label %21
17: ; preds = %14
%18 = tail call i32 @strncmp(i8* %16, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 8)
%19 = icmp eq i32 %18, 0
%20 = zext i1 %19 to i32
br label %29
21: ; preds = %14
%22 = tail call i32 @strncmp(i8* %16, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.1, i64 0, i64 0), i32 16)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %29
24: ; preds = %21
%25 = icmp eq i8** %2, null
br i1 %25, label %33, label %26
26: ; preds = %24
%27 = getelementptr inbounds i8, i8* %11, i64 17
%28 = tail call i8* @strchr(i8* %27, i8 signext 47)
store i8* %28, i8** %2
br label %33
29: ; preds = %17, %8, %21
%30 = phi i32 [ 1, %21 ], [ %10, %8 ], [ %20, %17 ]
%31 = add nuw nsw i64 %9, 1
%32 = icmp eq i64 %31, %7
br i1 %32, label %33, label %8
33: ; preds = %29, %3, %24, %26
%34 = phi i32 [ 1, %26 ], [ 1, %24 ], [ 0, %3 ], [ 0, %29 ]
ret i32 %34
}