#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*/ L_layer(int *);
int /*<<< orphan*/ L_layerInv(int *);
int READ_ROUND_KEY_BYTE(int);
int /*<<< orphan*/ S_layer(int *);
void round_function(uint8_t *data, uint8_t *rkey, uint8_t mode) {
  uint8_t i;
  for (i = 0; i < 8; i++)
    data[i] ^= READ_ROUND_KEY_BYTE(rkey[i]);
  if (mode == 0) {
    S_layer(data);
    L_layer(data);
  } else if (mode == 1) {
    L_layerInv(data);
    S_layer(data);
  } else
    S_layer(data);
}


x86 assembly (clang, -O0):
<round_function>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x8,-0x18(%rbp)
jge    1192 <round_function+0x52>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1050 <READ_ROUND_KEY_BYTE@plt>
mov    %eax,%edx
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
xor    (%rax,%rcx,4),%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115a <round_function+0x1a>
cmpl   $0x0,-0x14(%rbp)
jne    11b3 <round_function+0x73>
mov    -0x8(%rbp),%rdi
call   1030 <S_layer@plt>
mov    -0x8(%rbp),%rdi
call   1060 <L_layer@plt>
jmp    11e2 <round_function+0xa2>
cmpl   $0x1,-0x14(%rbp)
jne    11d4 <round_function+0x94>
mov    -0x8(%rbp),%rdi
call   1040 <L_layerInv@plt>
mov    -0x8(%rbp),%rdi
call   1030 <S_layer@plt>
jmp    11dd <round_function+0x9d>
mov    -0x8(%rbp),%rdi
call   1030 <S_layer@plt>
jmp    11e2 <round_function+0xa2>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<round_function>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %rsi,%rbp
mov    %rdi,%rbx
mov    (%rsi),%edi
call   1050 <READ_ROUND_KEY_BYTE@plt>
xor    %eax,(%rbx)
mov    0x4(%rbp),%edi
call   1050 <READ_ROUND_KEY_BYTE@plt>
xor    %eax,0x4(%rbx)
mov    0x8(%rbp),%edi
call   1050 <READ_ROUND_KEY_BYTE@plt>
xor    %eax,0x8(%rbx)
mov    0xc(%rbp),%edi
call   1050 <READ_ROUND_KEY_BYTE@plt>
xor    %eax,0xc(%rbx)
mov    0x10(%rbp),%edi
call   1050 <READ_ROUND_KEY_BYTE@plt>
xor    %eax,0x10(%rbx)
mov    0x14(%rbp),%edi
call   1050 <READ_ROUND_KEY_BYTE@plt>
xor    %eax,0x14(%rbx)
mov    0x18(%rbp),%edi
call   1050 <READ_ROUND_KEY_BYTE@plt>
xor    %eax,0x18(%rbx)
mov    0x1c(%rbp),%edi
call   1050 <READ_ROUND_KEY_BYTE@plt>
xor    %eax,0x1c(%rbx)
cmp    $0x1,%r14d
je     11c2 <round_function+0x82>
test   %r14d,%r14d
jne    11ca <round_function+0x8a>
mov    %rbx,%rdi
call   1030 <S_layer@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <L_layer@plt>
mov    %rbx,%rdi
call   1040 <L_layerInv@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <S_layer@plt>

LLVM IR (-O0):
define void @round_function(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
store i32 0, i32* %7
br label %8
8: ; preds = %24, %3
%9 = load i32, i32* %7
%10 = icmp slt i32 %9, 8
br i1 %10, label %11, label %27
11: ; preds = %8
%12 = load i32*, i32** %5
%13 = load i32, i32* %7
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %12, i64 %14
%16 = load i32, i32* %15
%17 = call i32 @READ_ROUND_KEY_BYTE(i32 %16)
%18 = load i32*, i32** %4
%19 = load i32, i32* %7
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %18, i64 %20
%22 = load i32, i32* %21
%23 = xor i32 %22, %17
store i32 %23, i32* %21
br label %24
24: ; preds = %11
%25 = load i32, i32* %7
%26 = add nsw i32 %25, 1
store i32 %26, i32* %7
br label %8
27: ; preds = %8
%28 = load i32, i32* %6
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %27
%31 = load i32*, i32** %4
%32 = call i32 @S_layer(i32* %31)
%33 = load i32*, i32** %4
%34 = call i32 @L_layer(i32* %33)
br label %47
35: ; preds = %27
%36 = load i32, i32* %6
%37 = icmp eq i32 %36, 1
br i1 %37, label %38, label %43
38: ; preds = %35
%39 = load i32*, i32** %4
%40 = call i32 @L_layerInv(i32* %39)
%41 = load i32*, i32** %4
%42 = call i32 @S_layer(i32* %41)
br label %46
43: ; preds = %35
%44 = load i32*, i32** %4
%45 = call i32 @S_layer(i32* %44)
br label %46
46: ; preds = %43, %38
br label %47
47: ; preds = %46, %30
ret void
}

