#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*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ stderr;
unsigned int parseBinary(char *str) {
  unsigned int val = 0;
  if (*str == 'b') {
    str++;
    while (*str) {
      if (*str == '0') {
        val <<= 1;
      } else if (*str == '1') {
        val = (val << 1) + 1;
      } else {
        goto binaryError;
      }
    }
  }
  return val;
binaryError:
  fprintf(stderr, "Unrecognized numeric value: %s\n", str);
  return 999;
}


x86 assembly (clang, -O0):
<parseBinary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x62,%eax
jne    119f <parseBinary+0x8f>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
je     119a <parseBinary+0x8a>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jne    116a <parseBinary+0x5a>
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1195 <parseBinary+0x85>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x31,%eax
jne    118b <parseBinary+0x7b>
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1190 <parseBinary+0x80>
jmp    11aa <parseBinary+0x9a>
jmp    1195 <parseBinary+0x85>
jmp    113f <parseBinary+0x2f>
jmp    119f <parseBinary+0x8f>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ca <parseBinary+0xba>
mov    0x2e2f(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe42(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x3e7,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parseBinary>:
push   %rax
xor    %eax,%eax
cmpb   $0x62,(%rdi)
jne    1135 <parseBinary+0x25>
mov    %rdi,%rdx
movzbl 0x1(%rdi),%ecx
cmp    $0x31,%rcx
ja     1137 <parseBinary+0x27>
movabs $0x3000000000001,%rsi
bt     %rcx,%rsi
jae    1137 <parseBinary+0x27>
pop    %rcx
ret
add    $0x1,%rdx
mov    0x2e9e(%rip),%rax
mov    (%rax),%edi
lea    0xeb5(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x3e7,%eax
pop    %rcx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [32 x i8] c"Unrecognized numeric value: %s\0A\00"
define i32 @parseBinary(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 0, i32* %4
%5 = load i8*, i8** %3
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp eq i32 %7, 98
br i1 %8, label %9, label %37
9: ; preds = %1
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i32 1
store i8* %11, i8** %3
br label %12
12: ; preds = %35, %9
%13 = load i8*, i8** %3
%14 = load i8, i8* %13
%15 = icmp ne i8 %14, 0
br i1 %15, label %16, label %36
16: ; preds = %12
%17 = load i8*, i8** %3
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp eq i32 %19, 48
br i1 %20, label %21, label %24
21: ; preds = %16
%22 = load i32, i32* %4
%23 = shl i32 %22, 1
store i32 %23, i32* %4
br label %35
24: ; preds = %16
%25 = load i8*, i8** %3
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 49
br i1 %28, label %29, label %33
29: ; preds = %24
%30 = load i32, i32* %4
%31 = shl i32 %30, 1
%32 = add i32 %31, 1
store i32 %32, i32* %4
br label %34
33: ; preds = %24
br label %39
34: ; preds = %29
br label %35
35: ; preds = %34, %21
br label %12
36: ; preds = %12
br label %37
37: ; preds = %36, %1
%38 = load i32, i32* %4
store i32 %38, i32* %2
br label %43
39: ; preds = %33
%40 = load i32, i32* @stderr
%41 = load i8*, i8** %3
%42 = call i32 @fprintf(i32 %40, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %41)
store i32 999, i32* %2
br label %43
43: ; preds = %39, %37
%44 = load i32, i32* %2
ret i32 %44
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [32 x i8] c"Unrecognized numeric value: %s\0A\00"
define i32 @parseBinary(i8* %0) {
%2 = load i8, i8* %0
%3 = icmp eq i8 %2, 98
br i1 %3, label %4, label %10
4: ; preds = %1
%5 = getelementptr inbounds i8, i8* %0, i64 1
%6 = load i8, i8* %5
switch i8 %6, label %7 [
i8 0, label %10
i8 48, label %10
i8 49, label %10
]
7: ; preds = %4
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i8* %5)
br label %10
10: ; preds = %4, %4, %4, %1, %7
%11 = phi i32 [ 999, %7 ], [ 0, %1 ], [ 0, %4 ], [ 0, %4 ], [ 0, %4 ]
ret i32 %11
}