#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 */
unsigned short SHRT_MAX;
short SHRT_MIN;
unsigned short USHRT_MAX;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
void range_short(void) {
  unsigned short max, umax;
  short min;
  int BITS = 16;
  min = SHRT_MIN;
  max = SHRT_MAX;
  umax = USHRT_MAX;
  printf("limit.h: short\n");
  printf(" %19d\tmin\n%20d\tmax\n%20u\tumax\n", min, max, umax);
  min = ~0 << (BITS - 1);
  max = ~(~0 << (BITS - 1));
  umax = ~0;
  printf("bitshift: short\n");
  printf(" %19d\tmin\n%20d\tmax\n%20u\tumax\n", min, max, umax);
  puts("");
  return;
}


x86 assembly (clang, -O0):
<range_short>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x10,-0xc(%rbp)
mov    0x2ea2(%rip),%rax
mov    (%rax),%ax
mov    %ax,-0x6(%rbp)
mov    0x2e8c(%rip),%rax
mov    (%rax),%ax
mov    %ax,-0x2(%rbp)
mov    0x2e96(%rip),%rax
mov    (%rax),%ax
mov    %ax,-0x4(%rbp)
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movswl -0x6(%rbp),%esi
movzwl -0x2(%rbp),%edx
movzwl -0x4(%rbp),%ecx
lea    0xe96(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
mov    $0xffffffff,%eax
shl    %cl,%eax
mov    %ax,-0x6(%rbp)
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
mov    $0xffffffff,%eax
shl    %cl,%eax
xor    $0xffffffff,%eax
mov    %ax,-0x2(%rbp)
movw   $0xffff,-0x4(%rbp)
lea    0xe7b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movswl -0x6(%rbp),%esi
movzwl -0x2(%rbp),%edx
movzwl -0x4(%rbp),%ecx
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe34(%rip),%rdi
call   1030 <puts@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<range_short>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x2e9a(%rip),%rax
movswl (%rax),%r14d
mov    0x2e87(%rip),%rax
movzwl (%rax),%ebp
mov    0x2e95(%rip),%rax
movzwl (%rax),%ebx
lea    0xec1(%rip),%rdi
call   1040 <puts@plt>
lea    0xe97(%rip),%r15
mov    %r15,%rdi
mov    %r14d,%esi
mov    %ebp,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeac(%rip),%rdi
call   1040 <puts@plt>
mov    %r15,%rdi
mov    $0xffff8000,%esi
mov    $0x7fff,%edx
mov    $0xffff,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@SHRT_MIN = global i16 0
@SHRT_MAX = global i16 0
@USHRT_MAX = global i16 0
@.str = [16 x i8] c"limit.h: short\0A\00"
@.str.1 = [30 x i8] c" %19d\09min\0A%20d\09max\0A%20u\09umax\0A\00"
@.str.2 = [17 x i8] c"bitshift: short\0A\00"
@.str.3 = [1 x i8] zeroinitializer
define void @range_short() {
%1 = alloca i16
%2 = alloca i16
%3 = alloca i16
%4 = alloca i32
store i32 16, i32* %4
%5 = load i16, i16* @SHRT_MIN
store i16 %5, i16* %3
%6 = load i16, i16* @SHRT_MAX
store i16 %6, i16* %1
%7 = load i16, i16* @USHRT_MAX
store i16 %7, i16* %2
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%9 = load i16, i16* %3
%10 = sext i16 %9 to i32
%11 = load i16, i16* %1
%12 = zext i16 %11 to i32
%13 = load i16, i16* %2
%14 = zext i16 %13 to i32
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %10, i32 %12, i32 %14)
%16 = load i32, i32* %4
%17 = sub nsw i32 %16, 1
%18 = shl i32 -1, %17
%19 = trunc i32 %18 to i16
store i16 %19, i16* %3
%20 = load i32, i32* %4
%21 = sub nsw i32 %20, 1
%22 = shl i32 -1, %21
%23 = xor i32 %22, -1
%24 = trunc i32 %23 to i16
store i16 %24, i16* %1
store i16 -1, i16* %2
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%26 = load i16, i16* %3
%27 = sext i16 %26 to i32
%28 = load i16, i16* %1
%29 = zext i16 %28 to i32
%30 = load i16, i16* %2
%31 = zext i16 %30 to i32
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %27, i32 %29, i32 %31)
%33 = call i32 @puts(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@SHRT_MIN = global i16 0
@SHRT_MAX = global i16 0
@USHRT_MAX = global i16 0
@.str.1 = [30 x i8] c" %19d\09min\0A%20d\09max\0A%20u\09umax\0A\00"
@str = [15 x i8] c"limit.h: short\00"
@str.4 = [16 x i8] c"bitshift: short\00"
define void @range_short() {
%1 = load i16, i16* @SHRT_MIN
%2 = load i16, i16* @SHRT_MAX
%3 = load i16, i16* @USHRT_MAX
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%5 = sext i16 %1 to i32
%6 = zext i16 %2 to i32
%7 = zext i16 %3 to i32
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 %5, i32 %6, i32 %7)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.4, i64 0, i64 0))
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i32 -32768, i32 32767, i32 65535)
%11 = tail call i32 @putchar(i32 10)
ret void
}