#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*/ strncpy(char *, char *, size_t);
extern void hashmap_error(int error, char *buffer, size_t buffer_len) {
  switch (error) {
  case -3:
    strncpy(buffer, "Key not found", buffer_len);
    break;
  case -2:
    strncpy(buffer, "Hashmap full", buffer_len);
    break;
  case -1:
    strncpy(buffer, "Out of memory.", buffer_len);
    break;
  case 0:
    strncpy(buffer, "Ok", buffer_len);
    break;
  }
}


x86 assembly (clang, -O0):
<hashmap_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x4(%rbp),%eax
add    $0x3,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x3,%eax
ja     11ab <hashmap_error+0x9b>
mov    -0x20(%rbp),%rax
lea    0xebd(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xeb5(%rip),%rsi
call   1030 <strncpy@plt>
jmp    11ab <hashmap_error+0x9b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xeaa(%rip),%rsi
call   1030 <strncpy@plt>
jmp    11ab <hashmap_error+0x9b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe9e(%rip),%rsi
call   1030 <strncpy@plt>
jmp    11ab <hashmap_error+0x9b>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe94(%rip),%rsi
call   1030 <strncpy@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hashmap_error>:
add    $0x3,%edi
cmp    $0x3,%edi
ja     1134 <hashmap_error+0x24>
movslq %edi,%rax
lea    0xf0e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
mov    %rsi,%rdi
mov    %rax,%rsi
jmp    1030 <strncpy@plt>
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Key not found\00"
@.str.1 = [13 x i8] c"Hashmap full\00"
@.str.2 = [15 x i8] c"Out of memory.\00"
@.str.3 = [3 x i8] c"Ok\00"
define void @hashmap_error(i32 %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
store i32 %0, i32* %4
store i8* %1, i8** %5
store i64 %2, i64* %6
%7 = load i32, i32* %4
switch i32 %7, label %24 [
i32 -3, label %8
i32 -2, label %12
i32 -1, label %16
i32 0, label %20
]
8: ; preds = %3
%9 = load i8*, i8** %5
%10 = load i64, i64* %6
%11 = call i32 @strncpy(i8* %9, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i64 %10)
br label %24
12: ; preds = %3
%13 = load i8*, i8** %5
%14 = load i64, i64* %6
%15 = call i32 @strncpy(i8* %13, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i64 %14)
br label %24
16: ; preds = %3
%17 = load i8*, i8** %5
%18 = load i64, i64* %6
%19 = call i32 @strncpy(i8* %17, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i64 %18)
br label %24
20: ; preds = %3
%21 = load i8*, i8** %5
%22 = load i64, i64* %6
%23 = call i32 @strncpy(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i64 %22)
br label %24
24: ; preds = %3, %20, %16, %12, %8
ret void
}

LLVM IR (-O2):
@.str = [14 x i8] c"Key not found\00"
@.str.1 = [13 x i8] c"Hashmap full\00"
@.str.2 = [15 x i8] c"Out of memory.\00"
@.str.3 = [3 x i8] c"Ok\00"
@reltable.hashmap_error = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([14 x i8]* @.str to i64), i64 ptrtoint ([4 x i32]* @reltable.hashmap_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.1 to i64), i64 ptrtoint ([4 x i32]* @reltable.hashmap_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([15 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.hashmap_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.3 to i64), i64 ptrtoint ([4 x i32]* @reltable.hashmap_error to i64)) to i32)]
define void @hashmap_error(i32 %0, i8* %1, i64 %2) {
%4 = add i32 %0, 3
%5 = icmp ult i32 %4, 4
br i1 %5, label %6, label %11
6: ; preds = %3
%7 = sext i32 %4 to i64
%8 = shl i64 %7, 2
%9 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.hashmap_error to i8*), i64 %8)
%10 = tail call i32 @strncpy(i8* %1, i8* %9, i64 %2)
br label %11
11: ; preds = %3, %6
ret void
}