int main() {
  int x1, x2;
  double y1, y2;
  x1 = 8;
  x2 = 5;
  y1 = 10.5;
  y2 = 15.5;
  printf("Before: x1=%d,int2=%d\n", x1, x2);
  swap(&x1, &x2, sizeof(int));
  printf("After: x1=%d,int2=%d\n", x1, x2);
  printf("Before: y1=%lf,y2=%lf\n", y1, y2);
  swap(&y1, &y2, sizeof(double));
  printf("After: y1=%lf,y2=%lf\n", y1, y2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x8,-0x8(%rbp)
movl   $0x5,-0xc(%rbp)
movsd  0xec3(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xeae(%rip),%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x8(%rbp),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x4,%edx
mov    $0x0,%al
call   1040 <swap@plt>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
lea    0xe99(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
mov    $0x8,%edx
mov    $0x0,%al
call   1040 <swap@plt>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
lea    0xe84(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
movl   $0x8,0x4(%rsp)
movl   $0x5,(%rsp)
movabs $0x4025000000000000,%rax
mov    %rax,0x10(%rsp)
movabs $0x402f000000000000,%rax
mov    %rax,0x8(%rsp)
lea    0xeb8(%rip),%rdi
mov    $0x8,%esi
mov    $0x5,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x4(%rsp),%rdi
mov    %rsp,%rsi
mov    $0x4,%edx
xor    %eax,%eax
call   1040 <swap@plt>
mov    0x4(%rsp),%esi
mov    (%rsp),%edx
lea    0xe9c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xea4(%rip),%rdi
movsd  0xe5f(%rip),%xmm0
movsd  0xe5f(%rip),%xmm1
mov    $0x2,%al
call   1030 <printf@plt>
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
mov    $0x8,%edx
xor    %eax,%eax
call   1040 <swap@plt>
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
lea    0xe7b(%rip),%rdi
mov    $0x2,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Before: x1=%d,int2=%d\0A\00"
@.str.1 = [22 x i8] c"After: x1=%d,int2=%d\0A\00"
@.str.2 = [23 x i8] c"Before: y1=%lf,y2=%lf\0A\00"
@.str.3 = [22 x i8] c"After: y1=%lf,y2=%lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca double
%5 = alloca double
store i32 0, i32* %1
store i32 8, i32* %2
store i32 5, i32* %3
store double 1.050000e+01, double* %4
store double 1.550000e+01, double* %5
%6 = load i32, i32* %2
%7 = load i32, i32* %3
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %7)
%9 = call i32 (i32*, i32*, i64, ...) bitcast (i32 (...)* @swap to i32 (i32*, i32*, i64, ...)*)(i32* %2, i32* %3, i64 4)
%10 = load i32, i32* %2
%11 = load i32, i32* %3
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %10, i32 %11)
%13 = load double, double* %4
%14 = load double, double* %5
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), double %13, double %14)
%16 = call i32 (double*, double*, i64, ...) bitcast (i32 (...)* @swap to i32 (double*, double*, i64, ...)*)(double* %4, double* %5, i64 8)
%17 = load double, double* %4
%18 = load double, double* %5
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), double %17, double %18)
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"Before: x1=%d,int2=%d\0A\00"
@.str.1 = [22 x i8] c"After: x1=%d,int2=%d\0A\00"
@.str.2 = [23 x i8] c"Before: y1=%lf,y2=%lf\0A\00"
@.str.3 = [22 x i8] c"After: y1=%lf,y2=%lf\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca double
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast double* %3 to i8*
%8 = bitcast double* %4 to i8*
store i32 8, i32* %1
store i32 5, i32* %2
store double 1.050000e+01, double* %3
store double 1.550000e+01, double* %4
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 8, i32 5)
%10 = call i32 (i32*, i32*, i64, ...) bitcast (i32 (...)* @swap to i32 (i32*, i32*, i64, ...)*)(i32* %1, i32* %2, i64 4)
%11 = load i32, i32* %1
%12 = load i32, i32* %2
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %11, i32 %12)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), double 1.050000e+01, double 1.550000e+01)
%15 = call i32 (double*, double*, i64, ...) bitcast (i32 (...)* @swap to i32 (double*, double*, i64, ...)*)(double* %3, double* %4, i64 8)
%16 = load double, double* %3
%17 = load double, double* %4
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), double %16, double %17)
ret i32 0
}