#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 */
int strlen(char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
int file_filter(const struct dirent *a) {
  int match = 0;
  if (!strncmp(a->d_name, "video", 5)) {
    if (strlen(a->d_name) > 5) {
      if ((a->d_name[5] >= '0') && (a->d_name[5] <= '9')) {
        match = 1;
      }
      if (strlen(a->d_name) > 6) {
        match = 0;
        if ((a->d_name[6] >= '0') && (a->d_name[6] <= '9')) {
          match = 1;
        }
      }
      if (strlen(a->d_name) > 7) {
        match = 0;
      }
    }
  }
  return match;
}


x86 assembly (clang, -O0):
<file_filter>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
lea    0xebf(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    120e <file_filter+0xee>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1040 <strlen@plt>
cmp    $0x5,%eax
jle    1209 <file_filter+0xe9>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl 0x5(%rax),%eax
cmp    $0x30,%eax
jl     1198 <file_filter+0x78>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl 0x5(%rax),%eax
cmp    $0x39,%eax
jg     1198 <file_filter+0x78>
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1040 <strlen@plt>
cmp    $0x6,%eax
jle    11e8 <file_filter+0xc8>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl 0x6(%rax),%eax
cmp    $0x30,%eax
jl     11e3 <file_filter+0xc3>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movsbl 0x6(%rax),%eax
cmp    $0x39,%eax
jg     11e3 <file_filter+0xc3>
movl   $0x1,-0xc(%rbp)
jmp    11e8 <file_filter+0xc8>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1040 <strlen@plt>
cmp    $0x7,%eax
jle    1204 <file_filter+0xe4>
movl   $0x0,-0xc(%rbp)
jmp    1209 <file_filter+0xe9>
jmp    120e <file_filter+0xee>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<file_filter>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    (%rdi),%rdi
lea    0xed0(%rip),%rsi
mov    $0x5,%edx
call   1030 <strncmp@plt>
xor    %ebp,%ebp
test   %eax,%eax
jne    1180 <file_filter+0x60>
mov    (%rbx),%rdi
call   1040 <strlen@plt>
cmp    $0x6,%eax
jl     1180 <file_filter+0x60>
mov    (%rbx),%rdi
mov    0x5(%rdi),%bpl
call   1040 <strlen@plt>
mov    (%rbx),%rdi
cmp    $0x7,%eax
jl     1165 <file_filter+0x45>
mov    0x6(%rdi),%bpl
add    $0xd0,%bpl
cmp    $0xa,%bpl
setb   %bl
call   1040 <strlen@plt>
cmp    $0x8,%eax
setl   %al
and    %bl,%al
movzbl %al,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.dirent = type { i8* }
@.str = [6 x i8] c"video\00"
define i32 @file_filter(%struct.dirent* nocapture %0) {
%2 = getelementptr inbounds %struct.dirent, %struct.dirent* %0, i64 0, i32 0
%3 = load i8*, i8** %2
%4 = tail call i32 @strncmp(i8* %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %28
6: ; preds = %1
%7 = load i8*, i8** %2
%8 = tail call i32 @strlen(i8* %7)
%9 = icmp sgt i32 %8, 5
br i1 %9, label %10, label %28
10: ; preds = %6
%11 = load i8*, i8** %2
%12 = getelementptr inbounds i8, i8* %11, i64 5
%13 = load i8, i8* %12
%14 = tail call i32 @strlen(i8* %11)
%15 = icmp sgt i32 %14, 6
%16 = load i8*, i8** %2
br i1 %15, label %17, label %20
17: ; preds = %10
%18 = getelementptr inbounds i8, i8* %16, i64 6
%19 = load i8, i8* %18
br label %20
20: ; preds = %10, %17
%21 = phi i8 [ %19, %17 ], [ %13, %10 ]
%22 = add i8 %21, -48
%23 = icmp ult i8 %22, 10
%24 = tail call i32 @strlen(i8* %16)
%25 = icmp slt i32 %24, 8
%26 = select i1 %25, i1 %23, i1 false
%27 = zext i1 %26 to i32
br label %28
28: ; preds = %20, %6, %1
%29 = phi i32 [ 0, %1 ], [ 0, %6 ], [ %27, %20 ]
ret i32 %29
}