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

/* Variables and functions */
int /*<<< orphan*/ memcpy(scalar_t__ **, int *, int);
uint32_t ojp_htonl(uint32_t val) {
  uint8_t bytes[4] = {0};
  memcpy(&bytes, &val, 4);
  return ((uint32_t)bytes[3] << 0) | ((uint32_t)bytes[2] << 8) |
         ((uint32_t)bytes[1] << 16) | ((uint32_t)bytes[0] << 24);
}


x86 assembly (clang, -O0):
<ojp_htonl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1030 <memset@plt>
lea    -0x30(%rbp),%rdi
lea    -0x4(%rbp),%rsi
mov    $0x4,%edx
call   1040 <memcpy@plt>
mov    -0x18(%rbp),%rax
shl    $0x0,%eax
mov    -0x20(%rbp),%rcx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0x28(%rbp),%rcx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x30(%rbp),%rcx
shl    $0x18,%ecx
or     %ecx,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ojp_htonl>:
sub    $0x38,%rsp
mov    %edi,0xc(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rsi
mov    $0x4,%edx
call   1030 <memcpy@plt>
mov    0x20(%rsp),%ecx
shl    $0x8,%ecx
or     0x28(%rsp),%ecx
mov    0x10(%rsp),%eax
mov    0x18(%rsp),%edx
shl    $0x10,%edx
shl    $0x18,%eax
or     %edx,%eax
or     %ecx,%eax
add    $0x38,%rsp
ret

LLVM IR (-O0):
define i32 @ojp_htonl(i32 %0) {
%2 = alloca i32
%3 = alloca [4 x i64]
store i32 %0, i32* %2
%4 = bitcast [4 x i64]* %3 to i8*
%5 = bitcast [4 x i64]* %3 to i64**
%6 = call i32 @memcpy(i64** %5, i32* %2, i32 4)
%7 = getelementptr inbounds [4 x i64], [4 x i64]* %3, i64 0, i64 3
%8 = load i64, i64* %7
%9 = trunc i64 %8 to i32
%10 = shl i32 %9, 0
%11 = getelementptr inbounds [4 x i64], [4 x i64]* %3, i64 0, i64 2
%12 = load i64, i64* %11
%13 = trunc i64 %12 to i32
%14 = shl i32 %13, 8
%15 = or i32 %10, %14
%16 = getelementptr inbounds [4 x i64], [4 x i64]* %3, i64 0, i64 1
%17 = load i64, i64* %16
%18 = trunc i64 %17 to i32
%19 = shl i32 %18, 16
%20 = or i32 %15, %19
%21 = getelementptr inbounds [4 x i64], [4 x i64]* %3, i64 0, i64 0
%22 = load i64, i64* %21
%23 = trunc i64 %22 to i32
%24 = shl i32 %23, 24
%25 = or i32 %20, %24
ret i32 %25
}

LLVM IR (-O2):
define i32 @ojp_htonl(i32 %0) {
%2 = alloca i32
%3 = alloca [4 x i64]
store i32 %0, i32* %2
%4 = bitcast [4 x i64]* %3 to i8*
%5 = bitcast [4 x i64]* %3 to i64**
%6 = call i32 @memcpy(i64** %5, i32* %2, i32 4)
%7 = getelementptr inbounds [4 x i64], [4 x i64]* %3, i64 0, i64 3
%8 = load i64, i64* %7
%9 = trunc i64 %8 to i32
%10 = getelementptr inbounds [4 x i64], [4 x i64]* %3, i64 0, i64 2
%11 = load i64, i64* %10
%12 = trunc i64 %11 to i32
%13 = shl i32 %12, 8
%14 = or i32 %13, %9
%15 = getelementptr inbounds [4 x i64], [4 x i64]* %3, i64 0, i64 1
%16 = load i64, i64* %15
%17 = trunc i64 %16 to i32
%18 = shl i32 %17, 16
%19 = or i32 %14, %18
%20 = getelementptr inbounds [4 x i64], [4 x i64]* %3, i64 0, i64 0
%21 = load i64, i64* %20
%22 = trunc i64 %21 to i32
%23 = shl i32 %22, 24
%24 = or i32 %19, %23
ret i32 %24
}