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

/* Variables and functions */
void set_block_number_in_tweak_1(uint8_t *tweak, const uint64_t block_no) {
  tweak[0] = ((block_no >> 56ULL) & 0x7f) ^ 0x80;
  tweak[1] = ((block_no >> 48ULL) & 0xff);
  tweak[2] = ((block_no >> 40ULL) & 0xff);
  tweak[3] = ((block_no >> 32ULL) & 0xff);
  tweak[4] = ((block_no >> 24ULL) & 0xff);
  tweak[5] = ((block_no >> 16ULL) & 0xff);
  tweak[6] = ((block_no >> 8ULL) & 0xff);
  tweak[7] = ((block_no >> 0ULL) & 0xff);
}


x86 assembly (clang, -O0):
<set_block_number_in_tweak_1>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rcx
shr    $0x38,%rcx
and    $0x7f,%rcx
xor    $0x80,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x10(%rbp),%rcx
shr    $0x30,%rcx
and    $0xff,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x10(%rbp),%rcx
shr    $0x28,%rcx
and    $0xff,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    -0x10(%rbp),%rcx
shr    $0x20,%rcx
and    $0xff,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x18(%rax)
mov    -0x10(%rbp),%rcx
shr    $0x18,%rcx
and    $0xff,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x20(%rax)
mov    -0x10(%rbp),%rcx
shr    $0x10,%rcx
and    $0xff,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x28(%rax)
mov    -0x10(%rbp),%rcx
shr    $0x8,%rcx
and    $0xff,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x30(%rax)
mov    -0x10(%rbp),%rcx
shr    $0x0,%rcx
and    $0xff,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x38(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_block_number_in_tweak_1>:
push   %rbp
push   %rbx
mov    %rsi,%rax
mov    %rsi,%r8
mov    %rsi,%r9
mov    %eax,%ecx
mov    %eax,%edx
movzbl %ah,%ebp
movzbl %al,%ebx
shr    $0x38,%rax
or     $0x80,%rax
mov    %rax,(%rdi)
shr    $0x30,%r8
movzbl %r8b,%eax
mov    %rax,0x8(%rdi)
shr    $0x28,%r9
movzbl %r9b,%eax
mov    %rax,0x10(%rdi)
shr    $0x20,%rsi
movzbl %sil,%eax
mov    %rax,0x18(%rdi)
shr    $0x18,%ecx
mov    %rcx,0x20(%rdi)
shr    $0x10,%edx
movzbl %dl,%eax
mov    %rax,0x28(%rdi)
mov    %rbp,0x30(%rdi)
mov    %rbx,0x38(%rdi)
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @set_block_number_in_tweak_1(i64* %0, i64 %1) {
%3 = alloca i64*
%4 = alloca i64
store i64* %0, i64** %3
store i64 %1, i64* %4
%5 = load i64, i64* %4
%6 = lshr i64 %5, 56
%7 = and i64 %6, 127
%8 = xor i64 %7, 128
%9 = load i64*, i64** %3
%10 = getelementptr inbounds i64, i64* %9, i64 0
store i64 %8, i64* %10
%11 = load i64, i64* %4
%12 = lshr i64 %11, 48
%13 = and i64 %12, 255
%14 = load i64*, i64** %3
%15 = getelementptr inbounds i64, i64* %14, i64 1
store i64 %13, i64* %15
%16 = load i64, i64* %4
%17 = lshr i64 %16, 40
%18 = and i64 %17, 255
%19 = load i64*, i64** %3
%20 = getelementptr inbounds i64, i64* %19, i64 2
store i64 %18, i64* %20
%21 = load i64, i64* %4
%22 = lshr i64 %21, 32
%23 = and i64 %22, 255
%24 = load i64*, i64** %3
%25 = getelementptr inbounds i64, i64* %24, i64 3
store i64 %23, i64* %25
%26 = load i64, i64* %4
%27 = lshr i64 %26, 24
%28 = and i64 %27, 255
%29 = load i64*, i64** %3
%30 = getelementptr inbounds i64, i64* %29, i64 4
store i64 %28, i64* %30
%31 = load i64, i64* %4
%32 = lshr i64 %31, 16
%33 = and i64 %32, 255
%34 = load i64*, i64** %3
%35 = getelementptr inbounds i64, i64* %34, i64 5
store i64 %33, i64* %35
%36 = load i64, i64* %4
%37 = lshr i64 %36, 8
%38 = and i64 %37, 255
%39 = load i64*, i64** %3
%40 = getelementptr inbounds i64, i64* %39, i64 6
store i64 %38, i64* %40
%41 = load i64, i64* %4
%42 = lshr i64 %41, 0
%43 = and i64 %42, 255
%44 = load i64*, i64** %3
%45 = getelementptr inbounds i64, i64* %44, i64 7
store i64 %43, i64* %45
ret void
}

LLVM IR (-O2):
define void @set_block_number_in_tweak_1(i64* nocapture writeonly %0, i64 %1) {
%3 = lshr i64 %1, 56
%4 = or i64 %3, 128
store i64 %4, i64* %0
%5 = lshr i64 %1, 48
%6 = and i64 %5, 255
%7 = getelementptr inbounds i64, i64* %0, i64 1
store i64 %6, i64* %7
%8 = lshr i64 %1, 40
%9 = and i64 %8, 255
%10 = getelementptr inbounds i64, i64* %0, i64 2
store i64 %9, i64* %10
%11 = lshr i64 %1, 32
%12 = and i64 %11, 255
%13 = getelementptr inbounds i64, i64* %0, i64 3
store i64 %12, i64* %13
%14 = lshr i64 %1, 24
%15 = and i64 %14, 255
%16 = getelementptr inbounds i64, i64* %0, i64 4
store i64 %15, i64* %16
%17 = lshr i64 %1, 16
%18 = and i64 %17, 255
%19 = getelementptr inbounds i64, i64* %0, i64 5
store i64 %18, i64* %19
%20 = lshr i64 %1, 8
%21 = and i64 %20, 255
%22 = getelementptr inbounds i64, i64* %0, i64 6
store i64 %21, i64* %22
%23 = and i64 %1, 255
%24 = getelementptr inbounds i64, i64* %0, i64 7
store i64 %23, i64* %24
ret void
}