#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 */
typedef void *u_char;

/* Variables and functions */
void swap_bytes(const u_char *src, u_char *dst, int n) {
  u_char c[4];
  for (n = n / 4; n > 0; n--) {
    c[3] = *src++;
    c[2] = *src++;
    c[1] = *src++;
    c[0] = *src++;
    *dst++ = c[0];
    *dst++ = c[1];
    *dst++ = c[2];
    *dst++ = c[3];
  }
}


x86 assembly (clang, -O0):
<swap_bytes>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    11e5 <swap_bytes+0xe5>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x8(%rbp)
mov    (%rax),%rax
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,-0x10(%rbp)
mov    %rcx,(%rax)
mov    -0x38(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,-0x10(%rbp)
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,-0x10(%rbp)
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x8,%rdx
mov    %rdx,-0x10(%rbp)
mov    %rcx,(%rax)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    111d <swap_bytes+0x1d>
pop    %rbp
ret

x86 assembly (clang, -O2):
<swap_bytes>:
cmp    $0x4,%edx
jl     113c <swap_bytes+0x3c>
shr    $0x2,%edx
add    $0x1,%edx
xor    %eax,%eax
nopl   (%rax)
movdqu (%rdi,%rax,1),%xmm0
movdqu 0x10(%rdi,%rax,1),%xmm1
pshufd $0x4e,%xmm1,%xmm1
movdqu %xmm1,(%rsi,%rax,1)
pshufd $0x4e,%xmm0,%xmm0
movdqu %xmm0,0x10(%rsi,%rax,1)
add    $0x20,%rax
add    $0xffffffff,%edx
cmp    $0x1,%edx
ja     1110 <swap_bytes+0x10>
ret

LLVM IR (-O0):
define void @swap_bytes(i8** %0, i8** %1, i32 %2) {
%4 = alloca i8**
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [4 x i8*]
store i8** %0, i8*** %4
store i8** %1, i8*** %5
store i32 %2, i32* %6
%8 = load i32, i32* %6
%9 = sdiv i32 %8, 4
store i32 %9, i32* %6
br label %10
10: ; preds = %46, %3
%11 = load i32, i32* %6
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %49
13: ; preds = %10
%14 = load i8**, i8*** %4
%15 = getelementptr inbounds i8*, i8** %14, i32 1
store i8** %15, i8*** %4
%16 = load i8*, i8** %14
%17 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 3
store i8* %16, i8** %17
%18 = load i8**, i8*** %4
%19 = getelementptr inbounds i8*, i8** %18, i32 1
store i8** %19, i8*** %4
%20 = load i8*, i8** %18
%21 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 2
store i8* %20, i8** %21
%22 = load i8**, i8*** %4
%23 = getelementptr inbounds i8*, i8** %22, i32 1
store i8** %23, i8*** %4
%24 = load i8*, i8** %22
%25 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 1
store i8* %24, i8** %25
%26 = load i8**, i8*** %4
%27 = getelementptr inbounds i8*, i8** %26, i32 1
store i8** %27, i8*** %4
%28 = load i8*, i8** %26
%29 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 0
store i8* %28, i8** %29
%30 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 0
%31 = load i8*, i8** %30
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i32 1
store i8** %33, i8*** %5
store i8* %31, i8** %32
%34 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 1
%35 = load i8*, i8** %34
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i32 1
store i8** %37, i8*** %5
store i8* %35, i8** %36
%38 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 2
%39 = load i8*, i8** %38
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i32 1
store i8** %41, i8*** %5
store i8* %39, i8** %40
%42 = getelementptr inbounds [4 x i8*], [4 x i8*]* %7, i64 0, i64 3
%43 = load i8*, i8** %42
%44 = load i8**, i8*** %5
%45 = getelementptr inbounds i8*, i8** %44, i32 1
store i8** %45, i8*** %5
store i8* %43, i8** %44
br label %46
46: ; preds = %13
%47 = load i32, i32* %6
%48 = add nsw i32 %47, -1
store i32 %48, i32* %6
br label %10
49: ; preds = %10
ret void
}

LLVM IR (-O2):
define void @swap_bytes(i8** nocapture %0, i8** nocapture writeonly %1, i32 %2) {
%4 = icmp sgt i32 %2, 3
br i1 %4, label %5, label %25
5: ; preds = %3
%6 = lshr i32 %2, 2
br label %7
7: ; preds = %5, %7
%8 = phi i8** [ %14, %7 ], [ %0, %5 ]
%9 = phi i8** [ %20, %7 ], [ %1, %5 ]
%10 = phi i32 [ %23, %7 ], [ %6, %5 ]
%11 = getelementptr inbounds i8*, i8** %8, i64 2
%12 = bitcast i8** %8 to <2 x i8*>*
%13 = load <2 x i8*>, <2 x i8*>* %12
%14 = getelementptr inbounds i8*, i8** %8, i64 4
%15 = bitcast i8** %11 to <2 x i8*>*
%16 = load <2 x i8*>, <2 x i8*>* %15
%17 = getelementptr inbounds i8*, i8** %9, i64 2
%18 = shufflevector <2 x i8*> %16, <2 x i8*> poison, <2 x i32> <i32 1, i32 0>
%19 = bitcast i8** %9 to <2 x i8*>*
store <2 x i8*> %18, <2 x i8*>* %19
%20 = getelementptr inbounds i8*, i8** %9, i64 4
%21 = shufflevector <2 x i8*> %13, <2 x i8*> poison, <2 x i32> <i32 1, i32 0>
%22 = bitcast i8** %17 to <2 x i8*>*
store <2 x i8*> %21, <2 x i8*>* %22
%23 = add nsw i32 %10, -1
%24 = icmp ugt i32 %10, 1
br i1 %24, label %7, label %25
25: ; preds = %7, %3
ret void
}