#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 */
struct dirent {
  char *d_name;
};

/* Variables and functions */
scalar_t__ strncmp(char *, char *, int);
int select_cards(const struct dirent *drm) {
  if (strncmp(drm->d_name, "card", 4) != 0 || drm->d_name[4] < '0' ||
      drm->d_name[4] > '9' || drm->d_name[5] != '\0')
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<select_cards>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
lea    0xed6(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    117a <select_cards+0x6a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl 0x4(%rax),%eax
cmp    $0x30,%eax
jl     117a <select_cards+0x6a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl 0x4(%rax),%eax
cmp    $0x39,%eax
jg     117a <select_cards+0x6a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl 0x5(%rax),%eax
cmp    $0x0,%eax
je     1186 <select_cards+0x76>
movl   $0x0,-0x4(%rbp)
jmp    118d <select_cards+0x7d>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<select_cards>:
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%rdi
lea    0xee2(%rip),%rsi
mov    $0x4,%edx
call   1030 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
je     1134 <select_cards+0x24>
pop    %rbx
ret
mov    (%rbx),%rcx
mov    0x4(%rcx),%dl
add    $0xc6,%dl
cmp    $0xf6,%dl
jb     1132 <select_cards+0x22>
xor    %eax,%eax
cmpb   $0x0,0x5(%rcx)
sete   %al
pop    %rbx
ret

LLVM IR (-O0):
%struct.dirent = type { i8* }
@.str = [5 x i8] c"card\00"
define i32 @select_cards(%struct.dirent* %0) {
%2 = alloca i32
%3 = alloca %struct.dirent*
store %struct.dirent* %0, %struct.dirent** %3
%4 = load %struct.dirent*, %struct.dirent** %3
%5 = getelementptr inbounds %struct.dirent, %struct.dirent* %4, i32 0, i32 0
%6 = load i8*, i8** %5
%7 = call i64 @strncmp(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%8 = icmp ne i64 %7, 0
br i1 %8, label %33, label %9
9: ; preds = %1
%10 = load %struct.dirent*, %struct.dirent** %3
%11 = getelementptr inbounds %struct.dirent, %struct.dirent* %10, i32 0, i32 0
%12 = load i8*, i8** %11
%13 = getelementptr inbounds i8, i8* %12, i64 4
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp slt i32 %15, 48
br i1 %16, label %33, label %17
17: ; preds = %9
%18 = load %struct.dirent*, %struct.dirent** %3
%19 = getelementptr inbounds %struct.dirent, %struct.dirent* %18, i32 0, i32 0
%20 = load i8*, i8** %19
%21 = getelementptr inbounds i8, i8* %20, i64 4
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp sgt i32 %23, 57
br i1 %24, label %33, label %25
25: ; preds = %17
%26 = load %struct.dirent*, %struct.dirent** %3
%27 = getelementptr inbounds %struct.dirent, %struct.dirent* %26, i32 0, i32 0
%28 = load i8*, i8** %27
%29 = getelementptr inbounds i8, i8* %28, i64 5
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %25, %17, %9, %1
store i32 0, i32* %2
br label %35
34: ; preds = %25
store i32 1, i32* %2
br label %35
35: ; preds = %34, %33
%36 = load i32, i32* %2
ret i32 %36
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
@.str = [5 x i8] c"card\00"
define i32 @select_cards(%struct.dirent* nocapture %0) {
%2 = getelementptr inbounds %struct.dirent, %struct.dirent* %0, i64 0, i32 0
%3 = load i8*, i8** %2
%4 = tail call i64 @strncmp(i8* %3, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 4)
%5 = icmp eq i64 %4, 0
br i1 %5, label %6, label %17
6: ; preds = %1
%7 = load i8*, i8** %2
%8 = getelementptr inbounds i8, i8* %7, i64 4
%9 = load i8, i8* %8
%10 = add i8 %9, -58
%11 = icmp ult i8 %10, -10
br i1 %11, label %17, label %12
12: ; preds = %6
%13 = getelementptr inbounds i8, i8* %7, i64 5
%14 = load i8, i8* %13
%15 = icmp eq i8 %14, 0
%16 = zext i1 %15 to i32
br label %17
17: ; preds = %12, %1, %6
%18 = phi i32 [ 0, %6 ], [ 0, %1 ], [ %16, %12 ]
ret i32 %18
}