#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__ strcasecmp(char const *, char *);
char *strrchr(char const *, char);
int check_yuvfile(const char *filename) {
  char *ext;
  ext = strrchr(filename, '.');
  if (!ext || (strcasecmp(filename, ext) == 0))
    return -1;
  if (strcasecmp(ext + 1, "yuv") == 0)
    return 0;
  return -1;
}


x86 assembly (clang, -O0):
<check_yuvfile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1160 <check_yuvfile+0x40>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    116c <check_yuvfile+0x4c>
movl   $0xffffffff,-0x4(%rbp)
jmp    119d <check_yuvfile+0x7d>
mov    -0x18(%rbp),%rdi
add    $0x1,%rdi
lea    0xe85(%rip),%rsi
call   1030 <strcasecmp@plt>
cmp    $0x0,%rax
jne    1196 <check_yuvfile+0x76>
movl   $0x0,-0x4(%rbp)
jmp    119d <check_yuvfile+0x7d>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_yuvfile>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbp
mov    $0x2e,%esi
call   1040 <strrchr@plt>
mov    $0xffffffff,%r14d
test   %rax,%rax
je     1168 <check_yuvfile+0x48>
mov    %rax,%rbx
mov    %rbp,%rdi
mov    %rax,%rsi
call   1030 <strcasecmp@plt>
test   %rax,%rax
je     1168 <check_yuvfile+0x48>
add    $0x1,%rbx
lea    0xea6(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcasecmp@plt>
neg    %rax
sbb    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"yuv\00"
define i32 @check_yuvfile(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i8* @strrchr(i8* %5, i8 signext 46)
store i8* %6, i8** %4
%7 = load i8*, i8** %4
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %14
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = load i8*, i8** %4
%12 = call i64 @strcasecmp(i8* %10, i8* %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %9, %1
store i32 -1, i32* %2
br label %22
15: ; preds = %9
%16 = load i8*, i8** %4
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = call i64 @strcasecmp(i8* %17, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %15
store i32 0, i32* %2
br label %22
21: ; preds = %15
store i32 -1, i32* %2
br label %22
22: ; preds = %21, %20, %14
%23 = load i32, i32* %2
ret i32 %23
}

LLVM IR (-O2):
@.str = [4 x i8] c"yuv\00"
define i32 @check_yuvfile(i8* %0) {
%2 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 46)
%3 = icmp eq i8* %2, null
br i1 %3, label %12, label %4
4: ; preds = %1
%5 = tail call i64 @strcasecmp(i8* %0, i8* %2)
%6 = icmp eq i64 %5, 0
br i1 %6, label %12, label %7
7: ; preds = %4
%8 = getelementptr inbounds i8, i8* %2, i64 1
%9 = tail call i64 @strcasecmp(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%10 = icmp ne i64 %9, 0
%11 = sext i1 %10 to i32
br label %12
12: ; preds = %7, %1, %4
%13 = phi i32 [ -1, %4 ], [ -1, %1 ], [ %11, %7 ]
ret i32 %13
}