#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 */
scalar_t__ strncmp(char const *, char *, int);
int cpa_cmd_contains_path(const char *prefix, int prefix_len) {
  int i;
  if (*prefix == '~')
    return 1;
  if (prefix_len >= (sizeof("/") - 1) &&
      strncmp(prefix, "/", (sizeof("/") - 1)) == 0)
    return 1;
  for (i = 0; i < prefix_len; i++) {
    if (prefix_len - i >= (sizeof("/") - 1) &&
        strncmp(prefix + i, "/", (sizeof("/") - 1)) == 0)
      return 1;
  };
  return 0;
}


x86 assembly (clang, -O0):
<cpa_cmd_contains_path>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7e,%eax
jne    113b <cpa_cmd_contains_path+0x2b>
movl   $0x1,-0x4(%rbp)
jmp    11e5 <cpa_cmd_contains_path+0xd5>
movslq -0x14(%rbp),%rax
cmp    $0x1,%rax
jb     1174 <cpa_cmd_contains_path+0x64>
mov    -0x10(%rbp),%rdi
lea    0xeac(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1174 <cpa_cmd_contains_path+0x64>
movl   $0x1,-0x4(%rbp)
jmp    11e5 <cpa_cmd_contains_path+0xd5>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11de <cpa_cmd_contains_path+0xce>
mov    -0x14(%rbp),%eax
sub    -0x18(%rbp),%eax
cltq
cmp    $0x1,%rax
jb     11cb <cpa_cmd_contains_path+0xbb>
mov    -0x10(%rbp),%rdi
movslq -0x18(%rbp),%rax
add    %rax,%rdi
lea    0xe55(%rip),%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11cb <cpa_cmd_contains_path+0xbb>
movl   $0x1,-0x4(%rbp)
jmp    11e5 <cpa_cmd_contains_path+0xd5>
jmp    11d0 <cpa_cmd_contains_path+0xc0>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    117b <cpa_cmd_contains_path+0x6b>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cpa_cmd_contains_path>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    $0x1,%r15d
cmpb   $0x7e,(%rdi)
je     1182 <cpa_cmd_contains_path+0x72>
mov    %esi,%r14d
test   %esi,%esi
je     117f <cpa_cmd_contains_path+0x6f>
mov    %rdi,%rbx
lea    0xecd(%rip),%rsi
mov    $0x1,%r15d
mov    $0x1,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1182 <cpa_cmd_contains_path+0x72>
test   %r14d,%r14d
jle    117f <cpa_cmd_contains_path+0x6f>
mov    %r14d,%ebp
lea    0xea9(%rip),%r14
mov    $0x1,%r15d
nopl   (%rax)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1182 <cpa_cmd_contains_path+0x72>
add    $0x1,%rbx
add    $0xffffffffffffffff,%rbp
jne    1160 <cpa_cmd_contains_path+0x50>
xor    %r15d,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
define i32 @cpa_cmd_contains_path(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%7 = load i8*, i8** %4
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp eq i32 %9, 126
br i1 %10, label %11, label %12
11: ; preds = %2
store i32 1, i32* %3
br label %45
12: ; preds = %2
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = icmp uge i64 %14, 1
br i1 %15, label %16, label %21
16: ; preds = %12
%17 = load i8*, i8** %4
%18 = call i64 @strncmp(i8* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %16
store i32 1, i32* %3
br label %45
21: ; preds = %16, %12
store i32 0, i32* %6
br label %22
22: ; preds = %41, %21
%23 = load i32, i32* %6
%24 = load i32, i32* %5
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %44
26: ; preds = %22
%27 = load i32, i32* %5
%28 = load i32, i32* %6
%29 = sub nsw i32 %27, %28
%30 = sext i32 %29 to i64
%31 = icmp uge i64 %30, 1
br i1 %31, label %32, label %40
32: ; preds = %26
%33 = load i8*, i8** %4
%34 = load i32, i32* %6
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %33, i64 %35
%37 = call i64 @strncmp(i8* %36, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %40
39: ; preds = %32
store i32 1, i32* %3
br label %45
40: ; preds = %32, %26
br label %41
41: ; preds = %40
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
store i32 %43, i32* %6
br label %22
44: ; preds = %22
store i32 0, i32* %3
br label %45
45: ; preds = %44, %39, %20, %11
%46 = load i32, i32* %3
ret i32 %46
}

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
define i32 @cpa_cmd_contains_path(i8* %0, i32 %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 126
br i1 %4, label %22, label %5
5: ; preds = %2
%6 = icmp eq i32 %1, 0
br i1 %6, label %22, label %7
7: ; preds = %5
%8 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%9 = icmp eq i64 %8, 0
br i1 %9, label %22, label %10
10: ; preds = %7
%11 = icmp sgt i32 %1, 0
br i1 %11, label %12, label %22
12: ; preds = %10
%13 = zext i32 %1 to i64
br label %16
14: ; preds = %16
%15 = icmp eq i64 %21, %13
br i1 %15, label %22, label %16
16: ; preds = %12, %14
%17 = phi i64 [ 0, %12 ], [ %21, %14 ]
%18 = getelementptr inbounds i8, i8* %0, i64 %17
%19 = tail call i64 @strncmp(i8* %18, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i32 1)
%20 = icmp eq i64 %19, 0
%21 = add nuw nsw i64 %17, 1
br i1 %20, label %22, label %14
22: ; preds = %16, %14, %5, %10, %7, %2
%23 = phi i32 [ 1, %2 ], [ 1, %7 ], [ 0, %10 ], [ 0, %5 ], [ 1, %16 ], [ 0, %14 ]
ret i32 %23
}