#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, unsigned short);
int /*<<< orphan*/ stdin;
int main(void) {
  unsigned short x = 0x12ab, y = 0, z = 0;
  printf("Initial Value: 0x%X\n", x);
  y = x >> 8;
  z = (x & 0xFF);
  z = z << 8;
  x = y | z;
  printf("New Value:     0x%X\n", x);
  fflush(stdin);
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movw   $0x12ab,-0x6(%rbp)
movw   $0x0,-0x8(%rbp)
movw   $0x0,-0xa(%rbp)
lea    0xea8(%rip),%rdi
movzwl -0x6(%rbp),%esi
call   1030 <printf@plt>
movzwl -0x6(%rbp),%eax
sar    $0x8,%eax
mov    %ax,-0x8(%rbp)
movzwl -0x6(%rbp),%eax
and    $0xff,%eax
mov    %ax,-0xa(%rbp)
movzwl -0xa(%rbp),%eax
shl    $0x8,%eax
mov    %ax,-0xa(%rbp)
movzwl -0x8(%rbp),%eax
movzwl -0xa(%rbp),%ecx
or     %ecx,%eax
mov    %ax,-0x6(%rbp)
lea    0xe7c(%rip),%rdi
movzwl -0x6(%rbp),%esi
call   1030 <printf@plt>
mov    0x2e3f(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    $0x0,%al
call   1040 <getchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
mov    $0x12ab,%esi
call   1030 <printf@plt>
lea    0xecc(%rip),%rdi
mov    $0xab12,%esi
call   1030 <printf@plt>
mov    0x2e8e(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
xor    %eax,%eax
call   1040 <getchar@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [21 x i8] c"Initial Value: 0x%X\0A\00"
@.str.1 = [21 x i8] c"New Value: 0x%X\0A\00"
@stdin = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i16
%3 = alloca i16
%4 = alloca i16
store i32 0, i32* %1
store i16 4779, i16* %2
store i16 0, i16* %3
store i16 0, i16* %4
%5 = load i16, i16* %2
%6 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i16 zeroext %5)
%7 = load i16, i16* %2
%8 = zext i16 %7 to i32
%9 = ashr i32 %8, 8
%10 = trunc i32 %9 to i16
store i16 %10, i16* %3
%11 = load i16, i16* %2
%12 = zext i16 %11 to i32
%13 = and i32 %12, 255
%14 = trunc i32 %13 to i16
store i16 %14, i16* %4
%15 = load i16, i16* %4
%16 = zext i16 %15 to i32
%17 = shl i32 %16, 8
%18 = trunc i32 %17 to i16
store i16 %18, i16* %4
%19 = load i16, i16* %3
%20 = zext i16 %19 to i32
%21 = load i16, i16* %4
%22 = zext i16 %21 to i32
%23 = or i32 %20, %22
%24 = trunc i32 %23 to i16
store i16 %24, i16* %2
%25 = load i16, i16* %2
%26 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i16 zeroext %25)
%27 = load i32, i32* @stdin
%28 = call i32 @fflush(i32 %27)
%29 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"Initial Value: 0x%X\0A\00"
@.str.1 = [21 x i8] c"New Value: 0x%X\0A\00"
@stdin = global i32 0
define i32 @main() {
%1 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i16 zeroext 4779)
%2 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i16 zeroext -21742)
%3 = load i32, i32* @stdin
%4 = tail call i32 @fflush(i32 %3)
%5 = tail call i32 (...) @getchar()
ret i32 0
}