#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_shrt_1(short);
short signed_range(short const, short const);
int /*<<< orphan*/ sink(int /*<<< orphan*/);
void test_shrt_range(short n) {
  const short min = (-0x7fff - 1);
  const short max = 0x7fff;
  sink(f_shrt_1(n));
  sink(f_shrt_1(signed_range(min, min + 1)));
  sink(f_shrt_1(signed_range(min, 0)));
  sink(f_shrt_1(signed_range(-1, 0)));
  sink(f_shrt_1(signed_range(-1, 1)));
  sink(f_shrt_1(signed_range(0, 1)));
  sink(f_shrt_1(signed_range(0, max - 1)));
  sink(f_shrt_1(signed_range(1, max)));
  sink(f_shrt_1(signed_range(max - 1, max)));
}


x86 assembly (clang, -O0):
<test_shrt_range>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
movw   $0x8000,-0x4(%rbp)
movw   $0x7fff,-0x6(%rbp)
movswl -0x2(%rbp),%edi
call   1050 <f_shrt_1@plt>
mov    %eax,%edi
call   1040 <sink@plt>
mov    $0xffff8000,%edi
mov    $0xffff8001,%esi
call   1030 <signed_range@plt>
movswl %ax,%edi
call   1050 <f_shrt_1@plt>
mov    %eax,%edi
call   1040 <sink@plt>
mov    $0xffff8000,%edi
xor    %esi,%esi
call   1030 <signed_range@plt>
movswl %ax,%edi
call   1050 <f_shrt_1@plt>
mov    %eax,%edi
call   1040 <sink@plt>
mov    $0xffffffff,%edi
xor    %esi,%esi
call   1030 <signed_range@plt>
movswl %ax,%edi
call   1050 <f_shrt_1@plt>
mov    %eax,%edi
call   1040 <sink@plt>
mov    $0xffffffff,%edi
mov    $0x1,%esi
call   1030 <signed_range@plt>
movswl %ax,%edi
call   1050 <f_shrt_1@plt>
mov    %eax,%edi
call   1040 <sink@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1030 <signed_range@plt>
movswl %ax,%edi
call   1050 <f_shrt_1@plt>
mov    %eax,%edi
call   1040 <sink@plt>
xor    %edi,%edi
mov    $0x7ffe,%esi
call   1030 <signed_range@plt>
movswl %ax,%edi
call   1050 <f_shrt_1@plt>
mov    %eax,%edi
call   1040 <sink@plt>
mov    $0x1,%edi
mov    $0x7fff,%esi
call   1030 <signed_range@plt>
movswl %ax,%edi
call   1050 <f_shrt_1@plt>
mov    %eax,%edi
call   1040 <sink@plt>
mov    $0x7ffe,%edi
mov    $0x7fff,%esi
call   1030 <signed_range@plt>
movswl %ax,%edi
call   1050 <f_shrt_1@plt>
mov    %eax,%edi
call   1040 <sink@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_shrt_range>:
push   %rax
call   1050 <f_shrt_1@plt>
mov    %eax,%edi
call   1040 <sink@plt>
mov    $0xffff8000,%edi
mov    $0xffff8001,%esi
call   1030 <signed_range@plt>
movswl %ax,%edi
call   1050 <f_shrt_1@plt>
mov    %eax,%edi
call   1040 <sink@plt>
mov    $0xffff8000,%edi
xor    %esi,%esi
call   1030 <signed_range@plt>
movswl %ax,%edi
call   1050 <f_shrt_1@plt>
mov    %eax,%edi
call   1040 <sink@plt>
mov    $0xffffffff,%edi
xor    %esi,%esi
call   1030 <signed_range@plt>
movswl %ax,%edi
call   1050 <f_shrt_1@plt>
mov    %eax,%edi
call   1040 <sink@plt>
mov    $0xffffffff,%edi
mov    $0x1,%esi
call   1030 <signed_range@plt>
movswl %ax,%edi
call   1050 <f_shrt_1@plt>
mov    %eax,%edi
call   1040 <sink@plt>
xor    %edi,%edi
mov    $0x1,%esi
call   1030 <signed_range@plt>
movswl %ax,%edi
call   1050 <f_shrt_1@plt>
mov    %eax,%edi
call   1040 <sink@plt>
xor    %edi,%edi
mov    $0x7ffe,%esi
call   1030 <signed_range@plt>
movswl %ax,%edi
call   1050 <f_shrt_1@plt>
mov    %eax,%edi
call   1040 <sink@plt>
mov    $0x1,%edi
mov    $0x7fff,%esi
call   1030 <signed_range@plt>
movswl %ax,%edi
call   1050 <f_shrt_1@plt>
mov    %eax,%edi
call   1040 <sink@plt>
mov    $0x7ffe,%edi
mov    $0x7fff,%esi
call   1030 <signed_range@plt>
movswl %ax,%edi
call   1050 <f_shrt_1@plt>
mov    %eax,%edi
pop    %rax
jmp    1040 <sink@plt>

