#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 */
int /*<<< orphan*/ f_ushrt_1(unsigned short);
int /*<<< orphan*/ sink(int /*<<< orphan*/);
unsigned short unsigned_range(int, unsigned short const);
void test_ushrt_range(unsigned short n) {
  const unsigned short max = (0x7fff * 2 + 1);
  sink(f_ushrt_1(n));
  sink(f_ushrt_1(unsigned_range(0, 1)));
  sink(f_ushrt_1(unsigned_range(1, max - 1)));
  sink(f_ushrt_1(unsigned_range(1, max)));
  sink(f_ushrt_1(unsigned_range(0, max - 1)));
}


x86 assembly (clang, -O0):
<test_ushrt_range>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
movw   $0xffff,-0x4(%rbp)
movzwl -0x2(%rbp),%edi
call   1030 <f_ushrt_1@plt>
mov    %eax,%edi
call   1040 <sink@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1050 <unsigned_range@plt>
movzwl %ax,%edi
call   1030 <f_ushrt_1@plt>
mov    %eax,%edi
call   1040 <sink@plt>
mov    $0x1,%edi
mov    $0xfffe,%esi
call   1050 <unsigned_range@plt>
movzwl %ax,%edi
call   1030 <f_ushrt_1@plt>
mov    %eax,%edi
call   1040 <sink@plt>
mov    $0x1,%edi
mov    $0xffff,%esi
call   1050 <unsigned_range@plt>
movzwl %ax,%edi
call   1030 <f_ushrt_1@plt>
mov    %eax,%edi
call   1040 <sink@plt>
xor    %edi,%edi
mov    $0xfffe,%esi
call   1050 <unsigned_range@plt>
movzwl %ax,%edi
call   1030 <f_ushrt_1@plt>
mov    %eax,%edi
call   1040 <sink@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_ushrt_range>:
push   %rax
call   1030 <f_ushrt_1@plt>
mov    %eax,%edi
call   1040 <sink@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1050 <unsigned_range@plt>
movzwl %ax,%edi
call   1030 <f_ushrt_1@plt>
mov    %eax,%edi
call   1040 <sink@plt>
mov    $0x1,%edi
mov    $0xfffe,%esi
call   1050 <unsigned_range@plt>
movzwl %ax,%edi
call   1030 <f_ushrt_1@plt>
mov    %eax,%edi
call   1040 <sink@plt>
mov    $0x1,%edi
mov    $0xffff,%esi
call   1050 <unsigned_range@plt>
movzwl %ax,%edi
call   1030 <f_ushrt_1@plt>
mov    %eax,%edi
call   1040 <sink@plt>
xor    %edi,%edi
mov    $0xfffe,%esi
call   1050 <unsigned_range@plt>
movzwl %ax,%edi
call   1030 <f_ushrt_1@plt>
mov    %eax,%edi
pop    %rax
jmp    1040 <sink@plt>

LLVM IR (-O0):
define void @test_ushrt_range(i16 zeroext %0) {
%2 = alloca i16
%3 = alloca i16
store i16 %0, i16* %2
store i16 -1, i16* %3
%4 = load i16, i16* %2
%5 = call i32 @f_ushrt_1(i16 zeroext %4)
%6 = call i32 @sink(i32 %5)
%7 = call zeroext i16 @unsigned_range(i32 0, i16 zeroext 1)
%8 = call i32 @f_ushrt_1(i16 zeroext %7)
%9 = call i32 @sink(i32 %8)
%10 = call zeroext i16 @unsigned_range(i32 1, i16 zeroext -2)
%11 = call i32 @f_ushrt_1(i16 zeroext %10)
%12 = call i32 @sink(i32 %11)
%13 = call zeroext i16 @unsigned_range(i32 1, i16 zeroext -1)
%14 = call i32 @f_ushrt_1(i16 zeroext %13)
%15 = call i32 @sink(i32 %14)
%16 = call zeroext i16 @unsigned_range(i32 0, i16 zeroext -2)
%17 = call i32 @f_ushrt_1(i16 zeroext %16)
%18 = call i32 @sink(i32 %17)
ret void
}

LLVM IR (-O2):
define void @test_ushrt_range(i16 zeroext %0) {
%2 = tail call i32 @f_ushrt_1(i16 zeroext %0)
%3 = tail call i32 @sink(i32 %2)
%4 = tail call zeroext i16 @unsigned_range(i32 0, i16 zeroext 1)
%5 = tail call i32 @f_ushrt_1(i16 zeroext %4)
%6 = tail call i32 @sink(i32 %5)
%7 = tail call zeroext i16 @unsigned_range(i32 1, i16 zeroext -2)
%8 = tail call i32 @f_ushrt_1(i16 zeroext %7)
%9 = tail call i32 @sink(i32 %8)
%10 = tail call zeroext i16 @unsigned_range(i32 1, i16 zeroext -1)
%11 = tail call i32 @f_ushrt_1(i16 zeroext %10)
%12 = tail call i32 @sink(i32 %11)
%13 = tail call zeroext i16 @unsigned_range(i32 0, i16 zeroext -2)
%14 = tail call i32 @f_ushrt_1(i16 zeroext %13)
%15 = tail call i32 @sink(i32 %14)
ret void
}