#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 /*<<< orphan*/ uint8_t;
typedef int /*<<< orphan*/ int32_t;

/* Variables and functions */
void gffi_set_int_32_swapped(uint8_t *location, int offset, int32_t value) {
  uint8_t *buf = (uint8_t *)&value;
  location[offset + 0] = buf[3];
  location[offset + 1] = buf[2];
  location[offset + 2] = buf[1];
  location[offset + 3] = buf[0];
}


x86 assembly (clang, -O0):
<gffi_set_int_32_swapped>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
lea    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%edx
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x0,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%edx
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%edx
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x3,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
pop    %rbp
ret

x86 assembly (clang, -O2):
<gffi_set_int_32_swapped>:
movslq %esi,%rax
mov    %edx,0xc(%rdi,%rax,4)
ret

LLVM IR (-O0):
define void @gffi_set_int_32_swapped(i32* %0, i32 %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
store i32* %0, i32** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32* %6, i32** %7
%8 = load i32*, i32** %7
%9 = getelementptr inbounds i32, i32* %8, i64 3
%10 = load i32, i32* %9
%11 = load i32*, i32** %4
%12 = load i32, i32* %5
%13 = add nsw i32 %12, 0
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %11, i64 %14
store i32 %10, i32* %15
%16 = load i32*, i32** %7
%17 = getelementptr inbounds i32, i32* %16, i64 2
%18 = load i32, i32* %17
%19 = load i32*, i32** %4
%20 = load i32, i32* %5
%21 = add nsw i32 %20, 1
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %19, i64 %22
store i32 %18, i32* %23
%24 = load i32*, i32** %7
%25 = getelementptr inbounds i32, i32* %24, i64 1
%26 = load i32, i32* %25
%27 = load i32*, i32** %4
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 2
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32, i32* %27, i64 %30
store i32 %26, i32* %31
%32 = load i32*, i32** %7
%33 = getelementptr inbounds i32, i32* %32, i64 0
%34 = load i32, i32* %33
%35 = load i32*, i32** %4
%36 = load i32, i32* %5
%37 = add nsw i32 %36, 3
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %35, i64 %38
store i32 %34, i32* %39
ret void
}

LLVM IR (-O2):
define void @gffi_set_int_32_swapped(i32* nocapture writeonly %0, i32 %1, i32 %2) {
%4 = add nsw i32 %1, 3
%5 = sext i32 %4 to i64
%6 = getelementptr inbounds i32, i32* %0, i64 %5
store i32 %2, i32* %6
ret void
}