#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 */
char *expand8to16(char);
char *expand8to16NoCopy(char);
char *expand8to32(char);
char *expand(char c, int mode) {
  switch (mode) {
  case 0:
    return expand8to16NoCopy(c);
    break;
  case 1:
    return expand8to16(c);
    break;
  case 2:
    return expand8to32(c);
    break;
  default:
    return expand8to16NoCopy(c);
    break;
  }
}


x86 assembly (clang, -O0):
<expand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x9(%rbp)
mov    %esi,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
test   %eax,%eax
je     1176 <expand+0x46>
jmp    1154 <expand+0x24>
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
je     1188 <expand+0x58>
jmp    1165 <expand+0x35>
mov    -0x14(%rbp),%eax
sub    $0x2,%eax
je     119a <expand+0x6a>
jmp    11ac <expand+0x7c>
movsbl -0x9(%rbp),%edi
call   1040 <expand8to16NoCopy@plt>
mov    %rax,-0x8(%rbp)
jmp    11b9 <expand+0x89>
movsbl -0x9(%rbp),%edi
call   1050 <expand8to16@plt>
mov    %rax,-0x8(%rbp)
jmp    11b9 <expand+0x89>
movsbl -0x9(%rbp),%edi
call   1030 <expand8to32@plt>
mov    %rax,-0x8(%rbp)
jmp    11b9 <expand+0x89>
movsbl -0x9(%rbp),%edi
call   1040 <expand8to16NoCopy@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<expand>:
movsbl %dil,%edi
cmp    $0x2,%esi
je     1145 <expand+0x15>
cmp    $0x1,%esi
je     114a <expand+0x1a>
test   %esi,%esi
jmp    1040 <expand8to16NoCopy@plt>
jmp    1030 <expand8to32@plt>
jmp    1050 <expand8to16@plt>

LLVM IR (-O0):
define i8* @expand(i8 signext %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i8
%5 = alloca i32
store i8 %0, i8* %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
switch i32 %6, label %16 [
i32 0, label %7
i32 1, label %10
i32 2, label %13
]
7: ; preds = %2
%8 = load i8, i8* %4
%9 = call i8* @expand8to16NoCopy(i8 signext %8)
store i8* %9, i8** %3
br label %19
10: ; preds = %2
%11 = load i8, i8* %4
%12 = call i8* @expand8to16(i8 signext %11)
store i8* %12, i8** %3
br label %19
13: ; preds = %2
%14 = load i8, i8* %4
%15 = call i8* @expand8to32(i8 signext %14)
store i8* %15, i8** %3
br label %19
16: ; preds = %2
%17 = load i8, i8* %4
%18 = call i8* @expand8to16NoCopy(i8 signext %17)
store i8* %18, i8** %3
br label %19
19: ; preds = %16, %13, %10, %7
%20 = load i8*, i8** %3
ret i8* %20
}

LLVM IR (-O2):
define i8* @expand(i8 signext %0, i32 %1) {
switch i32 %1, label %9 [
i32 0, label %3
i32 1, label %5
i32 2, label %7
]
3: ; preds = %2
%4 = tail call i8* @expand8to16NoCopy(i8 signext %0)
br label %11
5: ; preds = %2
%6 = tail call i8* @expand8to16(i8 signext %0)
br label %11
7: ; preds = %2
%8 = tail call i8* @expand8to32(i8 signext %0)
br label %11
9: ; preds = %2
%10 = tail call i8* @expand8to16NoCopy(i8 signext %0)
br label %11
11: ; preds = %9, %7, %5, %3
%12 = phi i8* [ %10, %9 ], [ %8, %7 ], [ %6, %5 ], [ %4, %3 ]
ret i8* %12
}