void rev32(unsigned char *x, const unsigned char *t) {
  for (int i = 0; i < 32; i++) {
    x[31 - i] = t[i];
  }
}


x86 assembly (clang, -O0):
<rev32>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x20,-0x14(%rbp)
jge    1148 <rev32+0x48>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
mov    $0x1f,%ecx
sub    -0x14(%rbp),%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1113 <rev32+0x13>
pop    %rbp
ret

x86 assembly (clang, -O2):
<rev32>:
lea    0x20(%rsi),%rax
cmp    %rdi,%rax
jbe    114a <rev32+0x4a>
lea    0x20(%rdi),%rax
cmp    %rsi,%rax
jbe    114a <rev32+0x4a>
add    $0x3,%rsi
mov    $0x20,%eax
nopl   0x0(%rax,%rax,1)
movzbl -0x3(%rsi),%ecx
mov    %cl,-0x1(%rdi,%rax,1)
movzbl -0x2(%rsi),%ecx
mov    %cl,-0x2(%rdi,%rax,1)
movzbl -0x1(%rsi),%ecx
mov    %cl,-0x3(%rdi,%rax,1)
movzbl (%rsi),%ecx
mov    %cl,-0x4(%rdi,%rax,1)
add    $0x4,%rsi
add    $0xfffffffffffffffc,%rax
jne    1120 <rev32+0x20>
ret
movdqu (%rsi),%xmm0
pxor   %xmm1,%xmm1
movdqa %xmm0,%xmm2
punpcklbw %xmm1,%xmm2
pshufd $0x4e,%xmm2,%xmm2
pshuflw $0x1b,%xmm2,%xmm2
pshufhw $0x1b,%xmm2,%xmm2
punpckhbw %xmm1,%xmm0
pshufd $0x4e,%xmm0,%xmm0
pshuflw $0x1b,%xmm0,%xmm0
pshufhw $0x1b,%xmm0,%xmm0
packuswb %xmm2,%xmm0
movdqu %xmm0,0x10(%rdi)
movdqu 0x10(%rsi),%xmm0
movdqa %xmm0,%xmm2
punpcklbw %xmm1,%xmm2
pshufd $0x4e,%xmm2,%xmm2
pshuflw $0x1b,%xmm2,%xmm2
pshufhw $0x1b,%xmm2,%xmm2
punpckhbw %xmm1,%xmm0
pshufd $0x4e,%xmm0,%xmm0
pshuflw $0x1b,%xmm0,%xmm0
pshufhw $0x1b,%xmm0,%xmm0
packuswb %xmm2,%xmm0
movdqu %xmm0,(%rdi)
ret

LLVM IR (-O0):
define void @rev32(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %5
br label %6
6: ; preds = %20, %2
%7 = load i32, i32* %5
%8 = icmp slt i32 %7, 32
br i1 %8, label %9, label %23
9: ; preds = %6
%10 = load i8*, i8** %4
%11 = load i32, i32* %5
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = load i8, i8* %13
%15 = load i8*, i8** %3
%16 = load i32, i32* %5
%17 = sub nsw i32 31, %16
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %15, i64 %18
store i8 %14, i8* %19
br label %20
20: ; preds = %9
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %6
23: ; preds = %6
ret void
}

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