#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*/ strcmp(char *, char *);
char to_decimal(char *binary) {
  if (!strcmp("000", binary))
    return '0';
  if (!strcmp("001", binary))
    return '1';
  if (!strcmp("010", binary))
    return '2';
  if (!strcmp("011", binary))
    return '3';
  if (!strcmp("100", binary))
    return '4';
  if (!strcmp("101", binary))
    return '5';
  if (!strcmp("110", binary))
    return '6';
  if (!strcmp("111", binary))
    return '7';
  return '-';
}


x86 assembly (clang, -O0):
<to_decimal>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xed9(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    113e <to_decimal+0x2e>
movb   $0x30,-0x1(%rbp)
jmp    1230 <to_decimal+0x120>
mov    -0x10(%rbp),%rsi
lea    0xebb(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1160 <to_decimal+0x50>
movb   $0x31,-0x1(%rbp)
jmp    1230 <to_decimal+0x120>
mov    -0x10(%rbp),%rsi
lea    0xe9d(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    1182 <to_decimal+0x72>
movb   $0x32,-0x1(%rbp)
jmp    1230 <to_decimal+0x120>
mov    -0x10(%rbp),%rsi
lea    0xe7f(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11a4 <to_decimal+0x94>
movb   $0x33,-0x1(%rbp)
jmp    1230 <to_decimal+0x120>
mov    -0x10(%rbp),%rsi
lea    0xe61(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11c6 <to_decimal+0xb6>
movb   $0x34,-0x1(%rbp)
jmp    1230 <to_decimal+0x120>
mov    -0x10(%rbp),%rsi
lea    0xe43(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11e8 <to_decimal+0xd8>
movb   $0x35,-0x1(%rbp)
jmp    1230 <to_decimal+0x120>
mov    -0x10(%rbp),%rsi
lea    0xe25(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    120a <to_decimal+0xfa>
movb   $0x36,-0x1(%rbp)
jmp    1230 <to_decimal+0x120>
mov    -0x10(%rbp),%rsi
lea    0xe07(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    122c <to_decimal+0x11c>
movb   $0x37,-0x1(%rbp)
jmp    1230 <to_decimal+0x120>
movb   $0x2d,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<to_decimal>:
push   %rbx
mov    %rdi,%rbx
lea    0xee5(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11c1 <to_decimal+0xb1>
lea    0xed2(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11c5 <to_decimal+0xb5>
lea    0xebf(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11c9 <to_decimal+0xb9>
lea    0xeb0(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11cd <to_decimal+0xbd>
lea    0xea1(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11d1 <to_decimal+0xc1>
lea    0xe92(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11d5 <to_decimal+0xc5>
lea    0xe83(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
je     11d9 <to_decimal+0xc9>
lea    0xe74(%rip),%rdi
mov    %rbx,%rsi
call   1030 <strcmp@plt>
test   %eax,%eax
mov    $0x37,%ecx
mov    $0x2d,%eax
cmove  %ecx,%eax
pop    %rbx
ret
mov    $0x30,%al
pop    %rbx
ret
mov    $0x31,%al
pop    %rbx
ret
mov    $0x32,%al
pop    %rbx
ret
mov    $0x33,%al
pop    %rbx
ret
mov    $0x34,%al
pop    %rbx
ret
mov    $0x35,%al
pop    %rbx
ret
mov    $0x36,%al
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"000\00"
@.str.1 = [4 x i8] c"001\00"
@.str.2 = [4 x i8] c"010\00"
@.str.3 = [4 x i8] c"011\00"
@.str.4 = [4 x i8] c"100\00"
@.str.5 = [4 x i8] c"101\00"
@.str.6 = [4 x i8] c"110\00"
@.str.7 = [4 x i8] c"111\00"
define signext i8 @to_decimal(i8* %0) {
%2 = alloca i8
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i32 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %4)
%6 = icmp ne i32 %5, 0
br i1 %6, label %8, label %7
7: ; preds = %1
store i8 48, i8* %2
br label %44
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i32 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%11 = icmp ne i32 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %8
store i8 49, i8* %2
br label %44
13: ; preds = %8
%14 = load i8*, i8** %3
%15 = call i32 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %13
store i8 50, i8* %2
br label %44
18: ; preds = %13
%19 = load i8*, i8** %3
%20 = call i32 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %18
store i8 51, i8* %2
br label %44
23: ; preds = %18
%24 = load i8*, i8** %3
%25 = call i32 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %24)
%26 = icmp ne i32 %25, 0
br i1 %26, label %28, label %27
27: ; preds = %23
store i8 52, i8* %2
br label %44
28: ; preds = %23
%29 = load i8*, i8** %3
%30 = call i32 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %29)
%31 = icmp ne i32 %30, 0
br i1 %31, label %33, label %32
32: ; preds = %28
store i8 53, i8* %2
br label %44
33: ; preds = %28
%34 = load i8*, i8** %3
%35 = call i32 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %34)
%36 = icmp ne i32 %35, 0
br i1 %36, label %38, label %37
37: ; preds = %33
store i8 54, i8* %2
br label %44
38: ; preds = %33
%39 = load i8*, i8** %3
%40 = call i32 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* %39)
%41 = icmp ne i32 %40, 0
br i1 %41, label %43, label %42
42: ; preds = %38
store i8 55, i8* %2
br label %44
43: ; preds = %38
store i8 45, i8* %2
br label %44
44: ; preds = %43, %42, %37, %32, %27, %22, %17, %12, %7
%45 = load i8, i8* %2
ret i8 %45
}

LLVM IR (-O2):
@.str = [4 x i8] c"000\00"
@.str.1 = [4 x i8] c"001\00"
@.str.2 = [4 x i8] c"010\00"
@.str.3 = [4 x i8] c"011\00"
@.str.4 = [4 x i8] c"100\00"
@.str.5 = [4 x i8] c"101\00"
@.str.6 = [4 x i8] c"110\00"
@.str.7 = [4 x i8] c"111\00"
define signext i8 @to_decimal(i8* nocapture %0) {
%2 = tail call i32 @strcmp(i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* dereferenceable(1) %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %26, label %4
4: ; preds = %1
%5 = tail call i32 @strcmp(i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* dereferenceable(1) %0)
%6 = icmp eq i32 %5, 0
br i1 %6, label %26, label %7
7: ; preds = %4
%8 = tail call i32 @strcmp(i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* dereferenceable(1) %0)
%9 = icmp eq i32 %8, 0
br i1 %9, label %26, label %10
10: ; preds = %7
%11 = tail call i32 @strcmp(i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* dereferenceable(1) %0)
%12 = icmp eq i32 %11, 0
br i1 %12, label %26, label %13
13: ; preds = %10
%14 = tail call i32 @strcmp(i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* dereferenceable(1) %0)
%15 = icmp eq i32 %14, 0
br i1 %15, label %26, label %16
16: ; preds = %13
%17 = tail call i32 @strcmp(i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* dereferenceable(1) %0)
%18 = icmp eq i32 %17, 0
br i1 %18, label %26, label %19
19: ; preds = %16
%20 = tail call i32 @strcmp(i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* dereferenceable(1) %0)
%21 = icmp eq i32 %20, 0
br i1 %21, label %26, label %22
22: ; preds = %19
%23 = tail call i32 @strcmp(i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8* dereferenceable(1) %0)
%24 = icmp eq i32 %23, 0
%25 = select i1 %24, i8 55, i8 45
br label %26
26: ; preds = %22, %19, %16, %13, %10, %7, %4, %1
%27 = phi i8 [ 48, %1 ], [ 49, %4 ], [ 50, %7 ], [ 51, %10 ], [ 52, %13 ], [ 53, %16 ], [ 54, %19 ], [ %25, %22 ]
ret i8 %27
}