#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[4] = (tweak[4] & 0xe0) ^ ((block_no >> 24ULL) & 0x1f);
  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>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%eax
and    $0xe0,%eax
cltq
mov    -0x10(%rbp),%rcx
shr    $0x18,%rcx
and    $0x1f,%rcx
xor    %rcx,%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>:
push   %rbx
mov    $0xe0,%ecx
and    0x10(%rdi),%ecx
mov    %rsi,%rax
mov    %eax,%edx
movzbl %ah,%ebx
movzbl %al,%esi
shr    $0x18,%eax
and    $0x1f,%eax
or     %ecx,%eax
mov    %eax,0x10(%rdi)
shr    $0x10,%edx
movzbl %dl,%eax
mov    %eax,0x14(%rdi)
mov    %ebx,0x18(%rdi)
mov    %esi,0x1c(%rdi)
pop    %rbx
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 4
%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, 24
%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 4
store i32 %14, i32* %16
%17 = load i64, i64* %4
%18 = lshr i64 %17, 16
%19 = and i64 %18, 255
%20 = trunc i64 %19 to i32
%21 = load i32*, i32** %3
%22 = getelementptr inbounds i32, i32* %21, i64 5
store i32 %20, i32* %22
%23 = load i64, i64* %4
%24 = lshr i64 %23, 8
%25 = and i64 %24, 255
%26 = trunc i64 %25 to i32
%27 = load i32*, i32** %3
%28 = getelementptr inbounds i32, i32* %27, i64 6
store i32 %26, i32* %28
%29 = load i64, i64* %4
%30 = lshr i64 %29, 0
%31 = and i64 %30, 255
%32 = trunc i64 %31 to i32
%33 = load i32*, i32** %3
%34 = getelementptr inbounds i32, i32* %33, i64 7
store i32 %32, i32* %34
ret void
}

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