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

/* Variables and functions */
void set_nonce_in_tweak(uint8_t *tweak, const uint8_t *nonce) {
  tweak[0] = (tweak[0] & 0xf0) ^ nonce[0] >> 4;
  tweak[1] = (nonce[0] & 0xf) << 4 ^ (nonce[1] >> 4);
  tweak[2] = (nonce[1] & 0xf) << 4 ^ (nonce[2] >> 4);
  tweak[3] = (nonce[2] & 0xf) << 4 ^ (nonce[3] >> 4);
  tweak[4] = (nonce[3] & 0xf) << 4;
}


x86 assembly (clang, -O0):
<set_nonce_in_tweak>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
and    $0xf0,%ecx
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
sar    $0x4,%eax
xor    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
and    $0xf,%ecx
shl    $0x4,%ecx
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
sar    $0x4,%eax
xor    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%ecx
and    $0xf,%ecx
shl    $0x4,%ecx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%eax
sar    $0x4,%eax
xor    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%ecx
and    $0xf,%ecx
shl    $0x4,%ecx
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%eax
sar    $0x4,%eax
xor    %eax,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%ecx
and    $0xf,%ecx
shl    $0x4,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x10(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_nonce_in_tweak>:
mov    $0xf0,%eax
and    (%rdi),%eax
mov    (%rsi),%ecx
sar    $0x4,%ecx
xor    %eax,%ecx
mov    %ecx,(%rdi)
mov    (%rsi),%eax
mov    0x4(%rsi),%ecx
shl    $0x4,%eax
movzbl %al,%eax
sar    $0x4,%ecx
xor    %eax,%ecx
mov    %ecx,0x4(%rdi)
mov    0x4(%rsi),%eax
mov    0x8(%rsi),%ecx
shl    $0x4,%eax
movzbl %al,%eax
sar    $0x4,%ecx
xor    %eax,%ecx
mov    %ecx,0x8(%rdi)
mov    0x8(%rsi),%eax
mov    0xc(%rsi),%ecx
shl    $0x4,%eax
movzbl %al,%eax
sar    $0x4,%ecx
xor    %eax,%ecx
mov    %ecx,0xc(%rdi)
mov    0xc(%rsi),%eax
shl    $0x4,%eax
movzbl %al,%eax
mov    %eax,0x10(%rdi)
ret

LLVM IR (-O0):
define void @set_nonce_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** %3
%6 = getelementptr inbounds i32, i32* %5, i64 0
%7 = load i32, i32* %6
%8 = and i32 %7, 240
%9 = load i32*, i32** %4
%10 = getelementptr inbounds i32, i32* %9, i64 0
%11 = load i32, i32* %10
%12 = ashr i32 %11, 4
%13 = xor i32 %8, %12
%14 = load i32*, i32** %3
%15 = getelementptr inbounds i32, i32* %14, i64 0
store i32 %13, i32* %15
%16 = load i32*, i32** %4
%17 = getelementptr inbounds i32, i32* %16, i64 0
%18 = load i32, i32* %17
%19 = and i32 %18, 15
%20 = shl i32 %19, 4
%21 = load i32*, i32** %4
%22 = getelementptr inbounds i32, i32* %21, i64 1
%23 = load i32, i32* %22
%24 = ashr i32 %23, 4
%25 = xor i32 %20, %24
%26 = load i32*, i32** %3
%27 = getelementptr inbounds i32, i32* %26, i64 1
store i32 %25, i32* %27
%28 = load i32*, i32** %4
%29 = getelementptr inbounds i32, i32* %28, i64 1
%30 = load i32, i32* %29
%31 = and i32 %30, 15
%32 = shl i32 %31, 4
%33 = load i32*, i32** %4
%34 = getelementptr inbounds i32, i32* %33, i64 2
%35 = load i32, i32* %34
%36 = ashr i32 %35, 4
%37 = xor i32 %32, %36
%38 = load i32*, i32** %3
%39 = getelementptr inbounds i32, i32* %38, i64 2
store i32 %37, i32* %39
%40 = load i32*, i32** %4
%41 = getelementptr inbounds i32, i32* %40, i64 2
%42 = load i32, i32* %41
%43 = and i32 %42, 15
%44 = shl i32 %43, 4
%45 = load i32*, i32** %4
%46 = getelementptr inbounds i32, i32* %45, i64 3
%47 = load i32, i32* %46
%48 = ashr i32 %47, 4
%49 = xor i32 %44, %48
%50 = load i32*, i32** %3
%51 = getelementptr inbounds i32, i32* %50, i64 3
store i32 %49, i32* %51
%52 = load i32*, i32** %4
%53 = getelementptr inbounds i32, i32* %52, i64 3
%54 = load i32, i32* %53
%55 = and i32 %54, 15
%56 = shl i32 %55, 4
%57 = load i32*, i32** %3
%58 = getelementptr inbounds i32, i32* %57, i64 4
store i32 %56, i32* %58
ret void
}

LLVM IR (-O2):
define void @set_nonce_in_tweak(i32* nocapture %0, i32* nocapture %1) {
%3 = load i32, i32* %0
%4 = and i32 %3, 240
%5 = load i32, i32* %1
%6 = ashr i32 %5, 4
%7 = xor i32 %6, %4
store i32 %7, i32* %0
%8 = load i32, i32* %1
%9 = shl i32 %8, 4
%10 = and i32 %9, 240
%11 = getelementptr inbounds i32, i32* %1, i64 1
%12 = load i32, i32* %11
%13 = ashr i32 %12, 4
%14 = xor i32 %10, %13
%15 = getelementptr inbounds i32, i32* %0, i64 1
store i32 %14, i32* %15
%16 = load i32, i32* %11
%17 = shl i32 %16, 4
%18 = and i32 %17, 240
%19 = getelementptr inbounds i32, i32* %1, i64 2
%20 = load i32, i32* %19
%21 = ashr i32 %20, 4
%22 = xor i32 %18, %21
%23 = getelementptr inbounds i32, i32* %0, i64 2
store i32 %22, i32* %23
%24 = load i32, i32* %19
%25 = shl i32 %24, 4
%26 = and i32 %25, 240
%27 = getelementptr inbounds i32, i32* %1, i64 3
%28 = load i32, i32* %27
%29 = ashr i32 %28, 4
%30 = xor i32 %26, %29
%31 = getelementptr inbounds i32, i32* %0, i64 3
store i32 %30, i32* %31
%32 = load i32, i32* %27
%33 = shl i32 %32, 4
%34 = and i32 %33, 240
%35 = getelementptr inbounds i32, i32* %0, i64 4
store i32 %34, i32* %35
ret void
}