#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 strcmp(char *, char *);
int bitToDecimal(char *bit) {
  int test = strcmp(bit, "00");
  if (!strcmp(bit, "00")) {
    return 0;
  } else if (!strcmp(bit, "01")) {
    return 1;
  } else if (!strcmp(bit, "10")) {
    return 2;
  } else {
    return 3;
  }
}


x86 assembly (clang, -O0):
<bitToDecimal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xed9(%rip),%rsi
call   1030 <strcmp@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xec6(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1154 <bitToDecimal+0x44>
movl   $0x0,-0x4(%rbp)
jmp    11a5 <bitToDecimal+0x95>
mov    -0x10(%rbp),%rdi
lea    0xea4(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1179 <bitToDecimal+0x69>
movl   $0x1,-0x4(%rbp)
jmp    11a5 <bitToDecimal+0x95>
mov    -0x10(%rbp),%rdi
lea    0xe82(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    119e <bitToDecimal+0x8e>
movl   $0x2,-0x4(%rbp)
jmp    11a5 <bitToDecimal+0x95>
movl   $0x3,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bitToDecimal>:
push   %rbx
mov    %rdi,%rbx
lea    0xee5(%rip),%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1153 <bitToDecimal+0x43>
lea    0xed8(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1157 <bitToDecimal+0x47>
lea    0xec8(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
cmp    $0x1,%eax
mov    $0x3,%eax
sbb    $0x0,%eax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"00\00"
@.str.1 = [3 x i8] c"01\00"
@.str.2 = [3 x i8] c"10\00"
define i32 @bitToDecimal(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = call i32 @strcmp(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %6, i32* %4
%7 = load i8*, i8** %3
%8 = call i32 @strcmp(i8* %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%9 = icmp ne i32 %8, 0
br i1 %9, label %11, label %10
10: ; preds = %1
store i32 0, i32* %2
br label %22
11: ; preds = %1
%12 = load i8*, i8** %3
%13 = call i32 @strcmp(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp ne i32 %13, 0
br i1 %14, label %16, label %15
15: ; preds = %11
store i32 1, i32* %2
br label %22
16: ; preds = %11
%17 = load i8*, i8** %3
%18 = call i32 @strcmp(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp ne i32 %18, 0
br i1 %19, label %21, label %20
20: ; preds = %16
store i32 2, i32* %2
br label %22
21: ; preds = %16
store i32 3, i32* %2
br label %22
22: ; preds = %21, %20, %15, %10
%23 = load i32, i32* %2
ret i32 %23
}

LLVM IR (-O2):
@.str = [3 x i8] c"00\00"
@.str.1 = [3 x i8] c"01\00"
@.str.2 = [3 x i8] c"10\00"
define i32 @bitToDecimal(i8* nocapture %0) {
%2 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %2, 0
br i1 %3, label %11, label %4
4: ; preds = %1
%5 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %4
%8 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
%10 = select i1 %9, i32 2, i32 3
br label %11
11: ; preds = %7, %4, %1
%12 = phi i32 [ 0, %1 ], [ 1, %4 ], [ %10, %7 ]
ret i32 %12
}