#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 */
typedef int /*<<< orphan*/ EVP_MD;

/* Variables and functions */
int /*<<< orphan*/ const *EVP_dss1();
int /*<<< orphan*/ const *EVP_md5();
int /*<<< orphan*/ const *EVP_ripemd160();
int /*<<< orphan*/ const *EVP_sha1();
int /*<<< orphan*/ assert(int);
const EVP_MD *get_evp_md_for_hash(int hash) {
  assert(hash <= 3);
  switch (hash) {
  case 0:
    return EVP_ripemd160();
  case 1:
    return EVP_sha1();
  case 2:
    return EVP_dss1();
  case 3:
    return EVP_md5();
  default:
    return NULL;
  }
}


x86 assembly (clang, -O0):
<get_evp_md_for_hash>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
sub    $0x4,%eax
setl   %al
movzbl %al,%edi
call   1050 <assert@plt>
mov    -0xc(%rbp),%eax
mov    %rax,-0x18(%rbp)
sub    $0x3,%rax
ja     11d1 <get_evp_md_for_hash+0x81>
mov    -0x18(%rbp),%rax
lea    0xe78(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    $0x0,%al
call   1060 <EVP_ripemd160@plt>
mov    %rax,-0x8(%rbp)
jmp    11d9 <get_evp_md_for_hash+0x89>
mov    $0x0,%al
call   1040 <EVP_sha1@plt>
mov    %rax,-0x8(%rbp)
jmp    11d9 <get_evp_md_for_hash+0x89>
mov    $0x0,%al
call   1070 <EVP_dss1@plt>
mov    %rax,-0x8(%rbp)
jmp    11d9 <get_evp_md_for_hash+0x89>
mov    $0x0,%al
call   1030 <EVP_md5@plt>
mov    %rax,-0x8(%rbp)
jmp    11d9 <get_evp_md_for_hash+0x89>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_evp_md_for_hash>:
push   %rbx
mov    %edi,%ebx
xor    %edi,%edi
cmp    $0x4,%ebx
setl   %dil
call   1050 <assert@plt>
cmp    $0x3,%ebx
ja     1180 <get_evp_md_for_hash+0x30>
mov    %ebx,%eax
lea    0xe91(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
xor    %eax,%eax
pop    %rbx
jmp    1060 <EVP_ripemd160@plt>
xor    %eax,%eax
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
jmp    1040 <EVP_sha1@plt>
xor    %eax,%eax
pop    %rbx
jmp    1070 <EVP_dss1@plt>
xor    %eax,%eax
pop    %rbx
jmp    1030 <EVP_md5@plt>

LLVM IR (-O0):
define i32* @get_evp_md_for_hash(i32 %0) {
%2 = alloca i32*
%3 = alloca i32
store i32 %0, i32* %3
%4 = load i32, i32* %3
%5 = icmp sle i32 %4, 3
%6 = zext i1 %5 to i32
%7 = call i32 @assert(i32 %6)
%8 = load i32, i32* %3
switch i32 %8, label %17 [
i32 0, label %9
i32 1, label %11
i32 2, label %13
i32 3, label %15
]
9: ; preds = %1
%10 = call i32* (...) @EVP_ripemd160()
store i32* %10, i32** %2
br label %18
11: ; preds = %1
%12 = call i32* (...) @EVP_sha1()
store i32* %12, i32** %2
br label %18
13: ; preds = %1
%14 = call i32* (...) @EVP_dss1()
store i32* %14, i32** %2
br label %18
15: ; preds = %1
%16 = call i32* (...) @EVP_md5()
store i32* %16, i32** %2
br label %18
17: ; preds = %1
store i32* null, i32** %2
br label %18
18: ; preds = %17, %15, %13, %11, %9
%19 = load i32*, i32** %2
ret i32* %19
}

LLVM IR (-O2):
define i32* @get_evp_md_for_hash(i32 %0) {
%2 = icmp slt i32 %0, 4
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
switch i32 %0, label %13 [
i32 0, label %5
i32 1, label %7
i32 2, label %9
i32 3, label %11
]
5: ; preds = %1
%6 = tail call i32* (...) @EVP_ripemd160()
br label %13
7: ; preds = %1
%8 = tail call i32* (...) @EVP_sha1()
br label %13
9: ; preds = %1
%10 = tail call i32* (...) @EVP_dss1()
br label %13
11: ; preds = %1
%12 = tail call i32* (...) @EVP_md5()
br label %13
13: ; preds = %1, %11, %9, %7, %5
%14 = phi i32* [ %12, %11 ], [ %10, %9 ], [ %8, %7 ], [ %6, %5 ], [ null, %1 ]
ret i32* %14
}