LLVM IR (-O2):
define void @round_function(i32* %0, i32* nocapture %1, i32 %2) {
%4 = load i32, i32* %1
%5 = tail call i32 @READ_ROUND_KEY_BYTE(i32 %4)
%6 = load i32, i32* %0
%7 = xor i32 %6, %5
store i32 %7, i32* %0
%8 = getelementptr inbounds i32, i32* %1, i64 1
%9 = load i32, i32* %8
%10 = tail call i32 @READ_ROUND_KEY_BYTE(i32 %9)
%11 = getelementptr inbounds i32, i32* %0, i64 1
%12 = load i32, i32* %11
%13 = xor i32 %12, %10
store i32 %13, i32* %11
%14 = getelementptr inbounds i32, i32* %1, i64 2
%15 = load i32, i32* %14
%16 = tail call i32 @READ_ROUND_KEY_BYTE(i32 %15)
%17 = getelementptr inbounds i32, i32* %0, i64 2
%18 = load i32, i32* %17
%19 = xor i32 %18, %16
store i32 %19, i32* %17
%20 = getelementptr inbounds i32, i32* %1, i64 3
%21 = load i32, i32* %20
%22 = tail call i32 @READ_ROUND_KEY_BYTE(i32 %21)
%23 = getelementptr inbounds i32, i32* %0, i64 3
%24 = load i32, i32* %23
%25 = xor i32 %24, %22
store i32 %25, i32* %23
%26 = getelementptr inbounds i32, i32* %1, i64 4
%27 = load i32, i32* %26
%28 = tail call i32 @READ_ROUND_KEY_BYTE(i32 %27)
%29 = getelementptr inbounds i32, i32* %0, i64 4
%30 = load i32, i32* %29
%31 = xor i32 %30, %28
store i32 %31, i32* %29
%32 = getelementptr inbounds i32, i32* %1, i64 5
%33 = load i32, i32* %32
%34 = tail call i32 @READ_ROUND_KEY_BYTE(i32 %33)
%35 = getelementptr inbounds i32, i32* %0, i64 5
%36 = load i32, i32* %35
%37 = xor i32 %36, %34
store i32 %37, i32* %35
%38 = getelementptr inbounds i32, i32* %1, i64 6
%39 = load i32, i32* %38
%40 = tail call i32 @READ_ROUND_KEY_BYTE(i32 %39)
%41 = getelementptr inbounds i32, i32* %0, i64 6
%42 = load i32, i32* %41
%43 = xor i32 %42, %40
store i32 %43, i32* %41
%44 = getelementptr inbounds i32, i32* %1, i64 7
%45 = load i32, i32* %44
%46 = tail call i32 @READ_ROUND_KEY_BYTE(i32 %45)
%47 = getelementptr inbounds i32, i32* %0, i64 7
%48 = load i32, i32* %47
%49 = xor i32 %48, %46
store i32 %49, i32* %47
switch i32 %2, label %56 [
i32 0, label %50
i32 1, label %53
]
50: ; preds = %3
%51 = tail call i32 @S_layer(i32* %0)
%52 = tail call i32 @L_layer(i32* %0)
br label %58
53: ; preds = %3
%54 = tail call i32 @L_layerInv(i32* %0)
%55 = tail call i32 @S_layer(i32* %0)
br label %58
56: ; preds = %3
%57 = tail call i32 @S_layer(i32* %0)
br label %58
58: ; preds = %53, %56, %50
ret void
}