#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*/ expand1(char *, char const *, char **, int);
int /*<<< orphan*/ expand2(char *, char const *, char **, int);
int /*<<< orphan*/ expand3(char *, char const *, char **, int);
int /*<<< orphan*/ expand4(char *, char const *, char **, int);
int /*<<< orphan*/ expand5(char *, char const *, char **, int);
void expand(char *str, const char *fmt, char **args, int len, int out) {
  switch (len) {
  case 1:
    expand1(str, fmt, args, out);
    break;
  case 2:
    expand2(str, fmt, args, out);
    break;
  case 3:
    expand3(str, fmt, args, out);
    break;
  case 4:
    expand4(str, fmt, args, out);
    break;
  case 5:
    expand5(str, fmt, args, out);
    break;
  default:
    break;
  }
}


x86 assembly (clang, -O0):
<expand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x4,%eax
ja     1211 <expand+0xc1>
mov    -0x28(%rbp),%rax
lea    0xe75(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%ecx
call   1050 <expand1@plt>
jmp    1216 <expand+0xc6>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%ecx
call   1030 <expand2@plt>
jmp    1216 <expand+0xc6>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%ecx
call   1060 <expand3@plt>
jmp    1216 <expand+0xc6>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%ecx
call   1040 <expand4@plt>
jmp    1216 <expand+0xc6>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%ecx
call   1070 <expand5@plt>
jmp    1216 <expand+0xc6>
jmp    1216 <expand+0xc6>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<expand>:
add    $0xffffffff,%ecx
cmp    $0x4,%ecx
ja     1170 <expand+0x20>
lea    0xea1(%rip),%rax
movslq (%rax,%rcx,4),%rcx
add    %rax,%rcx
jmp    *%rcx
mov    %r8d,%ecx
jmp    1050 <expand1@plt>
ret
mov    %r8d,%ecx
jmp    1030 <expand2@plt>
mov    %r8d,%ecx
jmp    1060 <expand3@plt>
mov    %r8d,%ecx
jmp    1040 <expand4@plt>
mov    %r8d,%ecx
jmp    1070 <expand5@plt>

LLVM IR (-O0):
define void @expand(i8* %0, i8* %1, i8** %2, i32 %3, i32 %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8**
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8** %2, i8*** %8
store i32 %3, i32* %9
store i32 %4, i32* %10
%11 = load i32, i32* %9
switch i32 %11, label %42 [
i32 1, label %12
i32 2, label %18
i32 3, label %24
i32 4, label %30
i32 5, label %36
]
12: ; preds = %5
%13 = load i8*, i8** %6
%14 = load i8*, i8** %7
%15 = load i8**, i8*** %8
%16 = load i32, i32* %10
%17 = call i32 @expand1(i8* %13, i8* %14, i8** %15, i32 %16)
br label %43
18: ; preds = %5
%19 = load i8*, i8** %6
%20 = load i8*, i8** %7
%21 = load i8**, i8*** %8
%22 = load i32, i32* %10
%23 = call i32 @expand2(i8* %19, i8* %20, i8** %21, i32 %22)
br label %43
24: ; preds = %5
%25 = load i8*, i8** %6
%26 = load i8*, i8** %7
%27 = load i8**, i8*** %8
%28 = load i32, i32* %10
%29 = call i32 @expand3(i8* %25, i8* %26, i8** %27, i32 %28)
br label %43
30: ; preds = %5
%31 = load i8*, i8** %6
%32 = load i8*, i8** %7
%33 = load i8**, i8*** %8
%34 = load i32, i32* %10
%35 = call i32 @expand4(i8* %31, i8* %32, i8** %33, i32 %34)
br label %43
36: ; preds = %5
%37 = load i8*, i8** %6
%38 = load i8*, i8** %7
%39 = load i8**, i8*** %8
%40 = load i32, i32* %10
%41 = call i32 @expand5(i8* %37, i8* %38, i8** %39, i32 %40)
br label %43
42: ; preds = %5
br label %43
43: ; preds = %42, %36, %30, %24, %18, %12
ret void
}

LLVM IR (-O2):
define void @expand(i8* %0, i8* %1, i8** %2, i32 %3, i32 %4) {
switch i32 %3, label %16 [
i32 1, label %6
i32 2, label %8
i32 3, label %10
i32 4, label %12
i32 5, label %14
]
6: ; preds = %5
%7 = tail call i32 @expand1(i8* %0, i8* %1, i8** %2, i32 %4)
br label %16
8: ; preds = %5
%9 = tail call i32 @expand2(i8* %0, i8* %1, i8** %2, i32 %4)
br label %16
10: ; preds = %5
%11 = tail call i32 @expand3(i8* %0, i8* %1, i8** %2, i32 %4)
br label %16
12: ; preds = %5
%13 = tail call i32 @expand4(i8* %0, i8* %1, i8** %2, i32 %4)
br label %16
14: ; preds = %5
%15 = tail call i32 @expand5(i8* %0, i8* %1, i8** %2, i32 %4)
br label %16
16: ; preds = %5, %14, %12, %10, %8, %6
ret void
}