#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*/ isalpha(char);
int rb_enc_mbclen(char const *, char const *);
int has_magic(const char *p, const char *pend, int flags) {
  const int nocase = flags & 0x08;
  register char c;
  while (p < pend && (c = *p++) != 0) {
    switch (c) {
    case '*':
    case '?':
    case '[':
      return 1;
    default:
      if (!0 && isalpha(c) && nocase)
        return 1;
    }
    p = ((p - 1) + rb_enc_mbclen((p - 1), (pend)));
  }
  return 0;
}


x86 assembly (clang, -O0):
<has_magic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
and    $0x8,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
cmp    -0x18(%rbp),%rcx
mov    %al,-0x22(%rbp)
jae    116f <has_magic+0x4f>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
mov    (%rax),%al
mov    %al,-0x21(%rbp)
movsbl %al,%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x22(%rbp)
mov    -0x22(%rbp),%al
test   $0x1,%al
jne    117f <has_magic+0x5f>
jmp    1221 <has_magic+0x101>
movsbl -0x21(%rbp),%eax
mov    %eax,-0x28(%rbp)
sub    $0x2a,%eax
je     11b6 <has_magic+0x96>
jmp    1194 <has_magic+0x74>
mov    -0x28(%rbp),%eax
sub    $0x3f,%eax
je     11b6 <has_magic+0x96>
jmp    11a5 <has_magic+0x85>
mov    -0x28(%rbp),%eax
sub    $0x5b,%eax
jne    11c2 <has_magic+0xa2>
jmp    11b6 <has_magic+0x96>
movl   $0x1,-0x4(%rbp)
jmp    1228 <has_magic+0x108>
movsbl -0x21(%rbp),%edi
call   1030 <isalpha@plt>
cmp    $0x0,%eax
je     11ea <has_magic+0xca>
cmpl   $0x0,-0x20(%rbp)
je     11ea <has_magic+0xca>
movl   $0x1,-0x4(%rbp)
jmp    1228 <has_magic+0x108>
jmp    11ef <has_magic+0xcf>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
add    $0xffffffffffffffff,%rdi
mov    -0x18(%rbp),%rsi
call   1040 <rb_enc_mbclen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
jmp    113c <has_magic+0x1c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<has_magic>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    %rsi,%rdi
jae    118c <has_magic+0x6c>
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%rbp
movabs $0x2000000200001,%r12
mov    $0x1,%r15d
jmp    1165 <has_magic+0x45>
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1040 <rb_enc_mbclen@plt>
cltq
add    %rax,%rbp
cmp    %rbx,%rbp
jae    118c <has_magic+0x6c>
movsbl 0x0(%rbp),%edi
test   %edi,%edi
je     118c <has_magic+0x6c>
lea    -0x2a(%rdi),%eax
cmp    $0x31,%eax
ja     117b <has_magic+0x5b>
bt     %rax,%r12
jb     118f <has_magic+0x6f>
call   1030 <isalpha@plt>
test   $0x8,%r14b
je     1150 <has_magic+0x30>
test   %eax,%eax
je     1150 <has_magic+0x30>
jmp    118f <has_magic+0x6f>
xor    %r15d,%r15d
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @has_magic(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
%10 = load i32, i32* %7
%11 = and i32 %10, 8
store i32 %11, i32* %8
br label %12
12: ; preds = %37, %3
%13 = load i8*, i8** %5
%14 = load i8*, i8** %6
%15 = icmp ult i8* %13, %14
br i1 %15, label %16, label %22
16: ; preds = %12
%17 = load i8*, i8** %5
%18 = getelementptr inbounds i8, i8* %17, i32 1
store i8* %18, i8** %5
%19 = load i8, i8* %17
store i8 %19, i8* %9
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br label %22
22: ; preds = %16, %12
%23 = phi i1 [ false, %12 ], [ %21, %16 ]
br i1 %23, label %24, label %46
24: ; preds = %22
%25 = load i8, i8* %9
%26 = sext i8 %25 to i32
switch i32 %26, label %28 [
i32 42, label %27
i32 63, label %27
i32 91, label %27
]
27: ; preds = %24, %24, %24
store i32 1, i32* %4
br label %47
28: ; preds = %24
%29 = load i8, i8* %9
%30 = call i32 @isalpha(i8 signext %29)
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %36
32: ; preds = %28
%33 = load i32, i32* %8
%34 = icmp ne i32 %33, 0
br i1 %34, label %35, label %36
35: ; preds = %32
store i32 1, i32* %4
br label %47
36: ; preds = %32, %28
br label %37
37: ; preds = %36
%38 = load i8*, i8** %5
%39 = getelementptr inbounds i8, i8* %38, i64 -1
%40 = load i8*, i8** %5
%41 = getelementptr inbounds i8, i8* %40, i64 -1
%42 = load i8*, i8** %6
%43 = call i32 @rb_enc_mbclen(i8* %41, i8* %42)
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i8, i8* %39, i64 %44
store i8* %45, i8** %5
br label %12
46: ; preds = %22
store i32 0, i32* %4
br label %47
47: ; preds = %46, %35, %27
%48 = load i32, i32* %4
ret i32 %48
}

LLVM IR (-O2):
define i32 @has_magic(i8* %0, i8* %1, i32 %2) {
%4 = icmp ult i8* %0, %1
br i1 %4, label %5, label %23
5: ; preds = %3
%6 = and i32 %2, 8
%7 = icmp ne i32 %6, 0
br label %8
8: ; preds = %5, %18
%9 = phi i8* [ %0, %5 ], [ %21, %18 ]
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
br i1 %11, label %23, label %12
12: ; preds = %8
%13 = sext i8 %10 to i32
switch i32 %13, label %14 [
i32 42, label %23
i32 63, label %23
i32 91, label %23
]
14: ; preds = %12
%15 = tail call i32 @isalpha(i8 signext %10)
%16 = icmp ne i32 %15, 0
%17 = and i1 %7, %16
br i1 %17, label %23, label %18
18: ; preds = %14
%19 = tail call i32 @rb_enc_mbclen(i8* %9, i8* %1)
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %9, i64 %20
%22 = icmp ult i8* %21, %1
br i1 %22, label %8, label %23
23: ; preds = %12, %12, %12, %14, %18, %8, %3
%24 = phi i32 [ 0, %3 ], [ 0, %8 ], [ 0, %18 ], [ 1, %14 ], [ 1, %12 ], [ 1, %12 ], [ 1, %12 ]
ret i32 %24
}