#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*/ assert(int);
scalar_t__ strlen(char const *);
char *strstr(char const *, char const *);
int checkExtension(const char *extensions, const char *name) {
  int nlen = (int)strlen(name);
  int elen = (int)strlen(extensions);
  const char *e = extensions;
  assert(nlen > 0);
  while (1) {
    e = strstr(e, name);
    if (e == NULL)
      return 0;
    if (e == extensions + elen - nlen)
      return 1;
    if (*(e + nlen) == ' ')
      return 1;
    e += nlen;
  }
  return 0;
}


x86 assembly (clang, -O0):
<checkExtension>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x0,-0x1c(%rbp)
setg   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strstr@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1199 <checkExtension+0x69>
movl   $0x0,-0x4(%rbp)
jmp    1200 <checkExtension+0xd0>
mov    -0x28(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq -0x20(%rbp),%rdx
add    %rdx,%rcx
movslq -0x1c(%rbp),%rsi
xor    %edx,%edx
sub    %rsi,%rdx
add    %rdx,%rcx
cmp    %rcx,%rax
jne    11c9 <checkExtension+0x99>
movl   $0x1,-0x4(%rbp)
jmp    1200 <checkExtension+0xd0>
mov    -0x28(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    11ea <checkExtension+0xba>
movl   $0x1,-0x4(%rbp)
jmp    1200 <checkExtension+0xd0>
mov    -0x1c(%rbp),%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
jmp    1171 <checkExtension+0x41>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkExtension>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rax,%r12
xor    %edi,%edi
test   %r15d,%r15d
setg   %dil
call   1040 <assert@plt>
movslq %r12d,%r12
add    %rbx,%r12
movslq %r15d,%r15
sub    %r15,%r12
xchg   %ax,%ax
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <strstr@plt>
test   %rax,%rax
je     119c <checkExtension+0x6c>
mov    %rax,%rcx
mov    $0x1,%eax
cmp    %r12,%rcx
je     119e <checkExtension+0x6e>
mov    %rcx,%rbx
add    %r15,%rbx
cmpb   $0x20,(%rcx,%r15,1)
jne    1170 <checkExtension+0x40>
jmp    119e <checkExtension+0x6e>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @checkExtension(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%9 = load i8*, i8** %5
%10 = call i64 @strlen(i8* %9)
%11 = trunc i64 %10 to i32
store i32 %11, i32* %6
%12 = load i8*, i8** %4
%13 = call i64 @strlen(i8* %12)
%14 = trunc i64 %13 to i32
store i32 %14, i32* %7
%15 = load i8*, i8** %4
store i8* %15, i8** %8
%16 = load i32, i32* %6
%17 = icmp sgt i32 %16, 0
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
br label %20
20: ; preds = %2, %48
%21 = load i8*, i8** %8
%22 = load i8*, i8** %5
%23 = call i8* @strstr(i8* %21, i8* %22)
store i8* %23, i8** %8
%24 = load i8*, i8** %8
%25 = icmp eq i8* %24, null
br i1 %25, label %26, label %27
26: ; preds = %20
store i32 0, i32* %3
br label %53
27: ; preds = %20
%28 = load i8*, i8** %8
%29 = load i8*, i8** %4
%30 = load i32, i32* %7
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %29, i64 %31
%33 = load i32, i32* %6
%34 = sext i32 %33 to i64
%35 = sub i64 0, %34
%36 = getelementptr inbounds i8, i8* %32, i64 %35
%37 = icmp eq i8* %28, %36
br i1 %37, label %38, label %39
38: ; preds = %27
store i32 1, i32* %3
br label %53
39: ; preds = %27
%40 = load i8*, i8** %8
%41 = load i32, i32* %6
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %40, i64 %42
%44 = load i8, i8* %43
%45 = sext i8 %44 to i32
%46 = icmp eq i32 %45, 32
br i1 %46, label %47, label %48
47: ; preds = %39
store i32 1, i32* %3
br label %53
48: ; preds = %39
%49 = load i32, i32* %6
%50 = load i8*, i8** %8
%51 = sext i32 %49 to i64
%52 = getelementptr inbounds i8, i8* %50, i64 %51
store i8* %52, i8** %8
br label %20
53: ; preds = %47, %38, %26
%54 = load i32, i32* %3
ret i32 %54
}

LLVM IR (-O2):
define i32 @checkExtension(i8* %0, i8* nocapture %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%4 = trunc i64 %3 to i32
%5 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%6 = icmp sgt i32 %4, 0
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = shl i64 %5, 32
%10 = ashr exact i64 %9, 32
%11 = getelementptr inbounds i8, i8* %0, i64 %10
%12 = shl i64 %3, 32
%13 = ashr exact i64 %12, 32
%14 = sub nsw i64 0, %13
%15 = getelementptr inbounds i8, i8* %11, i64 %14
br label %16
16: ; preds = %22, %2
%17 = phi i8* [ %0, %2 ], [ %23, %22 ]
%18 = tail call i8* @strstr(i8* dereferenceable(1) %17, i8* dereferenceable(1) %1)
%19 = icmp eq i8* %18, null
br i1 %19, label %26, label %20
20: ; preds = %16
%21 = icmp eq i8* %18, %15
br i1 %21, label %26, label %22
22: ; preds = %20
%23 = getelementptr inbounds i8, i8* %18, i64 %13
%24 = load i8, i8* %23
%25 = icmp eq i8 %24, 32
br i1 %25, label %26, label %16
26: ; preds = %22, %20, %16
%27 = phi i32 [ 0, %16 ], [ 1, %20 ], [ 1, %22 ]
ret i32 %27
}