#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, uint32_t block_no) {
  tweak[8] = ((block_no >> 24) & 0x0f) ^ (tweak[8] & 0xf0);
  tweak[9] = ((block_no >> 16) & 0xff);
  tweak[12] = ((block_no >> 8) & 0xff);
  tweak[13] = ((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    $0xf,%ecx
mov    -0x8(%rbp),%rax
mov    0x20(%rax),%eax
and    $0xf0,%eax
xor    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x20(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x10,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x24(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x8,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x30(%rax)
mov    -0xc(%rbp),%ecx
sar    $0x0,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x34(%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    $0xf0,%edx
and    0x20(%rdi),%edx
and    $0xf,%eax
or     %eax,%edx
mov    %edx,0x20(%rdi)
shr    $0x10,%ecx
movzbl %cl,%eax
mov    %eax,0x24(%rdi)
mov    %ebx,0x30(%rdi)
mov    %esi,0x34(%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, 15
%8 = load i32*, i32** %3
%9 = getelementptr inbounds i32, i32* %8, i64 8
%10 = load i32, i32* %9
%11 = and i32 %10, 240
%12 = xor i32 %7, %11
%13 = load i32*, i32** %3
%14 = getelementptr inbounds i32, i32* %13, i64 8
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 9
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 12
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 13
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, 15
%5 = getelementptr inbounds i32, i32* %0, i64 8
%6 = load i32, i32* %5
%7 = and i32 %6, 240
%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 9
store i32 %10, i32* %11
%12 = lshr i32 %1, 8
%13 = and i32 %12, 255
%14 = getelementptr inbounds i32, i32* %0, i64 12
store i32 %13, i32* %14
%15 = and i32 %1, 255
%16 = getelementptr inbounds i32, i32* %0, i64 13
store i32 %15, i32* %16
ret void
}