#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 *, unsigned int);
int /*<<< orphan*/ show_bytes(char *, int);
int main() {
  short sx = -12345;
  unsigned short usx = sx;
  int x = sx;
  unsigned ux = usx;
  printf("sx = %d:\t", sx);
  show_bytes((char *)&sx, sizeof(short));
  printf("usx = %u:\t", usx);
  show_bytes((char *)&usx, sizeof(unsigned short));
  printf("x = %d:\t", x);
  show_bytes((char *)&x, sizeof(int));
  printf("ux = %u:\t", ux);
  show_bytes((char *)&ux, sizeof(unsigned));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movw   $0xcfc7,-0x6(%rbp)
mov    -0x6(%rbp),%ax
mov    %ax,-0x8(%rbp)
movswl -0x6(%rbp),%eax
mov    %eax,-0xc(%rbp)
movzwl -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
movswl -0x6(%rbp),%esi
lea    0xeaa(%rip),%rdi
call   1030 <printf@plt>
lea    -0x6(%rbp),%rdi
mov    $0x2,%esi
call   1040 <show_bytes@plt>
movzwl -0x8(%rbp),%esi
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
lea    -0x8(%rbp),%rdi
mov    $0x2,%esi
call   1040 <show_bytes@plt>
mov    -0xc(%rbp),%esi
lea    0xe70(%rip),%rdi
call   1030 <printf@plt>
lea    -0xc(%rbp),%rdi
mov    $0x4,%esi
call   1040 <show_bytes@plt>
mov    -0x10(%rbp),%esi
lea    0xe67(%rip),%rdi
call   1030 <printf@plt>
lea    -0x10(%rbp),%rdi
mov    $0x4,%esi
call   1040 <show_bytes@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movw   $0xcfc7,0xe(%rsp)
movw   $0xcfc7,0xc(%rsp)
movl   $0xffffcfc7,0x14(%rsp)
ff
movl   $0xcfc7,0x10(%rsp)
lea    0xeb7(%rip),%rdi
mov    $0xffffcfc7,%esi
call   1030 <printf@plt>
lea    0xe(%rsp),%rdi
mov    $0x2,%esi
call   1040 <show_bytes@plt>
lea    0xea1(%rip),%rdi
mov    $0xcfc7,%esi
call   1030 <printf@plt>
lea    0xc(%rsp),%rdi
mov    $0x2,%esi
call   1040 <show_bytes@plt>
lea    0xe78(%rip),%rdi
mov    $0xffffcfc7,%esi
call   1030 <printf@plt>
lea    0x14(%rsp),%rdi
mov    $0x4,%esi
call   1040 <show_bytes@plt>
lea    0xe6c(%rip),%rdi
mov    $0xcfc7,%esi
call   1030 <printf@plt>
lea    0x10(%rsp),%rdi
mov    $0x4,%esi
call   1040 <show_bytes@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"sx = %d:\09\00"
@.str.1 = [11 x i8] c"usx = %u:\09\00"
@.str.2 = [9 x i8] c"x = %d:\09\00"
@.str.3 = [10 x i8] c"ux = %u:\09\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i16
%3 = alloca i16
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i16 -12345, i16* %2
%6 = load i16, i16* %2
store i16 %6, i16* %3
%7 = load i16, i16* %2
%8 = sext i16 %7 to i32
store i32 %8, i32* %4
%9 = load i16, i16* %3
%10 = zext i16 %9 to i32
store i32 %10, i32* %5
%11 = load i16, i16* %2
%12 = sext i16 %11 to i32
%13 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = bitcast i16* %2 to i8*
%15 = call i32 @show_bytes(i8* %14, i32 2)
%16 = load i16, i16* %3
%17 = zext i16 %16 to i32
%18 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = bitcast i16* %3 to i8*
%20 = call i32 @show_bytes(i8* %19, i32 2)
%21 = load i32, i32* %4
%22 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = bitcast i32* %4 to i8*
%24 = call i32 @show_bytes(i8* %23, i32 4)
%25 = load i32, i32* %5
%26 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %25)
%27 = bitcast i32* %5 to i8*
%28 = call i32 @show_bytes(i8* %27, i32 4)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"sx = %d:\09\00"
@.str.1 = [11 x i8] c"usx = %u:\09\00"
@.str.2 = [9 x i8] c"x = %d:\09\00"
@.str.3 = [10 x i8] c"ux = %u:\09\00"
define i32 @main() {
%1 = alloca i16
%2 = alloca i16
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i16* %1 to i8*
store i16 -12345, i16* %1
%6 = bitcast i16* %2 to i8*
store i16 -12345, i16* %2
%7 = bitcast i32* %3 to i8*
store i32 -12345, i32* %3
%8 = bitcast i32* %4 to i8*
store i32 53191, i32* %4
%9 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 -12345)
%10 = call i32 @show_bytes(i8* %5, i32 2)
%11 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 53191)
%12 = call i32 @show_bytes(i8* %6, i32 2)
%13 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i32 -12345)
%14 = call i32 @show_bytes(i8* %7, i32 4)
%15 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 53191)
%16 = call i32 @show_bytes(i8* %8, i32 4)
ret i32 0
}