#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*/ printf(char *, ...);
int main(void) {
  printf("short size is: %d byte(s)\n", sizeof(short));
  printf("unsigned short size is: %d byte(s)\n", sizeof(unsigned short));
  short max = 32767, min = -32768;
  unsigned short umax = 65535, umin = 0;
  printf("%d %d %d\n", max, (short)(max + 1), (short)(max + 2));
  printf("%d %d %d\n", min, (short)(min - 1), (short)(min - 2));
  printf("-------------------------------\n");
  printf("%d %d %d\n", umax, (unsigned short)(umax + 1),
         (unsigned short)(umax + 2));
  printf("%d %d %d\n", umin, (unsigned short)(umin - 1),
         (unsigned short)(umin - 2));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xee3(%rip),%rdi
mov    $0x2,%esi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec7(%rip),%rdi
mov    $0x2,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movw   $0x7fff,-0x6(%rbp)
movw   $0x8000,-0x8(%rbp)
movw   $0xffff,-0xa(%rbp)
movw   $0x0,-0xc(%rbp)
movswl -0x6(%rbp),%esi
movswl -0x6(%rbp),%eax
add    $0x1,%eax
movswl %ax,%edx
movswl -0x6(%rbp),%eax
add    $0x2,%eax
movswl %ax,%ecx
lea    0xea8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movswl -0x8(%rbp),%esi
movswl -0x8(%rbp),%eax
sub    $0x1,%eax
movswl %ax,%edx
movswl -0x8(%rbp),%eax
sub    $0x2,%eax
movswl %ax,%ecx
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movzwl -0xa(%rbp),%esi
movzwl -0xa(%rbp),%eax
add    $0x1,%eax
movzwl %ax,%edx
movzwl -0xa(%rbp),%eax
add    $0x2,%eax
movzwl %ax,%ecx
lea    0xe4e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movzwl -0xc(%rbp),%esi
movzwl -0xc(%rbp),%eax
sub    $0x1,%eax
movzwl %ax,%edx
movzwl -0xc(%rbp),%eax
sub    $0x2,%eax
movzwl %ax,%ecx
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xee1(%rip),%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec5(%rip),%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed6(%rip),%rbx
mov    %rbx,%rdi
mov    $0x7fff,%esi
mov    $0xffff8000,%edx
mov    $0xffff8001,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0xffff8000,%esi
mov    $0x7fff,%edx
mov    $0x7ffe,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea7(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0xffff,%esi
xor    %edx,%edx
mov    $0x1,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xffff,%edx
mov    $0xfffe,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [27 x i8] c"short size is: %d byte(s)\0A\00"
@.str.1 = [36 x i8] c"unsigned short size is: %d byte(s)\0A\00"
@.str.2 = [10 x i8] c"%d %d %d\0A\00"
@.str.3 = [33 x i8] c"-------------------------------\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i16
%3 = alloca i16
%4 = alloca i16
%5 = alloca i16
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i64 2)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i64 2)
store i16 32767, i16* %2
store i16 -32768, i16* %3
store i16 -1, i16* %4
store i16 0, i16* %5
%8 = load i16, i16* %2
%9 = sext i16 %8 to i32
%10 = load i16, i16* %2
%11 = sext i16 %10 to i32
%12 = add nsw i32 %11, 1
%13 = trunc i32 %12 to i16
%14 = sext i16 %13 to i32
%15 = load i16, i16* %2
%16 = sext i16 %15 to i32
%17 = add nsw i32 %16, 2
%18 = trunc i32 %17 to i16
%19 = sext i16 %18 to i32
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %9, i32 %14, i32 %19)
%21 = load i16, i16* %3
%22 = sext i16 %21 to i32
%23 = load i16, i16* %3
%24 = sext i16 %23 to i32
%25 = sub nsw i32 %24, 1
%26 = trunc i32 %25 to i16
%27 = sext i16 %26 to i32
%28 = load i16, i16* %3
%29 = sext i16 %28 to i32
%30 = sub nsw i32 %29, 2
%31 = trunc i32 %30 to i16
%32 = sext i16 %31 to i32
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %22, i32 %27, i32 %32)
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0))
%35 = load i16, i16* %4
%36 = zext i16 %35 to i32
%37 = load i16, i16* %4
%38 = zext i16 %37 to i32
%39 = add nsw i32 %38, 1
%40 = trunc i32 %39 to i16
%41 = zext i16 %40 to i32
%42 = load i16, i16* %4
%43 = zext i16 %42 to i32
%44 = add nsw i32 %43, 2
%45 = trunc i32 %44 to i16
%46 = zext i16 %45 to i32
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %36, i32 %41, i32 %46)
%48 = load i16, i16* %5
%49 = zext i16 %48 to i32
%50 = load i16, i16* %5
%51 = zext i16 %50 to i32
%52 = sub nsw i32 %51, 1
%53 = trunc i32 %52 to i16
%54 = zext i16 %53 to i32
%55 = load i16, i16* %5
%56 = zext i16 %55 to i32
%57 = sub nsw i32 %56, 2
%58 = trunc i32 %57 to i16
%59 = zext i16 %58 to i32
%60 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %49, i32 %54, i32 %59)
ret i32 0
}

LLVM IR (-O2):
@.str = [27 x i8] c"short size is: %d byte(s)\0A\00"
@.str.1 = [36 x i8] c"unsigned short size is: %d byte(s)\0A\00"
@.str.2 = [10 x i8] c"%d %d %d\0A\00"
@str = [32 x i8] c"-------------------------------\00"
define i32 @main() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i64 2)
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i64 2)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 32767, i32 -32768, i32 -32767)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 -32768, i32 32767, i32 32766)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 65535, i32 0, i32 1)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 0, i32 65535, i32 65534)
ret i32 0
}