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

/* Variables and functions */
void set_block_number_in_tweak(uint8_t *tweak, const uint64_t block_no) {
  tweak[8] = (tweak[8] & 0xe0) ^ ((block_no >> 56ULL) & 0x1f);
  tweak[9] = ((block_no >> 48ULL) & 0xff);
  tweak[10] = ((block_no >> 40ULL) & 0xff);
  tweak[11] = ((block_no >> 32ULL) & 0xff);
  tweak[12] = ((block_no >> 24ULL) & 0xff);
  tweak[13] = ((block_no >> 16ULL) & 0xff);
  tweak[14] = ((block_no >> 8ULL) & 0xff);
  tweak[15] = ((block_no >> 0ULL) & 0xff);
}


x86 assembly (clang, -O0):
<set_block_number_in_tweak>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0x20(%rax),%eax
and    $0xe0,%eax
cltq
mov    -0x10(%rbp),%rcx
shr    $0x38,%rcx
and    $0x1f,%rcx
xor    %rcx,%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x20(%rax)
mov    -0x10(%rbp),%rax
shr    $0x30,%rax
and    $0xff,%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x24(%rax)
mov    -0x10(%rbp),%rax
shr    $0x28,%rax
and    $0xff,%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x28(%rax)
mov    -0x10(%rbp),%rax
shr    $0x20,%rax
and    $0xff,%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x2c(%rax)
mov    -0x10(%rbp),%rax
shr    $0x18,%rax
and    $0xff,%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x30(%rax)
mov    -0x10(%rbp),%rax
shr    $0x10,%rax
and    $0xff,%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x34(%rax)
mov    -0x10(%rbp),%rax
shr    $0x8,%rax
and    $0xff,%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x38(%rax)
mov    -0x10(%rbp),%rax
shr    $0x0,%rax
and    $0xff,%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x3c(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_block_number_in_tweak>:
push   %rbp
push   %rbx
mov    %rsi,%rax
mov    %rsi,%r8
mov    %rsi,%r9
mov    %rsi,%rcx
mov    %eax,%edx
movzbl %ah,%ebp
movzbl %al,%r10d
mov    $0xe0,%ebx
and    0x20(%rdi),%ebx
shr    $0x38,%rax
and    $0x1f,%eax
or     %ebx,%eax
mov    %eax,0x20(%rdi)
shr    $0x30,%r8
movzbl %r8b,%eax
mov    %eax,0x24(%rdi)
shr    $0x28,%r9
movzbl %r9b,%eax
mov    %eax,0x28(%rdi)
shr    $0x20,%rcx
movzbl %cl,%eax
mov    %eax,0x2c(%rdi)
shr    $0x18,%edx
mov    %edx,0x30(%rdi)
shr    $0x10,%esi
movzbl %sil,%eax
mov    %eax,0x34(%rdi)
mov    %ebp,0x38(%rdi)
mov    %r10d,0x3c(%rdi)
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @set_block_number_in_tweak(i32* %0, i64 %1) {
%3 = alloca i32*
%4 = alloca i64
store i32* %0, i32** %3
store i64 %1, i64* %4
%5 = load i32*, i32** %3
%6 = getelementptr inbounds i32, i32* %5, i64 8
%7 = load i32, i32* %6
%8 = and i32 %7, 224
%9 = sext i32 %8 to i64
%10 = load i64, i64* %4
%11 = lshr i64 %10, 56
%12 = and i64 %11, 31
%13 = xor i64 %9, %12
%14 = trunc i64 %13 to i32
%15 = load i32*, i32** %3
%16 = getelementptr inbounds i32, i32* %15, i64 8
store i32 %14, i32* %16
%17 = load i64, i64* %4
%18 = lshr i64 %17, 48
%19 = and i64 %18, 255
%20 = trunc i64 %19 to i32
%21 = load i32*, i32** %3
%22 = getelementptr inbounds i32, i32* %21, i64 9
store i32 %20, i32* %22
%23 = load i64, i64* %4
%24 = lshr i64 %23, 40
%25 = and i64 %24, 255
%26 = trunc i64 %25 to i32
%27 = load i32*, i32** %3
%28 = getelementptr inbounds i32, i32* %27, i64 10
store i32 %26, i32* %28
%29 = load i64, i64* %4
%30 = lshr i64 %29, 32
%31 = and i64 %30, 255
%32 = trunc i64 %31 to i32
%33 = load i32*, i32** %3
%34 = getelementptr inbounds i32, i32* %33, i64 11
store i32 %32, i32* %34
%35 = load i64, i64* %4
%36 = lshr i64 %35, 24
%37 = and i64 %36, 255
%38 = trunc i64 %37 to i32
%39 = load i32*, i32** %3
%40 = getelementptr inbounds i32, i32* %39, i64 12
store i32 %38, i32* %40
%41 = load i64, i64* %4
%42 = lshr i64 %41, 16
%43 = and i64 %42, 255
%44 = trunc i64 %43 to i32
%45 = load i32*, i32** %3
%46 = getelementptr inbounds i32, i32* %45, i64 13
store i32 %44, i32* %46
%47 = load i64, i64* %4
%48 = lshr i64 %47, 8
%49 = and i64 %48, 255
%50 = trunc i64 %49 to i32
%51 = load i32*, i32** %3
%52 = getelementptr inbounds i32, i32* %51, i64 14
store i32 %50, i32* %52
%53 = load i64, i64* %4
%54 = lshr i64 %53, 0
%55 = and i64 %54, 255
%56 = trunc i64 %55 to i32
%57 = load i32*, i32** %3
%58 = getelementptr inbounds i32, i32* %57, i64 15
store i32 %56, i32* %58
ret void
}

LLVM IR (-O2):
define void @set_block_number_in_tweak(i32* nocapture %0, i64 %1) {
%3 = getelementptr inbounds i32, i32* %0, i64 8
%4 = load i32, i32* %3
%5 = and i32 %4, 224
%6 = lshr i64 %1, 56
%7 = trunc i64 %6 to i32
%8 = and i32 %7, 31
%9 = or i32 %5, %8
store i32 %9, i32* %3
%10 = lshr i64 %1, 48
%11 = trunc i64 %10 to i32
%12 = and i32 %11, 255
%13 = getelementptr inbounds i32, i32* %0, i64 9
store i32 %12, i32* %13
%14 = lshr i64 %1, 40
%15 = trunc i64 %14 to i32
%16 = and i32 %15, 255
%17 = getelementptr inbounds i32, i32* %0, i64 10
store i32 %16, i32* %17
%18 = lshr i64 %1, 32
%19 = trunc i64 %18 to i32
%20 = and i32 %19, 255
%21 = getelementptr inbounds i32, i32* %0, i64 11
store i32 %20, i32* %21
%22 = trunc i64 %1 to i32
%23 = lshr i32 %22, 24
%24 = getelementptr inbounds i32, i32* %0, i64 12
store i32 %23, i32* %24
%25 = lshr i32 %22, 16
%26 = and i32 %25, 255
%27 = getelementptr inbounds i32, i32* %0, i64 13
store i32 %26, i32* %27
%28 = lshr i32 %22, 8
%29 = and i32 %28, 255
%30 = getelementptr inbounds i32, i32* %0, i64 14
store i32 %29, i32* %30
%31 = and i32 %22, 255
%32 = getelementptr inbounds i32, i32* %0, i64 15
store i32 %31, i32* %32
ret void
}