#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 *, short, short, int, int);
int main() {
  short s1 = 0x8001;
  printf("0x%hx (%hd) -> 0x%08x (%d)\n", s1, s1, (int)s1, (int)s1);
  printf("0x%hx (%hu) -> 0x%08x (%u)\n", s1, s1, (unsigned int)s1,
         (unsigned int)s1);
  unsigned short s2 = 0x8001;
  printf("0x%hx (%hu) -> 0x%08x (%u)\n", s2, s2, (int)s2, (int)s2);
  short s3 = 0x7001;
  printf("0x%hx (%hd) -> 0x%08x (%d)\n", s3, s3, (int)s3, (int)s3);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movw   $0x8001,-0x6(%rbp)
mov    -0x6(%rbp),%dx
mov    -0x6(%rbp),%ax
movswl -0x6(%rbp),%ecx
movswl -0x6(%rbp),%r8d
lea    0xec3(%rip),%rdi
movswl %dx,%esi
movswl %ax,%edx
call   1030 <printf@plt>
mov    -0x6(%rbp),%dx
mov    -0x6(%rbp),%ax
movswl -0x6(%rbp),%ecx
movswl -0x6(%rbp),%r8d
lea    0xebc(%rip),%rdi
movswl %dx,%esi
movswl %ax,%edx
call   1030 <printf@plt>
movw   $0x8001,-0x8(%rbp)
mov    -0x8(%rbp),%dx
mov    -0x8(%rbp),%ax
movzwl -0x8(%rbp),%ecx
movzwl -0x8(%rbp),%r8d
lea    0xe93(%rip),%rdi
movswl %dx,%esi
movswl %ax,%edx
call   1030 <printf@plt>
movw   $0x7001,-0xa(%rbp)
mov    -0xa(%rbp),%dx
mov    -0xa(%rbp),%ax
movswl -0xa(%rbp),%ecx
movswl -0xa(%rbp),%r8d
lea    0xe4e(%rip),%rdi
movswl %dx,%esi
movswl %ax,%edx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xee5(%rip),%r14
mov    %r14,%rdi
mov    $0xffff8001,%esi
mov    $0xffff8001,%edx
mov    $0xffff8001,%ecx
mov    $0xffff8001,%r8d
call   1030 <printf@plt>
lea    0xedd(%rip),%rbx
mov    %rbx,%rdi
mov    $0xffff8001,%esi
mov    $0xffff8001,%edx
mov    $0xffff8001,%ecx
mov    $0xffff8001,%r8d
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    $0xffff8001,%esi
mov    $0xffff8001,%edx
mov    $0x8001,%ecx
mov    $0x8001,%r8d
call   1030 <printf@plt>
mov    %r14,%rdi
mov    $0x7001,%esi
mov    $0x7001,%edx
mov    $0x7001,%ecx
mov    $0x7001,%r8d
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [28 x i8] c"0x%hx (%hd) -> 0x%08x (%d)\0A\00"
@.str.1 = [28 x i8] c"0x%hx (%hu) -> 0x%08x (%u)\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i16
%3 = alloca i16
%4 = alloca i16
store i32 0, i32* %1
store i16 -32767, i16* %2
%5 = load i16, i16* %2
%6 = load i16, i16* %2
%7 = load i16, i16* %2
%8 = sext i16 %7 to i32
%9 = load i16, i16* %2
%10 = sext i16 %9 to i32
%11 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i16 signext %5, i16 signext %6, i32 %8, i32 %10)
%12 = load i16, i16* %2
%13 = load i16, i16* %2
%14 = load i16, i16* %2
%15 = sext i16 %14 to i32
%16 = load i16, i16* %2
%17 = sext i16 %16 to i32
%18 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i16 signext %12, i16 signext %13, i32 %15, i32 %17)
store i16 -32767, i16* %3
%19 = load i16, i16* %3
%20 = load i16, i16* %3
%21 = load i16, i16* %3
%22 = zext i16 %21 to i32
%23 = load i16, i16* %3
%24 = zext i16 %23 to i32
%25 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i16 signext %19, i16 signext %20, i32 %22, i32 %24)
store i16 28673, i16* %4
%26 = load i16, i16* %4
%27 = load i16, i16* %4
%28 = load i16, i16* %4
%29 = sext i16 %28 to i32
%30 = load i16, i16* %4
%31 = sext i16 %30 to i32
%32 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i16 signext %26, i16 signext %27, i32 %29, i32 %31)
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c"0x%hx (%hd) -> 0x%08x (%d)\0A\00"
@.str.1 = [28 x i8] c"0x%hx (%hu) -> 0x%08x (%u)\0A\00"
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i16 signext -32767, i16 signext -32767, i32 -32767, i32 -32767)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i16 signext -32767, i16 signext -32767, i32 -32767, i32 -32767)
%3 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i16 signext -32767, i16 signext -32767, i32 32769, i32 32769)
%4 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i16 signext 28673, i16 signext 28673, i32 28673, i32 28673)
ret i32 0
}