#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_4(uint8_t *tweak, const uint64_t block_no) {
  tweak[0] = (tweak[0] & 0xf0) ^ ((block_no >> 56ULL) & 0x0f);
  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_4>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
and    $0xf0,%eax
cltq
mov    -0x10(%rbp),%rcx
shr    $0x38,%rcx
and    $0xf,%rcx
xor    %rcx,%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
shr    $0x30,%rax
and    $0xff,%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x10(%rbp),%rax
shr    $0x28,%rax
and    $0xff,%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x10(%rbp),%rax
shr    $0x20,%rax
and    $0xff,%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x10(%rbp),%rax
shr    $0x18,%rax
and    $0xff,%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0x10(%rbp),%rax
shr    $0x10,%rax
and    $0xff,%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x14(%rax)
mov    -0x10(%rbp),%rax
shr    $0x8,%rax
and    $0xff,%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x18(%rax)
mov    -0x10(%rbp),%rax
shr    $0x0,%rax
and    $0xff,%rax
mov    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x1c(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_block_number_in_tweak_4>:
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    $0xf0,%ebx
and    (%rdi),%ebx
shr    $0x38,%rax
and    $0xf,%eax
or     %ebx,%eax
mov    %eax,(%rdi)
shr    $0x30,%r8
movzbl %r8b,%eax
mov    %eax,0x4(%rdi)
shr    $0x28,%r9
movzbl %r9b,%eax
mov    %eax,0x8(%rdi)
shr    $0x20,%rcx
movzbl %cl,%eax
mov    %eax,0xc(%rdi)
shr    $0x18,%edx
mov    %edx,0x10(%rdi)
shr    $0x10,%esi
movzbl %sil,%eax
mov    %eax,0x14(%rdi)
mov    %ebp,0x18(%rdi)
mov    %r10d,0x1c(%rdi)
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @set_block_number_in_tweak_4(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 0
%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, 56
%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 0
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 1
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 2
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 3
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 4
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 5
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 6
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 7
store i32 %56, i32* %58
ret void
}

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