void pvec(x) double x;
{
  union {
    double d;
    unsigned short s[4];
  } u;
  int i;
  u.d = x;
  for (i = 0; i < 4; i++)
    printf("0x%04x ", u.s[i]);
  printf("\n");
}


x86 assembly (clang, -O0):
<pvec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  -0x8(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x14(%rbp)
jge    115d <pvec+0x4d>
movslq -0x14(%rbp),%rax
movzwl -0x10(%rbp,%rax,2),%esi
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112e <pvec+0x1e>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pvec>:
push   %r14
push   %rbx
push   %rax
movq   %xmm0,%rbx
movzwl %bx,%esi
lea    0xecd(%rip),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%esi
shr    $0x10,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rax
shr    $0x20,%rax
movzwl %ax,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
shr    $0x30,%rbx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <putchar@plt>

LLVM IR (-O0):
%union.anon = type { double }
@.str = [8 x i8] c"0x%04x \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @pvec(double %0) {
%2 = alloca double
%3 = alloca %union.anon
%4 = alloca i32
store double %0, double* %2
%5 = load double, double* %2
%6 = bitcast %union.anon* %3 to double*
store double %5, double* %6
store i32 0, i32* %4
br label %7
7: ; preds = %18, %1
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 4
br i1 %9, label %10, label %21
10: ; preds = %7
%11 = bitcast %union.anon* %3 to [4 x i16]*
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [4 x i16], [4 x i16]* %11, i64 0, i64 %13
%15 = load i16, i16* %14
%16 = zext i16 %15 to i32
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %16)
br label %18
18: ; preds = %10
%19 = load i32, i32* %4
%20 = add nsw i32 %19, 1
store i32 %20, i32* %4
br label %7
21: ; preds = %7
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c"0x%04x \00"
define void @pvec(double %0) {
%2 = bitcast double %0 to i64
%3 = trunc i64 %2 to i32
%4 = and i32 %3, 65535
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %4)
%6 = trunc i64 %2 to i32
%7 = lshr i32 %6, 16
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = lshr i64 %2, 32
%10 = trunc i64 %9 to i32
%11 = and i32 %10, 65535
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = lshr i64 %2, 48
%14 = trunc i64 %13 to i32
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = tail call i32 @putchar(i32 10)
ret void
}