#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 int uint32_t;

/* Variables and functions */
void set_block_number_in_tweak(uint8_t *tweak, const uint32_t block_no) {
  tweak[4] = ((block_no >> 24) & 0x1f) ^ (tweak[4] & 0xe0);
  tweak[5] = ((block_no >> 16) & 0xff);
  tweak[6] = ((block_no >> 8) & 0xff);
  tweak[7] = ((block_no >> 0) & 0xff);
}


x86 assembly (clang, -O0):
<set_block_number_in_tweak>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%ecx
sar    $0x18,%ecx
and    $0x1f,%ecx
mov    -0x8(%rbp),%rax
mov    0x10(%rax),%eax
and    $0xe0,%eax
xor    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x10,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x14(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x8,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x18(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x0,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x1c(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_block_number_in_tweak>:
push   %rbx
mov    %esi,%eax
mov    %esi,%ecx
movzbl %ah,%ebx
movzbl %al,%esi
shr    $0x18,%eax
mov    $0xe0,%edx
and    0x10(%rdi),%edx
and    $0x1f,%eax
or     %eax,%edx
mov    %edx,0x10(%rdi)
shr    $0x10,%ecx
movzbl %cl,%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, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = ashr i32 %5, 24
%7 = and i32 %6, 31
%8 = load i32*, i32** %3
%9 = getelementptr inbounds i32, i32* %8, i64 4
%10 = load i32, i32* %9
%11 = and i32 %10, 224
%12 = xor i32 %7, %11
%13 = load i32*, i32** %3
%14 = getelementptr inbounds i32, i32* %13, i64 4
store i32 %12, i32* %14
%15 = load i32, i32* %4
%16 = ashr i32 %15, 16
%17 = and i32 %16, 255
%18 = load i32*, i32** %3
%19 = getelementptr inbounds i32, i32* %18, i64 5
store i32 %17, i32* %19
%20 = load i32, i32* %4
%21 = ashr i32 %20, 8
%22 = and i32 %21, 255
%23 = load i32*, i32** %3
%24 = getelementptr inbounds i32, i32* %23, i64 6
store i32 %22, i32* %24
%25 = load i32, i32* %4
%26 = ashr i32 %25, 0
%27 = and i32 %26, 255
%28 = load i32*, i32** %3
%29 = getelementptr inbounds i32, i32* %28, i64 7
store i32 %27, i32* %29
ret void
}

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