#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*/ pdie(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
void make_filename(int type, char *inputname, char *outputname) {
  switch (type) {
  case 0:
    snprintf(outputname, 512, "%s.out", inputname);
    break;
  case 1:
    snprintf(outputname, 512, "%s.key", inputname);
    break;
  case 2:
    snprintf(outputname, 512, "%s.enc", inputname);
    break;
  case 3:
    snprintf(outputname, 512, "%s.dataskey", inputname);
    break;
  case 4:
    snprintf(outputname, 512, "%s.keyskey", inputname);
    break;
  default:
    pdie("Internal error");
  }
}


x86 assembly (clang, -O0):
<make_filename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x20(%rbp)
sub    $0x4,%rax
ja     11ee <make_filename+0xce>
mov    -0x20(%rbp),%rax
lea    0xeb1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x200,%esi
lea    0xea8(%rip),%rdx
call   1040 <snprintf@plt>
jmp    11fa <make_filename+0xda>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x200,%esi
lea    0xe91(%rip),%rdx
call   1040 <snprintf@plt>
jmp    11fa <make_filename+0xda>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x200,%esi
lea    0xe7a(%rip),%rdx
call   1040 <snprintf@plt>
jmp    11fa <make_filename+0xda>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x200,%esi
lea    0xe63(%rip),%rdx
call   1040 <snprintf@plt>
jmp    11fa <make_filename+0xda>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    $0x200,%esi
lea    0xe51(%rip),%rdx
call   1040 <snprintf@plt>
jmp    11fa <make_filename+0xda>
lea    0xe4b(%rip),%rdi
call   1030 <pdie@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<make_filename>:
cmp    $0x4,%edi
ja     1143 <make_filename+0x23>
mov    %rsi,%rcx
mov    %edi,%eax
lea    0xecf(%rip),%rsi
movslq (%rsi,%rax,4),%rax
add    %rsi,%rax
jmp    *%rax
lea    0xed3(%rip),%rax
jmp    1171 <make_filename+0x51>
lea    0xef6(%rip),%rdi
jmp    1030 <pdie@plt>
lea    0xec5(%rip),%rax
jmp    1171 <make_filename+0x51>
lea    0xec3(%rip),%rax
jmp    1171 <make_filename+0x51>
lea    0xec1(%rip),%rax
jmp    1171 <make_filename+0x51>
lea    0xec4(%rip),%rax
mov    %rdx,%rdi
mov    $0x200,%esi
mov    %rax,%rdx
jmp    1040 <snprintf@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"%s.out\00"
@.str.1 = [7 x i8] c"%s.key\00"
@.str.2 = [7 x i8] c"%s.enc\00"
@.str.3 = [12 x i8] c"%s.dataskey\00"
@.str.4 = [11 x i8] c"%s.keyskey\00"
@.str.5 = [15 x i8] c"Internal error\00"
define void @make_filename(i32 %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
store i32 %0, i32* %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = load i32, i32* %4
switch i32 %7, label %28 [
i32 0, label %8
i32 1, label %12
i32 2, label %16
i32 3, label %20
i32 4, label %24
]
8: ; preds = %3
%9 = load i8*, i8** %6
%10 = load i8*, i8** %5
%11 = call i32 @snprintf(i8* %9, i32 512, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %30
12: ; preds = %3
%13 = load i8*, i8** %6
%14 = load i8*, i8** %5
%15 = call i32 @snprintf(i8* %13, i32 512, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %14)
br label %30
16: ; preds = %3
%17 = load i8*, i8** %6
%18 = load i8*, i8** %5
%19 = call i32 @snprintf(i8* %17, i32 512, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %18)
br label %30
20: ; preds = %3
%21 = load i8*, i8** %6
%22 = load i8*, i8** %5
%23 = call i32 @snprintf(i8* %21, i32 512, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %22)
br label %30
24: ; preds = %3
%25 = load i8*, i8** %6
%26 = load i8*, i8** %5
%27 = call i32 @snprintf(i8* %25, i32 512, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %26)
br label %30
28: ; preds = %3
%29 = call i32 @pdie(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
br label %30
30: ; preds = %28, %24, %20, %16, %12, %8
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%s.out\00"
@.str.1 = [7 x i8] c"%s.key\00"
@.str.2 = [7 x i8] c"%s.enc\00"
@.str.3 = [12 x i8] c"%s.dataskey\00"
@.str.4 = [11 x i8] c"%s.keyskey\00"
@.str.5 = [15 x i8] c"Internal error\00"
define void @make_filename(i32 %0, i8* %1, i8* %2) {
switch i32 %0, label %14 [
i32 0, label %4
i32 1, label %6
i32 2, label %8
i32 3, label %10
i32 4, label %12
]
4: ; preds = %3
%5 = tail call i32 @snprintf(i8* %2, i32 512, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %16
6: ; preds = %3
%7 = tail call i32 @snprintf(i8* %2, i32 512, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %1)
br label %16
8: ; preds = %3
%9 = tail call i32 @snprintf(i8* %2, i32 512, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %1)
br label %16
10: ; preds = %3
%11 = tail call i32 @snprintf(i8* %2, i32 512, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* %1)
br label %16
12: ; preds = %3
%13 = tail call i32 @snprintf(i8* %2, i32 512, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %1)
br label %16
14: ; preds = %3
%15 = tail call i32 @pdie(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
br label %16
16: ; preds = %14, %12, %10, %8, %6, %4
ret void
}