#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 */
short F_RDLCK;
short F_UNLCK;
short F_WRLCK;
short fuserl_l_type_decanonicalize(short l_type) {
  switch (l_type) {
  case 0:
    return F_RDLCK;
  case 1:
    return F_WRLCK;
  case 2:
    return F_UNLCK;
  default:
    return -1;
  }
}


x86 assembly (clang, -O0):
<fuserl_l_type_decanonicalize>:
push   %rbp
mov    %rsp,%rbp
mov    %di,%ax
mov    %ax,-0x4(%rbp)
movswl -0x4(%rbp),%eax
mov    %eax,-0x8(%rbp)
test   %eax,%eax
je     1141 <fuserl_l_type_decanonicalize+0x41>
jmp    111f <fuserl_l_type_decanonicalize+0x1f>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
je     1154 <fuserl_l_type_decanonicalize+0x54>
jmp    1130 <fuserl_l_type_decanonicalize+0x30>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
je     1167 <fuserl_l_type_decanonicalize+0x67>
jmp    117a <fuserl_l_type_decanonicalize+0x7a>
mov    0x2e80(%rip),%rax
mov    (%rax),%ax
mov    %ax,-0x2(%rbp)
jmp    1180 <fuserl_l_type_decanonicalize+0x80>
mov    0x2e7d(%rip),%rax
mov    (%rax),%ax
mov    %ax,-0x2(%rbp)
jmp    1180 <fuserl_l_type_decanonicalize+0x80>
mov    0x2e7a(%rip),%rax
mov    (%rax),%ax
mov    %ax,-0x2(%rbp)
jmp    1180 <fuserl_l_type_decanonicalize+0x80>
movw   $0xffff,-0x2(%rbp)
movswl -0x2(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<fuserl_l_type_decanonicalize>:
cmp    $0x2,%edi
je     111b <fuserl_l_type_decanonicalize+0x1b>
cmp    $0x1,%edi
je     1124 <fuserl_l_type_decanonicalize+0x24>
mov    $0xffff,%ax
test   %edi,%edi
jne    112e <fuserl_l_type_decanonicalize+0x2e>
mov    0x2eaf(%rip),%rax
jmp    112b <fuserl_l_type_decanonicalize+0x2b>
mov    0x2ec6(%rip),%rax
jmp    112b <fuserl_l_type_decanonicalize+0x2b>
mov    0x2ead(%rip),%rax
movzwl (%rax),%eax
ret

LLVM IR (-O0):
@F_RDLCK = global i16 0
@F_WRLCK = global i16 0
@F_UNLCK = global i16 0
define signext i16 @fuserl_l_type_decanonicalize(i16 signext %0) {
%2 = alloca i16
%3 = alloca i16
store i16 %0, i16* %3
%4 = load i16, i16* %3
%5 = sext i16 %4 to i32
switch i32 %5, label %12 [
i32 0, label %6
i32 1, label %8
i32 2, label %10
]
6: ; preds = %1
%7 = load i16, i16* @F_RDLCK
store i16 %7, i16* %2
br label %13
8: ; preds = %1
%9 = load i16, i16* @F_WRLCK
store i16 %9, i16* %2
br label %13
10: ; preds = %1
%11 = load i16, i16* @F_UNLCK
store i16 %11, i16* %2
br label %13
12: ; preds = %1
store i16 -1, i16* %2
br label %13
13: ; preds = %12, %10, %8, %6
%14 = load i16, i16* %2
ret i16 %14
}

LLVM IR (-O2):
@F_RDLCK = global i16 0
@F_WRLCK = global i16 0
@F_UNLCK = global i16 0
define signext i16 @fuserl_l_type_decanonicalize(i16 signext %0) {
%2 = sext i16 %0 to i32
switch i32 %2, label %9 [
i32 0, label %3
i32 1, label %5
i32 2, label %7
]
3: ; preds = %1
%4 = load i16, i16* @F_RDLCK
br label %9
5: ; preds = %1
%6 = load i16, i16* @F_WRLCK
br label %9
7: ; preds = %1
%8 = load i16, i16* @F_UNLCK
br label %9
9: ; preds = %1, %7, %5, %3
%10 = phi i16 [ %8, %7 ], [ %6, %5 ], [ %4, %3 ], [ -1, %1 ]
ret i16 %10
}