#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*/ *strchr(char *, char);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int in_dir(char *pt, char *p, int plen) {
  if (plen < strlen(pt) && strncmp(pt, p, plen) == 0)
    return strchr(&pt[plen + 1], '/') == NULL;
  else
    return 0;
}


x86 assembly (clang, -O0):
<in_dir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jge    11a6 <in_dir+0x76>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11a6 <in_dir+0x76>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
cltq
add    %rax,%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    11ad <in_dir+0x7d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<in_dir>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%r15
mov    %rdi,%rbx
call   1040 <strlen@plt>
xor    %r14d,%r14d
cmp    %ebp,%eax
jle    117c <in_dir+0x4c>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    117c <in_dir+0x4c>
movslq %ebp,%rax
lea    (%rax,%rbx,1),%rdi
add    $0x1,%rdi
mov    $0x2f,%esi
call   1050 <strchr@plt>
xor    %r14d,%r14d
test   %rax,%rax
sete   %r14b
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @in_dir(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%8 = load i32, i32* %7
%9 = load i8*, i8** %5
%10 = call i32 @strlen(i8* %9)
%11 = icmp slt i32 %8, %10
br i1 %11, label %12, label %27
12: ; preds = %3
%13 = load i8*, i8** %5
%14 = load i8*, i8** %6
%15 = load i32, i32* %7
%16 = call i64 @strncmp(i8* %13, i8* %14, i32 %15)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %27
18: ; preds = %12
%19 = load i8*, i8** %5
%20 = load i32, i32* %7
%21 = add nsw i32 %20, 1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %19, i64 %22
%24 = call i32* @strchr(i8* %23, i8 signext 47)
%25 = icmp eq i32* %24, null
%26 = zext i1 %25 to i32
store i32 %26, i32* %4
br label %28
27: ; preds = %12, %3
store i32 0, i32* %4
br label %28
28: ; preds = %27, %18
%29 = load i32, i32* %4
ret i32 %29
}

LLVM IR (-O2):
define i32 @in_dir(i8* %0, i8* %1, i32 %2) {
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp sgt i32 %4, %2
br i1 %5, label %6, label %16
6: ; preds = %3
%7 = tail call i64 @strncmp(i8* %0, i8* %1, i32 %2)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = add nsw i32 %2, 1
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = tail call i32* @strchr(i8* %12, i8 signext 47)
%14 = icmp eq i32* %13, null
%15 = zext i1 %14 to i32
br label %16
16: ; preds = %3, %6, %9
%17 = phi i32 [ %15, %9 ], [ 0, %6 ], [ 0, %3 ]
ret i32 %17
}