#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 */
struct triple {
  int dummy;
};
struct compile_state {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ internal_error(struct compile_state *, struct triple *,
                                  char *);
long get_mask_pool_ref(struct compile_state *state, struct triple *ins,
                       unsigned long mask, FILE *fp) {
  long ref;
  if (mask == 0xff) {
    ref = 1;
  } else if (mask == 0xffff) {
    ref = 2;
  } else {
    ref = 0;
    internal_error(state, ins, "unhandled mask value");
  }
  return ref;
}


x86 assembly (clang, -O0):
<get_mask_pool_ref>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
cmpq   $0xff,-0x18(%rbp)
jne    1143 <get_mask_pool_ref+0x33>
movq   $0x1,-0x28(%rbp)
jmp    117f <get_mask_pool_ref+0x6f>
cmpq   $0xffff,-0x18(%rbp)
jne    115e <get_mask_pool_ref+0x4e>
movq   $0x2,-0x28(%rbp)
jmp    117a <get_mask_pool_ref+0x6a>
movq   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    0xe8b(%rip),%rdx
call   1030 <internal_error@plt>
jmp    117f <get_mask_pool_ref+0x6f>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_mask_pool_ref>:
cmp    $0xff,%rdx
je     1128 <get_mask_pool_ref+0x18>
cmp    $0xffff,%rdx
jne    112e <get_mask_pool_ref+0x1e>
mov    $0x2,%eax
ret
mov    $0x1,%eax
ret
push   %rax
lea    0xeca(%rip),%rdx
call   1030 <internal_error@plt>
xor    %eax,%eax
add    $0x8,%rsp
ret

LLVM IR (-O0):
%struct.compile_state = type { i32 }
%struct.triple = type { i32 }
@.str = [21 x i8] c"unhandled mask value\00"
define i64 @get_mask_pool_ref(%struct.compile_state* %0, %struct.triple* %1, i64 %2, i32* %3) {
%5 = alloca %struct.compile_state*
%6 = alloca %struct.triple*
%7 = alloca i64
%8 = alloca i32*
%9 = alloca i64
store %struct.compile_state* %0, %struct.compile_state** %5
store %struct.triple* %1, %struct.triple** %6
store i64 %2, i64* %7
store i32* %3, i32** %8
%10 = load i64, i64* %7
%11 = icmp eq i64 %10, 255
br i1 %11, label %12, label %13
12: ; preds = %4
store i64 1, i64* %9
br label %22
13: ; preds = %4
%14 = load i64, i64* %7
%15 = icmp eq i64 %14, 65535
br i1 %15, label %16, label %17
16: ; preds = %13
store i64 2, i64* %9
br label %21
17: ; preds = %13
store i64 0, i64* %9
%18 = load %struct.compile_state*, %struct.compile_state** %5
%19 = load %struct.triple*, %struct.triple** %6
%20 = call i32 @internal_error(%struct.compile_state* %18, %struct.triple* %19, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %17, %16
br label %22
22: ; preds = %21, %12
%23 = load i64, i64* %9
ret i64 %23
}

LLVM IR (-O2):
%struct.compile_state = type { i32 }
%struct.triple = type { i32 }
@.str = [21 x i8] c"unhandled mask value\00"
define i64 @get_mask_pool_ref(%struct.compile_state* %0, %struct.triple* %1, i64 %2, i32* nocapture readnone %3) {
switch i64 %2, label %6 [
i64 255, label %8
i64 65535, label %5
]
5: ; preds = %4
br label %8
6: ; preds = %4
%7 = tail call i32 @internal_error(%struct.compile_state* %0, %struct.triple* %1, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %4, %5, %6
%9 = phi i64 [ 2, %5 ], [ 0, %6 ], [ 1, %4 ]
ret i64 %9
}