#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 /*<<< orphan*/);
int is_valid_const_3vl(const char *c) {
  const char *p;
  char ch;
  assert(c != NULL);
  for (p = c; (ch = *p); p++)
    if (ch != '0' && ch != '1' && ch != 'x')
      return 0;
  return 1;
}


x86 assembly (clang, -O0):
<is_valid_const_3vl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x19(%rbp)
cmp    $0x0,%al
je     1190 <is_valid_const_3vl+0x80>
movsbl -0x19(%rbp),%eax
cmp    $0x30,%eax
je     117a <is_valid_const_3vl+0x6a>
movsbl -0x19(%rbp),%eax
cmp    $0x31,%eax
je     117a <is_valid_const_3vl+0x6a>
movsbl -0x19(%rbp),%eax
cmp    $0x78,%eax
je     117a <is_valid_const_3vl+0x6a>
movl   $0x0,-0x4(%rbp)
jmp    1197 <is_valid_const_3vl+0x87>
jmp    117f <is_valid_const_3vl+0x6f>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1136 <is_valid_const_3vl+0x26>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<is_valid_const_3vl>:
push   %rbx
mov    %rdi,%rbx
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1030 <assert@plt>
jmp    1134 <is_valid_const_3vl+0x24>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbx
movzbl (%rbx),%eax
lea    -0x30(%rax),%ecx
cmp    $0x2,%cl
jb     1130 <is_valid_const_3vl+0x20>
cmp    $0x78,%al
je     1130 <is_valid_const_3vl+0x20>
test   %al,%al
jne    114e <is_valid_const_3vl+0x3e>
mov    $0x1,%eax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @is_valid_const_3vl(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8
store i8* %0, i8** %3
%6 = load i8*, i8** %3
%7 = icmp ne i8* %6, null
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = load i8*, i8** %3
store i8* %10, i8** %4
br label %11
11: ; preds = %29, %1
%12 = load i8*, i8** %4
%13 = load i8, i8* %12
store i8 %13, i8* %5
%14 = icmp ne i8 %13, 0
br i1 %14, label %15, label %32
15: ; preds = %11
%16 = load i8, i8* %5
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %17, 48
br i1 %18, label %19, label %28
19: ; preds = %15
%20 = load i8, i8* %5
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 49
br i1 %22, label %23, label %28
23: ; preds = %19
%24 = load i8, i8* %5
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 120
br i1 %26, label %27, label %28
27: ; preds = %23
store i32 0, i32* %2
br label %33
28: ; preds = %23, %19, %15
br label %29
29: ; preds = %28
%30 = load i8*, i8** %4
%31 = getelementptr inbounds i8, i8* %30, i32 1
store i8* %31, i8** %4
br label %11
32: ; preds = %11
store i32 1, i32* %2
br label %33
33: ; preds = %32, %27
%34 = load i32, i32* %2
ret i32 %34
}

LLVM IR (-O2):
define i32 @is_valid_const_3vl(i8* %0) {
%2 = icmp ne i8* %0, null
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
br label %5
5: ; preds = %8, %1
%6 = phi i8* [ %0, %1 ], [ %9, %8 ]
%7 = load i8, i8* %6
switch i8 %7, label %11 [
i8 0, label %10
i8 120, label %8
i8 49, label %8
i8 48, label %8
]
8: ; preds = %5, %5, %5
%9 = getelementptr inbounds i8, i8* %6, i64 1
br label %5
10: ; preds = %5
br label %11
11: ; preds = %5, %10
%12 = phi i32 [ 1, %10 ], [ 0, %5 ]
ret i32 %12
}