#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 int uint32_t;

/* Variables and functions */
uint32_t swab32a(uint32_t value, const unsigned char *shifts) {
  return (((value >> 0) & 0xFF) << shifts[0] * 8) |
         (((value >> 8) & 0xFF) << shifts[1] * 8) |
         (((value >> 16) & 0xFF) << shifts[2] * 8) |
         (((value >> 24) & 0xFF) << shifts[3] * 8);
}


x86 assembly (clang, -O0):
<swab32a>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x0,%eax
and    $0xff,%eax
mov    -0x10(%rbp),%rcx
movzbl (%rcx),%ecx
shl    $0x3,%ecx
shl    %cl,%eax
mov    -0x4(%rbp),%edx
sar    $0x8,%edx
and    $0xff,%edx
mov    -0x10(%rbp),%rcx
movzbl 0x1(%rcx),%ecx
shl    $0x3,%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    -0x4(%rbp),%edx
sar    $0x10,%edx
and    $0xff,%edx
mov    -0x10(%rbp),%rcx
movzbl 0x2(%rcx),%ecx
shl    $0x3,%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    -0x4(%rbp),%edx
sar    $0x18,%edx
and    $0xff,%edx
mov    -0x10(%rbp),%rcx
movzbl 0x3(%rcx),%ecx
shl    $0x3,%ecx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<swab32a>:
push   %rbx
mov    %edi,%edx
movzbl %dl,%edi
mov    (%rsi),%cl
mov    0x1(%rsi),%al
shl    $0x3,%cl
shl    %cl,%edi
movzbl %dh,%ebx
shl    $0x3,%al
mov    %eax,%ecx
shl    %cl,%ebx
mov    %edx,%eax
shr    $0x10,%eax
movzbl %al,%eax
mov    0x2(%rsi),%cl
shl    $0x3,%cl
shl    %cl,%eax
mov    0x3(%rsi),%cl
shr    $0x18,%edx
shl    $0x3,%cl
shl    %cl,%edx
or     %edi,%ebx
or     %edx,%eax
or     %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @swab32a(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%5 = load i32, i32* %3
%6 = ashr i32 %5, 0
%7 = and i32 %6, 255
%8 = load i8*, i8** %4
%9 = getelementptr inbounds i8, i8* %8, i64 0
%10 = load i8, i8* %9
%11 = zext i8 %10 to i32
%12 = mul nsw i32 %11, 8
%13 = shl i32 %7, %12
%14 = load i32, i32* %3
%15 = ashr i32 %14, 8
%16 = and i32 %15, 255
%17 = load i8*, i8** %4
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = load i8, i8* %18
%20 = zext i8 %19 to i32
%21 = mul nsw i32 %20, 8
%22 = shl i32 %16, %21
%23 = or i32 %13, %22
%24 = load i32, i32* %3
%25 = ashr i32 %24, 16
%26 = and i32 %25, 255
%27 = load i8*, i8** %4
%28 = getelementptr inbounds i8, i8* %27, i64 2
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = mul nsw i32 %30, 8
%32 = shl i32 %26, %31
%33 = or i32 %23, %32
%34 = load i32, i32* %3
%35 = ashr i32 %34, 24
%36 = and i32 %35, 255
%37 = load i8*, i8** %4
%38 = getelementptr inbounds i8, i8* %37, i64 3
%39 = load i8, i8* %38
%40 = zext i8 %39 to i32
%41 = mul nsw i32 %40, 8
%42 = shl i32 %36, %41
%43 = or i32 %33, %42
ret i32 %43
}

LLVM IR (-O2):
define i32 @swab32a(i32 %0, i8* nocapture %1) {
%3 = and i32 %0, 255
%4 = load i8, i8* %1
%5 = zext i8 %4 to i32
%6 = shl nuw nsw i32 %5, 3
%7 = shl i32 %3, %6
%8 = lshr i32 %0, 8
%9 = and i32 %8, 255
%10 = getelementptr inbounds i8, i8* %1, i64 1
%11 = load i8, i8* %10
%12 = zext i8 %11 to i32
%13 = shl nuw nsw i32 %12, 3
%14 = shl i32 %9, %13
%15 = or i32 %14, %7
%16 = lshr i32 %0, 16
%17 = and i32 %16, 255
%18 = getelementptr inbounds i8, i8* %1, i64 2
%19 = load i8, i8* %18
%20 = zext i8 %19 to i32
%21 = shl nuw nsw i32 %20, 3
%22 = shl i32 %17, %21
%23 = or i32 %15, %22
%24 = lshr i32 %0, 24
%25 = getelementptr inbounds i8, i8* %1, i64 3
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = shl nuw nsw i32 %27, 3
%29 = shl i32 %24, %28
%30 = or i32 %23, %29
ret i32 %30
}