#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*/ mame_stricmp(char const *, char const *);
scalar_t__ strlen(char const *);
int findextension(const char *extensions, const char *ext) {
  if (*ext == '.')
    ext++;
  while (*extensions) {
    if (!mame_stricmp(extensions, ext))
      return 1;
    extensions += strlen(extensions) + 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<findextension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    114c <findextension+0x2c>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1151 <findextension+0x31>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     119a <findextension+0x7a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <mame_stricmp@plt>
cmp    $0x0,%eax
jne    1180 <findextension+0x60>
movl   $0x1,-0x4(%rbp)
jmp    11a1 <findextension+0x81>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x1,%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
jmp    1151 <findextension+0x31>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findextension>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
cmpb   $0x2e,(%rsi)
sete   %cl
xor    %r14d,%r14d
cmpb   $0x0,(%rdi)
je     116b <findextension+0x4b>
mov    %rsi,%rbx
mov    %rdi,%rbp
mov    %cl,%al
add    %rax,%rbx
nop
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1030 <mame_stricmp@plt>
test   %eax,%eax
je     1165 <findextension+0x45>
mov    %rbp,%rdi
call   1040 <strlen@plt>
cmpb   $0x0,0x1(%rax,%rbp,1)
lea    0x1(%rax,%rbp,1),%rbp
jne    1140 <findextension+0x20>
jmp    116b <findextension+0x4b>
mov    $0x1,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @findextension(i8* %0, i8* %1) {
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 46
%5 = zext i1 %4 to i64
%6 = getelementptr i8, i8* %1, i64 %5
%7 = load i8, i8* %0
%8 = icmp eq i8 %7, 0
br i1 %8, label %19, label %9
9: ; preds = %2, %13
%10 = phi i8* [ %16, %13 ], [ %0, %2 ]
%11 = tail call i32 @mame_stricmp(i8* %10, i8* %6)
%12 = icmp eq i32 %11, 0
br i1 %12, label %19, label %13
13: ; preds = %9
%14 = tail call i64 @strlen(i8* %10)
%15 = add nsw i64 %14, 1
%16 = getelementptr inbounds i8, i8* %10, i64 %15
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %19, label %9
19: ; preds = %9, %13, %2
%20 = phi i32 [ 0, %2 ], [ 0, %13 ], [ 1, %9 ]
ret i32 %20
}