#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*/ abort();
const char *digitset(unsigned base, int caps) {
  switch (base) {
  case 2:
    return "01";
  case 8:
    return "01234567";
  case 10:
    return "0123456789";
  case 16:
    return caps ? "0123456789ABCDEF" : "0123456789abcdef";
  default:
    abort();
    return NULL;
  }
}


x86 assembly (clang, -O0):
<digitset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0xfffffffe,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0xe,%eax
ja     1198 <digitset+0x88>
mov    -0x18(%rbp),%rax
lea    0xec2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeee(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119f <digitset+0x8f>
lea    0xee1(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119f <digitset+0x8f>
lea    0xeda(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    119f <digitset+0x8f>
mov    -0x10(%rbp),%edx
lea    0xee3(%rip),%rax
lea    0xecb(%rip),%rcx
cmp    $0x0,%edx
cmovne %rcx,%rax
mov    %rax,-0x8(%rbp)
jmp    119f <digitset+0x8f>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<digitset>:
push   %rax
add    $0xfffffffe,%edi
ror    %edi
cmp    $0x7,%edi
ja     115a <digitset+0x4a>
lea    0xefe(%rip),%rax
lea    0xed7(%rip),%rcx
movslq (%rcx,%rdi,4),%rdx
add    %rcx,%rdx
jmp    *%rdx
lea    0xeea(%rip),%rax
pop    %rcx
ret
lea    0xeea(%rip),%rax
pop    %rcx
ret
test   %esi,%esi
lea    0xefb(%rip),%rcx
lea    0xee3(%rip),%rax
cmove  %rcx,%rax
pop    %rcx
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"01\00"
@.str.1 = [9 x i8] c"01234567\00"
@.str.2 = [11 x i8] c"0123456789\00"
@.str.3 = [17 x i8] c"0123456789ABCDEF\00"
@.str.4 = [17 x i8] c"0123456789abcdef\00"
define i8* @digitset(i32 %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %4
switch i32 %6, label %15 [
i32 2, label %7
i32 8, label %8
i32 10, label %9
i32 16, label %10
]
7: ; preds = %2
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %3
br label %17
8: ; preds = %2
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8** %3
br label %17
9: ; preds = %2
store i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i8** %3
br label %17
10: ; preds = %2
%11 = load i32, i32* %5
%12 = icmp ne i32 %11, 0
%13 = zext i1 %12 to i64
%14 = select i1 %12, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0)
store i8* %14, i8** %3
br label %17
15: ; preds = %2
%16 = call i32 (...) @abort()
unreachable
17: ; preds = %10, %9, %8, %7
%18 = load i8*, i8** %3
ret i8* %18
}

LLVM IR (-O2):
@.str = [3 x i8] c"01\00"
@.str.1 = [9 x i8] c"01234567\00"
@.str.2 = [11 x i8] c"0123456789\00"
@.str.3 = [17 x i8] c"0123456789ABCDEF\00"
@.str.4 = [17 x i8] c"0123456789abcdef\00"
define i8* @digitset(i32 %0, i32 %1) {
%3 = add i32 %0, -2
%4 = tail call i32 @llvm.fshl.i32(i32 %3, i32 %3, i32 31)
switch i32 %4, label %10 [
i32 0, label %12
i32 3, label %5
i32 4, label %6
i32 7, label %7
]
5: ; preds = %2
br label %12
6: ; preds = %2
br label %12
7: ; preds = %2
%8 = icmp eq i32 %1, 0
%9 = select i1 %8, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0)
br label %12
10: ; preds = %2
%11 = tail call i32 (...) @abort()
unreachable
12: ; preds = %2, %7, %6, %5
%13 = phi i8* [ %9, %7 ], [ getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), %6 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), %5 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %2 ]
ret i8* %13
}