int xlate_size(int *size, int type) {
  if (type == 0) {
    switch (*size) {
    case 0:
      return (256);
    case 1:
      return (257);
    case 2:
      return (258);
    }
  } else if (type == 1) {
    switch (*size) {
    case 1:
      *size = 0;
      return (256);
    case 2:
      *size = 2;
      return (258);
    case 3:
      *size = 1;
      return (257);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<xlate_size>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1176 <xlate_size+0x76>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
test   %eax,%eax
je     114d <xlate_size+0x4d>
jmp    112b <xlate_size+0x2b>
mov    -0x18(%rbp),%eax
sub    $0x1,%eax
je     1159 <xlate_size+0x59>
jmp    113c <xlate_size+0x3c>
mov    -0x18(%rbp),%eax
sub    $0x2,%eax
je     1165 <xlate_size+0x65>
jmp    1171 <xlate_size+0x71>
movl   $0x100,-0x4(%rbp)
jmp    120c <xlate_size+0x10c>
movl   $0x101,-0x4(%rbp)
jmp    120c <xlate_size+0x10c>
movl   $0x102,-0x4(%rbp)
jmp    120c <xlate_size+0x10c>
jmp    1205 <xlate_size+0x105>
cmpl   $0x1,-0x14(%rbp)
jne    1200 <xlate_size+0x100>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x1,%eax
je     11b9 <xlate_size+0xb9>
jmp    1197 <xlate_size+0x97>
mov    -0x1c(%rbp),%eax
sub    $0x2,%eax
je     11cf <xlate_size+0xcf>
jmp    11a8 <xlate_size+0xa8>
mov    -0x1c(%rbp),%eax
sub    $0x3,%eax
je     11e5 <xlate_size+0xe5>
jmp    11fb <xlate_size+0xfb>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x100,-0x4(%rbp)
jmp    120c <xlate_size+0x10c>
mov    -0x10(%rbp),%rax
movl   $0x2,(%rax)
movl   $0x102,-0x4(%rbp)
jmp    120c <xlate_size+0x10c>
mov    -0x10(%rbp),%rax
movl   $0x1,(%rax)
movl   $0x101,-0x4(%rbp)
jmp    120c <xlate_size+0x10c>
jmp    1200 <xlate_size+0x100>
jmp    1205 <xlate_size+0x105>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<xlate_size>:
xor    %eax,%eax
cmp    $0x1,%esi
je     111c <xlate_size+0x1c>
test   %esi,%esi
jne    113f <xlate_size+0x3f>
mov    (%rdi),%ecx
lea    0x100(%rcx),%edx
xor    %eax,%eax
cmp    $0x3,%ecx
cmovb  %edx,%eax
ret
mov    (%rdi),%ecx
add    $0xffffffff,%ecx
cmp    $0x2,%ecx
ja     113f <xlate_size+0x3f>
movslq %ecx,%rax
lea    0xed0(%rip),%rcx
mov    (%rcx,%rax,4),%ecx
lea    0xed2(%rip),%rdx
mov    (%rdx,%rax,4),%eax
mov    %ecx,(%rdi)
ret

LLVM IR (-O0):
define i32 @xlate_size(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %2
%9 = load i32*, i32** %4
%10 = load i32, i32* %9
switch i32 %10, label %14 [
i32 0, label %11
i32 1, label %12
i32 2, label %13
]
11: ; preds = %8
store i32 256, i32* %3
br label %30
12: ; preds = %8
store i32 257, i32* %3
br label %30
13: ; preds = %8
store i32 258, i32* %3
br label %30
14: ; preds = %8
br label %29
15: ; preds = %2
%16 = load i32, i32* %5
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %28
18: ; preds = %15
%19 = load i32*, i32** %4
%20 = load i32, i32* %19
switch i32 %20, label %27 [
i32 1, label %21
i32 2, label %23
i32 3, label %25
]
21: ; preds = %18
%22 = load i32*, i32** %4
store i32 0, i32* %22
store i32 256, i32* %3
br label %30
23: ; preds = %18
%24 = load i32*, i32** %4
store i32 2, i32* %24
store i32 258, i32* %3
br label %30
25: ; preds = %18
%26 = load i32*, i32** %4
store i32 1, i32* %26
store i32 257, i32* %3
br label %30
27: ; preds = %18
br label %28
28: ; preds = %27, %15
br label %29
29: ; preds = %28, %14
store i32 0, i32* %3
br label %30
30: ; preds = %29, %25, %23, %21, %13, %12, %11
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@switch.table.xlate_size = [3 x i32] [i32 0, i32 2, i32 1]
@switch.table.xlate_size.1 = [3 x i32] [i32 256, i32 258, i32 257]
define i32 @xlate_size(i32* nocapture %0, i32 %1) {
switch i32 %1, label %19 [
i32 0, label %3
i32 1, label %8
]
3: ; preds = %2
%4 = load i32, i32* %0
%5 = icmp ult i32 %4, 3
%6 = add i32 %4, 256
%7 = select i1 %5, i32 %6, i32 0
br label %19
8: ; preds = %2
%9 = load i32, i32* %0
%10 = add i32 %9, -1
%11 = icmp ult i32 %10, 3
br i1 %11, label %12, label %19
12: ; preds = %8
%13 = sext i32 %10 to i64
%14 = getelementptr inbounds [3 x i32], [3 x i32]* @switch.table.xlate_size, i64 0, i64 %13
%15 = load i32, i32* %14
%16 = sext i32 %10 to i64
%17 = getelementptr inbounds [3 x i32], [3 x i32]* @switch.table.xlate_size.1, i64 0, i64 %16
%18 = load i32, i32* %17
store i32 %15, i32* %0
br label %19
19: ; preds = %8, %3, %12, %2
%20 = phi i32 [ 0, %2 ], [ 0, %8 ], [ %7, %3 ], [ %18, %12 ]
ret i32 %20
}