#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 strlen(char *);
int device_isValid_md_id(char *md_id) {
  int type;
  if (strlen(md_id) != 7)
    return 0;
  type = (((md_id[0] - 48) * 100) + ((md_id[1] - 48) * 10) + (md_id[2] - 48));
  if (type < 0 || type > 255 || type >= 28)
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<device_isValid_md_id>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x7,%eax
je     113a <device_isValid_md_id+0x2a>
movl   $0x0,-0x4(%rbp)
jmp    119b <device_isValid_md_id+0x8b>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
sub    $0x30,%eax
imul   $0x64,%eax,%eax
mov    -0x10(%rbp),%rcx
movsbl 0x1(%rcx),%ecx
sub    $0x30,%ecx
imul   $0xa,%ecx,%ecx
add    %ecx,%eax
mov    -0x10(%rbp),%rcx
movsbl 0x2(%rcx),%ecx
sub    $0x30,%ecx
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     1188 <device_isValid_md_id+0x78>
cmpl   $0xff,-0x14(%rbp)
jg     1188 <device_isValid_md_id+0x78>
cmpl   $0x1c,-0x14(%rbp)
jl     1194 <device_isValid_md_id+0x84>
movl   $0x0,-0x4(%rbp)
jmp    119b <device_isValid_md_id+0x8b>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<device_isValid_md_id>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x7,%ecx
jne    1147 <device_isValid_md_id+0x37>
movsbl (%rbx),%eax
imul   $0x64,%eax,%eax
movsbl 0x1(%rbx),%ecx
lea    (%rcx,%rcx,4),%ecx
movsbl 0x2(%rbx),%edx
lea    (%rax,%rcx,2),%eax
lea    (%rdx,%rax,1),%ecx
add    $0xffffeb30,%ecx
xor    %eax,%eax
cmp    $0x1c,%ecx
setb   %al
pop    %rbx
ret

LLVM IR (-O0):
define i32 @device_isValid_md_id(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @strlen(i8* %5)
%7 = icmp ne i32 %6, 7
br i1 %7, label %8, label %9
8: ; preds = %1
store i32 0, i32* %2
br label %39
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = sub nsw i32 %13, 48
%15 = mul nsw i32 %14, 100
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = sub nsw i32 %19, 48
%21 = mul nsw i32 %20, 10
%22 = add nsw i32 %15, %21
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i64 2
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = sub nsw i32 %26, 48
%28 = add nsw i32 %22, %27
store i32 %28, i32* %4
%29 = load i32, i32* %4
%30 = icmp slt i32 %29, 0
br i1 %30, label %37, label %31
31: ; preds = %9
%32 = load i32, i32* %4
%33 = icmp sgt i32 %32, 255
br i1 %33, label %37, label %34
34: ; preds = %31
%35 = load i32, i32* %4
%36 = icmp sge i32 %35, 28
br i1 %36, label %37, label %38
37: ; preds = %34, %31, %9
store i32 0, i32* %2
br label %39
38: ; preds = %34
store i32 1, i32* %2
br label %39
39: ; preds = %38, %37, %8
%40 = load i32, i32* %2
ret i32 %40
}

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