#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 *);
scalar_t__ strlen(char *);
char *strrchr(char *, char);
int CheckExtension(char *filename, char *ext) {
  char *s;
  if (!filename)
    return (0);
  if (strlen(filename) == 0)
    return (0);
  s = strrchr(filename, '.');
  if (!s)
    return (0);
  if (!strcmp(s, ext))
    return (1);
  return (0);
}


x86 assembly (clang, -O0):
<CheckExtension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1157 <CheckExtension+0x27>
movl   $0x0,-0x4(%rbp)
jmp    11c8 <CheckExtension+0x98>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
jne    1176 <CheckExtension+0x46>
movl   $0x0,-0x4(%rbp)
jmp    11c8 <CheckExtension+0x98>
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1040 <strrchr@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    119f <CheckExtension+0x6f>
movl   $0x0,-0x4(%rbp)
jmp    11c8 <CheckExtension+0x98>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%eax
jne    11c1 <CheckExtension+0x91>
movl   $0x1,-0x4(%rbp)
jmp    11c8 <CheckExtension+0x98>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CheckExtension>:
push   %r14
push   %rbx
push   %rax
xor    %ebx,%ebx
test   %rdi,%rdi
je     1154 <CheckExtension+0x34>
cmpb   $0x0,(%rdi)
je     1154 <CheckExtension+0x34>
mov    %rsi,%r14
mov    $0x2e,%esi
call   1030 <strrchr@plt>
test   %rax,%rax
je     1154 <CheckExtension+0x34>
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
xor    %ebx,%ebx
test   %eax,%eax
sete   %bl
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @CheckExtension(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
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 %28
10: ; preds = %2
%11 = load i8*, i8** %4
%12 = call i64 @strlen(i8* %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %10
store i32 0, i32* %3
br label %28
15: ; preds = %10
%16 = load i8*, i8** %4
%17 = call i8* @strrchr(i8* %16, i8 signext 46)
store i8* %17, i8** %6
%18 = load i8*, i8** %6
%19 = icmp ne i8* %18, null
br i1 %19, label %21, label %20
20: ; preds = %15
store i32 0, i32* %3
br label %28
21: ; preds = %15
%22 = load i8*, i8** %6
%23 = load i8*, i8** %5
%24 = call i32 @strcmp(i8* %22, i8* %23)
%25 = icmp ne i32 %24, 0
br i1 %25, label %27, label %26
26: ; preds = %21
store i32 1, i32* %3
br label %28
27: ; preds = %21
store i32 0, i32* %3
br label %28
28: ; preds = %27, %26, %20, %14, %9
%29 = load i32, i32* %3
ret i32 %29
}

LLVM IR (-O2):
define i32 @CheckExtension(i8* %0, i8* nocapture %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %14, label %4
4: ; preds = %2
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 0
br i1 %6, label %14, label %7
7: ; preds = %4
%8 = tail call i8* @strrchr(i8* %0, i8 signext 46)
%9 = icmp eq i8* %8, null
br i1 %9, label %14, label %10
10: ; preds = %7
%11 = tail call i32 @strcmp(i8* %8, i8* dereferenceable(1) %1)
%12 = icmp eq i32 %11, 0
%13 = zext i1 %12 to i32
br label %14
14: ; preds = %10, %7, %4, %2
%15 = phi i32 [ 0, %2 ], [ 0, %4 ], [ 0, %7 ], [ %13, %10 ]
ret i32 %15
}