#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 */
char *esa_device_str(int);
char *gaisler_device_str(int);
char *opencores_device_str(int);
extern char *device_id2str(int vendor, int id) {
  switch (vendor) {
  case 1:
    return gaisler_device_str(id);
  case 4:
    return esa_device_str(id);
  case 8:
    return opencores_device_str(id);
  case 2:
  default:
    break;
  }
  return 0;
}


x86 assembly (clang, -O0):
<device_id2str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x7,%eax
ja     119f <device_id2str+0x6f>
mov    -0x18(%rbp),%rax
lea    0xea2(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x10(%rbp),%edi
call   1030 <gaisler_device_str@plt>
mov    %rax,-0x8(%rbp)
jmp    11ac <device_id2str+0x7c>
mov    -0x10(%rbp),%edi
call   1040 <esa_device_str@plt>
mov    %rax,-0x8(%rbp)
jmp    11ac <device_id2str+0x7c>
mov    -0x10(%rbp),%edi
call   1050 <opencores_device_str@plt>
mov    %rax,-0x8(%rbp)
jmp    11ac <device_id2str+0x7c>
jmp    119f <device_id2str+0x6f>
jmp    11a4 <device_id2str+0x74>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<device_id2str>:
cmp    $0x8,%edi
je     1146 <device_id2str+0x16>
cmp    $0x4,%edi
je     114d <device_id2str+0x1d>
cmp    $0x1,%edi
jne    1154 <device_id2str+0x24>
mov    %esi,%edi
jmp    1030 <gaisler_device_str@plt>
mov    %esi,%edi
jmp    1050 <opencores_device_str@plt>
mov    %esi,%edi
jmp    1040 <esa_device_str@plt>
xor    %eax,%eax
ret

LLVM IR (-O0):
define i8* @device_id2str(i32 %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
%6 = load i32, i32* %4
switch i32 %6, label %17 [
i32 1, label %7
i32 4, label %10
i32 8, label %13
i32 2, label %16
]
7: ; preds = %2
%8 = load i32, i32* %5
%9 = call i8* @gaisler_device_str(i32 %8)
store i8* %9, i8** %3
br label %19
10: ; preds = %2
%11 = load i32, i32* %5
%12 = call i8* @esa_device_str(i32 %11)
store i8* %12, i8** %3
br label %19
13: ; preds = %2
%14 = load i32, i32* %5
%15 = call i8* @opencores_device_str(i32 %14)
store i8* %15, i8** %3
br label %19
16: ; preds = %2
br label %17
17: ; preds = %2, %16
br label %18
18: ; preds = %17
store i8* null, i8** %3
br label %19
19: ; preds = %18, %13, %10, %7
%20 = load i8*, i8** %3
ret i8* %20
}

LLVM IR (-O2):
define i8* @device_id2str(i32 %0, i32 %1) {
switch i32 %0, label %9 [
i32 1, label %3
i32 4, label %5
i32 8, label %7
]
3: ; preds = %2
%4 = tail call i8* @gaisler_device_str(i32 %1)
br label %9
5: ; preds = %2
%6 = tail call i8* @esa_device_str(i32 %1)
br label %9
7: ; preds = %2
%8 = tail call i8* @opencores_device_str(i32 %1)
br label %9
9: ; preds = %2, %7, %5, %3
%10 = phi i8* [ %8, %7 ], [ %6, %5 ], [ %4, %3 ], [ null, %2 ]
ret i8* %10
}