#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__ isdigit(char);
int strlen(char *);
scalar_t__ strncmp(char *, char *, int);
int path_has_part(char *path, char **part) {
  int l;
  if (!path)
    return 0;
  l = strlen(path);
  while (l > 1 && isdigit(path[l - 1]))
    l--;
  if (l < 5 || strncmp(path + l - 5, "-part", 5) != 0)
    return 0;
  *part = path + l - 4;
  return 1;
}


x86 assembly (clang, -O0):
<path_has_part>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1157 <path_has_part+0x27>
movl   $0x0,-0x4(%rbp)
jmp    120d <path_has_part+0xdd>
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x1c(%rbp)
xor    %eax,%eax
cmpl   $0x1,-0x1c(%rbp)
mov    %al,-0x1d(%rbp)
jle    1192 <path_has_part+0x62>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isdigit@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    11a2 <path_has_part+0x72>
jmp    11b0 <path_has_part+0x80>
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x1c(%rbp)
jmp    1163 <path_has_part+0x33>
cmpl   $0x5,-0x1c(%rbp)
jl     11e4 <path_has_part+0xb4>
mov    -0x10(%rbp),%rdi
movslq -0x1c(%rbp),%rax
add    %rax,%rdi
add    $0xfffffffffffffffb,%rdi
lea    0xe30(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     11f0 <path_has_part+0xc0>
movl   $0x0,-0x4(%rbp)
jmp    120d <path_has_part+0xdd>
mov    -0x10(%rbp),%rcx
movslq -0x1c(%rbp),%rax
add    %rax,%rcx
add    $0xfffffffffffffffc,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<path_has_part>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
xor    %r15d,%r15d
test   %rdi,%rdi
je     11bb <path_has_part+0x8b>
mov    %rsi,%r14
mov    %rdi,%r12
call   1050 <strlen@plt>
mov    %eax,%ebp
mov    %eax,%eax
lea    (%rax,%r12,1),%r13
add    $0xfffffffffffffffc,%r13
mov    %ebp,%ebx
add    $0xffffffff,%ebx
add    %r12,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cmp    $0x2,%ebp
jl     11bb <path_has_part+0x8b>
movsbl (%rbx),%edi
call   1040 <isdigit@plt>
add    $0xffffffff,%ebp
add    $0xffffffffffffffff,%r13
add    $0xffffffffffffffff,%rbx
test   %rax,%rax
jne    1170 <path_has_part+0x40>
add    $0x1,%ebp
cmp    $0x5,%ebp
jb     11bb <path_has_part+0x8b>
lea    0xe64(%rip),%rsi
mov    %r13,%rdi
mov    $0x5,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    11bb <path_has_part+0x8b>
add    $0x1,%r13
mov    %r13,(%r14)
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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