#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 const *, char const *);
char *strrchr(char const *, char);
int check_extension(const char *fpath, const char *extensions[],
                    unsigned size) {
  const char *pos = strrchr(fpath, '.');
  if (!pos)
    return 0;
  for (unsigned i = 0; i < size; i++) {
    if (!strcmp(pos, extensions[i]))
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<check_extension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x2e,%esi
call   1030 <strrchr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    115c <check_extension+0x3c>
movl   $0x0,-0x4(%rbp)
jmp    11b2 <check_extension+0x92>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jae    11ab <check_extension+0x8b>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    (%rax,%rcx,8),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1198 <check_extension+0x78>
movl   $0x1,-0x4(%rbp)
jmp    11b2 <check_extension+0x92>
jmp    119d <check_extension+0x7d>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1163 <check_extension+0x43>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_extension>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%r14
mov    $0x2e,%esi
call   1030 <strrchr@plt>
mov    %rax,%r15
xor    %eax,%eax
test   %r15,%r15
je     118b <check_extension+0x6b>
test   %ebp,%ebp
je     118b <check_extension+0x6b>
mov    (%r14),%rsi
mov    %r15,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1186 <check_extension+0x66>
mov    %ebp,%ebp
mov    $0x1,%ecx
nopw   0x0(%rax,%rax,1)
mov    %rcx,%rbx
cmp    %rcx,%rbp
je     117c <check_extension+0x5c>
mov    (%r14,%rbx,8),%rsi
mov    %r15,%rdi
call   1040 <strcmp@plt>
lea    0x1(%rbx),%rcx
test   %eax,%eax
jne    1160 <check_extension+0x40>
xor    %eax,%eax
cmp    %rbp,%rbx
setb   %al
jmp    118b <check_extension+0x6b>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @check_extension(i8* %0, i8** %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i32 %2, i32* %7
%10 = load i8*, i8** %5
%11 = call i8* @strrchr(i8* %10, i8 signext 46)
store i8* %11, i8** %8
%12 = load i8*, i8** %8
%13 = icmp ne i8* %12, null
br i1 %13, label %15, label %14
14: ; preds = %3
store i32 0, i32* %4
br label %35
15: ; preds = %3
store i32 0, i32* %9
br label %16
16: ; preds = %31, %15
%17 = load i32, i32* %9
%18 = load i32, i32* %7
%19 = icmp ult i32 %17, %18
br i1 %19, label %20, label %34
20: ; preds = %16
%21 = load i8*, i8** %8
%22 = load i8**, i8*** %6
%23 = load i32, i32* %9
%24 = zext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %22, i64 %24
%26 = load i8*, i8** %25
%27 = call i32 @strcmp(i8* %21, i8* %26)
%28 = icmp ne i32 %27, 0
br i1 %28, label %30, label %29
29: ; preds = %20
store i32 1, i32* %4
br label %35
30: ; preds = %20
br label %31
31: ; preds = %30
%32 = load i32, i32* %9
%33 = add i32 %32, 1
store i32 %33, i32* %9
br label %16
34: ; preds = %16
store i32 0, i32* %4
br label %35
35: ; preds = %34, %29, %14
%36 = load i32, i32* %4
ret i32 %36
}

LLVM IR (-O2):
define i32 @check_extension(i8* %0, i8** nocapture %1, i32 %2) {
%4 = tail call i8* @strrchr(i8* dereferenceable(1) %0, i8 signext 46)
%5 = icmp eq i8* %4, null
%6 = icmp eq i32 %2, 0
%7 = or i1 %5, %6
br i1 %7, label %25, label %8
8: ; preds = %3
%9 = zext i32 %2 to i64
%10 = load i8*, i8** %1
%11 = tail call i32 @strcmp(i8* %4, i8* dereferenceable(1) %10)
%12 = icmp eq i32 %11, 0
br i1 %12, label %25, label %13
13: ; preds = %8, %16
%14 = phi i64 [ %21, %16 ], [ 1, %8 ]
%15 = icmp eq i64 %14, %9
br i1 %15, label %22, label %16
16: ; preds = %13
%17 = getelementptr inbounds i8*, i8** %1, i64 %14
%18 = load i8*, i8** %17
%19 = tail call i32 @strcmp(i8* %4, i8* dereferenceable(1) %18)
%20 = icmp eq i32 %19, 0
%21 = add nuw nsw i64 %14, 1
br i1 %20, label %22, label %13
22: ; preds = %13, %16
%23 = icmp ult i64 %14, %9
%24 = zext i1 %23 to i32
br label %25
25: ; preds = %8, %22, %3
%26 = phi i32 [ 0, %3 ], [ 1, %8 ], [ %24, %22 ]
ret i32 %26
}