#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 uint64_t;
typedef int uint32_t;
typedef int low;
typedef int high;

/* Variables and functions */
uint64_t pal_ntohl64(uint64_t x) {
  uint32_t high = (uint32_t)((x & 0xffffffff00000000ULL) >> 32);
  uint32_t low = (uint32_t)((x & 0xffffffff));
  uint64_t res =
      ((uint64_t)(((((low)&0xff) << 24) | ((((low) >> 8) & 0xff) << 16) |
                   ((((low) >> 16) & 0xff) << 8) | ((((low) >> 24) & 0xff)))))
          << 32 |
      ((((high)&0xff) << 24) | ((((high) >> 8) & 0xff) << 16) |
       ((((high) >> 16) & 0xff) << 8) | ((((high) >> 24) & 0xff)));
  return (res);
}


x86 assembly (clang, -O0):
<pal_ntohl64>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
movslq -0x4(%rbp),%rax
movabs $0xffffffff00000000,%rcx
ff ff ff
and    %rcx,%rax
shr    $0x20,%rax
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0xff,%eax
shl    $0x18,%eax
mov    -0xc(%rbp),%ecx
sar    $0x8,%ecx
and    $0xff,%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0xc(%rbp),%ecx
sar    $0x10,%ecx
and    $0xff,%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    -0xc(%rbp),%ecx
sar    $0x18,%ecx
and    $0xff,%ecx
or     %ecx,%eax
mov    $0x20,%ecx
shl    %cl,%eax
mov    -0x8(%rbp),%ecx
and    $0xff,%ecx
shl    $0x18,%ecx
mov    -0x8(%rbp),%edx
sar    $0x8,%edx
and    $0xff,%edx
shl    $0x10,%edx
or     %edx,%ecx
mov    -0x8(%rbp),%edx
sar    $0x10,%edx
and    $0xff,%edx
shl    $0x8,%edx
or     %edx,%ecx
mov    -0x8(%rbp),%edx
sar    $0x18,%edx
and    $0xff,%edx
or     %edx,%ecx
or     %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
pop    %rbp
ret

x86 assembly (clang, -O2):
<pal_ntohl64>:
ret

LLVM IR (-O0):
define i32 @pal_ntohl64(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = sext i32 %6 to i64
%8 = and i64 %7, -4294967296
%9 = lshr i64 %8, 32
%10 = trunc i64 %9 to i32
store i32 %10, i32* %3
%11 = load i32, i32* %2
%12 = and i32 %11, -1
store i32 %12, i32* %4
%13 = load i32, i32* %4
%14 = and i32 %13, 255
%15 = shl i32 %14, 24
%16 = load i32, i32* %4
%17 = ashr i32 %16, 8
%18 = and i32 %17, 255
%19 = shl i32 %18, 16
%20 = or i32 %15, %19
%21 = load i32, i32* %4
%22 = ashr i32 %21, 16
%23 = and i32 %22, 255
%24 = shl i32 %23, 8
%25 = or i32 %20, %24
%26 = load i32, i32* %4
%27 = ashr i32 %26, 24
%28 = and i32 %27, 255
%29 = or i32 %25, %28
%30 = shl i32 %29, 32
%31 = load i32, i32* %3
%32 = and i32 %31, 255
%33 = shl i32 %32, 24
%34 = load i32, i32* %3
%35 = ashr i32 %34, 8
%36 = and i32 %35, 255
%37 = shl i32 %36, 16
%38 = or i32 %33, %37
%39 = load i32, i32* %3
%40 = ashr i32 %39, 16
%41 = and i32 %40, 255
%42 = shl i32 %41, 8
%43 = or i32 %38, %42
%44 = load i32, i32* %3
%45 = ashr i32 %44, 24
%46 = and i32 %45, 255
%47 = or i32 %43, %46
%48 = or i32 %30, %47
store i32 %48, i32* %5
%49 = load i32, i32* %5
ret i32 %49
}

LLVM IR (-O2):
define i32 @pal_ntohl64(i32 %0) {
ret i32 poison
}