#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 READ_ROUND_KEY_BYTE(int);
int /*<<< orphan*/ rrr_L(int *);
int /*<<< orphan*/ rrr_sbox(int *);
void rrr_SLK(uint8_t *data, uint8_t *roundKey, uint8_t *key_ctr) {
  uint8_t i;
  rrr_sbox(data);
  for (i = 0; i < 4; i++)
    rrr_L(data + i);
  for (i = 0; i < 4; i++) {
    data[i] ^= READ_ROUND_KEY_BYTE(roundKey[key_ctr[0]]);
    key_ctr[0] = (key_ctr[0] + 1) % 10;
  }
}


x86 assembly (clang, -O0):
<rrr_SLK>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <rrr_sbox@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x4,-0x1c(%rbp)
jge    1180 <rrr_SLK+0x50>
mov    -0x8(%rbp),%rdi
movslq -0x1c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
call   1050 <rrr_L@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1154 <rrr_SLK+0x24>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x4,-0x1c(%rbp)
jge    11d9 <rrr_SLK+0xa9>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq (%rcx),%rcx
mov    (%rax,%rcx,4),%edi
call   1040 <READ_ROUND_KEY_BYTE@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
xor    (%rax,%rcx,4),%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
add    $0x1,%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x18(%rbp),%rax
mov    %edx,(%rax)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1187 <rrr_SLK+0x57>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rrr_SLK>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
call   1030 <rrr_sbox@plt>
mov    %rbx,%rdi
call   1050 <rrr_L@plt>
lea    0x4(%rbx),%rdi
call   1050 <rrr_L@plt>
lea    0x8(%rbx),%rdi
call   1050 <rrr_L@plt>
lea    0xc(%rbx),%rdi
call   1050 <rrr_L@plt>
movslq (%r14),%rax
mov    (%r15,%rax,4),%edi
call   1040 <READ_ROUND_KEY_BYTE@plt>
xor    %eax,(%rbx)
mov    (%r14),%eax
mov    %eax,%ecx
add    $0x1,%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    $0x1,%eax
mov    %eax,(%r14)
cltq
mov    (%r15,%rax,4),%edi
call   1040 <READ_ROUND_KEY_BYTE@plt>
xor    %eax,0x4(%rbx)
mov    (%r14),%eax
mov    %eax,%ecx
add    $0x1,%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    $0x1,%eax
mov    %eax,(%r14)
cltq
mov    (%r15,%rax,4),%edi
call   1040 <READ_ROUND_KEY_BYTE@plt>
xor    %eax,0x8(%rbx)
mov    (%r14),%eax
mov    %eax,%ecx
add    $0x1,%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    $0x1,%eax
mov    %eax,(%r14)
cltq
mov    (%r15,%rax,4),%edi
call   1040 <READ_ROUND_KEY_BYTE@plt>
xor    %eax,0xc(%rbx)
mov    (%r14),%eax
mov    %eax,%ecx
add    $0x1,%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    $0x1,%eax
mov    %eax,(%r14)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @rrr_SLK(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%8 = load i32*, i32** %4
%9 = call i32 @rrr_sbox(i32* %8)
store i32 0, i32* %7
br label %10
10: ; preds = %19, %3
%11 = load i32, i32* %7
%12 = icmp slt i32 %11, 4
br i1 %12, label %13, label %22
13: ; preds = %10
%14 = load i32*, i32** %4
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* %14, i64 %16
%18 = call i32 @rrr_L(i32* %17)
br label %19
19: ; preds = %13
%20 = load i32, i32* %7
%21 = add nsw i32 %20, 1
store i32 %21, i32* %7
br label %10
22: ; preds = %10
store i32 0, i32* %7
br label %23
23: ; preds = %48, %22
%24 = load i32, i32* %7
%25 = icmp slt i32 %24, 4
br i1 %25, label %26, label %51
26: ; preds = %23
%27 = load i32*, i32** %5
%28 = load i32*, i32** %6
%29 = getelementptr inbounds i32, i32* %28, i64 0
%30 = load i32, i32* %29
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %27, i64 %31
%33 = load i32, i32* %32
%34 = call i32 @READ_ROUND_KEY_BYTE(i32 %33)
%35 = load i32*, i32** %4
%36 = load i32, i32* %7
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i32, i32* %35, i64 %37
%39 = load i32, i32* %38
%40 = xor i32 %39, %34
store i32 %40, i32* %38
%41 = load i32*, i32** %6
%42 = getelementptr inbounds i32, i32* %41, i64 0
%43 = load i32, i32* %42
%44 = add nsw i32 %43, 1
%45 = srem i32 %44, 10
%46 = load i32*, i32** %6
%47 = getelementptr inbounds i32, i32* %46, i64 0
store i32 %45, i32* %47
br label %48
48: ; preds = %26
%49 = load i32, i32* %7
%50 = add nsw i32 %49, 1
store i32 %50, i32* %7
br label %23
51: ; preds = %23
ret void
}

LLVM IR (-O2):
define void @rrr_SLK(i32* %0, i32* nocapture %1, i32* nocapture %2) {
%4 = tail call i32 @rrr_sbox(i32* %0)
%5 = tail call i32 @rrr_L(i32* %0)
%6 = getelementptr inbounds i32, i32* %0, i64 1
%7 = tail call i32 @rrr_L(i32* %6)
%8 = getelementptr inbounds i32, i32* %0, i64 2
%9 = tail call i32 @rrr_L(i32* %8)
%10 = getelementptr inbounds i32, i32* %0, i64 3
%11 = tail call i32 @rrr_L(i32* %10)
%12 = load i32, i32* %2
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i32, i32* %1, i64 %13
%15 = load i32, i32* %14
%16 = tail call i32 @READ_ROUND_KEY_BYTE(i32 %15)
%17 = load i32, i32* %0
%18 = xor i32 %17, %16
store i32 %18, i32* %0
%19 = load i32, i32* %2
%20 = add nsw i32 %19, 1
%21 = srem i32 %20, 10
store i32 %21, i32* %2
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %1, i64 %22
%24 = load i32, i32* %23
%25 = tail call i32 @READ_ROUND_KEY_BYTE(i32 %24)
%26 = load i32, i32* %6
%27 = xor i32 %26, %25
store i32 %27, i32* %6
%28 = load i32, i32* %2
%29 = add nsw i32 %28, 1
%30 = srem i32 %29, 10
store i32 %30, i32* %2
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %1, i64 %31
%33 = load i32, i32* %32
%34 = tail call i32 @READ_ROUND_KEY_BYTE(i32 %33)
%35 = load i32, i32* %8
%36 = xor i32 %35, %34
store i32 %36, i32* %8
%37 = load i32, i32* %2
%38 = add nsw i32 %37, 1
%39 = srem i32 %38, 10
store i32 %39, i32* %2
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i32, i32* %1, i64 %40
%42 = load i32, i32* %41
%43 = tail call i32 @READ_ROUND_KEY_BYTE(i32 %42)
%44 = load i32, i32* %10
%45 = xor i32 %44, %43
store i32 %45, i32* %10
%46 = load i32, i32* %2
%47 = add nsw i32 %46, 1
%48 = srem i32 %47, 10
store i32 %48, i32* %2
ret void
}