int *reverseFourByteWord(int *N) {
  char byteArray[4] = {'0', '0', '0', '0'};
  char *bytePointer;
  bytePointer = (char *)N;
  byteArray[0] = *bytePointer;
  byteArray[1] = *(bytePointer + 1);
  byteArray[2] = *(bytePointer + 2);
  byteArray[3] = *(bytePointer + 3);
  *bytePointer = byteArray[3];
  *(bytePointer + 1) = byteArray[2];
  *(bytePointer + 2) = byteArray[1];
  *(bytePointer + 3) = byteArray[0];
  N = (int *)bytePointer;
  return N;
}


x86 assembly (clang, -O0):
<reverseFourByteWord>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    0xef2(%rip),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%al
mov    %al,-0xc(%rbp)
mov    -0x18(%rbp),%rax
mov    0x1(%rax),%al
mov    %al,-0xb(%rbp)
mov    -0x18(%rbp),%rax
mov    0x2(%rax),%al
mov    %al,-0xa(%rbp)
mov    -0x18(%rbp),%rax
mov    0x3(%rax),%al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0xa(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0xb(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x2(%rax)
mov    -0xc(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x3(%rax)
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<reverseFourByteWord>:
mov    %rdi,%rax
mov    (%rdi),%sil
mov    0x1(%rdi),%dil
mov    0x2(%rax),%cl
mov    0x3(%rax),%dl
mov    %dl,(%rax)
mov    %cl,0x1(%rax)
mov    %dil,0x2(%rax)
mov    %sil,0x3(%rax)
ret

LLVM IR (-O0):
@__const.reverseFourByteWord.byteArray = [4 x i8] c"0000"
define i32* @reverseFourByteWord(i32* %0) {
%2 = alloca i32*
%3 = alloca [4 x i8]
%4 = alloca i8*
store i32* %0, i32** %2
%5 = bitcast [4 x i8]* %3 to i8*
%6 = load i32*, i32** %2
%7 = bitcast i32* %6 to i8*
store i8* %7, i8** %4
%8 = load i8*, i8** %4
%9 = load i8, i8* %8
%10 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
store i8 %9, i8* %10
%11 = load i8*, i8** %4
%12 = getelementptr inbounds i8, i8* %11, i64 1
%13 = load i8, i8* %12
%14 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 1
store i8 %13, i8* %14
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i64 2
%17 = load i8, i8* %16
%18 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 2
store i8 %17, i8* %18
%19 = load i8*, i8** %4
%20 = getelementptr inbounds i8, i8* %19, i64 3
%21 = load i8, i8* %20
%22 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 3
store i8 %21, i8* %22
%23 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 3
%24 = load i8, i8* %23
%25 = load i8*, i8** %4
store i8 %24, i8* %25
%26 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 2
%27 = load i8, i8* %26
%28 = load i8*, i8** %4
%29 = getelementptr inbounds i8, i8* %28, i64 1
store i8 %27, i8* %29
%30 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 1
%31 = load i8, i8* %30
%32 = load i8*, i8** %4
%33 = getelementptr inbounds i8, i8* %32, i64 2
store i8 %31, i8* %33
%34 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%35 = load i8, i8* %34
%36 = load i8*, i8** %4
%37 = getelementptr inbounds i8, i8* %36, i64 3
store i8 %35, i8* %37
%38 = load i8*, i8** %4
%39 = bitcast i8* %38 to i32*
store i32* %39, i32** %2
%40 = load i32*, i32** %2
ret i32* %40
}

LLVM IR (-O2):
define i32* @reverseFourByteWord(i32* returned %0) {
%2 = bitcast i32* %0 to i8*
%3 = load i8, i8* %2
%4 = getelementptr inbounds i8, i8* %2, i64 1
%5 = load i8, i8* %4
%6 = getelementptr inbounds i8, i8* %2, i64 2
%7 = load i8, i8* %6
%8 = getelementptr inbounds i8, i8* %2, i64 3
%9 = load i8, i8* %8
store i8 %9, i8* %2
store i8 %7, i8* %4
store i8 %5, i8* %6
store i8 %3, i8* %8
ret i32* %0
}