char *translate_long_virtual(unsigned char *buf, unsigned char *sunchanged,
                             int *launchp) {
  extern char *translate_rfxmeter(unsigned char *, unsigned char *, int *);
  extern char *translate_digimax(unsigned char *, unsigned char *, int *);
  if (buf[2] == 4)
    return translate_rfxmeter(buf, sunchanged, launchp);
  else if (buf[2] == 10)
    return translate_digimax(buf, sunchanged, launchp);
  return "";
}


x86 assembly (clang, -O0):
<translate_long_virtual>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movzbl 0x2(%rax),%eax
cmp    $0x4,%eax
jne    115f <translate_long_virtual+0x3f>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <translate_rfxmeter@plt>
mov    %rax,-0x8(%rbp)
jmp    119a <translate_long_virtual+0x7a>
mov    -0x10(%rbp),%rax
movzbl 0x2(%rax),%eax
cmp    $0xa,%eax
jne    118a <translate_long_virtual+0x6a>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <translate_digimax@plt>
mov    %rax,-0x8(%rbp)
jmp    119a <translate_long_virtual+0x7a>
jmp    118f <translate_long_virtual+0x6f>
lea    0xe6a(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<translate_long_virtual>:
mov    0x2(%rdi),%al
cmp    $0xa,%al
je     1130 <translate_long_virtual+0x10>
cmp    $0x4,%al
jne    1135 <translate_long_virtual+0x15>
jmp    1030 <translate_rfxmeter@plt>
jmp    1040 <translate_digimax@plt>
lea    0xec4(%rip),%rax
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define i8* @translate_long_virtual(i8* %0, i8* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32* %2, i32** %7
%8 = load i8*, i8** %5
%9 = getelementptr inbounds i8, i8* %8, i64 2
%10 = load i8, i8* %9
%11 = zext i8 %10 to i32
%12 = icmp eq i32 %11, 4
br i1 %12, label %13, label %18
13: ; preds = %3
%14 = load i8*, i8** %5
%15 = load i8*, i8** %6
%16 = load i32*, i32** %7
%17 = call i8* @translate_rfxmeter(i8* %14, i8* %15, i32* %16)
store i8* %17, i8** %4
br label %31
18: ; preds = %3
%19 = load i8*, i8** %5
%20 = getelementptr inbounds i8, i8* %19, i64 2
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = icmp eq i32 %22, 10
br i1 %23, label %24, label %29
24: ; preds = %18
%25 = load i8*, i8** %5
%26 = load i8*, i8** %6
%27 = load i32*, i32** %7
%28 = call i8* @translate_digimax(i8* %25, i8* %26, i32* %27)
store i8* %28, i8** %4
br label %31
29: ; preds = %18
br label %30
30: ; preds = %29
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %4
br label %31
31: ; preds = %30, %24, %13
%32 = load i8*, i8** %4
ret i8* %32
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define i8* @translate_long_virtual(i8* %0, i8* %1, i32* %2) {
%4 = getelementptr inbounds i8, i8* %0, i64 2
%5 = load i8, i8* %4
switch i8 %5, label %10 [
i8 4, label %6
i8 10, label %8
]
6: ; preds = %3
%7 = tail call i8* @translate_rfxmeter(i8* %0, i8* %1, i32* %2)
br label %10
8: ; preds = %3
%9 = tail call i8* @translate_digimax(i8* %0, i8* %1, i32* %2)
br label %10
10: ; preds = %3, %8, %6
%11 = phi i8* [ %7, %6 ], [ %9, %8 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %3 ]
ret i8* %11
}