#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 SEEK_CUR;
short SEEK_END;
short SEEK_SET;
short fuserl_l_whence_decanonicalize(short l_whence) {
  switch (l_whence) {
  case 0:
    return SEEK_SET;
  case 1:
    return SEEK_CUR;
  case 2:
    return SEEK_END;
  default:
    return -1;
  }
}


x86 assembly (clang, -O0):
<fuserl_l_whence_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_whence_decanonicalize+0x41>
jmp    111f <fuserl_l_whence_decanonicalize+0x1f>
mov    -0x8(%rbp),%eax
sub    $0x1,%eax
je     1154 <fuserl_l_whence_decanonicalize+0x54>
jmp    1130 <fuserl_l_whence_decanonicalize+0x30>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
je     1167 <fuserl_l_whence_decanonicalize+0x67>
jmp    117a <fuserl_l_whence_decanonicalize+0x7a>
mov    0x2e88(%rip),%rax
mov    (%rax),%ax
mov    %ax,-0x2(%rbp)
jmp    1180 <fuserl_l_whence_decanonicalize+0x80>
mov    0x2e85(%rip),%rax
mov    (%rax),%ax
mov    %ax,-0x2(%rbp)
jmp    1180 <fuserl_l_whence_decanonicalize+0x80>
mov    0x2e7a(%rip),%rax
mov    (%rax),%ax
mov    %ax,-0x2(%rbp)
jmp    1180 <fuserl_l_whence_decanonicalize+0x80>
movw   $0xffff,-0x2(%rbp)
movswl -0x2(%rbp),%eax
pop    %rbp
ret

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

LLVM IR (-O0):
@SEEK_SET = global i16 0
@SEEK_CUR = global i16 0
@SEEK_END = global i16 0
define signext i16 @fuserl_l_whence_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* @SEEK_SET
store i16 %7, i16* %2
br label %13
8: ; preds = %1
%9 = load i16, i16* @SEEK_CUR
store i16 %9, i16* %2
br label %13
10: ; preds = %1
%11 = load i16, i16* @SEEK_END
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):
@SEEK_SET = global i16 0
@SEEK_CUR = global i16 0
@SEEK_END = global i16 0
define signext i16 @fuserl_l_whence_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* @SEEK_SET
br label %9
5: ; preds = %1
%6 = load i16, i16* @SEEK_CUR
br label %9
7: ; preds = %1
%8 = load i16, i16* @SEEK_END
br label %9
9: ; preds = %1, %7, %5, %3
%10 = phi i16 [ %8, %7 ], [ %6, %5 ], [ %4, %3 ], [ -1, %1 ]
ret i16 %10
}