#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*/ isBinDigit(char const);
int strlen(char const *);
char tolower(char const);
int isBinNumber(const char *numero) {
  int longitud = strlen(numero);
  if (longitud >= 3 && numero[0] == '0' && tolower(numero[1]) == 'b') {
    int i;
    for (i = 2; i < longitud; i++) {
      if (!isBinDigit(numero[i]))
        return 0;
    }
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<isBinNumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jl     11d3 <isBinNumber+0xa3>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jne    11d3 <isBinNumber+0xa3>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1050 <tolower@plt>
movsbl %al,%eax
cmp    $0x62,%eax
jne    11d3 <isBinNumber+0xa3>
movl   $0x2,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11c7 <isBinNumber+0x97>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <isBinDigit@plt>
cmp    $0x0,%eax
jne    11b4 <isBinNumber+0x84>
movl   $0x0,-0x4(%rbp)
jmp    11da <isBinNumber+0xaa>
jmp    11b9 <isBinNumber+0x89>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1182 <isBinNumber+0x52>
movl   $0x1,-0x4(%rbp)
jmp    11da <isBinNumber+0xaa>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<isBinNumber>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <strlen@plt>
xor    %r14d,%r14d
cmp    $0x3,%eax
jl     118c <isBinNumber+0x5c>
cmpb   $0x30,(%rbx)
jne    118c <isBinNumber+0x5c>
mov    %eax,%ebp
movsbl 0x1(%rbx),%edi
call   1050 <tolower@plt>
cmp    $0x62,%al
jne    118c <isBinNumber+0x5c>
mov    %ebp,%r15d
mov    $0x2,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl (%rbx,%rbp,1),%edi
call   1040 <isBinDigit@plt>
test   %eax,%eax
je     118c <isBinNumber+0x5c>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    1170 <isBinNumber+0x40>
mov    $0x1,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @isBinNumber(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 2
br i1 %3, label %4, label %23
4: ; preds = %1
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 48
br i1 %6, label %7, label %23
7: ; preds = %4
%8 = getelementptr inbounds i8, i8* %0, i64 1
%9 = load i8, i8* %8
%10 = tail call signext i8 @tolower(i8 signext %9)
%11 = icmp eq i8 %10, 98
br i1 %11, label %12, label %23
12: ; preds = %7
%13 = zext i32 %2 to i64
br label %16
14: ; preds = %16
%15 = icmp eq i64 %22, %13
br i1 %15, label %23, label %16
16: ; preds = %12, %14
%17 = phi i64 [ 2, %12 ], [ %22, %14 ]
%18 = getelementptr inbounds i8, i8* %0, i64 %17
%19 = load i8, i8* %18
%20 = tail call i32 @isBinDigit(i8 signext %19)
%21 = icmp eq i32 %20, 0
%22 = add nuw nsw i64 %17, 1
br i1 %21, label %23, label %14
23: ; preds = %14, %16, %1, %4, %7
%24 = phi i32 [ 0, %7 ], [ 0, %4 ], [ 0, %1 ], [ 1, %14 ], [ 0, %16 ]
ret i32 %24
}