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

/* Variables and functions */
scalar_t__ htonl(scalar_t__);
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, scalar_t__ *, int);
uint64_t I2htonll(uint64_t h64) {
  uint64_t n64 = 0;
  uint32_t l32;
  uint32_t h32;
  uint8_t *t8;
  t8 = (uint8_t *)&n64;
  l32 = (uint32_t)(h64 & 0xFFFFFFFFUL);
  l32 = htonl(l32);
  h64 >>= 32;
  h32 = (uint32_t)(h64 & 0xFFFFFFFFUL);
  h32 = htonl(h32);
  memcpy(&t8[0], &h32, 4);
  memcpy(&t8[4], &l32, 4);
  return n64;
}


x86 assembly (clang, -O0):
<I2htonll>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
movslq -0x4(%rbp),%rax
movabs $0xffffffff,%rcx
and    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <htonl@plt>
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x20,%ecx
sar    %cl,%eax
mov    %eax,-0x4(%rbp)
movslq -0x4(%rbp),%rax
movabs $0xffffffff,%rcx
and    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <htonl@plt>
mov    %rax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x4,%edx
call   1040 <memcpy@plt>
mov    -0x20(%rbp),%rdi
add    $0x10,%rdi
lea    -0x10(%rbp),%rsi
mov    $0x4,%edx
call   1040 <memcpy@plt>
mov    -0x8(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<I2htonll>:
sub    $0x18,%rsp
movl   $0x0,0x4(%rsp)
mov    %edi,%edi
call   1030 <htonl@plt>
mov    %rax,0x10(%rsp)
call   1030 <htonl@plt>
mov    %rax,0x8(%rsp)
lea    0x4(%rsp),%rdi
lea    0x8(%rsp),%rsi
mov    $0x4,%edx
call   1040 <memcpy@plt>
lea    0x14(%rsp),%rdi
lea    0x10(%rsp),%rsi
mov    $0x4,%edx
call   1040 <memcpy@plt>
mov    0x4(%rsp),%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
define i32 @I2htonll(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32*
store i32 %0, i32* %2
store i32 0, i32* %3
store i32* %3, i32** %6
%7 = load i32, i32* %2
%8 = sext i32 %7 to i64
%9 = and i64 %8, 4294967295
store i64 %9, i64* %4
%10 = load i64, i64* %4
%11 = call i64 @htonl(i64 %10)
store i64 %11, i64* %4
%12 = load i32, i32* %2
%13 = ashr i32 %12, 32
store i32 %13, i32* %2
%14 = load i32, i32* %2
%15 = sext i32 %14 to i64
%16 = and i64 %15, 4294967295
store i64 %16, i64* %5
%17 = load i64, i64* %5
%18 = call i64 @htonl(i64 %17)
store i64 %18, i64* %5
%19 = load i32*, i32** %6
%20 = getelementptr inbounds i32, i32* %19, i64 0
%21 = call i32 @memcpy(i32* %20, i64* %5, i32 4)
%22 = load i32*, i32** %6
%23 = getelementptr inbounds i32, i32* %22, i64 4
%24 = call i32 @memcpy(i32* %23, i64* %4, i32 4)
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
define i32 @I2htonll(i32 %0) {
%2 = alloca i32
%3 = alloca i64
%4 = alloca i64
%5 = bitcast i32* %2 to i8*
store i32 0, i32* %2
%6 = bitcast i64* %3 to i8*
%7 = bitcast i64* %4 to i8*
%8 = zext i32 %0 to i64
%9 = tail call i64 @htonl(i64 %8)
store i64 %9, i64* %3
%10 = tail call i64 @htonl(i64 poison)
store i64 %10, i64* %4
%11 = call i32 @memcpy(i32* %2, i64* %4, i32 4)
%12 = getelementptr inbounds i32, i32* %2, i64 4
%13 = call i32 @memcpy(i32* %12, i64* %3, i32 4)
%14 = load i32, i32* %2
ret i32 %14
}