#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 */
int /*<<< orphan*/ rrr_SLK(int *, int *, int *);
int /*<<< orphan*/ rrr_sbox(int *);
void rrr_enc_dec_round(uint8_t *block, uint8_t *roundKey, uint8_t round,
                       uint8_t *key_ctr, uint8_t mode) {
  uint8_t i, temp[4];
  for (i = 0; i < 4; i++)
    temp[i] = block[i];
  rrr_SLK(block, roundKey, key_ctr);
  rrr_SLK(block, roundKey, key_ctr);
  block[3] ^= round;
  rrr_SLK(block, roundKey, key_ctr);
  if (mode == 1)
    key_ctr[0] = (key_ctr[0] + 6) % 10;
  rrr_sbox(block);
  for (i = 0; i < 4; i++)
    block[i] ^= block[i + 4];
  for (i = 0; i < 4; i++)
    block[i + 4] = temp[i];
}


x86 assembly (clang, -O0):
<rrr_enc_dec_round>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
cmpl   $0x4,-0x28(%rbp)
jge    116d <rrr_enc_dec_round+0x4d>
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
movslq -0x28(%rbp),%rax
mov    %ecx,-0x40(%rbp,%rax,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1142 <rrr_enc_dec_round+0x22>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <rrr_SLK@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <rrr_SLK@plt>
mov    -0x14(%rbp),%ecx
mov    -0x8(%rbp),%rax
xor    0xc(%rax),%ecx
mov    %ecx,0xc(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1040 <rrr_SLK@plt>
cmpl   $0x1,-0x24(%rbp)
jne    11ce <rrr_enc_dec_round+0xae>
mov    -0x20(%rbp),%rax
mov    (%rax),%eax
add    $0x6,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x20(%rbp),%rax
mov    %edx,(%rax)
mov    -0x8(%rbp),%rdi
call   1030 <rrr_sbox@plt>
movl   $0x0,-0x28(%rbp)
cmpl   $0x4,-0x28(%rbp)
jge    1214 <rrr_enc_dec_round+0xf4>
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    $0x4,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x8(%rbp),%rax
movslq -0x28(%rbp),%rcx
xor    (%rax,%rcx,4),%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11de <rrr_enc_dec_round+0xbe>
movl   $0x0,-0x28(%rbp)
cmpl   $0x4,-0x28(%rbp)
jge    124b <rrr_enc_dec_round+0x12b>
movslq -0x28(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%edx
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%ecx
add    $0x4,%ecx
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    121b <rrr_enc_dec_round+0xfb>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rrr_enc_dec_round>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %r8d,%r15d
mov    %rcx,%r14
mov    %edx,%r12d
mov    %rsi,%rbp
mov    %rdi,%rbx
movups (%rdi),%xmm0
movaps %xmm0,(%rsp)
mov    %rcx,%rdx
call   1040 <rrr_SLK@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r14,%rdx
call   1040 <rrr_SLK@plt>
xor    %r12d,0xc(%rbx)
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %r14,%rdx
call   1040 <rrr_SLK@plt>
cmp    $0x1,%r15d
jne    119e <rrr_enc_dec_round+0x7e>
mov    (%r14),%eax
mov    %eax,%ecx
add    $0x6,%ecx
movslq %ecx,%rcx
imul   $0x66666667,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
neg    %ecx
add    %ecx,%eax
add    $0x6,%eax
mov    %eax,(%r14)
mov    %rbx,%rdi
call   1030 <rrr_sbox@plt>
movups (%rbx),%xmm0
movups 0x10(%rbx),%xmm1
xorps  %xmm0,%xmm1
movups %xmm1,(%rbx)
movaps (%rsp),%xmm0
movups %xmm0,0x10(%rbx)
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @rrr_enc_dec_round(i32* %0, i32* %1, i32 %2, i32* %3, i32 %4) {
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca [4 x i32]
store i32* %0, i32** %6
store i32* %1, i32** %7
store i32 %2, i32* %8
store i32* %3, i32** %9
store i32 %4, i32* %10
store i32 0, i32* %11
br label %13
13: ; preds = %25, %5
%14 = load i32, i32* %11
%15 = icmp slt i32 %14, 4
br i1 %15, label %16, label %28
16: ; preds = %13
%17 = load i32*, i32** %6
%18 = load i32, i32* %11
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i32, i32* %17, i64 %19
%21 = load i32, i32* %20
%22 = load i32, i32* %11
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [4 x i32], [4 x i32]* %12, i64 0, i64 %23
store i32 %21, i32* %24
br label %25
25: ; preds = %16
%26 = load i32, i32* %11
%27 = add nsw i32 %26, 1
store i32 %27, i32* %11
br label %13
28: ; preds = %13
%29 = load i32*, i32** %6
%30 = load i32*, i32** %7
%31 = load i32*, i32** %9
%32 = call i32 @rrr_SLK(i32* %29, i32* %30, i32* %31)
%33 = load i32*, i32** %6
%34 = load i32*, i32** %7
%35 = load i32*, i32** %9
%36 = call i32 @rrr_SLK(i32* %33, i32* %34, i32* %35)
%37 = load i32, i32* %8
%38 = load i32*, i32** %6
%39 = getelementptr inbounds i32, i32* %38, i64 3
%40 = load i32, i32* %39
%41 = xor i32 %40, %37
store i32 %41, i32* %39
%42 = load i32*, i32** %6
%43 = load i32*, i32** %7
%44 = load i32*, i32** %9
%45 = call i32 @rrr_SLK(i32* %42, i32* %43, i32* %44)
%46 = load i32, i32* %10
%47 = icmp eq i32 %46, 1
br i1 %47, label %48, label %56
48: ; preds = %28
%49 = load i32*, i32** %9
%50 = getelementptr inbounds i32, i32* %49, i64 0
%51 = load i32, i32* %50
%52 = add nsw i32 %51, 6
%53 = srem i32 %52, 10
%54 = load i32*, i32** %9
%55 = getelementptr inbounds i32, i32* %54, i64 0
store i32 %53, i32* %55
br label %56
56: ; preds = %48, %28
%57 = load i32*, i32** %6
%58 = call i32 @rrr_sbox(i32* %57)
store i32 0, i32* %11
br label %59
59: ; preds = %75, %56
%60 = load i32, i32* %11
%61 = icmp slt i32 %60, 4
br i1 %61, label %62, label %78
62: ; preds = %59
%63 = load i32*, i32** %6
%64 = load i32, i32* %11
%65 = add nsw i32 %64, 4
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i32, i32* %63, i64 %66
%68 = load i32, i32* %67
%69 = load i32*, i32** %6
%70 = load i32, i32* %11
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i32, i32* %69, i64 %71
%73 = load i32, i32* %72
%74 = xor i32 %73, %68
store i32 %74, i32* %72
br label %75
75: ; preds = %62
%76 = load i32, i32* %11
%77 = add nsw i32 %76, 1
store i32 %77, i32* %11
br label %59
78: ; preds = %59
store i32 0, i32* %11
br label %79
79: ; preds = %92, %78
%80 = load i32, i32* %11
%81 = icmp slt i32 %80, 4
br i1 %81, label %82, label %95
82: ; preds = %79
%83 = load i32, i32* %11
%84 = sext i32 %83 to i64
%85 = getelementptr inbounds [4 x i32], [4 x i32]* %12, i64 0, i64 %84
%86 = load i32, i32* %85
%87 = load i32*, i32** %6
%88 = load i32, i32* %11
%89 = add nsw i32 %88, 4
%90 = sext i32 %89 to i64
%91 = getelementptr inbounds i32, i32* %87, i64 %90
store i32 %86, i32* %91
br label %92
92: ; preds = %82
%93 = load i32, i32* %11
%94 = add nsw i32 %93, 1
store i32 %94, i32* %11
br label %79
95: ; preds = %79
ret void
}

LLVM IR (-O2):
define void @rrr_enc_dec_round(i32* %0, i32* %1, i32 %2, i32* %3, i32 %4) {
%6 = bitcast i32* %0 to i8*
%7 = alloca [4 x i32]
%8 = bitcast [4 x i32]* %7 to i8*
%9 = tail call i32 @rrr_SLK(i32* %0, i32* %1, i32* %3)
%10 = tail call i32 @rrr_SLK(i32* %0, i32* %1, i32* %3)
%11 = getelementptr inbounds i32, i32* %0, i64 3
%12 = load i32, i32* %11
%13 = xor i32 %12, %2
store i32 %13, i32* %11
%14 = tail call i32 @rrr_SLK(i32* %0, i32* %1, i32* %3)
%15 = icmp eq i32 %4, 1
br i1 %15, label %16, label %20
16: ; preds = %5
%17 = load i32, i32* %3
%18 = add nsw i32 %17, 6
%19 = srem i32 %18, 10
store i32 %19, i32* %3
br label %20
20: ; preds = %16, %5
%21 = tail call i32 @rrr_sbox(i32* %0)
%22 = getelementptr i32, i32* %0, i64 4
%23 = bitcast i32* %22 to <4 x i32>*
%24 = load <4 x i32>, <4 x i32>* %23
%25 = bitcast i32* %0 to <4 x i32>*
%26 = load <4 x i32>, <4 x i32>* %25
%27 = xor <4 x i32> %26, %24
%28 = bitcast i32* %0 to <4 x i32>*
store <4 x i32> %27, <4 x i32>* %28
%29 = bitcast i32* %22 to i8*
ret void
}