#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 */
unsigned int codec_base32_decode(unsigned char *, unsigned char *);
unsigned int codec_base64_decode(unsigned char *, unsigned char *);
unsigned int codec_binary_decode(unsigned char *, unsigned int,
                                 unsigned char *);
int /*<<< orphan*/ error(char *, unsigned char);
unsigned int codec_decode(unsigned char codec, unsigned char *input,
                          unsigned int in_len, unsigned char *output) {
  unsigned int ret = 0;
  switch (codec) {
  case 0x0:
    ret = codec_base32_decode(input, output);
    break;
  case 0x2:
    ret = codec_base64_decode(input, output);
    break;
  case 0x1:
    ret = codec_binary_decode(input, in_len, output);
    break;
  default:
    error("unknown codec: %.2x\n", codec);
  }
  return ret;
}


x86 assembly (clang, -O0):
<codec_decode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movzbl -0x1(%rbp),%eax
mov    %eax,-0x28(%rbp)
test   %eax,%eax
je     1196 <codec_decode+0x56>
jmp    1174 <codec_decode+0x34>
mov    -0x28(%rbp),%eax
sub    $0x1,%eax
je     11c0 <codec_decode+0x80>
jmp    1185 <codec_decode+0x45>
mov    -0x28(%rbp),%eax
sub    $0x2,%eax
je     11ab <codec_decode+0x6b>
jmp    11d8 <codec_decode+0x98>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <codec_base32_decode@plt>
mov    %eax,-0x24(%rbp)
jmp    11e8 <codec_decode+0xa8>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <codec_base64_decode@plt>
mov    %eax,-0x24(%rbp)
jmp    11e8 <codec_decode+0xa8>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
call   1030 <codec_binary_decode@plt>
mov    %eax,-0x24(%rbp)
jmp    11e8 <codec_decode+0xa8>
lea    0xe21(%rip),%rdi
movzbl -0x1(%rbp),%esi
call   1050 <error@plt>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<codec_decode>:
cmp    $0x2,%dil
je     115c <codec_decode+0x1c>
cmp    $0x1,%dil
je     1167 <codec_decode+0x27>
test   %dil,%dil
jne    1174 <codec_decode+0x34>
mov    %rsi,%rdi
mov    %rcx,%rsi
jmp    1060 <codec_base32_decode@plt>
mov    %rsi,%rdi
mov    %rcx,%rsi
jmp    1040 <codec_base64_decode@plt>
mov    %rsi,%rdi
mov    %edx,%esi
mov    %rcx,%rdx
jmp    1030 <codec_binary_decode@plt>
push   %rax
movzbl %dil,%esi
lea    0xe80(%rip),%rdi
call   1050 <error@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [21 x i8] c"unknown codec: %.2x\0A\00"
define i32 @codec_decode(i8 zeroext %0, i8* %1, i32 %2, i8* %3) {
%5 = alloca i8
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
store i8 %0, i8* %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i8* %3, i8** %8
store i32 0, i32* %9
%10 = load i8, i8* %5
%11 = zext i8 %10 to i32
switch i32 %11, label %25 [
i32 0, label %12
i32 2, label %16
i32 1, label %20
]
12: ; preds = %4
%13 = load i8*, i8** %6
%14 = load i8*, i8** %8
%15 = call i32 @codec_base32_decode(i8* %13, i8* %14)
store i32 %15, i32* %9
br label %28
16: ; preds = %4
%17 = load i8*, i8** %6
%18 = load i8*, i8** %8
%19 = call i32 @codec_base64_decode(i8* %17, i8* %18)
store i32 %19, i32* %9
br label %28
20: ; preds = %4
%21 = load i8*, i8** %6
%22 = load i32, i32* %7
%23 = load i8*, i8** %8
%24 = call i32 @codec_binary_decode(i8* %21, i32 %22, i8* %23)
store i32 %24, i32* %9
br label %28
25: ; preds = %4
%26 = load i8, i8* %5
%27 = call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8 zeroext %26)
br label %28
28: ; preds = %25, %20, %16, %12
%29 = load i32, i32* %9
ret i32 %29
}

LLVM IR (-O2):
@.str = [21 x i8] c"unknown codec: %.2x\0A\00"
define i32 @codec_decode(i8 zeroext %0, i8* %1, i32 %2, i8* %3) {
switch i8 %0, label %11 [
i8 0, label %5
i8 2, label %7
i8 1, label %9
]
5: ; preds = %4
%6 = tail call i32 @codec_base32_decode(i8* %1, i8* %3)
br label %13
7: ; preds = %4
%8 = tail call i32 @codec_base64_decode(i8* %1, i8* %3)
br label %13
9: ; preds = %4
%10 = tail call i32 @codec_binary_decode(i8* %1, i32 %2, i8* %3)
br label %13
11: ; preds = %4
%12 = tail call i32 @error(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8 zeroext %0)
br label %13
13: ; preds = %11, %9, %7, %5
%14 = phi i32 [ 0, %11 ], [ %10, %9 ], [ %8, %7 ], [ %6, %5 ]
ret i32 %14
}