#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 */
scalar_t__ isalpha(unsigned char);
scalar_t__ isdigit(unsigned char);
scalar_t__ strchr(char const *, char const);
int endin_istag(const char *buf) {
  const char others[] = "!@#$^&*()+=?[~>";
  if (buf[0] != '%')
    return 0;
  if (buf[2] != ' ')
    return 0;
  if (isalpha((unsigned char)buf[1]))
    return 1;
  if (isdigit((unsigned char)buf[1]))
    return 1;
  if (strchr(others, buf[1]))
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<endin_istag>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    0xebd(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeba(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x25,%eax
je     116e <endin_istag+0x3e>
movl   $0x0,-0x4(%rbp)
jmp    11ff <endin_istag+0xcf>
mov    -0x10(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x20,%eax
je     118b <endin_istag+0x5b>
movl   $0x0,-0x4(%rbp)
jmp    11ff <endin_istag+0xcf>
mov    -0x10(%rbp),%rax
movzbl 0x1(%rax),%edi
call   1050 <isalpha@plt>
cmp    $0x0,%rax
je     11ae <endin_istag+0x7e>
movl   $0x1,-0x4(%rbp)
jmp    11ff <endin_istag+0xcf>
mov    -0x10(%rbp),%rax
movzbl 0x1(%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
je     11d1 <endin_istag+0xa1>
movl   $0x1,-0x4(%rbp)
jmp    11ff <endin_istag+0xcf>
lea    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%esi
call   1040 <strchr@plt>
cmp    $0x0,%rax
je     11f8 <endin_istag+0xc8>
movl   $0x1,-0x4(%rbp)
jmp    11ff <endin_istag+0xcf>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<endin_istag>:
push   %rbp
push   %rbx
sub    $0x18,%rsp
movaps 0xec3(%rip),%xmm0
movaps %xmm0,(%rsp)
xor    %ebp,%ebp
cmpb   $0x25,(%rdi)
jne    1187 <endin_istag+0x57>
mov    %rdi,%rbx
cmpb   $0x20,0x2(%rdi)
jne    1187 <endin_istag+0x57>
movzbl 0x1(%rbx),%edi
call   1050 <isalpha@plt>
mov    $0x1,%ebp
test   %rax,%rax
jne    1187 <endin_istag+0x57>
movzbl 0x1(%rbx),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
jne    1187 <endin_istag+0x57>
movsbl 0x1(%rbx),%esi
mov    %rsp,%rdi
call   1040 <strchr@plt>
xor    %ebp,%ebp
test   %rax,%rax
setne  %bpl
mov    %ebp,%eax
add    $0x18,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@__const.endin_istag.others = [16 x i8] c"!@#$^&*()+=?[~>\00"
define i32 @endin_istag(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [16 x i8]
store i8* %0, i8** %3
%5 = bitcast [16 x i8]* %4 to i8*
%6 = load i8*, i8** %3
%7 = getelementptr inbounds i8, i8* %6, i64 0
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 37
br i1 %10, label %11, label %12
11: ; preds = %1
store i32 0, i32* %2
br label %42
12: ; preds = %1
%13 = load i8*, i8** %3
%14 = getelementptr inbounds i8, i8* %13, i64 2
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 32
br i1 %17, label %18, label %19
18: ; preds = %12
store i32 0, i32* %2
br label %42
19: ; preds = %12
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i64 1
%22 = load i8, i8* %21
%23 = call i64 @isalpha(i8 zeroext %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %19
store i32 1, i32* %2
br label %42
26: ; preds = %19
%27 = load i8*, i8** %3
%28 = getelementptr inbounds i8, i8* %27, i64 1
%29 = load i8, i8* %28
%30 = call i64 @isdigit(i8 zeroext %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %26
store i32 1, i32* %2
br label %42
33: ; preds = %26
%34 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%35 = load i8*, i8** %3
%36 = getelementptr inbounds i8, i8* %35, i64 1
%37 = load i8, i8* %36
%38 = call i64 @strchr(i8* %34, i8 signext %37)
%39 = icmp ne i64 %38, 0
br i1 %39, label %40, label %41
40: ; preds = %33
store i32 1, i32* %2
br label %42
41: ; preds = %33
store i32 0, i32* %2
br label %42
42: ; preds = %41, %40, %32, %25, %18, %11
%43 = load i32, i32* %2
ret i32 %43
}

LLVM IR (-O2):
@__const.endin_istag.others = [16 x i8] c"!@#$^&*()+=?[~>\00"
define i32 @endin_istag(i8* nocapture %0) {
%2 = alloca [16 x i8]
%3 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 37
br i1 %5, label %6, label %24
6: ; preds = %1
%7 = getelementptr inbounds i8, i8* %0, i64 2
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 32
br i1 %9, label %10, label %24
10: ; preds = %6
%11 = getelementptr inbounds i8, i8* %0, i64 1
%12 = load i8, i8* %11
%13 = tail call i64 @isalpha(i8 zeroext %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %24
15: ; preds = %10
%16 = load i8, i8* %11
%17 = tail call i64 @isdigit(i8 zeroext %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %15
%20 = load i8, i8* %11
%21 = call i64 @strchr(i8* %3, i8 signext %20)
%22 = icmp ne i64 %21, 0
%23 = zext i1 %22 to i32
br label %24
24: ; preds = %19, %15, %10, %6, %1
%25 = phi i32 [ 0, %1 ], [ 0, %6 ], [ 1, %10 ], [ 1, %15 ], [ %23, %19 ]
ret i32 %25
}