#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 *);
int /*<<< orphan*/ stderr;
char *single_digit_oct_to_bin(char oct_dig) {
  switch (oct_dig) {
  case '0':
    return "000";
    break;
  case '1':
    return "001";
    break;
  case '2':
    return "010";
    break;
  case '3':
    return "011";
    break;
  case '4':
    return "100";
    break;
  case '5':
    return "101";
    break;
  case '6':
    return "110";
    break;
  case '7':
    return "111";
    break;
  default:
    fprintf(stderr,
            "you inputted a non-digit character in one of your number string");
    return "";
    break;
  }
}


x86 assembly (clang, -O0):
<single_digit_oct_to_bin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x9(%rbp)
movsbl -0x9(%rbp),%eax
add    $0xffffffd0,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x7,%eax
ja     11c8 <single_digit_oct_to_bin+0xb8>
mov    -0x18(%rbp),%rax
lea    0xec1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xed1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e8 <single_digit_oct_to_bin+0xd8>
lea    0xec5(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e8 <single_digit_oct_to_bin+0xd8>
lea    0xeb9(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e8 <single_digit_oct_to_bin+0xd8>
lea    0xead(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e8 <single_digit_oct_to_bin+0xd8>
lea    0xea1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e8 <single_digit_oct_to_bin+0xd8>
lea    0xe95(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e8 <single_digit_oct_to_bin+0xd8>
lea    0xe89(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e8 <single_digit_oct_to_bin+0xd8>
lea    0xe7d(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11e8 <single_digit_oct_to_bin+0xd8>
mov    0x2e11(%rip),%rax
mov    (%rax),%edi
lea    0xe68(%rip),%rsi
call   1030 <fprintf@plt>
lea    0xe3f(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<single_digit_oct_to_bin>:
push   %rax
add    $0xffffffd0,%edi
cmp    $0x8,%edi
jae    112c <single_digit_oct_to_bin+0x1c>
movslq %edi,%rax
lea    0xf3d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
pop    %rcx
ret
mov    0x2ead(%rip),%rax
mov    (%rax),%edi
lea    0xee4(%rip),%rsi
call   1030 <fprintf@plt>
lea    0xebb(%rip),%rax
pop    %rcx
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"
@stderr = global i32 0
@.str.8 = [64 x i8] c"you inputted a non-digit character in one of your number string\00"
@.str.9 = [1 x i8] zeroinitializer
define i8* @single_digit_oct_to_bin(i8 signext %0) {
%2 = alloca i8*
%3 = alloca i8
store i8 %0, i8* %3
%4 = load i8, i8* %3
%5 = sext i8 %4 to i32
switch i32 %5, label %14 [
i32 48, label %6
i32 49, label %7
i32 50, label %8
i32 51, label %9
i32 52, label %10
i32 53, label %11
i32 54, label %12
i32 55, label %13
]
6: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %2
br label %17
7: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %17
8: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %17
9: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %17
10: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %17
11: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8** %2
br label %17
12: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %17
13: ; preds = %1
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0), i8** %2
br label %17
14: ; preds = %1
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.8, i64 0, i64 0))
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %17
17: ; preds = %14, %13, %12, %11, %10, %9, %8, %7, %6
%18 = load i8*, i8** %2
ret i8* %18
}

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"
@stderr = global i32 0
@.str.8 = [64 x i8] c"you inputted a non-digit character in one of your number string\00"
@.str.9 = [1 x i8] zeroinitializer
@reltable.single_digit_oct_to_bin = [8 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str to i64), i64 ptrtoint ([8 x i32]* @reltable.single_digit_oct_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.1 to i64), i64 ptrtoint ([8 x i32]* @reltable.single_digit_oct_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.2 to i64), i64 ptrtoint ([8 x i32]* @reltable.single_digit_oct_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.3 to i64), i64 ptrtoint ([8 x i32]* @reltable.single_digit_oct_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.4 to i64), i64 ptrtoint ([8 x i32]* @reltable.single_digit_oct_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.5 to i64), i64 ptrtoint ([8 x i32]* @reltable.single_digit_oct_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.6 to i64), i64 ptrtoint ([8 x i32]* @reltable.single_digit_oct_to_bin to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.7 to i64), i64 ptrtoint ([8 x i32]* @reltable.single_digit_oct_to_bin to i64)) to i32)]
define i8* @single_digit_oct_to_bin(i8 signext %0) {
%2 = sext i8 %0 to i32
%3 = add nsw i32 %2, -48
%4 = icmp ult i32 %3, 8
br i1 %4, label %8, label %5
5: ; preds = %1
%6 = load i32, i32* @stderr
%7 = tail call i32 @fprintf(i32 %6, i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.8, i64 0, i64 0))
br label %12
8: ; preds = %1
%9 = sext i32 %3 to i64
%10 = shl i64 %9, 2
%11 = call i8* @llvm.load.relative.i64(i8* bitcast ([8 x i32]* @reltable.single_digit_oct_to_bin to i8*), i64 %10)
br label %12
12: ; preds = %8, %5
%13 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.9, i64 0, i64 0), %5 ], [ %11, %8 ]
ret i8* %13
}