#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 */

/* Variables and functions */
unsigned char getRconValue(int);
unsigned char getsboxValue(unsigned char);
int /*<<< orphan*/ rotate(unsigned char *);
void core(unsigned char *word, int iteration) {
  int i;
  rotate(word);
  for (i = 0; i < 4; ++i) {
    word[i] = getsboxValue(word[i]);
  }
  word[0] = word[0] ^ getRconValue(iteration);
}


x86 assembly (clang, -O0):
<core>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <rotate@plt>
movl   $0x0,-0x10(%rbp)
cmpl   $0x4,-0x10(%rbp)
jge    1185 <core+0x55>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
call   1030 <getsboxValue@plt>
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    114f <core+0x1f>
mov    -0x8(%rbp),%rax
movzbl (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <getRconValue@plt>
mov    %al,%cl
mov    -0x14(%rbp),%eax
movzbl %cl,%ecx
xor    %ecx,%eax
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<core>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%rbx
call   1050 <rotate@plt>
movzbl (%rbx),%edi
call   1030 <getsboxValue@plt>
mov    %al,(%rbx)
movzbl 0x1(%rbx),%edi
call   1030 <getsboxValue@plt>
mov    %al,0x1(%rbx)
movzbl 0x2(%rbx),%edi
call   1030 <getsboxValue@plt>
mov    %al,0x2(%rbx)
movzbl 0x3(%rbx),%edi
call   1030 <getsboxValue@plt>
mov    %al,0x3(%rbx)
mov    (%rbx),%r14b
mov    %ebp,%edi
call   1040 <getRconValue@plt>
xor    %r14b,%al
mov    %al,(%rbx)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @core(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%6 = load i8*, i8** %3
%7 = call i32 @rotate(i8* %6)
store i32 0, i32* %5
br label %8
8: ; preds = %22, %2
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, 4
br i1 %10, label %11, label %25
11: ; preds = %8
%12 = load i8*, i8** %3
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %12, i64 %14
%16 = load i8, i8* %15
%17 = call zeroext i8 @getsboxValue(i8 zeroext %16)
%18 = load i8*, i8** %3
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
store i8 %17, i8* %21
br label %22
22: ; preds = %11
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
br label %8
25: ; preds = %8
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i64 0
%28 = load i8, i8* %27
%29 = zext i8 %28 to i32
%30 = load i32, i32* %4
%31 = call zeroext i8 @getRconValue(i32 %30)
%32 = zext i8 %31 to i32
%33 = xor i32 %29, %32
%34 = trunc i32 %33 to i8
%35 = load i8*, i8** %3
%36 = getelementptr inbounds i8, i8* %35, i64 0
store i8 %34, i8* %36
ret void
}

LLVM IR (-O2):
define void @core(i8* %0, i32 %1) {
%3 = tail call i32 @rotate(i8* %0)
%4 = load i8, i8* %0
%5 = tail call zeroext i8 @getsboxValue(i8 zeroext %4)
store i8 %5, i8* %0
%6 = getelementptr inbounds i8, i8* %0, i64 1
%7 = load i8, i8* %6
%8 = tail call zeroext i8 @getsboxValue(i8 zeroext %7)
store i8 %8, i8* %6
%9 = getelementptr inbounds i8, i8* %0, i64 2
%10 = load i8, i8* %9
%11 = tail call zeroext i8 @getsboxValue(i8 zeroext %10)
store i8 %11, i8* %9
%12 = getelementptr inbounds i8, i8* %0, i64 3
%13 = load i8, i8* %12
%14 = tail call zeroext i8 @getsboxValue(i8 zeroext %13)
store i8 %14, i8* %12
%15 = load i8, i8* %0
%16 = tail call zeroext i8 @getRconValue(i32 %1)
%17 = xor i8 %16, %15
store i8 %17, i8* %0
ret void
}