#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;

/* Variables and functions */
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, int *, int);
void put64bit(uint8_t **ptr, uint64_t val) {
  val = ((((val) << 56) & 0xFF00000000000000) |
         (((val) << 40) & 0xFF000000000000) | (((val) << 24) & 0xFF0000000000) |
         (((val) << 8) & 0xFF00000000) | (((val) >> 8) & 0xFF000000) |
         (((val) >> 24) & 0xFF0000) | (((val) >> 40) & 0xFF00) |
         (((val) >> 56) & 0xFF));
  memcpy(*ptr, &val, 8);
  (*ptr) += 8;
}


x86 assembly (clang, -O0):
<put64bit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x38,%ecx
shl    %cl,%eax
cltq
movabs $0xff00000000000000,%rcx
and    %rcx,%rax
mov    -0xc(%rbp),%edx
mov    $0x28,%ecx
shl    %cl,%edx
mov    %edx,%ecx
movslq %ecx,%rcx
movabs $0xff000000000000,%rdx
and    %rdx,%rcx
or     %rcx,%rax
mov    -0xc(%rbp),%ecx
shl    $0x18,%ecx
movslq %ecx,%rcx
movabs $0xff0000000000,%rdx
and    %rdx,%rcx
or     %rcx,%rax
mov    -0xc(%rbp),%ecx
shl    $0x8,%ecx
movslq %ecx,%rcx
movabs $0xff00000000,%rdx
and    %rdx,%rcx
or     %rcx,%rax
mov    -0xc(%rbp),%ecx
sar    $0x8,%ecx
and    $0xff000000,%ecx
mov    %ecx,%ecx
or     %rcx,%rax
mov    -0xc(%rbp),%ecx
sar    $0x18,%ecx
and    $0xff0000,%ecx
movslq %ecx,%rcx
or     %rcx,%rax
mov    -0xc(%rbp),%edx
mov    $0x28,%ecx
sar    %cl,%edx
mov    %edx,%ecx
and    $0xff00,%ecx
movslq %ecx,%rcx
or     %rcx,%rax
mov    -0xc(%rbp),%edx
mov    $0x38,%ecx
sar    %cl,%edx
mov    %edx,%ecx
and    $0xff,%ecx
movslq %ecx,%rcx
or     %rcx,%rax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x8,%edx
call   1030 <memcpy@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x20,%rcx
mov    %rcx,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<put64bit>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    (%rdi),%rdi
lea    0xc(%rsp),%rsi
mov    $0x8,%edx
call   1030 <memcpy@plt>
addq   $0x20,(%rbx)
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @put64bit(i32** %0, i32 %1) {
%3 = alloca i32**
%4 = alloca i32
store i32** %0, i32*** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = shl i32 %5, 56
%7 = sext i32 %6 to i64
%8 = and i64 %7, -72057594037927936
%9 = load i32, i32* %4
%10 = shl i32 %9, 40
%11 = sext i32 %10 to i64
%12 = and i64 %11, 71776119061217280
%13 = or i64 %8, %12
%14 = load i32, i32* %4
%15 = shl i32 %14, 24
%16 = sext i32 %15 to i64
%17 = and i64 %16, 280375465082880
%18 = or i64 %13, %17
%19 = load i32, i32* %4
%20 = shl i32 %19, 8
%21 = sext i32 %20 to i64
%22 = and i64 %21, 1095216660480
%23 = or i64 %18, %22
%24 = load i32, i32* %4
%25 = ashr i32 %24, 8
%26 = and i32 %25, -16777216
%27 = zext i32 %26 to i64
%28 = or i64 %23, %27
%29 = load i32, i32* %4
%30 = ashr i32 %29, 24
%31 = and i32 %30, 16711680
%32 = sext i32 %31 to i64
%33 = or i64 %28, %32
%34 = load i32, i32* %4
%35 = ashr i32 %34, 40
%36 = and i32 %35, 65280
%37 = sext i32 %36 to i64
%38 = or i64 %33, %37
%39 = load i32, i32* %4
%40 = ashr i32 %39, 56
%41 = and i32 %40, 255
%42 = sext i32 %41 to i64
%43 = or i64 %38, %42
%44 = trunc i64 %43 to i32
store i32 %44, i32* %4
%45 = load i32**, i32*** %3
%46 = load i32*, i32** %45
%47 = call i32 @memcpy(i32* %46, i32* %4, i32 8)
%48 = load i32**, i32*** %3
%49 = load i32*, i32** %48
%50 = getelementptr inbounds i32, i32* %49, i64 8
store i32* %50, i32** %48
ret void
}

LLVM IR (-O2):
define void @put64bit(i32** nocapture %0, i32 %1) {
%3 = alloca i32
%4 = load i32*, i32** %0
%5 = call i32 @memcpy(i32* %4, i32* %3, i32 8)
%6 = load i32*, i32** %0
%7 = getelementptr inbounds i32, i32* %6, i64 8
store i32* %7, i32** %0
ret void
}