#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*/ strcmp(char *, char *);
int strlen(char const *);
scalar_t__ strncmp(char *, char const *, int);
char *strrchr(char const *, char);
bool is_mkv(const char *path) {
  if (!path || strlen(path) < 19)
    return false;
  if (strncmp("/output/", path, sizeof("/output/") - 1) != 0)
    return false;
  char *dot = strrchr(path, '.');
  return dot && !strcmp(dot, ".mkv");
}


x86 assembly (clang, -O0):
<is_mkv>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1169 <is_mkv+0x29>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
cmp    $0x13,%eax
jge    1175 <is_mkv+0x35>
movl   $0x0,-0x4(%rbp)
jmp    11e8 <is_mkv+0xa8>
mov    -0x10(%rbp),%rsi
lea    0xe80(%rip),%rdi
mov    $0x8,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     11a0 <is_mkv+0x60>
movl   $0x0,-0x4(%rbp)
jmp    11e8 <is_mkv+0xa8>
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1050 <strrchr@plt>
mov    %rax,-0x18(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x18(%rbp)
mov    %al,-0x19(%rbp)
je     11dd <is_mkv+0x9d>
mov    -0x18(%rbp),%rdi
lea    0xe3c(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_mkv>:
push   %rbp
push   %rbx
push   %rax
xor    %ebp,%ebp
test   %rdi,%rdi
je     1199 <is_mkv+0x59>
mov    %rdi,%rbx
call   1040 <strlen@plt>
cmp    $0x13,%eax
jl     1199 <is_mkv+0x59>
lea    0xea2(%rip),%rdi
mov    %rbx,%rsi
mov    $0x8,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    1199 <is_mkv+0x59>
mov    %rbx,%rdi
mov    $0x2e,%esi
call   1050 <strrchr@plt>
test   %rax,%rax
je     1199 <is_mkv+0x59>
lea    0xe80(%rip),%rsi
mov    %rax,%rdi
call   1060 <strcmp@plt>
xor    %ebp,%ebp
test   %eax,%eax
sete   %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"/output/\00"
@.str.1 = [5 x i8] c".mkv\00"
define i32 @is_mkv(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = call i32 @strlen(i8* %8)
%10 = icmp slt i32 %9, 19
br i1 %10, label %11, label %12
11: ; preds = %7, %1
store i32 0, i32* %2
br label %30
12: ; preds = %7
%13 = load i8*, i8** %3
%14 = call i64 @strncmp(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %13, i32 8)
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %12
store i32 0, i32* %2
br label %30
17: ; preds = %12
%18 = load i8*, i8** %3
%19 = call i8* @strrchr(i8* %18, i8 signext 46)
store i8* %19, i8** %4
%20 = load i8*, i8** %4
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %27
22: ; preds = %17
%23 = load i8*, i8** %4
%24 = call i32 @strcmp(i8* %23, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%25 = icmp ne i32 %24, 0
%26 = xor i1 %25, true
br label %27
27: ; preds = %22, %17
%28 = phi i1 [ false, %17 ], [ %26, %22 ]
%29 = zext i1 %28 to i32
store i32 %29, i32* %2
br label %30
30: ; preds = %27, %16, %11
%31 = load i32, i32* %2
ret i32 %31
}

LLVM IR (-O2):
@.str = [9 x i8] c"/output/\00"
@.str.1 = [5 x i8] c".mkv\00"
define i32 @is_mkv(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %16, label %3
3: ; preds = %1
%4 = tail call i32 @strlen(i8* %0)
%5 = icmp slt i32 %4, 19
br i1 %5, label %16, label %6
6: ; preds = %3
%7 = tail call i64 @strncmp(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %0, i32 8)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = tail call i8* @strrchr(i8* %0, i8 signext 46)
%11 = icmp eq i8* %10, null
br i1 %11, label %16, label %12
12: ; preds = %9
%13 = tail call i32 @strcmp(i8* %10, i8* dereferenceable(5) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32 %13, 0
%15 = zext i1 %14 to i32
br label %16
16: ; preds = %9, %12, %6, %1, %3
%17 = phi i32 [ 0, %3 ], [ 0, %1 ], [ 0, %6 ], [ 0, %9 ], [ %15, %12 ]
ret i32 %17
}