#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 uint64_t;
typedef int uint32_t;
typedef int /*<<< orphan*/ uint16_t;

/* Variables and functions */
int _kasumi_FL(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
int _kasumi_FO(int, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
               int /*<<< orphan*/ *, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
               int /*<<< orphan*/ *, int);
uint64_t _kasumi(uint64_t P, uint16_t *KLi1, uint16_t *KLi2, uint16_t *KOi1,
                 uint16_t *KOi2, uint16_t *KOi3, uint16_t *KIi1, uint16_t *KIi2,
                 uint16_t *KIi3) {
  uint32_t i, L = P >> 32, R = P;
  for (i = 0; i < 8; i++) {
    R ^= _kasumi_FO(_kasumi_FL(L, KLi1, KLi2, i), KOi1, KOi2, KOi3, KIi1, KIi2,
                    KIi3, i);
    i++;
    L ^= _kasumi_FL(_kasumi_FO(R, KOi1, KOi2, KOi3, KIi1, KIi2, KIi3, i), KLi1,
                    KLi2, i);
  }
  return (((uint64_t)L) << 32) + R;
}


x86 assembly (clang, -O0):
<_kasumi>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x20,%ecx
sar    %cl,%eax
mov    %eax,-0x38(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x3c(%rbp)
movl   $0x0,-0x34(%rbp)
cmpl   $0x8,-0x34(%rbp)
jge    120c <_kasumi+0xec>
mov    -0x38(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x34(%rbp),%ecx
call   1030 <_kasumi_FL@plt>
mov    %eax,%edi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    0x10(%rbp),%r8
mov    0x18(%rbp),%r9
mov    0x20(%rbp),%r10
mov    -0x34(%rbp),%eax
mov    %r10,(%rsp)
mov    %eax,0x8(%rsp)
call   1040 <_kasumi_FO@plt>
xor    -0x3c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x3c(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
mov    -0x30(%rbp),%rcx
mov    0x10(%rbp),%r8
mov    0x18(%rbp),%r9
mov    0x20(%rbp),%r10
mov    -0x34(%rbp),%eax
mov    %r10,(%rsp)
mov    %eax,0x8(%rsp)
call   1040 <_kasumi_FO@plt>
mov    %eax,%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x34(%rbp),%ecx
call   1030 <_kasumi_FL@plt>
xor    -0x38(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1165 <_kasumi+0x45>
mov    -0x38(%rbp),%eax
mov    $0x20,%ecx
shl    %cl,%eax
add    -0x3c(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
LLVM IR (-O0):
define i32 @_kasumi(i32 %0, i32* %1, i32* %2, i32* %3, i32* %4, i32* %5, i32* %6, i32* %7, i32* %8) {
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i32*
%17 = alloca i32*
%18 = alloca i32*
%19 = alloca i32
%20 = alloca i32
%21 = alloca i32
store i32 %0, i32* %10
store i32* %1, i32** %11
store i32* %2, i32** %12
store i32* %3, i32** %13
store i32* %4, i32** %14
store i32* %5, i32** %15
store i32* %6, i32** %16
store i32* %7, i32** %17
store i32* %8, i32** %18
%22 = load i32, i32* %10
%23 = ashr i32 %22, 32
store i32 %23, i32* %20
%24 = load i32, i32* %10
store i32 %24, i32* %21
store i32 0, i32* %19
br label %25
25: ; preds = %61, %9
%26 = load i32, i32* %19
%27 = icmp slt i32 %26, 8
br i1 %27, label %28, label %64
28: ; preds = %25
%29 = load i32, i32* %20
%30 = load i32*, i32** %11
%31 = load i32*, i32** %12
%32 = load i32, i32* %19
%33 = call i32 @_kasumi_FL(i32 %29, i32* %30, i32* %31, i32 %32)
%34 = load i32*, i32** %13
%35 = load i32*, i32** %14
%36 = load i32*, i32** %15
%37 = load i32*, i32** %16
%38 = load i32*, i32** %17
%39 = load i32*, i32** %18
%40 = load i32, i32* %19
%41 = call i32 @_kasumi_FO(i32 %33, i32* %34, i32* %35, i32* %36, i32* %37, i32* %38, i32* %39, i32 %40)
%42 = load i32, i32* %21
%43 = xor i32 %42, %41
store i32 %43, i32* %21
%44 = load i32, i32* %19
%45 = add nsw i32 %44, 1
store i32 %45, i32* %19
%46 = load i32, i32* %21
%47 = load i32*, i32** %13
%48 = load i32*, i32** %14
%49 = load i32*, i32** %15
%50 = load i32*, i32** %16
%51 = load i32*, i32** %17
%52 = load i32*, i32** %18
%53 = load i32, i32* %19
%54 = call i32 @_kasumi_FO(i32 %46, i32* %47, i32* %48, i32* %49, i32* %50, i32* %51, i32* %52, i32 %53)
%55 = load i32*, i32** %11
%56 = load i32*, i32** %12
%57 = load i32, i32* %19
%58 = call i32 @_kasumi_FL(i32 %54, i32* %55, i32* %56, i32 %57)
%59 = load i32, i32* %20
%60 = xor i32 %59, %58
store i32 %60, i32* %20
br label %61
61: ; preds = %28
%62 = load i32, i32* %19
%63 = add nsw i32 %62, 1
store i32 %63, i32* %19
br label %25
64: ; preds = %25
%65 = load i32, i32* %20
%66 = shl i32 %65, 32
%67 = load i32, i32* %21
%68 = add nsw i32 %66, %67
ret i32 %68
}

LLVM IR (-O2):