#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 uint16_t;

/* Variables and functions */
int /*<<< orphan*/ memcpy(void *, void const *, int);
void utils_int32Copy(void *dst, const void *src) {
  const bool is_big_endian = (*(uint16_t *)"\0\xff" < 0x100);
  if (is_big_endian)
    memcpy(dst, src, 4);
  else {
    ((uint8_t *)dst)[0] = ((const uint8_t *)src)[3];
    ((uint8_t *)dst)[1] = ((const uint8_t *)src)[2];
    ((uint8_t *)dst)[2] = ((const uint8_t *)src)[1];
    ((uint8_t *)dst)[3] = ((const uint8_t *)src)[0];
  }
}


x86 assembly (clang, -O0):
<utils_int32Copy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x100,0xed6(%rip)
setl   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1156 <utils_int32Copy+0x46>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x4,%edx
call   1030 <memcpy@plt>
jmp    118c <utils_int32Copy+0x7c>
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0xc(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<utils_int32Copy>:
mov    0xc(%rsi),%eax
mov    %eax,(%rdi)
mov    0x8(%rsi),%eax
mov    %eax,0x4(%rdi)
mov    0x4(%rsi),%eax
mov    %eax,0x8(%rdi)
mov    (%rsi),%eax
mov    %eax,0xc(%rdi)
ret

LLVM IR (-O0):
@.str = [3 x i8] c"\00\FF\00"
define void @utils_int32Copy(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i32, i32* bitcast ([3 x i8]* @.str to i32*)
%7 = icmp slt i32 %6, 256
%8 = zext i1 %7 to i32
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i8*, i8** %3
%13 = load i8*, i8** %4
%14 = call i32 @memcpy(i8* %12, i8* %13, i32 4)
br label %44
15: ; preds = %2
%16 = load i8*, i8** %4
%17 = bitcast i8* %16 to i32*
%18 = getelementptr inbounds i32, i32* %17, i64 3
%19 = load i32, i32* %18
%20 = load i8*, i8** %3
%21 = bitcast i8* %20 to i32*
%22 = getelementptr inbounds i32, i32* %21, i64 0
store i32 %19, i32* %22
%23 = load i8*, i8** %4
%24 = bitcast i8* %23 to i32*
%25 = getelementptr inbounds i32, i32* %24, i64 2
%26 = load i32, i32* %25
%27 = load i8*, i8** %3
%28 = bitcast i8* %27 to i32*
%29 = getelementptr inbounds i32, i32* %28, i64 1
store i32 %26, i32* %29
%30 = load i8*, i8** %4
%31 = bitcast i8* %30 to i32*
%32 = getelementptr inbounds i32, i32* %31, i64 1
%33 = load i32, i32* %32
%34 = load i8*, i8** %3
%35 = bitcast i8* %34 to i32*
%36 = getelementptr inbounds i32, i32* %35, i64 2
store i32 %33, i32* %36
%37 = load i8*, i8** %4
%38 = bitcast i8* %37 to i32*
%39 = getelementptr inbounds i32, i32* %38, i64 0
%40 = load i32, i32* %39
%41 = load i8*, i8** %3
%42 = bitcast i8* %41 to i32*
%43 = getelementptr inbounds i32, i32* %42, i64 3
store i32 %40, i32* %43
br label %44
44: ; preds = %15, %11
ret void
}

LLVM IR (-O2):
define void @utils_int32Copy(i8* nocapture writeonly %0, i8* nocapture %1) {
%3 = bitcast i8* %1 to i32*
%4 = getelementptr inbounds i8, i8* %1, i64 12
%5 = bitcast i8* %4 to i32*
%6 = load i32, i32* %5
%7 = bitcast i8* %0 to i32*
store i32 %6, i32* %7
%8 = getelementptr inbounds i8, i8* %1, i64 8
%9 = bitcast i8* %8 to i32*
%10 = load i32, i32* %9
%11 = getelementptr inbounds i8, i8* %0, i64 4
%12 = bitcast i8* %11 to i32*
store i32 %10, i32* %12
%13 = getelementptr inbounds i8, i8* %1, i64 4
%14 = bitcast i8* %13 to i32*
%15 = load i32, i32* %14
%16 = getelementptr inbounds i8, i8* %0, i64 8
%17 = bitcast i8* %16 to i32*
store i32 %15, i32* %17
%18 = load i32, i32* %3
%19 = getelementptr inbounds i8, i8* %0, i64 12
%20 = bitcast i8* %19 to i32*
store i32 %18, i32* %20
ret void
}