int main(int argc, char *argv[]) {
  int i = 0;
  float x = 0;
  double dx = 0;
  assign_byte(&i);
  assign_byte(&x);
  assign_byte(&dx);
  printf("values are %d %12.4g %12.4lg\n", i, x, dx);
  swap_4bytes(&i);
  swap_4bytes(&x);
  swap_8bytes(&dx);
  printf("post-swap, i and x are %d %12.4g %12.4lg\n", i, x, dx);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
lea    -0x14(%rbp),%rdi
mov    $0x0,%al
call   1050 <assign_byte@plt>
lea    -0x18(%rbp),%rdi
mov    $0x0,%al
call   1050 <assign_byte@plt>
lea    -0x20(%rbp),%rdi
mov    $0x0,%al
call   1050 <assign_byte@plt>
mov    -0x14(%rbp),%esi
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  -0x20(%rbp),%xmm1
lea    0xe61(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
lea    -0x14(%rbp),%rdi
mov    $0x0,%al
call   1060 <swap_4bytes@plt>
lea    -0x18(%rbp),%rdi
mov    $0x0,%al
call   1060 <swap_4bytes@plt>
lea    -0x20(%rbp),%rdi
mov    $0x0,%al
call   1030 <swap_8bytes@plt>
mov    -0x14(%rbp),%esi
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  -0x20(%rbp),%xmm1
lea    0xe3f(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0x4(%rsp)
movl   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
lea    0x4(%rsp),%r14
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <assign_byte@plt>
mov    %rsp,%r15
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <assign_byte@plt>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <assign_byte@plt>
mov    0x4(%rsp),%esi
movss  (%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0x8(%rsp),%xmm1
lea    0xe5a(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <swap_4bytes@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <swap_4bytes@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <swap_8bytes@plt>
mov    0x4(%rsp),%esi
movss  (%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0x8(%rsp),%xmm1
lea    0xe39(%rip),%rdi
mov    $0x2,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [30 x i8] c"values are %d %12.4g %12.4lg\0A\00"
@.str.1 = [42 x i8] c"post-swap, i and x are %d %12.4g %12.4lg\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
%6 = alloca float
%7 = alloca double
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i32 0, i32* %5
store float 0.000000e+00, float* %6
store double 0.000000e+00, double* %7
%8 = call i32 (i32*, ...) bitcast (i32 (...)* @assign_byte to i32 (i32*, ...)*)(i32* %5)
%9 = call i32 (float*, ...) bitcast (i32 (...)* @assign_byte to i32 (float*, ...)*)(float* %6)
%10 = call i32 (double*, ...) bitcast (i32 (...)* @assign_byte to i32 (double*, ...)*)(double* %7)
%11 = load i32, i32* %5
%12 = load float, float* %6
%13 = fpext float %12 to double
%14 = load double, double* %7
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %11, double %13, double %14)
%16 = call i32 (i32*, ...) bitcast (i32 (...)* @swap_4bytes to i32 (i32*, ...)*)(i32* %5)
%17 = call i32 (float*, ...) bitcast (i32 (...)* @swap_4bytes to i32 (float*, ...)*)(float* %6)
%18 = call i32 (double*, ...) bitcast (i32 (...)* @swap_8bytes to i32 (double*, ...)*)(double* %7)
%19 = load i32, i32* %5
%20 = load float, float* %6
%21 = fpext float %20 to double
%22 = load double, double* %7
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i32 %19, double %21, double %22)
ret i32 0
}

LLVM IR (-O2):
@.str = [30 x i8] c"values are %d %12.4g %12.4lg\0A\00"
@.str.1 = [42 x i8] c"post-swap, i and x are %d %12.4g %12.4lg\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca float
%5 = alloca double
%6 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%7 = bitcast float* %4 to i8*
store float 0.000000e+00, float* %4
%8 = bitcast double* %5 to i8*
store double 0.000000e+00, double* %5
%9 = call i32 (i32*, ...) bitcast (i32 (...)* @assign_byte to i32 (i32*, ...)*)(i32* %3)
%10 = call i32 (float*, ...) bitcast (i32 (...)* @assign_byte to i32 (float*, ...)*)(float* %4)
%11 = call i32 (double*, ...) bitcast (i32 (...)* @assign_byte to i32 (double*, ...)*)(double* %5)
%12 = load i32, i32* %3
%13 = load float, float* %4
%14 = fpext float %13 to double
%15 = load double, double* %5
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0), i32 %12, double %14, double %15)
%17 = call i32 (i32*, ...) bitcast (i32 (...)* @swap_4bytes to i32 (i32*, ...)*)(i32* %3)
%18 = call i32 (float*, ...) bitcast (i32 (...)* @swap_4bytes to i32 (float*, ...)*)(float* %4)
%19 = call i32 (double*, ...) bitcast (i32 (...)* @swap_8bytes to i32 (double*, ...)*)(double* %5)
%20 = load i32, i32* %3
%21 = load float, float* %4
%22 = fpext float %21 to double
%23 = load double, double* %5
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.1, i64 0, i64 0), i32 %20, double %22, double %23)
ret i32 0
}