#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*/ uint32_t;

/* Variables and functions */
scalar_t__ otfcc_check_endian();
uint32_t otfcc_endian_convert32(uint32_t i) {
  if (otfcc_check_endian()) {
    union {
      uint8_t i1[4];
      uint32_t i4;
    } src, des;
    src.i4 = i;
    des.i1[0] = src.i1[3];
    des.i1[1] = src.i1[2];
    des.i1[2] = src.i1[1];
    des.i1[3] = src.i1[0];
    return des.i4;
  } else {
    return i;
  }
}


x86 assembly (clang, -O0):
<otfcc_endian_convert32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    $0x0,%al
call   1030 <otfcc_check_endian@plt>
cmp    $0x0,%rax
je     1155 <otfcc_endian_convert32+0x45>
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x28(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    115b <otfcc_endian_convert32+0x4b>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<otfcc_endian_convert32>:
push   %rbx
mov    %edi,%ebx
xor    %eax,%eax
call   1030 <otfcc_check_endian@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
%union.anon = type { [4 x i32] }
define i32 @otfcc_endian_convert32(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca %union.anon
%5 = alloca %union.anon
store i32 %0, i32* %3
%6 = call i64 (...) @otfcc_check_endian()
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %33
8: ; preds = %1
%9 = load i32, i32* %3
%10 = bitcast %union.anon* %4 to i32*
store i32 %9, i32* %10
%11 = bitcast %union.anon* %4 to [4 x i32]*
%12 = getelementptr inbounds [4 x i32], [4 x i32]* %11, i64 0, i64 3
%13 = load i32, i32* %12
%14 = bitcast %union.anon* %5 to [4 x i32]*
%15 = getelementptr inbounds [4 x i32], [4 x i32]* %14, i64 0, i64 0
store i32 %13, i32* %15
%16 = bitcast %union.anon* %4 to [4 x i32]*
%17 = getelementptr inbounds [4 x i32], [4 x i32]* %16, i64 0, i64 2
%18 = load i32, i32* %17
%19 = bitcast %union.anon* %5 to [4 x i32]*
%20 = getelementptr inbounds [4 x i32], [4 x i32]* %19, i64 0, i64 1
store i32 %18, i32* %20
%21 = bitcast %union.anon* %4 to [4 x i32]*
%22 = getelementptr inbounds [4 x i32], [4 x i32]* %21, i64 0, i64 1
%23 = load i32, i32* %22
%24 = bitcast %union.anon* %5 to [4 x i32]*
%25 = getelementptr inbounds [4 x i32], [4 x i32]* %24, i64 0, i64 2
store i32 %23, i32* %25
%26 = bitcast %union.anon* %4 to [4 x i32]*
%27 = getelementptr inbounds [4 x i32], [4 x i32]* %26, i64 0, i64 0
%28 = load i32, i32* %27
%29 = bitcast %union.anon* %5 to [4 x i32]*
%30 = getelementptr inbounds [4 x i32], [4 x i32]* %29, i64 0, i64 3
store i32 %28, i32* %30
%31 = bitcast %union.anon* %5 to i32*
%32 = load i32, i32* %31
store i32 %32, i32* %2
br label %35
33: ; preds = %1
%34 = load i32, i32* %3
store i32 %34, i32* %2
br label %35
35: ; preds = %33, %8
%36 = load i32, i32* %2
ret i32 %36
}

LLVM IR (-O2):
define i32 @otfcc_endian_convert32(i32 returned %0) {
%2 = tail call i64 (...) @otfcc_check_endian()
ret i32 %0
}