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

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

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