#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 atoi(char const *);
int dtype_isvalid(const char *dtype) {
  if (!dtype)
    return 0;
  switch (dtype[0]) {
  case '<':
  case '>':
  case '|':
  case '=':
    break;
  default:
    return 0;
  }
  switch (dtype[1]) {
  case 'S':
  case 'b':
  case 'i':
  case 'f':
  case 'u':
  case 'c':
    break;
  default:
    return 0;
  }
  int width = atoi(&dtype[2]);
  if (width > 16 || width <= 0)
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<dtype_isvalid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1133 <dtype_isvalid+0x23>
movl   $0x0,-0x4(%rbp)
jmp    1218 <dtype_isvalid+0x108>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x18(%rbp)
add    $0xffffffc4,%eax
sub    $0x3,%eax
jb     115f <dtype_isvalid+0x4f>
jmp    114e <dtype_isvalid+0x3e>
mov    -0x18(%rbp),%eax
sub    $0x7c,%eax
jne    1164 <dtype_isvalid+0x54>
jmp    115f <dtype_isvalid+0x4f>
jmp    1170 <dtype_isvalid+0x60>
movl   $0x0,-0x4(%rbp)
jmp    1218 <dtype_isvalid+0x108>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x53,%eax
je     11d0 <dtype_isvalid+0xc0>
jmp    1189 <dtype_isvalid+0x79>
mov    -0x1c(%rbp),%eax
add    $0xffffff9e,%eax
sub    $0x2,%eax
jb     11d0 <dtype_isvalid+0xc0>
jmp    119d <dtype_isvalid+0x8d>
mov    -0x1c(%rbp),%eax
sub    $0x66,%eax
je     11d0 <dtype_isvalid+0xc0>
jmp    11ae <dtype_isvalid+0x9e>
mov    -0x1c(%rbp),%eax
sub    $0x69,%eax
je     11d0 <dtype_isvalid+0xc0>
jmp    11bf <dtype_isvalid+0xaf>
mov    -0x1c(%rbp),%eax
sub    $0x75,%eax
jne    11d5 <dtype_isvalid+0xc5>
jmp    11d0 <dtype_isvalid+0xc0>
jmp    11e1 <dtype_isvalid+0xd1>
movl   $0x0,-0x4(%rbp)
jmp    1218 <dtype_isvalid+0x108>
mov    -0x10(%rbp),%rdi
add    $0x2,%rdi
call   1030 <atoi@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x10,-0x14(%rbp)
jg     1205 <dtype_isvalid+0xf5>
cmpl   $0x0,-0x14(%rbp)
jg     1211 <dtype_isvalid+0x101>
movl   $0x0,-0x4(%rbp)
jmp    1218 <dtype_isvalid+0x108>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dtype_isvalid>:
push   %rax
xor    %eax,%eax
test   %rdi,%rdi
je     115a <dtype_isvalid+0x4a>
movsbl (%rdi),%ecx
lea    -0x3c(%rcx),%edx
cmp    $0x3,%edx
jb     1128 <dtype_isvalid+0x18>
cmp    $0x7c,%ecx
jne    115a <dtype_isvalid+0x4a>
movsbl 0x1(%rdi),%ecx
add    $0xffffffad,%ecx
cmp    $0x22,%ecx
ja     115a <dtype_isvalid+0x4a>
movabs $0x400498001,%rdx
bt     %rcx,%rdx
jae    115a <dtype_isvalid+0x4a>
add    $0x2,%rdi
call   1030 <atoi@plt>
mov    %eax,%ecx
add    $0xffffffff,%ecx
xor    %eax,%eax
cmp    $0x10,%ecx
setb   %al
pop    %rcx
ret

LLVM IR (-O0):
define i32 @dtype_isvalid(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp ne i8* %5, null
br i1 %6, label %8, label %7
7: ; preds = %1
store i32 0, i32* %2
br label %33
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
switch i32 %12, label %14 [
i32 60, label %13
i32 62, label %13
i32 124, label %13
i32 61, label %13
]
13: ; preds = %8, %8, %8, %8
br label %15
14: ; preds = %8
store i32 0, i32* %2
br label %33
15: ; preds = %13
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
switch i32 %19, label %21 [
i32 83, label %20
i32 98, label %20
i32 105, label %20
i32 102, label %20
i32 117, label %20
i32 99, label %20
]
20: ; preds = %15, %15, %15, %15, %15, %15
br label %22
21: ; preds = %15
store i32 0, i32* %2
br label %33
22: ; preds = %20
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i64 2
%25 = call i32 @atoi(i8* %24)
store i32 %25, i32* %4
%26 = load i32, i32* %4
%27 = icmp sgt i32 %26, 16
br i1 %27, label %31, label %28
28: ; preds = %22
%29 = load i32, i32* %4
%30 = icmp sle i32 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %28, %22
store i32 0, i32* %2
br label %33
32: ; preds = %28
store i32 1, i32* %2
br label %33
33: ; preds = %32, %31, %21, %14, %7
%34 = load i32, i32* %2
ret i32 %34
}

LLVM IR (-O2):
define i32 @dtype_isvalid(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %16, label %3
3: ; preds = %1
%4 = load i8, i8* %0
%5 = sext i8 %4 to i32
switch i32 %5, label %16 [
i32 60, label %6
i32 62, label %6
i32 124, label %6
i32 61, label %6
]
6: ; preds = %3, %3, %3, %3
%7 = getelementptr inbounds i8, i8* %0, i64 1
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
switch i32 %9, label %16 [
i32 83, label %10
i32 98, label %10
i32 105, label %10
i32 102, label %10
i32 117, label %10
i32 99, label %10
]
10: ; preds = %6, %6, %6, %6, %6, %6
%11 = getelementptr inbounds i8, i8* %0, i64 2
%12 = tail call i32 @atoi(i8* %11)
%13 = add i32 %12, -1
%14 = icmp ult i32 %13, 16
%15 = zext i1 %14 to i32
br label %16
16: ; preds = %6, %3, %1, %10
%17 = phi i32 [ %15, %10 ], [ 0, %1 ], [ 0, %3 ], [ 0, %6 ]
ret i32 %17
}