#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 */
struct section {
  int dummy;
};
struct keyword {
  int dummy;
};
struct config {
  int dummy;
};

/* Variables and functions */
short cfg_get_type(int, char *, char *);
char *cfg_get_type_str(int indx, char *section, char *keyword) {
  struct config *ptr;
  struct section *sp;
  struct keyword *kp;
  short type;
  type = cfg_get_type(indx, section, keyword);
  switch (type) {
  case 1:
    return ("scalar");
  case 2:
    return ("array");
  case 3:
    return ("hash");
  default:
    return ("unknown");
  }
}


x86 assembly (clang, -O0):
<cfg_get_type_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <cfg_get_type@plt>
mov    %ax,-0x3a(%rbp)
movswl -0x3a(%rbp),%eax
mov    %eax,-0x40(%rbp)
sub    $0x1,%eax
je     116e <cfg_get_type_str+0x5e>
jmp    114c <cfg_get_type_str+0x3c>
mov    -0x40(%rbp),%eax
sub    $0x2,%eax
je     117e <cfg_get_type_str+0x6e>
jmp    115d <cfg_get_type_str+0x4d>
mov    -0x40(%rbp),%eax
sub    $0x3,%eax
je     118e <cfg_get_type_str+0x7e>
jmp    119e <cfg_get_type_str+0x8e>
lea    0xe8b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11a9 <cfg_get_type_str+0x99>
lea    0xe82(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11a9 <cfg_get_type_str+0x99>
lea    0xe78(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11a9 <cfg_get_type_str+0x99>
lea    0xe6d(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cfg_get_type_str>:
push   %rax
call   1030 <cfg_get_type@plt>
cwtl
add    $0xffffffff,%eax
cmp    $0x2,%eax
ja     1131 <cfg_get_type_str+0x21>
cltq
lea    0xef4(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
pop    %rcx
ret
lea    0xeda(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
%struct.config = type { i32 }
%struct.section = type { i32 }
%struct.keyword = type { i32 }
@.str = [7 x i8] c"scalar\00"
@.str.1 = [6 x i8] c"array\00"
@.str.2 = [5 x i8] c"hash\00"
@.str.3 = [8 x i8] c"unknown\00"
define i8* @cfg_get_type_str(i32 %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca %struct.config*
%9 = alloca %struct.section*
%10 = alloca %struct.keyword*
%11 = alloca i16
store i32 %0, i32* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%12 = load i32, i32* %5
%13 = load i8*, i8** %6
%14 = load i8*, i8** %7
%15 = call signext i16 @cfg_get_type(i32 %12, i8* %13, i8* %14)
store i16 %15, i16* %11
%16 = load i16, i16* %11
%17 = sext i16 %16 to i32
switch i32 %17, label %21 [
i32 1, label %18
i32 2, label %19
i32 3, label %20
]
18: ; preds = %3
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %4
br label %22
19: ; preds = %3
store i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8** %4
br label %22
20: ; preds = %3
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %4
br label %22
21: ; preds = %3
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i8** %4
br label %22
22: ; preds = %21, %20, %19, %18
%23 = load i8*, i8** %4
ret i8* %23
}

LLVM IR (-O2):
%struct.config = type { i32 }
%struct.section = type { i32 }
%struct.keyword = type { i32 }
@.str = [7 x i8] c"scalar\00"
@.str.1 = [6 x i8] c"array\00"
@.str.2 = [5 x i8] c"hash\00"
@.str.3 = [8 x i8] c"unknown\00"
@reltable.cfg_get_type_str = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str to i64), i64 ptrtoint ([3 x i32]* @reltable.cfg_get_type_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.1 to i64), i64 ptrtoint ([3 x i32]* @reltable.cfg_get_type_str to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([5 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.cfg_get_type_str to i64)) to i32)]
define i8* @cfg_get_type_str(i32 %0, i8* %1, i8* %2) {
%4 = tail call signext i16 @cfg_get_type(i32 %0, i8* %1, i8* %2)
%5 = sext i16 %4 to i32
%6 = add nsw i32 %5, -1
%7 = icmp ult i32 %6, 3
br i1 %7, label %8, label %12
8: ; preds = %3
%9 = sext i32 %6 to i64
%10 = shl i64 %9, 2
%11 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.cfg_get_type_str to i8*), i64 %10)
br label %12
12: ; preds = %3, %8
%13 = phi i8* [ %11, %8 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), %3 ]
ret i8* %13
}