int _swapl_by_addr(int *l) {
  int r[2];
  register char *p, *q;
  p = (char *)&r[1];
  q = (char *)l;
  *--p = *q++;
  *--p = *q++;
  *--p = *q++;
  *--p = *q++;
  return r[0];
}


x86 assembly (clang, -O0):
<_swapl_by_addr>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
lea    -0x10(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0xffffffffffffffff,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,-0x1(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0xffffffffffffffff,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,-0x1(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0xffffffffffffffff,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,-0x1(%rax)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0xffffffffffffffff,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,-0x1(%rax)
mov    -0x10(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<_swapl_by_addr>:
mov    (%rdi),%eax
bswap  %eax
ret

LLVM IR (-O0):
define i32 @_swapl_by_addr(i32* %0) {
%2 = alloca i32*
%3 = alloca [2 x i32]
%4 = alloca i8*
%5 = alloca i8*
store i32* %0, i32** %2
%6 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 1
%7 = bitcast i32* %6 to i8*
store i8* %7, i8** %4
%8 = load i32*, i32** %2
%9 = bitcast i32* %8 to i8*
store i8* %9, i8** %5
%10 = load i8*, i8** %5
%11 = getelementptr inbounds i8, i8* %10, i32 1
store i8* %11, i8** %5
%12 = load i8, i8* %10
%13 = load i8*, i8** %4
%14 = getelementptr inbounds i8, i8* %13, i32 -1
store i8* %14, i8** %4
store i8 %12, i8* %14
%15 = load i8*, i8** %5
%16 = getelementptr inbounds i8, i8* %15, i32 1
store i8* %16, i8** %5
%17 = load i8, i8* %15
%18 = load i8*, i8** %4
%19 = getelementptr inbounds i8, i8* %18, i32 -1
store i8* %19, i8** %4
store i8 %17, i8* %19
%20 = load i8*, i8** %5
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %5
%22 = load i8, i8* %20
%23 = load i8*, i8** %4
%24 = getelementptr inbounds i8, i8* %23, i32 -1
store i8* %24, i8** %4
store i8 %22, i8* %24
%25 = load i8*, i8** %5
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %5
%27 = load i8, i8* %25
%28 = load i8*, i8** %4
%29 = getelementptr inbounds i8, i8* %28, i32 -1
store i8* %29, i8** %4
store i8 %27, i8* %29
%30 = getelementptr inbounds [2 x i32], [2 x i32]* %3, i64 0, i64 0
%31 = load i32, i32* %30
ret i32 %31
}

LLVM IR (-O2):
define i32 @_swapl_by_addr(i32* nocapture %0) {
%2 = bitcast i32* %0 to i8*
%3 = getelementptr inbounds i8, i8* %2, i64 1
%4 = load i8, i8* %2
%5 = getelementptr inbounds i8, i8* %2, i64 2
%6 = load i8, i8* %3
%7 = getelementptr inbounds i8, i8* %2, i64 3
%8 = load i8, i8* %5
%9 = load i8, i8* %7
%10 = zext i8 %4 to i32
%11 = shl nuw i32 %10, 24
%12 = zext i8 %6 to i32
%13 = shl nuw nsw i32 %12, 16
%14 = or i32 %13, %11
%15 = zext i8 %8 to i32
%16 = shl nuw nsw i32 %15, 8
%17 = or i32 %14, %16
%18 = zext i8 %9 to i32
%19 = or i32 %17, %18
ret i32 %19
}