void byte_swap_assign(void *out_ptr, void *in_ptr, int nmemb) {
  int j;
  char *char_in_ptr, *char_out_ptr;
  double *double_in_ptr, *double_out_ptr;
  double_in_ptr = (double *)in_ptr;
  double_out_ptr = (double *)out_ptr;
  for (j = 0; j < nmemb; j++) {
    char_in_ptr = (char *)double_in_ptr;
    char_out_ptr = (char *)double_out_ptr;
    char_out_ptr[7] = char_in_ptr[0];
    char_out_ptr[6] = char_in_ptr[1];
    char_out_ptr[5] = char_in_ptr[2];
    char_out_ptr[4] = char_in_ptr[3];
    char_out_ptr[3] = char_in_ptr[4];
    char_out_ptr[2] = char_in_ptr[5];
    char_out_ptr[1] = char_in_ptr[6];
    char_out_ptr[0] = char_in_ptr[7];
    double_in_ptr++;
    double_out_ptr++;
  }
}


x86 assembly (clang, -O0):
<byte_swap_assign>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11d6 <byte_swap_assign+0xd6>
mov    -0x30(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%cl
mov    -0x28(%rbp),%rax
mov    %cl,0x7(%rax)
mov    -0x20(%rbp),%rax
mov    0x1(%rax),%cl
mov    -0x28(%rbp),%rax
mov    %cl,0x6(%rax)
mov    -0x20(%rbp),%rax
mov    0x2(%rax),%cl
mov    -0x28(%rbp),%rax
mov    %cl,0x5(%rax)
mov    -0x20(%rbp),%rax
mov    0x3(%rax),%cl
mov    -0x28(%rbp),%rax
mov    %cl,0x4(%rax)
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%cl
mov    -0x28(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x20(%rbp),%rax
mov    0x5(%rax),%cl
mov    -0x28(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0x20(%rbp),%rax
mov    0x6(%rax),%cl
mov    -0x28(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x20(%rbp),%rax
mov    0x7(%rax),%cl
mov    -0x28(%rbp),%rax
mov    %cl,(%rax)
mov    -0x30(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x30(%rbp)
mov    -0x38(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1126 <byte_swap_assign+0x26>
pop    %rbp
ret

x86 assembly (clang, -O2):
<byte_swap_assign>:
test   %edx,%edx
jle    115e <byte_swap_assign+0x5e>
mov    %edx,%eax
xor    %ecx,%ecx
nopl   0x0(%rax,%rax,1)
movzbl (%rsi,%rcx,8),%edx
mov    %dl,0x7(%rdi,%rcx,8)
movzbl 0x1(%rsi,%rcx,8),%edx
mov    %dl,0x6(%rdi,%rcx,8)
movzbl 0x2(%rsi,%rcx,8),%edx
mov    %dl,0x5(%rdi,%rcx,8)
movzbl 0x3(%rsi,%rcx,8),%edx
mov    %dl,0x4(%rdi,%rcx,8)
movzbl 0x4(%rsi,%rcx,8),%edx
mov    %dl,0x3(%rdi,%rcx,8)
movzbl 0x5(%rsi,%rcx,8),%edx
mov    %dl,0x2(%rdi,%rcx,8)
movzbl 0x6(%rsi,%rcx,8),%edx
mov    %dl,0x1(%rdi,%rcx,8)
movzbl 0x7(%rsi,%rcx,8),%edx
mov    %dl,(%rdi,%rcx,8)
add    $0x1,%rcx
cmp    %ecx,%eax
jne    1110 <byte_swap_assign+0x10>
ret

LLVM IR (-O0):
define void @byte_swap_assign(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca double*
%11 = alloca double*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%12 = load i8*, i8** %5
%13 = bitcast i8* %12 to double*
store double* %13, double** %10
%14 = load i8*, i8** %4
%15 = bitcast i8* %14 to double*
store double* %15, double** %11
store i32 0, i32* %7
br label %16
16: ; preds = %69, %3
%17 = load i32, i32* %7
%18 = load i32, i32* %6
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %72
20: ; preds = %16
%21 = load double*, double** %10
%22 = bitcast double* %21 to i8*
store i8* %22, i8** %8
%23 = load double*, double** %11
%24 = bitcast double* %23 to i8*
store i8* %24, i8** %9
%25 = load i8*, i8** %8
%26 = getelementptr inbounds i8, i8* %25, i64 0
%27 = load i8, i8* %26
%28 = load i8*, i8** %9
%29 = getelementptr inbounds i8, i8* %28, i64 7
store i8 %27, i8* %29
%30 = load i8*, i8** %8
%31 = getelementptr inbounds i8, i8* %30, i64 1
%32 = load i8, i8* %31
%33 = load i8*, i8** %9
%34 = getelementptr inbounds i8, i8* %33, i64 6
store i8 %32, i8* %34
%35 = load i8*, i8** %8
%36 = getelementptr inbounds i8, i8* %35, i64 2
%37 = load i8, i8* %36
%38 = load i8*, i8** %9
%39 = getelementptr inbounds i8, i8* %38, i64 5
store i8 %37, i8* %39
%40 = load i8*, i8** %8
%41 = getelementptr inbounds i8, i8* %40, i64 3
%42 = load i8, i8* %41
%43 = load i8*, i8** %9
%44 = getelementptr inbounds i8, i8* %43, i64 4
store i8 %42, i8* %44
%45 = load i8*, i8** %8
%46 = getelementptr inbounds i8, i8* %45, i64 4
%47 = load i8, i8* %46
%48 = load i8*, i8** %9
%49 = getelementptr inbounds i8, i8* %48, i64 3
store i8 %47, i8* %49
%50 = load i8*, i8** %8
%51 = getelementptr inbounds i8, i8* %50, i64 5
%52 = load i8, i8* %51
%53 = load i8*, i8** %9
%54 = getelementptr inbounds i8, i8* %53, i64 2
store i8 %52, i8* %54
%55 = load i8*, i8** %8
%56 = getelementptr inbounds i8, i8* %55, i64 6
%57 = load i8, i8* %56
%58 = load i8*, i8** %9
%59 = getelementptr inbounds i8, i8* %58, i64 1
store i8 %57, i8* %59
%60 = load i8*, i8** %8
%61 = getelementptr inbounds i8, i8* %60, i64 7
%62 = load i8, i8* %61
%63 = load i8*, i8** %9
%64 = getelementptr inbounds i8, i8* %63, i64 0
store i8 %62, i8* %64
%65 = load double*, double** %10
%66 = getelementptr inbounds double, double* %65, i32 1
store double* %66, double** %10
%67 = load double*, double** %11
%68 = getelementptr inbounds double, double* %67, i32 1
store double* %68, double** %11
br label %69
69: ; preds = %20
%70 = load i32, i32* %7
%71 = add nsw i32 %70, 1
store i32 %71, i32* %7
br label %16
72: ; preds = %16
ret void
}

LLVM IR (-O2):
define void @byte_swap_assign(i8* nocapture writeonly %0, i8* nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %40
5: ; preds = %3
%6 = bitcast i8* %0 to double*
%7 = bitcast i8* %1 to double*
br label %8
8: ; preds = %5, %8
%9 = phi double* [ %37, %8 ], [ %6, %5 ]
%10 = phi double* [ %36, %8 ], [ %7, %5 ]
%11 = phi i32 [ %38, %8 ], [ 0, %5 ]
%12 = bitcast double* %10 to i8*
%13 = bitcast double* %9 to i8*
%14 = load i8, i8* %12
%15 = getelementptr inbounds i8, i8* %13, i64 7
store i8 %14, i8* %15
%16 = getelementptr inbounds i8, i8* %12, i64 1
%17 = load i8, i8* %16
%18 = getelementptr inbounds i8, i8* %13, i64 6
store i8 %17, i8* %18
%19 = getelementptr inbounds i8, i8* %12, i64 2
%20 = load i8, i8* %19
%21 = getelementptr inbounds i8, i8* %13, i64 5
store i8 %20, i8* %21
%22 = getelementptr inbounds i8, i8* %12, i64 3
%23 = load i8, i8* %22
%24 = getelementptr inbounds i8, i8* %13, i64 4
store i8 %23, i8* %24
%25 = getelementptr inbounds i8, i8* %12, i64 4
%26 = load i8, i8* %25
%27 = getelementptr inbounds i8, i8* %13, i64 3
store i8 %26, i8* %27
%28 = getelementptr inbounds i8, i8* %12, i64 5
%29 = load i8, i8* %28
%30 = getelementptr inbounds i8, i8* %13, i64 2
store i8 %29, i8* %30
%31 = getelementptr inbounds i8, i8* %12, i64 6
%32 = load i8, i8* %31
%33 = getelementptr inbounds i8, i8* %13, i64 1
store i8 %32, i8* %33
%34 = getelementptr inbounds i8, i8* %12, i64 7
%35 = load i8, i8* %34
store i8 %35, i8* %13
%36 = getelementptr inbounds double, double* %10, i64 1
%37 = getelementptr inbounds double, double* %9, i64 1
%38 = add nuw nsw i32 %11, 1
%39 = icmp eq i32 %38, %2
br i1 %39, label %40, label %8
40: ; preds = %8, %3
ret void
}