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

/* Variables and functions */
int ntohll(int);
void put_unaligned_u64(uint64_t *p_, uint64_t x_) {
  uint8_t *p = (uint8_t *)p_;
  uint64_t x = ntohll(x_);
  p[0] = x >> 56;
  p[1] = x >> 48;
  p[2] = x >> 40;
  p[3] = x >> 32;
  p[4] = x >> 24;
  p[5] = x >> 16;
  p[6] = x >> 8;
  p[7] = x;
}


x86 assembly (clang, -O0):
<put_unaligned_u64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <ntohll@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0x38,%ecx
sar    %cl,%eax
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x1c(%rbp),%eax
mov    $0x30,%ecx
sar    %cl,%eax
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x1c(%rbp),%eax
mov    $0x28,%ecx
sar    %cl,%eax
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x1c(%rbp),%eax
mov    $0x20,%ecx
sar    %cl,%eax
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x1c(%rbp),%ecx
sar    $0x18,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0x1c(%rbp),%ecx
sar    $0x10,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x14(%rax)
mov    -0x1c(%rbp),%ecx
sar    $0x8,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x18(%rax)
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,0x1c(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<put_unaligned_u64>:
push   %rbx
mov    %rdi,%rbx
mov    %esi,%edi
call   1030 <ntohll@plt>
mov    %eax,%ecx
sar    $0x18,%ecx
mov    %ecx,0x10(%rbx)
mov    %eax,%ecx
sar    $0x10,%ecx
mov    %ecx,0x14(%rbx)
mov    %eax,%ecx
sar    $0x8,%ecx
mov    %ecx,0x18(%rbx)
mov    %eax,0x1c(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
define void @put_unaligned_u64(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%7 = load i32*, i32** %3
store i32* %7, i32** %5
%8 = load i32, i32* %4
%9 = call i32 @ntohll(i32 %8)
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = ashr i32 %10, 56
%12 = load i32*, i32** %5
%13 = getelementptr inbounds i32, i32* %12, i64 0
store i32 %11, i32* %13
%14 = load i32, i32* %6
%15 = ashr i32 %14, 48
%16 = load i32*, i32** %5
%17 = getelementptr inbounds i32, i32* %16, i64 1
store i32 %15, i32* %17
%18 = load i32, i32* %6
%19 = ashr i32 %18, 40
%20 = load i32*, i32** %5
%21 = getelementptr inbounds i32, i32* %20, i64 2
store i32 %19, i32* %21
%22 = load i32, i32* %6
%23 = ashr i32 %22, 32
%24 = load i32*, i32** %5
%25 = getelementptr inbounds i32, i32* %24, i64 3
store i32 %23, i32* %25
%26 = load i32, i32* %6
%27 = ashr i32 %26, 24
%28 = load i32*, i32** %5
%29 = getelementptr inbounds i32, i32* %28, i64 4
store i32 %27, i32* %29
%30 = load i32, i32* %6
%31 = ashr i32 %30, 16
%32 = load i32*, i32** %5
%33 = getelementptr inbounds i32, i32* %32, i64 5
store i32 %31, i32* %33
%34 = load i32, i32* %6
%35 = ashr i32 %34, 8
%36 = load i32*, i32** %5
%37 = getelementptr inbounds i32, i32* %36, i64 6
store i32 %35, i32* %37
%38 = load i32, i32* %6
%39 = load i32*, i32** %5
%40 = getelementptr inbounds i32, i32* %39, i64 7
store i32 %38, i32* %40
ret void
}

LLVM IR (-O2):
define void @put_unaligned_u64(i32* nocapture writeonly %0, i32 %1) {
%3 = tail call i32 @ntohll(i32 %1)
%4 = ashr i32 %3, 24
%5 = getelementptr inbounds i32, i32* %0, i64 4
store i32 %4, i32* %5
%6 = ashr i32 %3, 16
%7 = getelementptr inbounds i32, i32* %0, i64 5
store i32 %6, i32* %7
%8 = ashr i32 %3, 8
%9 = getelementptr inbounds i32, i32* %0, i64 6
store i32 %8, i32* %9
%10 = getelementptr inbounds i32, i32* %0, i64 7
store i32 %3, i32* %10
ret void
}