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

/* Variables and functions */
int _compare_mem(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ _kasumi_key_expand(
    int /*<<< orphan*/ *, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
    int /*<<< orphan*/ *, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
    int /*<<< orphan*/ *, int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
void test_expansion(uint8_t *test_key, uint16_t *_KLi1, uint16_t *_KLi2,
                    uint16_t *_KOi1, uint16_t *_KOi2, uint16_t *_KOi3,
                    uint16_t *_KIi1, uint16_t *_KIi2, uint16_t *_KIi3,
                    uint16_t *_KLi1_r, uint16_t *_KLi2_r, uint16_t *_KOi1_r,
                    uint16_t *_KOi2_r, uint16_t *_KOi3_r, uint16_t *_KIi1_r,
                    uint16_t *_KIi2_r, uint16_t *_KIi3_r) {
  _kasumi_key_expand(test_key, _KLi1, _KLi2, _KOi1, _KOi2, _KOi3, _KIi1, _KIi2,
                     _KIi3);
  int passed = 1;
  passed = _compare_mem((uint8_t *)_KLi1, (uint8_t *)_KLi1_r, 16);
  passed = _compare_mem((uint8_t *)_KLi2, (uint8_t *)_KLi2_r, 16);
  passed = _compare_mem((uint8_t *)_KOi1, (uint8_t *)_KOi1_r, 16);
  passed = _compare_mem((uint8_t *)_KOi2, (uint8_t *)_KOi2_r, 16);
  passed = _compare_mem((uint8_t *)_KOi3, (uint8_t *)_KOi3_r, 16);
  passed = _compare_mem((uint8_t *)_KIi1, (uint8_t *)_KIi1_r, 16);
  passed = _compare_mem((uint8_t *)_KIi2, (uint8_t *)_KIi2_r, 16);
  passed = _compare_mem((uint8_t *)_KIi3, (uint8_t *)_KIi3_r, 16);
  if (passed)
    printf(" OK. ");
  else
    printf("FAILED!");
}


x86 assembly (clang, -O0):
<test_expansion>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    0x60(%rbp),%rax
mov    0x58(%rbp),%rax
mov    0x50(%rbp),%rax
mov    0x48(%rbp),%rax
mov    0x40(%rbp),%rax
mov    0x38(%rbp),%rax
mov    0x30(%rbp),%rax
mov    0x28(%rbp),%rax
mov    0x20(%rbp),%rax
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
mov    -0x30(%rbp),%r9
mov    0x10(%rbp),%r11
mov    0x18(%rbp),%r10
mov    0x20(%rbp),%rax
mov    %r11,(%rsp)
mov    %r10,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1040 <_kasumi_key_expand@plt>
movl   $0x1,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x28(%rbp),%rsi
mov    $0x10,%edx
call   1050 <_compare_mem@plt>
mov    %eax,-0x34(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x30(%rbp),%rsi
mov    $0x10,%edx
call   1050 <_compare_mem@plt>
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x38(%rbp),%rsi
mov    $0x10,%edx
call   1050 <_compare_mem@plt>
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%rdi
mov    0x40(%rbp),%rsi
mov    $0x10,%edx
call   1050 <_compare_mem@plt>
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%rdi
mov    0x48(%rbp),%rsi
mov    $0x10,%edx
call   1050 <_compare_mem@plt>
mov    %eax,-0x34(%rbp)
mov    0x10(%rbp),%rdi
mov    0x50(%rbp),%rsi
mov    $0x10,%edx
call   1050 <_compare_mem@plt>
mov    %eax,-0x34(%rbp)
mov    0x18(%rbp),%rdi
mov    0x58(%rbp),%rsi
mov    $0x10,%edx
call   1050 <_compare_mem@plt>
mov    %eax,-0x34(%rbp)
mov    0x20(%rbp),%rdi
mov    0x60(%rbp),%rsi
mov    $0x10,%edx
call   1050 <_compare_mem@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
je     127d <test_expansion+0x14d>
lea    0xd8d(%rip),%rdi
call   1030 <printf@plt>
jmp    1289 <test_expansion+0x159>
lea    0xd82(%rip),%rdi
call   1030 <printf@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_expansion>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %r9,0x18(%rsp)
mov    %r8,0x10(%rsp)
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%rbx
mov    0xe0(%rsp),%rax
mov    %rax,0x50(%rsp)
mov    0xd8(%rsp),%rax
mov    %rax,0x48(%rsp)
mov    0xd0(%rsp),%rax
mov    %rax,0x40(%rsp)
mov    0xc8(%rsp),%rax
mov    %rax,0x30(%rsp)
mov    0xc0(%rsp),%rax
mov    %rax,0x28(%rsp)
mov    0xb8(%rsp),%rax
mov    %rax,0x20(%rsp)
mov    0xb0(%rsp),%rax
mov    %rax,0x8(%rsp)
mov    0xa8(%rsp),%r14
mov    0x90(%rsp),%r13
mov    0x98(%rsp),%rbp
mov    0xa0(%rsp),%rax
mov    %rax,0x38(%rsp)
sub    $0x8,%rsp
push   %rax
push   %rbp
push   %r13
call   1040 <_kasumi_key_expand@plt>
add    $0x20,%rsp
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x10,%edx
call   1050 <_compare_mem@plt>
mov    %r12,%rdi
mov    0x8(%rsp),%rsi
mov    $0x10,%edx
call   1050 <_compare_mem@plt>
mov    %r15,%rdi
mov    0x20(%rsp),%rsi
mov    $0x10,%edx
call   1050 <_compare_mem@plt>
mov    0x10(%rsp),%rdi
mov    0x28(%rsp),%rsi
mov    $0x10,%edx
call   1050 <_compare_mem@plt>
mov    0x18(%rsp),%rdi
mov    0x30(%rsp),%rsi
mov    $0x10,%edx
call   1050 <_compare_mem@plt>
mov    %r13,%rdi
mov    0x40(%rsp),%rsi
mov    $0x10,%edx
call   1050 <_compare_mem@plt>
mov    %rbp,%rdi
mov    0x48(%rsp),%rsi
mov    $0x10,%edx
call   1050 <_compare_mem@plt>
mov    0x38(%rsp),%rdi
mov    0x50(%rsp),%rsi
mov    $0x10,%edx
call   1050 <_compare_mem@plt>
test   %eax,%eax
lea    0xd87(%rip),%rax
lea    0xd7a(%rip),%rdi
cmove  %rax,%rdi
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [6 x i8] c" OK. \00"
@.str.1 = [8 x i8] c"FAILED!\00"
define void @test_expansion(i32* %0, i32* %1, i32* %2, i32* %3, i32* %4, i32* %5, i32* %6, i32* %7, i32* %8, i32* %9, i32* %10, i32* %11, i32* %12, i32* %13, i32* %14, i32* %15, i32* %16) {
%18 = alloca i32*
%19 = alloca i32*
%20 = alloca i32*
%21 = alloca i32*
%22 = alloca i32*
%23 = alloca i32*
%24 = alloca i32*
%25 = alloca i32*
%26 = alloca i32*
%27 = alloca i32*
%28 = alloca i32*
%29 = alloca i32*
%30 = alloca i32*
%31 = alloca i32*
%32 = alloca i32*
%33 = alloca i32*
%34 = alloca i32*
%35 = alloca i32
store i32* %0, i32** %18
store i32* %1, i32** %19
store i32* %2, i32** %20
store i32* %3, i32** %21
store i32* %4, i32** %22
store i32* %5, i32** %23
store i32* %6, i32** %24
store i32* %7, i32** %25
store i32* %8, i32** %26
store i32* %9, i32** %27
store i32* %10, i32** %28
store i32* %11, i32** %29
store i32* %12, i32** %30
store i32* %13, i32** %31
store i32* %14, i32** %32
store i32* %15, i32** %33
store i32* %16, i32** %34
%36 = load i32*, i32** %18
%37 = load i32*, i32** %19
%38 = load i32*, i32** %20
%39 = load i32*, i32** %21
%40 = load i32*, i32** %22
%41 = load i32*, i32** %23
%42 = load i32*, i32** %24
%43 = load i32*, i32** %25
%44 = load i32*, i32** %26
%45 = call i32 @_kasumi_key_expand(i32* %36, i32* %37, i32* %38, i32* %39, i32* %40, i32* %41, i32* %42, i32* %43, i32* %44)
store i32 1, i32* %35
%46 = load i32*, i32** %19
%47 = load i32*, i32** %27
%48 = call i32 @_compare_mem(i32* %46, i32* %47, i32 16)
store i32 %48, i32* %35
%49 = load i32*, i32** %20
%50 = load i32*, i32** %28
%51 = call i32 @_compare_mem(i32* %49, i32* %50, i32 16)
store i32 %51, i32* %35
%52 = load i32*, i32** %21
%53 = load i32*, i32** %29
%54 = call i32 @_compare_mem(i32* %52, i32* %53, i32 16)
store i32 %54, i32* %35
%55 = load i32*, i32** %22
%56 = load i32*, i32** %30
%57 = call i32 @_compare_mem(i32* %55, i32* %56, i32 16)
store i32 %57, i32* %35
%58 = load i32*, i32** %23
%59 = load i32*, i32** %31
%60 = call i32 @_compare_mem(i32* %58, i32* %59, i32 16)
store i32 %60, i32* %35
%61 = load i32*, i32** %24
%62 = load i32*, i32** %32
%63 = call i32 @_compare_mem(i32* %61, i32* %62, i32 16)
store i32 %63, i32* %35
%64 = load i32*, i32** %25
%65 = load i32*, i32** %33
%66 = call i32 @_compare_mem(i32* %64, i32* %65, i32 16)
store i32 %66, i32* %35
%67 = load i32*, i32** %26
%68 = load i32*, i32** %34
%69 = call i32 @_compare_mem(i32* %67, i32* %68, i32 16)
store i32 %69, i32* %35
%70 = load i32, i32* %35
%71 = icmp ne i32 %70, 0
br i1 %71, label %72, label %74
72: ; preds = %17
%73 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
br label %76
74: ; preds = %17
%75 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %76
76: ; preds = %74, %72
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c" OK. \00"
@.str.1 = [8 x i8] c"FAILED!\00"
define void @test_expansion(i32* %0, i32* %1, i32* %2, i32* %3, i32* %4, i32* %5, i32* %6, i32* %7, i32* %8, i32* %9, i32* %10, i32* %11, i32* %12, i32* %13, i32* %14, i32* %15, i32* %16) {
%18 = tail call i32 @_kasumi_key_expand(i32* %0, i32* %1, i32* %2, i32* %3, i32* %4, i32* %5, i32* %6, i32* %7, i32* %8)
%19 = tail call i32 @_compare_mem(i32* %1, i32* %9, i32 16)
%20 = tail call i32 @_compare_mem(i32* %2, i32* %10, i32 16)
%21 = tail call i32 @_compare_mem(i32* %3, i32* %11, i32 16)
%22 = tail call i32 @_compare_mem(i32* %4, i32* %12, i32 16)
%23 = tail call i32 @_compare_mem(i32* %5, i32* %13, i32 16)
%24 = tail call i32 @_compare_mem(i32* %6, i32* %14, i32 16)
%25 = tail call i32 @_compare_mem(i32* %7, i32* %15, i32 16)
%26 = tail call i32 @_compare_mem(i32* %8, i32* %16, i32 16)
%27 = icmp eq i32 %26, 0
%28 = select i1 %27, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0)
%29 = tail call i32 @printf(i8* dereferenceable(1) %28)
ret void
}