#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[6] = (tweak[6] & 0xf0) ^ ((block_no >> 40ULL) & 0xf);
  tweak[7] = ((block_no >> 32ULL) & 0xff);
  tweak[8] = ((block_no >> 24ULL) & 0xff);
  tweak[9] = ((block_no >> 16ULL) & 0xff);
  tweak[10] = ((block_no >> 8ULL) & 0xff);
  tweak[11] = ((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    0x18(%rax),%eax
and    $0xf0,%eax
cltq
mov    -0x10(%rbp),%rcx
shr    $0x28,%rcx
and    $0xf,%rcx
xor    %rcx,%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x18(%rax)
mov    -0x10(%rbp),%rax
shr    $0x20,%rax
and    $0xff,%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x1c(%rax)
mov    -0x10(%rbp),%rax
shr    $0x18,%rax
and    $0xff,%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x20(%rax)
mov    -0x10(%rbp),%rax
shr    $0x10,%rax
and    $0xff,%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x24(%rax)
mov    -0x10(%rbp),%rax
shr    $0x8,%rax
and    $0xff,%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x28(%rax)
mov    -0x10(%rbp),%rax
shr    $0x0,%rax
and    $0xff,%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x2c(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_block_number_in_tweak>:
push   %rbp
push   %rbx
mov    %rsi,%rax
mov    %rsi,%rdx
mov    %eax,%ecx
movzbl %ah,%ebp
movzbl %al,%r8d
mov    $0xf0,%ebx
and    0x18(%rdi),%ebx
shr    $0x28,%rax
and    $0xf,%eax
or     %ebx,%eax
mov    %eax,0x18(%rdi)
shr    $0x20,%rdx
movzbl %dl,%eax
mov    %eax,0x1c(%rdi)
shr    $0x18,%ecx
mov    %ecx,0x20(%rdi)
shr    $0x10,%esi
movzbl %sil,%eax
mov    %eax,0x24(%rdi)
mov    %ebp,0x28(%rdi)
mov    %r8d,0x2c(%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 6
%7 = load i32, i32* %6
%8 = and i32 %7, 240
%9 = sext i32 %8 to i64
%10 = load i64, i64* %4
%11 = lshr i64 %10, 40
%12 = and i64 %11, 15
%13 = xor i64 %9, %12
%14 = trunc i64 %13 to i32
%15 = load i32*, i32** %3
%16 = getelementptr inbounds i32, i32* %15, i64 6
store i32 %14, i32* %16
%17 = load i64, i64* %4
%18 = lshr i64 %17, 32
%19 = and i64 %18, 255
%20 = trunc i64 %19 to i32
%21 = load i32*, i32** %3
%22 = getelementptr inbounds i32, i32* %21, i64 7
store i32 %20, i32* %22
%23 = load i64, i64* %4
%24 = lshr i64 %23, 24
%25 = and i64 %24, 255
%26 = trunc i64 %25 to i32
%27 = load i32*, i32** %3
%28 = getelementptr inbounds i32, i32* %27, i64 8
store i32 %26, i32* %28
%29 = load i64, i64* %4
%30 = lshr i64 %29, 16
%31 = and i64 %30, 255
%32 = trunc i64 %31 to i32
%33 = load i32*, i32** %3
%34 = getelementptr inbounds i32, i32* %33, i64 9
store i32 %32, i32* %34
%35 = load i64, i64* %4
%36 = lshr i64 %35, 8
%37 = and i64 %36, 255
%38 = trunc i64 %37 to i32
%39 = load i32*, i32** %3
%40 = getelementptr inbounds i32, i32* %39, i64 10
store i32 %38, i32* %40
%41 = load i64, i64* %4
%42 = lshr i64 %41, 0
%43 = and i64 %42, 255
%44 = trunc i64 %43 to i32
%45 = load i32*, i32** %3
%46 = getelementptr inbounds i32, i32* %45, i64 11
store i32 %44, i32* %46
ret void
}

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