LLVM IR (-O0):
define void @test_shrt_range(i16 signext %0) {
%2 = alloca i16
%3 = alloca i16
%4 = alloca i16
store i16 %0, i16* %2
store i16 -32768, i16* %3
store i16 32767, i16* %4
%5 = load i16, i16* %2
%6 = call i32 @f_shrt_1(i16 signext %5)
%7 = call i32 @sink(i32 %6)
%8 = call signext i16 @signed_range(i16 signext -32768, i16 signext -32767)
%9 = call i32 @f_shrt_1(i16 signext %8)
%10 = call i32 @sink(i32 %9)
%11 = call signext i16 @signed_range(i16 signext -32768, i16 signext 0)
%12 = call i32 @f_shrt_1(i16 signext %11)
%13 = call i32 @sink(i32 %12)
%14 = call signext i16 @signed_range(i16 signext -1, i16 signext 0)
%15 = call i32 @f_shrt_1(i16 signext %14)
%16 = call i32 @sink(i32 %15)
%17 = call signext i16 @signed_range(i16 signext -1, i16 signext 1)
%18 = call i32 @f_shrt_1(i16 signext %17)
%19 = call i32 @sink(i32 %18)
%20 = call signext i16 @signed_range(i16 signext 0, i16 signext 1)
%21 = call i32 @f_shrt_1(i16 signext %20)
%22 = call i32 @sink(i32 %21)
%23 = call signext i16 @signed_range(i16 signext 0, i16 signext 32766)
%24 = call i32 @f_shrt_1(i16 signext %23)
%25 = call i32 @sink(i32 %24)
%26 = call signext i16 @signed_range(i16 signext 1, i16 signext 32767)
%27 = call i32 @f_shrt_1(i16 signext %26)
%28 = call i32 @sink(i32 %27)
%29 = call signext i16 @signed_range(i16 signext 32766, i16 signext 32767)
%30 = call i32 @f_shrt_1(i16 signext %29)
%31 = call i32 @sink(i32 %30)
ret void
}

LLVM IR (-O2):
define void @test_shrt_range(i16 signext %0) {
%2 = tail call i32 @f_shrt_1(i16 signext %0)
%3 = tail call i32 @sink(i32 %2)
%4 = tail call signext i16 @signed_range(i16 signext -32768, i16 signext -32767)
%5 = tail call i32 @f_shrt_1(i16 signext %4)
%6 = tail call i32 @sink(i32 %5)
%7 = tail call signext i16 @signed_range(i16 signext -32768, i16 signext 0)
%8 = tail call i32 @f_shrt_1(i16 signext %7)
%9 = tail call i32 @sink(i32 %8)
%10 = tail call signext i16 @signed_range(i16 signext -1, i16 signext 0)
%11 = tail call i32 @f_shrt_1(i16 signext %10)
%12 = tail call i32 @sink(i32 %11)
%13 = tail call signext i16 @signed_range(i16 signext -1, i16 signext 1)
%14 = tail call i32 @f_shrt_1(i16 signext %13)
%15 = tail call i32 @sink(i32 %14)
%16 = tail call signext i16 @signed_range(i16 signext 0, i16 signext 1)
%17 = tail call i32 @f_shrt_1(i16 signext %16)
%18 = tail call i32 @sink(i32 %17)
%19 = tail call signext i16 @signed_range(i16 signext 0, i16 signext 32766)
%20 = tail call i32 @f_shrt_1(i16 signext %19)
%21 = tail call i32 @sink(i32 %20)
%22 = tail call signext i16 @signed_range(i16 signext 1, i16 signext 32767)
%23 = tail call i32 @f_shrt_1(i16 signext %22)
%24 = tail call i32 @sink(i32 %23)
%25 = tail call signext i16 @signed_range(i16 signext 32766, i16 signext 32767)
%26 = tail call i32 @f_shrt_1(i16 signext %25)
%27 = tail call i32 @sink(i32 %26)
ret void
}